# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
992467 | Alfraganus | Game (IOI14_game) | C++17 | 1020 ms | 2672 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "game.h"
#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> graph;
void initialize(int n) {
graph.resize(n);
for(int i = 0; i < n; i ++)
for(int j = i + 1; j < n; j ++)
graph[i].push_back(j), graph[j].push_back(i);
}
int hasEdge(int u, int v) {
vector<int> p;
for(auto x : graph[u])
if(x != v)
p.push_back(x);
graph[u] = p;
p.clear();
for(auto x : graph[v])
if(x != u)
p.push_back(x);
graph[v] = p;
vector<bool> used(graph.size());
int cnt = 1;
deque<int> q;
q.push_back(u);
used[u] = 1;
while(!q.empty()){
int u = q.front();
q.pop_front();
for(auto x : graph[u]){
if(!used[x]){
used[x] = true;
q.push_back(x);
cnt ++;
}
}
}
if(cnt == graph.size())
return 0;
graph[u].push_back(v);
graph[v].push_back(u);
return 1;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |