Submission #50159

#TimeUsernameProblemLanguageResultExecution timeMemory
50159Just_Solve_The_ProblemGame (IOI14_game)C++11
42 / 100
24 ms1964 KiB
#include <bits/stdc++.h> #include "game.h" using namespace std; #define pb push_back #define all(s) s.begin(), s.end() #define sz(s) (int)s.size() const int N = 1500 + 7; int n; vector < int > gr[N]; void initialize(int nn) { n = nn; assert(n <= 80); for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { gr[i].pb(j); gr[j].pb(i); } } } bool check() { queue < int > q; q.push(0); vector < int > used(n); used[0] = 1; int c = 1; while(!q.empty()) { int v = q.front(); q.pop(); for (int to : gr[v]) { if (!used[to]) { q.push(to); used[to] = 1; c++; } } } return c == n; } int hasEdge(int u, int v) { gr[u].erase(find(all(gr[u]), v)); gr[v].erase(find(all(gr[v]), u)); if (!check()) { gr[u].pb(v); gr[v].pb(u); return 1; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...