#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define F first
#define S second
using namespace std;
int N, M, adj[2005][2005];
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
cin >> N >> M;
for(int i = 1; i <= M; i++)
{
int A, B, ans = 0;
cin >> A >> B;
adj[A][B] = 1;
for(int t = 1; t <= 10; t++)
for(int x = 1; x <= N; x++)
for(int y = 1; y <= N; y++)
if(adj[x][y])
for(int z = 1; z <= N; z++)
if(adj[y][z] && adj[z][y] && x != z && adj[x][z] == 0)
adj[x][z] = 1;
for(int x = 1; x <= N; x++)
for(int y = 1; y <= N; y++)
if(adj[x][y])
for(int z = 1; z <= N; z++)
if(adj[y][z] && adj[z][y] && x != z && adj[x][z] == 0)
assert(false);
for(int x = 1; x <= N; x++)
for(int y = 1; y <= N; y++)
ans += adj[x][y];
cout << ans << '\n';
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
2 ms |
328 KB |
Output is correct |
6 |
Correct |
3 ms |
324 KB |
Output is correct |
7 |
Execution timed out |
5045 ms |
536 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
2 ms |
328 KB |
Output is correct |
6 |
Correct |
3 ms |
324 KB |
Output is correct |
7 |
Execution timed out |
5045 ms |
536 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
2 ms |
328 KB |
Output is correct |
6 |
Correct |
3 ms |
324 KB |
Output is correct |
7 |
Execution timed out |
5045 ms |
536 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |