제출 #157101

#제출 시각아이디문제언어결과실행 시간메모리
157101InfiniteJest게임 (IOI14_game)C++14
0 / 100
3 ms380 KiB
#include <iostream> #include <fstream> #include <vector> #include <queue> #include <algorithm> #include <math.h> #define pb push_back #define mp make_pair #define fi first #define se second using namespace std; ifstream in("input.txt"); ofstream out("output.txt"); typedef long long ll; int N; int k[1600]; int s[1600]; int p[1600][1600]; int find(int x){ while(x!=k[x])x=k[x]; return k[x]; } bool same(int a, int b){ return find(a)==find(b); } void unite(int a, int b){ a=find(a); b=find(b); if(s[a]<s[b])swap(a,b); k[b]=a; s[a]+=s[b]; for(int i=0;i<N;i++)p[a][i]+=p[b][i]; } void initialize(int n){ N=n; for(int i=0;i<n;i++){ k[i]=i; s[i]=1; } } int hasEdge(int u, int v){ u=find(u); v=find(v); if(u==v)return 1; if(p[u][v]/*+p[v][u]*/==s[u]*s[v]-1){ unite(u,v); return 1; } p[u][v]++; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...