제출 #159865

#제출 시각아이디문제언어결과실행 시간메모리
159865maximath_1게임 (IOI14_game)C++11
0 / 100
28 ms10104 KiB
#include "game.h" #include<bits/stdc++.h> using namespace std; int par[1569], sz[1569]; int m, cnt[1569][1569]; int find(int x){ return par[x]==x?x:par[x]=find(par[x]); } void uni(int a, int b){ if(a<b) swap(a, b); par[a]=b; sz[b]+=a; } void initialize(int n){ m=n; memset(cnt, 0, sizeof(cnt)); for(int i=0; i<n; i++){ par[i]=i; sz[i]=1; } } int hasEdge(int u, int v){ u=find(u); v=find(v); cnt[u][v]++; cnt[v][u]++; if(cnt[u][v]==sz[u]*sz[v]){ uni(u, v); for(int i=0; i<m; i++){ cnt[u][i]+=cnt[v][i]; cnt[i][u]+=cnt[i][v]; } return 1; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...