Submission #484240

#TimeUsernameProblemLanguageResultExecution timeMemory
484240blueMaking Friends on Joitter is Fun (JOI20_joitter2)C++17
0 / 100
5044 ms204 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...