#include "game.h"
#include <bits/stdc++.h>
using namespace std;
const int N = 1500;
int sz[N];
int p[N];
int eBetween[N][N];
int n;
int getRoot(int node)
{
if (p[node] == node) return node;
p[node] = getRoot(p[node]);
return p[node];
}
void initialize(int n1) {
n = n1;
for (int i = 0; i < n; i++)
{
p[i] = i;
sz[i] = 1;
}
for (int i = 0; i < n; i++)
{
for (int j = i + 1; j < n; j++)
{
eBetween[i][j] = 1;
eBetween[j][i] = 1;
}
}
}
int hasEdge(int u, int v) {
u = getRoot(u);
v = getRoot(v);
if (eBetween[u][v] == 1)
{
if (sz[u] < sz[v])
{
swap(u, v);
}
sz[u] += sz[v];
for (int i = 0; i < n; i++)
{
int num = eBetween[v][i];
eBetween[u][i] += num;
eBetween[i][u] += num;
}
return 1;
} else
{
eBetween[u][v]--;
eBetween[v][u]--;
return 0;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |