제출 #260186

#제출 시각아이디문제언어결과실행 시간메모리
260186alexandra_udristoiu게임 (IOI14_game)C++14
0 / 100
1 ms512 KiB
#include<iostream> #include "game.h" using namespace std; static int n; static int a[1505][1505], r[1505], num[1505]; static int rad(int x){ while(r[x] > 0){ x = r[x]; } return x; } void initialize(int N) { n = N; for(int i = 1; i <= n; i++){ r[i] = -1; } } int hasEdge(int x, int y) { int r1, r2, i; r1 = rad(x); r2 = rad(y); if(r1 == r2){ return 1; } if(r[r1] > r[r2]){ swap(r1, r2); } if(a[r1][r2] != num[r1] * num[r2] - 1){ a[r1][r2]++; a[r2][r1]++; return 0; } r[r1] += r[r2]; num[r1] += num[r2]; r[r2] = r1; for(i = 1; i <= n; i++){ a[r1][i] += a[r2][i]; a[i][r1] = a[r1][i]; } return 1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...