Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<cstdio>
- #include<vector>
- #include<algorithm>
- #define MAX 100000
- using namespace std;
- //vector<int>v[100000];
- vector<int>node[MAX];
- int in[MAX];
- int out[MAX];
- int main()
- {
- //string str;
- int i,j,item,n,edge,pre,post;
- cin >> n >> edge ;
- for(i=0; i<edge; ++i)
- {
- cin >> pre >> post;
- node[pre].push_back(post);
- }
- //sort(node.begin(),node.end());
- cout << "nodes are joined among:" << endl;
- for(i=0; i<=n; ++i)
- {
- for(j=0; j<node[i].size(); ++j)
- {
- ++out[i];
- ++in[node[i][j]];
- if(!j)
- {
- cout << i << " >> ";
- }
- if(j)cout<<",";cout << node[i][j];
- }
- cout << endl;
- }
- cout << "indegree & outdegree" << endl;
- for(i=0; i<=n; ++i)
- {
- if(i)
- cout << i << " " << "in:" << in[i] << ", " << "out: " << out[i] <<endl;
- }
- //node.clear();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment