# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
897216 |
2024-01-02T17:48:07 Z |
aqxa |
Game (IOI14_game) |
C++17 |
|
1 ms |
4544 KB |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 1505;
int a[N][N], cnt[N][N];
int n;
vector<int> e;
int get(int x) { return e[x] < 0 ? x : e[x] = get(e[x]); }
bool unite(int x, int y) {
x = get(x); y = get(y);
if (x == y) return false;
if (e[x] > e[y]) swap(x, y);
e[x] += e[y]; e[y] = x;
return true;
}
void initialize(int _n) {
n = _n;
e = vector<int>(n, -1);
for (int i = 0; i < n; ++i) {
for (int j = i + 1; j < n; ++j) {
a[i][j] = -1;
cnt[i][j] = 1;
}
}
}
int hasEdge(int u, int v) {
u--; v--;
if (u > v) swap(u, v);
int cu = get(u), cv = get(v);
if (cu == cv) return 1;
if (cu > cv) swap(cu, cv);
if (cnt[cu][cv] == 1) {
unite(cu, cv);
int np = get(cu);
for (int i = 0; i < n; ++i) {
if (e[i] < 0 && i != cu && i != cv) {
cnt[min(i, np)][max(i, np)] = cnt[min(i, cu)][max(i, cu)] + cnt[min(i, cv)][max(i, cv)];
}
}
return 1;
} else {
cnt[cu][cv]--;
return 0;
}
}
// int32_t main() {
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// return 0;
// }
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
4444 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
4444 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
4544 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |