This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
using namespace std;
int main()
{
int N, M;
cin >> N >> M;
int follow[1+N][1+N];
for(int i = 1; i <= N; i++)
for(int j = 1; j <= N; j++)
follow[i][j] = 0;
int ans = 0;
for(int j = 1; j <= M; j++)
{
int a, b;
cin >> a >> b;
if(!follow[a][b]) ans++;
follow[a][b] = 1;
for(int q = 1; q <= N*N*N; q++)
{
for(int x = 1; x <= N; x++)
{
for(int y = 1; y <= N; y++)
{
for(int z = 1; z <= N; z++)
{
if(x == y || y == z || z == x) continue;
if(follow[x][y] && !follow[x][z] && follow[y][z] && follow[z][y])
{
ans++;
follow[x][z] = 1;
}
}
}
}
}
cout << ans << '\n';
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |