File tree 6 files changed +50
-0
lines changed
6 files changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -229,6 +229,7 @@ There are solutions for the following
229
229
1 . [ Racing Around the Alphabet] ( racingalphabet.cc ) ([ problem site] ( https://open.kattis.com/problems/racingalphabet ) )
230
230
1 . [ Ragged Right] ( raggedright.cc ) ([ problem site] ( https://open.kattis.com/problems/raggedright ) )
231
231
1 . [ Railroad] ( railroad2.cc ) ([ problem site] ( https://open.kattis.com/problems/railroad2 ) )
232
+ 1 . [ Reactivity Series] ( reactivity.cc ) ([ problem site] ( https://open.kattis.com/problems/reactivity ) )
232
233
1 . [ Working at the Restaurant] ( restaurant.cc ) ([ problem site] ( https://open.kattis.com/problems/restaurant ) )
233
234
1 . [ Reversed Binary Numbers] ( reversebinary.py ) ([ problem site] ( https://open.kattis.com/problems/reversebinary ) )
234
235
1 . [ Reverse Rot] ( reverserot.cc ) ([ problem site] ( https://open.kattis.com/problems/reverserot ) )
Original file line number Diff line number Diff line change
1
+ 0 1
Original file line number Diff line number Diff line change
1
+ 2 1
2
+ 0 1
Original file line number Diff line number Diff line change
1
+ back to the lab
Original file line number Diff line number Diff line change
1
+ 4 4
2
+ 0 1
3
+ 0 2
4
+ 2 3
5
+ 1 3
Original file line number Diff line number Diff line change
1
+ // https://open.kattis.com/problems/reactivity
2
+ #include < bits/stdc++.h>
3
+
4
+ using namespace std ;
5
+ using vi = vector<int >;
6
+ using vvi = vector<vi>;
7
+ using qi = queue<int >;
8
+
9
+ int main () {
10
+ int n, m, u, v;
11
+ cin >> n >> m;
12
+ vvi g (n);
13
+ vi a (n), b;
14
+ for (int i = 0 ; i < m; i++) {
15
+ cin >> u >> v;
16
+ g[u].push_back (v);
17
+ a[v]++;
18
+ }
19
+ qi q;
20
+ for (int i = 0 ; i < n; i++)
21
+ if (!a[i]) q.push (i);
22
+ bool ok = 1 ;
23
+ while (!q.empty ()) {
24
+ if (q.size () > 1 ) {
25
+ ok = 0 ;
26
+ break ;
27
+ }
28
+ u = q.front ();
29
+ q.pop ();
30
+ b.push_back (u);
31
+ for (int v : g[u]) {
32
+ a[v]--;
33
+ if (!a[v]) q.push (v);
34
+ }
35
+ }
36
+ if (ok)
37
+ for (int i = 0 ; i < n; i++) cout << b[i] << " \n " [i == n - 1 ];
38
+ else
39
+ cout << " back to the lab\n " ;
40
+ }
You can’t perform that action at this time.
0 commit comments