#include "bits/stdc++.h"
using namespace std;
using ll = long long;
ll get(int l, int r = -1) {
if (r == -1) return 1ll * l * (l + 1) / 2;
return 1ll * (r - l + 1) * (l + r) / 2;
}
void solve() {
int n, m;
cin >> n >> m;
int ans = 0;
vector con(n + 1, vector(n + 1, false));
while (m--) {
int u, v;
cin >> u >> v;
if (!con[u][v]) ans++;
con[u][v] = true;
for (int times = 0; times < n; times++) {
for (int x = 1; x <= n; x++) {
for (int y = 1; y <= n; y++) {
if (x == y or !con[x][y]) continue;
for (int z = 1; z <= n; z++) {
if (x == z or y == z or !con[y][z] or !con[z][y]) continue;
// cout << x << ' ' << y << ' ' << z << endl;
if (!con[x][z]) ans++;
con[x][z] = true;
}
}
}
}
cout << ans << '\n';
}
}
int main() {
cin.tie(0)->sync_with_stdio(false);
int queries = 1;
#ifdef sunnatov
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
// cin >> queries;
for (int test_case = 1; test_case <= queries; test_case++) {
#ifdef sunnatov
cout << "Test case: " << test_case << endl;
#endif
solve();
cout << '\n';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 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 |
Correct |
2 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
348 KB |
Output is correct |
7 |
Execution timed out |
5072 ms |
348 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 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 |
Correct |
2 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
348 KB |
Output is correct |
7 |
Execution timed out |
5072 ms |
348 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 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 |
Correct |
2 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
348 KB |
Output is correct |
7 |
Execution timed out |
5072 ms |
348 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |