Submission #162631

#TimeUsernameProblemLanguageResultExecution timeMemory
162631demetreGame (IOI14_game)C++14
0 / 100
4 ms632 KiB
#include<bits/stdc++.h> using namespace std; int N, n, a, b, f[1001][1001], fix[1001], p[1001]; void initialize (int n) { N = n; for (int i=0; i<N; i++){ p[i] = i; fix[i] = 1; } } int getcol (int l){ if (l == p[l]) return l; return getcol (p[l]); } void col (int k, int l){ int w = getcol(k); int u = getcol(l); p[w] = u; fix[u]+=fix[w]; fix[w] = 0; p[k] = l; for (int i = 0; i < N; i++){ f[u][i]+=f[w][i]; f[i][u]+=f[i][w]; } } int hasEdge (int u, int v){ cin >> a >> b; a = getcol(a); b = getcol(b); f[a][b]++; f[b][a]++; if (f[a][b] == fix[a]*fix[b]){ cout << "YES" << endl; if (fix[a] >= fix[b]) swap(a, b); col (a, b); } else cout << "NO" << endl; }

Compilation message (stderr)

game.cpp: In function 'int hasEdge(int, int)':
game.cpp:49: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...