#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ar array
const int mxN = 1000;
int n, m, p[mxN], sz[mxN];
bool edge[mxN][mxN];
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m;
for (int i = 0; i < m; ++i) {
int a, b; cin >> a >> b, --a, --b;
edge[a][b] = 1;
bool g = 1;
while(g) {
g = 0;
for (int x = 0; x < n; ++x) for (int y = 0; y < n; ++y) for (int z = 0; z < n; ++z) {
if (x == y || x == z || y == z || !edge[x][y] || !edge[y][z] || !edge[z][y] || edge[x][z]) continue;
edge[x][z] = 1;
g = 1;
}
}
int ans = 0;
for (int i = 0; i < n; ++i) ans += count(edge[i], edge[i] + n, 1);
cout << ans << "\n";
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
396 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
997 ms |
492 KB |
Output is correct |
8 |
Correct |
987 ms |
592 KB |
Output is correct |
9 |
Correct |
979 ms |
492 KB |
Output is correct |
10 |
Correct |
57 ms |
364 KB |
Output is correct |
11 |
Correct |
56 ms |
364 KB |
Output is correct |
12 |
Correct |
56 ms |
492 KB |
Output is correct |
13 |
Correct |
55 ms |
364 KB |
Output is correct |
14 |
Correct |
59 ms |
364 KB |
Output is correct |
15 |
Correct |
62 ms |
364 KB |
Output is correct |
16 |
Correct |
56 ms |
364 KB |
Output is correct |
17 |
Correct |
67 ms |
364 KB |
Output is correct |
18 |
Correct |
56 ms |
364 KB |
Output is correct |
19 |
Correct |
59 ms |
364 KB |
Output is correct |
20 |
Correct |
137 ms |
364 KB |
Output is correct |
21 |
Correct |
981 ms |
620 KB |
Output is correct |
22 |
Correct |
145 ms |
364 KB |
Output is correct |
23 |
Correct |
430 ms |
364 KB |
Output is correct |
24 |
Correct |
210 ms |
364 KB |
Output is correct |
25 |
Correct |
800 ms |
620 KB |
Output is correct |
26 |
Correct |
39 ms |
364 KB |
Output is correct |
27 |
Correct |
36 ms |
364 KB |
Output is correct |
28 |
Correct |
44 ms |
364 KB |
Output is correct |
29 |
Correct |
46 ms |
364 KB |
Output is correct |
30 |
Correct |
61 ms |
364 KB |
Output is correct |
31 |
Correct |
811 ms |
620 KB |
Output is correct |
32 |
Correct |
64 ms |
364 KB |
Output is correct |
33 |
Correct |
808 ms |
492 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
396 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
997 ms |
492 KB |
Output is correct |
8 |
Correct |
987 ms |
592 KB |
Output is correct |
9 |
Correct |
979 ms |
492 KB |
Output is correct |
10 |
Correct |
57 ms |
364 KB |
Output is correct |
11 |
Correct |
56 ms |
364 KB |
Output is correct |
12 |
Correct |
56 ms |
492 KB |
Output is correct |
13 |
Correct |
55 ms |
364 KB |
Output is correct |
14 |
Correct |
59 ms |
364 KB |
Output is correct |
15 |
Correct |
62 ms |
364 KB |
Output is correct |
16 |
Correct |
56 ms |
364 KB |
Output is correct |
17 |
Correct |
67 ms |
364 KB |
Output is correct |
18 |
Correct |
56 ms |
364 KB |
Output is correct |
19 |
Correct |
59 ms |
364 KB |
Output is correct |
20 |
Correct |
137 ms |
364 KB |
Output is correct |
21 |
Correct |
981 ms |
620 KB |
Output is correct |
22 |
Correct |
145 ms |
364 KB |
Output is correct |
23 |
Correct |
430 ms |
364 KB |
Output is correct |
24 |
Correct |
210 ms |
364 KB |
Output is correct |
25 |
Correct |
800 ms |
620 KB |
Output is correct |
26 |
Correct |
39 ms |
364 KB |
Output is correct |
27 |
Correct |
36 ms |
364 KB |
Output is correct |
28 |
Correct |
44 ms |
364 KB |
Output is correct |
29 |
Correct |
46 ms |
364 KB |
Output is correct |
30 |
Correct |
61 ms |
364 KB |
Output is correct |
31 |
Correct |
811 ms |
620 KB |
Output is correct |
32 |
Correct |
64 ms |
364 KB |
Output is correct |
33 |
Correct |
808 ms |
492 KB |
Output is correct |
34 |
Execution timed out |
5058 ms |
640 KB |
Time limit exceeded |
35 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
396 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
997 ms |
492 KB |
Output is correct |
8 |
Correct |
987 ms |
592 KB |
Output is correct |
9 |
Correct |
979 ms |
492 KB |
Output is correct |
10 |
Correct |
57 ms |
364 KB |
Output is correct |
11 |
Correct |
56 ms |
364 KB |
Output is correct |
12 |
Correct |
56 ms |
492 KB |
Output is correct |
13 |
Correct |
55 ms |
364 KB |
Output is correct |
14 |
Correct |
59 ms |
364 KB |
Output is correct |
15 |
Correct |
62 ms |
364 KB |
Output is correct |
16 |
Correct |
56 ms |
364 KB |
Output is correct |
17 |
Correct |
67 ms |
364 KB |
Output is correct |
18 |
Correct |
56 ms |
364 KB |
Output is correct |
19 |
Correct |
59 ms |
364 KB |
Output is correct |
20 |
Correct |
137 ms |
364 KB |
Output is correct |
21 |
Correct |
981 ms |
620 KB |
Output is correct |
22 |
Correct |
145 ms |
364 KB |
Output is correct |
23 |
Correct |
430 ms |
364 KB |
Output is correct |
24 |
Correct |
210 ms |
364 KB |
Output is correct |
25 |
Correct |
800 ms |
620 KB |
Output is correct |
26 |
Correct |
39 ms |
364 KB |
Output is correct |
27 |
Correct |
36 ms |
364 KB |
Output is correct |
28 |
Correct |
44 ms |
364 KB |
Output is correct |
29 |
Correct |
46 ms |
364 KB |
Output is correct |
30 |
Correct |
61 ms |
364 KB |
Output is correct |
31 |
Correct |
811 ms |
620 KB |
Output is correct |
32 |
Correct |
64 ms |
364 KB |
Output is correct |
33 |
Correct |
808 ms |
492 KB |
Output is correct |
34 |
Execution timed out |
5058 ms |
640 KB |
Time limit exceeded |
35 |
Halted |
0 ms |
0 KB |
- |