# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
920658 | Macker | Game (IOI14_game) | C++17 | 1066 ms | 13144 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;
typedef long long ll;
#define all(v) v.begin(), v.end()
vector<set<int>> adj;
set<int> active;
int n;
bool dfs(int a, int f){
bool ret = 0;
//if(adj[a].size() < active.size()){
for (auto &b : adj[a]) {
if(active.find(b) != active.end()){
active.erase(b);
if(b == f) return 1;
if(dfs(b, f)) return 1;
}
}
/*
}
else{
set<int> tmp = active;
for (auto &b : tmp) {
if(adj[a].find(b) != adj[a].end()){
active.erase(b);
if(b == f) return 1;
if(dfs(b, f)) return 1;
}
}
}
*/
return 0;
}
void initialize(int N) {
n = N;
adj.resize(n);
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if(j != i) adj[i].insert(j);
}
}
}
int hasEdge(int u, int v) {
for (int i = 0; i < n; i++) {
active.insert(i);
}
adj[u].erase(v);
adj[v].erase(u);
if(dfs(u, v)) return 0;
else {
adj[u].insert(v);
adj[v].insert(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... |