Submission #961718

# Submission time Handle Problem Language Result Execution time Memory
961718 2024-04-12T11:06:14 Z danikoynov Making Friends on Joitter is Fun (JOI20_joitter2) C++14
0 / 100
1 ms 348 KB
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;
typedef long long ll;

const int maxn = 2010;

int n, par[maxn], m;

int find_leader(int v)
{
    if (par[v] == v)
        return v;
    return (par[v] = find_leader(par[v]));
}

int ed[maxn][maxn];
void solve()
{
    cin >> n >> m;

    for (int i = 1; i <= m; i ++)
    {
        int v, u;
        cin >> v >> u;
        ed[v][u] = 1;
        for (int y = 1; y <= n; y ++)
            for (int z = 1; z <= n; z ++)
            {
               if (y == z)
                    continue;
                if (!(ed[y][z] && ed[z][y]))
                    continue;
                for (int w = 1; w <= n; w ++)
                {
                     if (w == y || w== z)
                         continue;
                    if (ed[w][z] || ed[w][y])
                    {
                        ed[w][z] = ed[w][y] = 1;
                    }

                }
            }

        ll edges = 0;
        for (int x = 1; x <= n; x ++)
            for (int y = 1; y <= n; y ++)
               {
                    //if (v == u && ed[v][u])
                      //   cout << "v " << v << endl;
                    edges += ed[x][y];
               }
        cout << edges << endl;
        //for (int j = 1; j <= n; j ++)
        //cout << "sz " << j << " " << sz[j] << endl;

    }
}

int main()
{
    solve();
    return 0;
}
/**
6 7
1 2
2 3
3 4
4 5
5 6
6 5
5 4

5 9
3 1
5 1
3 4
5 2
1 2
5 4
3 5
2 4
1 3

2 5
4 5
4 3
4 2
2 3
3 2
5 3
2 1
1 5
4 1
1 4


*/
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Incorrect 1 ms 348 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Incorrect 1 ms 348 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Incorrect 1 ms 348 KB Output isn't correct
6 Halted 0 ms 0 KB -