-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSCC5.cpp
41 lines (40 loc) · 886 Bytes
/
SCC5.cpp
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
#include <bits/stdc++.h>
using namespace std;
int in[100005], out[100005];
int main()
{
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int t, n, m, i, a, b;
cin >> t;
while (t--)
{
memset(in, 0, sizeof in);
memset(out, 0, sizeof out);
cin >> n >> m;
for (i = 0; i < m; i++)
{
cin >> a >> b;
//cout << "marking " << a << " " << b << endl;
out[a]++;
in[b]++;
}
a = -1;
for (i = 1; i <= n; i++)
{
//cout << in[i] << endl;
if (out[i] == 0 && in[i] == n - 1)
{
a = i;
break;
}
}
if (a == -1)
cout << "dead\n";
else
cout << "alive " << a << endl;
}
return 0;
}