이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "game.h"
#define debug(x) cerr << #x << " " << x << "\n"
#define debugs(x) cerr << #x << " " << x << " "
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <long double, pii> muchie;
const ll NMAX = 5001;
const ll VMAX = 1000001;
const ll INF = (1LL << 60);
const ll MOD = 1000000007;
const ll BLOCK = 1000000;
const ll base = 13137;
const ll nr_of_bits = 16;
int p[NMAX];
vector <int> comp[NMAX];
int q[NMAX][NMAX];
int N;
void initialize(int n) {
N = n;
for(int i = 0; i < N; i++)
{
p[i] = i;
comp[i].push_back(i);
}
}
int root(int x){
if(x == p[x])
return x;
return p[x] = root(p[x]);
}
int hasEdge(int u, int v) {
q[u][v] = 1;
q[v][u] = 1;
u = root(u);
v = root(v);
if(u == v){
return 0; /// we don't really care
}
int ok = 0;
for(auto x : comp[u]){
for(auto y : comp[v]){
ok += (!q[x][y]);
}
}
if(ok){
return 0;
}
for(auto x : comp[u])
comp[v].push_back(x);
p[u] = v;
return 1;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |