-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtesting.cpp
More file actions
43 lines (40 loc) · 836 Bytes
/
testing.cpp
File metadata and controls
43 lines (40 loc) · 836 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include<bits/stdc++.h>
using namespace std;
void topo(int node, vector<int> &visited, map<int, vector<int>> &map, vector<int> &q){
visited[node] = 1;
for(auto x : map[node]){
if(!visited[x]){
topo(x, visited, map, q);
}
}
q.push_back(node);
}
int main(int argc, char** argv){
for(int i = 0; i < argc; i++){
cout << argv[i]<< endl;
}
int n, m, val1, val2;
cin >> n >> m;
cout << n << m;
return 0;
while(cin >> n >> m && n && m){
map<int, vector<int>> map;
vector<int> visited(n+1, 0);
vector<int> q;
for(int i = 0; i < m; i++){
cin >> val1 >> val2;
map[val1].push_back(val2);
}
for(int i = 1; i <= n; i++){
if(!visited[i]){
topo(i, visited, map, q);
}
}
for(int i = q.size()-1; i >= 0; i--){
cout << q[i];
if(i) cout << " ";
}
cout << endl;
}
return 0;
}