Submission #558130

#TimeUsernameProblemLanguageResultExecution timeMemory
558130OlympiaGame (IOI14_game)C++17
0 / 100
1 ms340 KiB
#include <bits/stdc++.h> #include <game.h> using namespace std; struct dsu { vector<int> parent; vector<int> compSize; int n; int cc = 0; void fill(){ cc = n; parent.resize(n), compSize.resize(n); for(int i = 0; i < n; i++){ parent[i] = i, compSize[i] = 1; } } int find_head(int x){ if(x == parent[x]){ return x; } return find_head(parent[x]); } void join(int x, int y){ x = find_head(x); y = find_head(y); if(x == y){ return; } cc--; if(compSize[x] > compSize[y]){ swap(x,y); //ensures that compSize[x1] <= compSize[y1] } parent[x] = y; compSize[y] += compSize[x]; } bool comp(int x, int y){ return (find_head(x) == find_head(y)); } }; dsu d; vector<set<int> > e; void initialize (int n) { d.n = n; e.resize(n); d.fill(); for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (j != i) { e[i].insert(j); } } } } int hasEdge (int u, int v) { u--, v--; e[u].erase(v); e[v].erase(u); d.fill(); for (int i = 0; i < e.size(); i++) { for (int j: e[i]) { d.join(i, j); } } if (d.cc != 1) { return false; } e[u].insert(v); e[v].insert(u); return true; }

Compilation message (stderr)

game.cpp: In function 'int hasEdge(int, int)':
game.cpp:59:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::set<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |     for (int i = 0; i < e.size(); i++) {
      |                     ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...