# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
113963 | baqargam | Game (IOI14_game) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <cstdio>
#include <cassert>
#include "game.h"
using namespace std;
int n,m,k,l,i,j,a,b,col[1505],sz[1505],d[1505][1505];
int read_int() {
int x;
assert(scanf("%d", &x) == 1);
return x;
}
void unite(int a,int b){
sz[a]+=sz[b];
for(int i=0;i<n;i++){
if(col[i]==b) col[i]=a;
d[a][i]+=d[b][i];
}
}
int hasEdge(int a,int b){
if(d[col[a]][col[b]]+1==sz[a]*sz[b])
{
unite(col[a],col[b]);
return 1;
}
else
return 0;
}
int main() {
int u, v;
n = read_int();
initialize(n);
for (int i = 0; i < n * (n - 1) / 2; i++) {
u = read_int();
v = read_int();
printf("%d\n", hasEdge(u, v));
}
return 0;
}