File tree 4 files changed +41
-0
lines changed
4 files changed +41
-0
lines changed Original file line number Diff line number Diff line change
1
+ 4 1 5 2 3
Original file line number Diff line number Diff line change
1
+ 5 4
2
+ 1 2
3
+ 2 3
4
+ 1 3
5
+ 1 5
6
+ 0 0
Original file line number Diff line number Diff line change
1
+ // https://uva.onlinejudge.org/external/103/10305.pdf
2
+ #include < bits/stdc++.h>
3
+ using namespace std ;
4
+ using vi=vector<int >;
5
+ using vvi=vector<vi>;
6
+ int main (){
7
+ for (;;){
8
+ int n,m,u,v;
9
+ cin>>n>>m;
10
+ if (!n)break ;
11
+ vvi g (n);
12
+ for (int i=0 ;i<m;i++){
13
+ cin>>u>>v;
14
+ u--;v--;
15
+ g[u].push_back (v);
16
+ }
17
+ vi s (n),p;
18
+ function<void (int )>dfs=[&](int u){
19
+ s[u]=1 ;
20
+ for (int v:g[u])
21
+ if (!s[v])
22
+ dfs (v);
23
+ p.push_back (u);
24
+ };
25
+ for (int i=0 ;i<n;i++)
26
+ if (!s[i])
27
+ dfs (i);
28
+ reverse (p.begin (),p.end ());
29
+ for (int i=0 ;i<n;i++)
30
+ cout<<p[i]+1 <<" \n " [i==n-1 ];
31
+ }
32
+ }
Original file line number Diff line number Diff line change @@ -59,6 +59,8 @@ There are solutions for the following
59
59
([ problem site] ( https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=1119 ) )
60
60
1 . [ 10227 - Forests] ( 10227.py )
61
61
([ problem site] ( https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=1168 ) )
62
+ 1 . [ 10305 - Ordering Tasks] ( 10305.cc )
63
+ ([ problem site] ( https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=1246 ) )
62
64
1 . [ 10369 - Arctic Network] ( 10369.cc )
63
65
([ problem site] ( https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=1310 ) )
64
66
1 . [ 10301 - Rings and Glue] ( 10301.cc )
You can’t perform that action at this time.
0 commit comments