Submission #1016712

#TimeUsernameProblemLanguageResultExecution timeMemory
1016712n3rm1nGame (IOI14_game)C++17
0 / 100
1 ms348 KiB
#include <bits/stdc++.h> #include "game.h" using namespace std; const int MAXN = 2e3 + 10; int vcnt; vector < int > g[MAXN]; 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 (auto nb: s[beg]) { if(!visited[nb])dfs0(nb); } } 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; } viscnt = 0; memset(visited, 0, sizeof(visited)); dfs0(0); //cout << viscnt << endl; if(viscnt != vcnt) { 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 dfs0(int)':
game.cpp:36:9: warning: unused variable 'nb' [-Wunused-variable]
   36 |     int nb;
      |         ^~
game.cpp: In function 'void print_edges()':
game.cpp:47:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |         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...