Submission #393449

#TimeUsernameProblemLanguageResultExecution timeMemory
393449peuchGame (IOI14_game)C++17
Compilation error
0 ms0 KiB
#include <cstdio> #include <cassert> #include "game.h" #include "game.h" #include<bits/stdc++.h> using namespace std; const int MAXN = 1510; int N; int rep[MAXN], tam[MAXN]; vector<int> grp[MAXN]; int conect[MAXN][MAXN]; int find(int a){ if(rep[a] == a) return a; return rep[a] = find(rep[a]); } bool test(int u, int v){ u = find(u); v = find(v); if(rand() & 1) swap(u, v); conect[u][v]++; conect[v][u]++; int cnt = 0; for(int i = 0; i < grp[u].size(); i++) cnt += conect[v][grp[u][i]]; return cnt == tam[u] * tam[v]; } void uni(int a, int b){ a = find(a); b = find(b); if(rand() & 1) swap(a, b); for(int i = 0; i < grp[a].size(); i++){ grp[b].push_back(grp[a][i]); } for(int i = 0; i < N; i++) conect[b][i] += conect[a][i]; rep[a] = b; tam[b] += tam[a]; } void initialize(int n) { srand(time(0)); N = n; for(int i = 0; i < N; i++){ rep[i] = i; grp[i].push_back(i); tam[i] = 1; } } int hasEdge(int u, int v) { if(test(u, v)) { uni(u, v); return 1; } return 0; } int read_int() { int x; assert(scanf("%d", &x) == 1); return x; } int main() { int n, u, v; n = read_int(); initialize(n); for (int i = 0; i < n * (n - 1) / 2; i++) { u = read_int(); v = read_int(); printf("%d\n", hasEdge(u, v)); } return 0; }

Compilation message (stderr)

game.cpp: In function 'bool test(int, int)':
game.cpp:27:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |  for(int i = 0; i < grp[u].size(); i++)
      |                 ~~^~~~~~~~~~~~~~~
game.cpp: In function 'void uni(int, int)':
game.cpp:36:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |  for(int i = 0; i < grp[a].size(); i++){
      |                 ~~^~~~~~~~~~~~~~~
/tmp/ccqwKKyW.o: In function `read_int()':
grader.cpp:(.text+0x0): multiple definition of `read_int()'
/tmp/ccIy4kdV.o:game.cpp:(.text+0x150): first defined here
/tmp/ccqwKKyW.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccIy4kdV.o:game.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status