Submission #835240

#TimeUsernameProblemLanguageResultExecution timeMemory
835240LiudasGame (IOI14_game)C++17
0 / 100
1 ms212 KiB
#include <iostream> #include <numeric> #include <vector> #include <set> using namespace std; vector<set<int>> can; vector<int> par; int get(int x){ if(par[x] != x){ return par[x] = get(par[x]); } return x; } void merge(int u, int v){ par[u] = v; } void initialize(int N){ par.resize(N); set<int> con; for(int i = 0; i < N; i ++){ con.insert(i); } can.resize(N); for(int i = 0; i < N; i ++){ con.erase(i); can[i] = con; con.insert(i); } iota(par.begin(), par.end(), 0); } int hasEdge(int u, int v){ u = get(u); v = get(v); if(u == v){return 0;} can[u].erase(v); can[v].erase(u); if(can[u].size() == 0){ for(int i = 0; i < par.size(); i ++){ if(get(i) == u){ can[v].erase(i); } } merge(u, v); return 1; } if(can[v].size() == 0){ for(int i = 0; i < par.size(); i ++){ if(get(i) == v){ can[u].erase(i); } } merge(v, u); return 1; } return 0; }

Compilation message (stderr)

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