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 F first
#define S second
int a[1501][1501], a1[1501];
set<int> s[1501];
void initialize(int n) {
for(int i=0; i<n; i++){
for(int t=i+1; t<n; t++){
a[i][t]=-1;
a[t][i]=-1;
a1[i]+=t;
a1[t]+=i;
s[i].insert(t);
s[t].insert(i);
}
}
return ;
}
int hasEdge(int u, int v){
if(a[u][v]!=-1)return a[u][v];
a[u][v]=0;
a[v][u]=0;
s[u].erase(v);
s[v].erase(u);
a1[u]-=v;
a1[v]-=u;
int c=0;
while(s[u].size()==1){
a[u][a1[u]]=1;
a[a1[u]][u]=1;
s[u].erase(a1[u]);
s[a1[u]].erase(u);
a1[a1[u]]-=u;
c=u;
u=a1[u];
a1[c]=0;
}
while(s[v].size()==1){
a[v][a1[v]]=1;
a[a1[v]][v]=1;
s[v].erase(a1[v]);
s[a1[v]].erase(v);
a1[a1[v]]-=v;
c=v;
v=a1[v];
a1[c]=0;
}
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... |