이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |