Submission #702493

#TimeUsernameProblemLanguageResultExecution timeMemory
702493math_rabbit_1028Game (IOI14_game)C++14
0 / 100
1 ms212 KiB
#include "game.h" #include <bits/stdc++.h> using namespace std; int root[1515], dep[1515], can[1515], comp, last; void initialize(int n) { for (int i = 0; i < n; i++) root[i] = i; for (int i = 0; i < n; i++) dep[i] = 1; for (int i = 0; i < n; i++) can[i] = n - 1; comp = n; last = n * (n - 1) / 2; } int Find(int v) { if (v == root[v]) return v; else return root[v] = Find(root[v]); } int hasEdge(int u, int v) { last--; if (last == 0) return 1; u = Find(u); v = Find(v); //cout << u << " " << v << " " << can[u] << " " << can[v] << "\n"; if (u == v) return 1; else if (comp <= 2) { can[u]--; can[v]--; return 0; } else if (can[u] > 1 && can[v] > 1) { can[u]--; can[v]--; return 0; } else { if (dep[u] > dep[v]) { root[v] = u; can[u] = can[u] + can[v] - 2; } else if (dep[u] < dep[v]) { root[u] = v; can[v] = can[v] + can[u] - 2; } else { root[u] = v; dep[v] = dep[v]++; can[v] = can[v] + can[u] - 2; } comp--; return 1; } }

Compilation message (stderr)

game.cpp: In function 'int hasEdge(int, int)':
game.cpp:47:20: warning: operation on 'dep[v]' may be undefined [-Wsequence-point]
   47 |             dep[v] = dep[v]++;
      |             ~~~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...