Submission #1016716

#TimeUsernameProblemLanguageResultExecution timeMemory
1016716n3rm1nGame (IOI14_game)C++17
15 / 100
1 ms856 KiB
#include <bits/stdc++.h> #include "game.h" using namespace std; const int MAXN = 2e3 + 10; int vcnt; vector < int > g[MAXN]; unordered_set < int> s[MAXN]; void initialize(int n) { vcnt = n; for (int i = 0; i < n; ++ i) { for (int j = 0; j < n; ++ j) if(i != j)s[i].insert(j); } } int visited[MAXN], viscnt = 0; void dfs(int beg) { visited[beg] = 1; viscnt ++; int nb; for (int i = 0; i < g[beg].size(); ++ i) { nb = g[beg][i]; if(!visited[nb])dfs(nb); } } void dfs0(int beg) { //cout << beg << endl; visited[beg] = 1; viscnt ++; int nb; for (unordered_set<int>::iterator it = s[beg].begin(); it != s[beg].end(); it ++) { nb = *it; if(!visited[nb])dfs0(nb); } } int f = 0; void print_edges() { for (int i = 0; i < vcnt; ++ i) { cout << "for " << i << endl; for (int j = 0; j < g[i].size(); ++ j) cout << g[i][j] << " "; cout << endl; } } int hasEdge(int u, int v) { viscnt = 0; memset(visited, 0, sizeof(visited)); g[u].push_back(v); g[v].push_back(u); dfs(0); g[u].pop_back(); g[v].pop_back(); s[u].erase(v); s[v].erase(u); if(viscnt == vcnt) { return 0; } if(f) { f = 1; s[u].insert(v); s[v].insert(u); g[u].push_back(v); g[v].push_back(u); return 1; } viscnt = 0; memset(visited, 0, sizeof(visited)); dfs0(0); //cout << viscnt << endl; if(viscnt != vcnt) { f = 1; s[u].insert(v); s[v].insert(u); g[u].push_back(v); g[v].push_back(u); return 1; } return 0; }

Compilation message (stderr)

game.cpp: In function 'void dfs(int)':
game.cpp:24:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |     for (int i = 0; i < g[beg].size(); ++ i)
      |                     ~~^~~~~~~~~~~~~~~
game.cpp: In function 'void print_edges()':
game.cpp:49:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |         for  (int j = 0; j < g[i].size(); ++ j)
      |                          ~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...