제출 #413462

#제출 시각아이디문제언어결과실행 시간메모리
413462Antekb게임 (IOI14_game)C++14
100 / 100
508 ms25288 KiB
#include "game.h" #include<bits/stdc++.h> #define st first #define nd second using namespace std; const int N=1505; int E[N][N]; int n; int r[N]; void initialize(int _n){ n=_n; //cout<<n<<"\n"; for(int i=0; i<n; i++){ r[i]=i; for(int j=0; j<i; j++){ E[i][j]=E[j][i]=1; } } } int find(int v){ if(r[v]==v)return v; return r[v]=find(r[v]); } void Union(int u, int v){ //cout<<u<<"a"<<v<<"\n"; for(int i=0; i<n; i++){ if(i==u || i==v)continue; E[u][i]+=E[v][i]; E[i][u]+=E[i][v]; E[v][i]=0; E[i][v]=0; assert(E[u][i]==E[i][u]); } r[v]=u; } int hasEdge(int u, int v) { //cout<<u<<" "<<v<<"\n"; u=find(u); v=find(v); assert(u!=v); E[u][v]--; E[v][u]--; /*for(int i=0; i<n; i++){ for(int j=0; j<n; j++){ cout<<E[i][j]<<" "; } cout<<"\n"; } cout<<"\n";*/ if(E[v][u]==0){ Union(u, v); return 1; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...