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 <bits/stdc++.h>
#include "game.h"
using namespace std;
#define F first
#define S second
const int MAXN = 1505;
int coredge[MAXN], deg[MAXN];
set<pair<int, int>> s;
int n;
void initialize(int _n) {
n = _n;
for(int i=0;i<n;i++) s.insert({deg[i], i});
}
int hasEdge(int u, int v) {
++coredge[u]; ++coredge[v];
int topnode = s.begin()->S;
if(u != topnode && v != topnode) {
s.erase({deg[u],u});
s.erase({deg[v],v});
++deg[u]; ++deg[v];
s.insert({deg[u],u});
s.insert({deg[v],v});
return 1;
} else {
if((u == topnode && coredge[u] == n-1) || (v == topnode && coredge[v] == n-1)) {
s.erase({deg[u],u});
s.erase({deg[v],v});
++deg[u]; ++deg[v];
s.insert({deg[u],u});
s.insert({deg[v],v});
return 1;
} else {
return 0;
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |