#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 = y + 1; z <= n; z ++)
{
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 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |