#include "game.h"
#include <bits/stdc++.h>
using namespace std;
const int N = 2000;
int nFaits[N][N];
int ens[N], taille[N];
int nNoeuds;
set<int> zones;
void initialize(int n) {
nNoeuds = n;
for (int noeud = 0; noeud < nNoeuds; ++noeud){
ens[noeud] = noeud;
taille[noeud] = 1;
zones.insert(noeud);
}
}
int find(int noeud){
if (ens[noeud] != noeud)
ens[noeud] = find(ens[noeud]);
return ens[noeud];
}
void add(int a, int b, int delta){
nFaits[a][b] += delta;
nFaits[b][a] += delta;
}
void fusion(int pere, int fils){
zones.erase(fils);
for (int zone : zones)
add(pere, zone, nFaits[zone][fils]);
taille[pere] += taille[fils];
ens[fils] = pere;
}
int hasEdge(int u, int v) {
u = find(u), v = find(v);
if (nFaits[u][v] == taille[u] * taille[v] - 1){
fusion(u, v);
return 1;
}
else
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |