Submission #59815

#TimeUsernameProblemLanguageResultExecution timeMemory
59815hamzqq9Game (IOI14_game)C++14
0 / 100
6 ms1028 KiB
#include "game.h" #include<bits/stdc++.h> #define st first #define nd second #define mp make_pair #define sz(x) x.size() using namespace std; #define N 1505 set< pair<int,int> > edge_set[N]; int ata[N],rem[N],n; int bul(int node) { if(ata[node]==node) return node; return ata[node]=bul(ata[node]); } void initialize(int n) { ::n=n; for(int i=0;i<n;i++) { for(int j=0;j<n;j++) { if(j==i) continue ; edge_set[i].insert({min(i,j),max(i,j)}); } ata[i]=i; } } void finish(int au) { int node1=edge_set[au].begin()->st; int node2=edge_set[au].begin()->nd; edge_set[au].clear(); int anode1=bul(node1); int anode2=bul(node2); if(sz(edge_set[anode1])<sz(edge_set[anode2])) swap(anode1,anode2); for(auto x:edge_set[anode2]) edge_set[anode1].insert(x); ata[anode2]=anode1; } int hasEdge(int u, int v) { int au=bul(u); int av=bul(v); edge_set[au].erase(edge_set[au].find({min(u,v),max(u,v)})); edge_set[av].erase(edge_set[av].find({min(u,v),max(u,v)})); if(sz(edge_set[au])==1) { finish(au); } if(sz(edge_set[av])==1) { finish(av); } } /* #include <cstdio> #include <cassert> #include "game.h" int read_int() { int x; assert(scanf("%d", &x) == 1); return x; } int bab[N]; int fin(int node) { if(bab[node]==node) return node; return bab[node]=fin(bab[node]); } void bug(vector< pair<int,int> > ed) { for(auto x:ed) { printf("%d %d\n",x.st,x.nd); } } int main() { int n, u, v; n = 4; vector< pair<int,int> > ed; for(int i=0;i<4;i++) { for(int j=0;j<i;j++) { ed.push_back(mp(i,j)); } } int tot=0; do { int comp=4; for(int i=0;i<n;i++) bab[i]=i; initialize(n); for (int i = 0; i < n * (n - 1) / 2; i++) { u = ed[i].st; v = ed[i].nd; // printf("%d %d ",u,v); int res=hasEdge(u,v); if(res) { int bu=fin(u); int bv=fin(v); if(bu!=bv) { bab[bu]=bv; comp--; } } if(comp==1 && i<n*(n-1)/2-1) { bug(ed); return 0; } } if(comp>1) { bug(ed); return 0; } } while(next_permutation(ed.begin(),ed.end())); return 0; } */

Compilation message (stderr)

game.cpp: In function 'int hasEdge(int, int)':
game.cpp:81:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...