제출 #65653

#제출 시각아이디문제언어결과실행 시간메모리
65653IvanC게임 (IOI14_game)C++17
100 / 100
639 ms30352 KiB
#include "game.h" #include <bits/stdc++.h> using namespace std; const int MAXN = 1510; static int pai[MAXN],grau[MAXN][MAXN],N; int find(int x){ if(x == pai[x]) return x; return pai[x] = find(pai[x]); } void join(int x,int y){ x = find(x); y = find(y); if(x == y) return; if(x > y) swap(x,y); pai[y] = x; for(int i = 0;i<N;i++){ if(find(i) != i) continue; grau[x][i] += grau[y][i]; grau[i][x] += grau[i][y]; grau[y][i] = 0; grau[i][y] = 0; } } void initialize(int n){ for(int i = 0;i<n;i++){ pai[i] = i; for(int j = 0;j<n;j++) grau[i][j] = 1; grau[i][i] = 0; } N = n; } int hasEdge(int u, int v) { int x = find(u),y = find(v); if(x == y){ return 0; } grau[x][y]--; grau[y][x]--; if(grau[x][y] == 0){ join(x,y); return 1; } else{ return 0; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...