Submission #961711

# Submission time Handle Problem Language Result Execution time Memory
961711 2024-04-12T10:59:54 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 v = 1; v <= n; v ++)
            for (int u = 1; u <= n; u ++)
            {
                if (!(ed[v][u] && ed[u][v]))
                    continue;
                for (int w = 1; w <= n; w ++)
                {
                     if (w == v || w== u)
                         continue;
                    if (ed[w][v] || ed[w][u])
                    {
                        ed[w][v] = ed[w][u] = 1;
                    }

                }
            }

        ll edges = 0;
        for (int v = 1; v <= n; v ++)
            for (int u = 1; u <= n; u ++)
               {
                    //if (v == u && ed[v][u])
                      //   cout << "v " << v << endl;
                    edges += ed[v][u];
               }
        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 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 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 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 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 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 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 -