제출 #1013090

#제출 시각아이디문제언어결과실행 시간메모리
1013090Luvidi게임 (IOI14_game)C++17
100 / 100
224 ms26448 KiB
#include "game.h" #include <bits/stdc++.h> using namespace std; int n,par[1500],sz[1500],cnt[1500][1500]; int rep(int x){ while(x!=par[x])x=par[x]; return x; } void join(int x,int y){ if(sz[x]>sz[y])swap(x,y); par[x]=y; sz[y]+=sz[x]; for(int i=0;i<n;i++){ if(par[i]!=i)continue; if(i==y)continue; cnt[y][i]+=cnt[x][i]; cnt[i][y]+=cnt[i][x]; } } void initialize(int x) { n=x; for(int i=0;i<n;i++){ par[i]=i; sz[i]=1; } for(int i=0;i<n;i++){ for(int j=0;j<n;j++)cnt[i][j]=1; } } int hasEdge(int u, int v) { u=rep(u); v=rep(v); cnt[u][v]--; cnt[v][u]--; if(u==v)return 1; if(cnt[u][v])return 0; join(u,v); return 1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...