제출 #1062948

#제출 시각아이디문제언어결과실행 시간메모리
1062948YassirSalama게임 (IOI14_game)C++17
0 / 100
3 ms9052 KiB
#include "game.h" #include<bits/stdc++.h> using namespace std; const int maxn=1501; int par[maxn]; int cnt[maxn][maxn]; int n; void initialize(int _n) { n=_n; for(int i=0;i<n;i++) par[i]=i; memset(cnt,1,sizeof(cnt)); } int find(int node){ return node==par[node]?node:par[node]=find(par[node]); } void merge(int a,int b){ a=find(a);b=find(b); if(a==b) return; for(int i=0;i<n;i++) cnt[a][i]+=cnt[b][i],cnt[i][a]+=cnt[i][b]; par[b]=a; } int hasEdge(int u, int v) { u=find(u); v=find(v); if(cnt[u][v]==1){ merge(u,v);return 1; } cnt[u][v]--,cnt[v][u]--; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...