Submission #1016686

#TimeUsernameProblemLanguageResultExecution timeMemory
1016686n3rm1nGame (IOI14_game)C++17
42 / 100
1073 ms7340 KiB
#include <bits/stdc++.h> #include "game.h" using namespace std; const int MAXN = 2e3 + 10; int vcnt; int used[MAXN][MAXN]; vector < int > g[MAXN]; void initialize(int n) { vcnt = n; } int visited[MAXN], viscnt = 0; void dfs(int beg) { // cout << "* " << beg << endl; 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 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) { //cout << vcnt << endl; viscnt = 0; memset(visited, 0, sizeof(visited)); g[u].push_back(v); g[v].push_back(u); // print_edges(); // cout << " -- " << endl; // cout << "starting a dfs" << endl; dfs(0); // cout << " -- " << endl; // cout << "after connecting = "<< viscnt << endl; if(viscnt == vcnt) /// svyrzva { g[u].pop_back(); g[v].pop_back(); used[u][v] = 2; used[v][u] = 2; /// print_edges(); return 0; } g[u].pop_back(); g[v].pop_back(); for (int i = 0; i < vcnt; ++ i) { for (int j = i+1; j < vcnt; ++ j) { if(!used[i][j] && !(i == min(u, v) && j == (max(u, v)))) { g[i].push_back(j); g[j].push_back(i); } } } viscnt = 0; memset(visited, 0, sizeof(visited)); //print_edges(); dfs(0); for (int i = 0; i < vcnt; ++ i) { vector < int > neww; while(g[i].size()) { int nb = g[i].back(); if(used[i][nb] == 1)break; g[i].pop_back(); } } if(viscnt != vcnt) { used[u][v] = 1; used[v][u] = 1; g[u].push_back(v); g[v].push_back(u); // print_edges(); return 1; } // g[u].push_back(v); // g[v].push_back(u); used[u][v] = 2; used[v][u] = 2; //print_edges(); return 0; }

Compilation message (stderr)

game.cpp: In function 'void dfs(int)':
game.cpp:19:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |     for (int i = 0; i < g[beg].size(); ++ i)
      |                     ~~^~~~~~~~~~~~~~~
game.cpp: In function 'void print_edges()':
game.cpp:31:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |         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...