# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
210695 | peuch | Game (IOI14_game) | C++17 | 1099 ms | 2424 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;
const int MAXN = 1600;
int marcAux;
int marc[MAXN];
int cnt;
int N;
vector<int> ar[MAXN];
void dfs(int cur){
cnt++;
marc[cur] = marcAux;
for(int i = 0; i < ar[cur].size(); i++){
int viz = ar[cur][i];
if(marc[viz] == marcAux) continue;
dfs(viz);
}
}
void initialize(int n) {
N = n;
for(int i = 0; i < n; i++){
for(int j = i + 1; j < n; j++){
ar[i].push_back(j);
ar[j].push_back(i);
}
}
}
int hasEdge(int u, int v) {
int id = -1;
for(int i = 0; i < ar[u].size(); i++)
if(ar[u][i] == v) id = i;
if(id < 0) return 0;
ar[u].erase(ar[u].begin() + id);
for(int i = 0; i < ar[v].size(); i++)
if(ar[v][i] == u) id = i;
if(id < 0) return 0;
ar[v].erase(ar[v].begin() + id);
marcAux++;
cnt = 0;
dfs(0);
if(cnt == N) return 0;
else{
ar[u].push_back(v);
ar[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... |