이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |