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<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int cnt[1505],cnt2[1505],ind,ind1[1505],x[1505],bio[1505][1505],n1;
void initialize(int n) {
memset(ind1,-1,sizeof(ind1));
n1=n;
}
int hasEdge(int u, int v) {
int a=u,b=v,c=0,ret;
bio[a][b]=1;
bio[b][a]=1;
if(ind1[a]!=-1 && ind1[b]!=-1 && ind1[a]>ind1[b]) swap(a,b);
if(ind1[b]!=-1 && ind1[a]==-1) swap(a,b);
//if(a==1 && b==2) cout << cnt[a] << " " << cnt2[a] << " " << ind1[a] << " " << ind << "\n";
if(ind1[a]!=-1) {
if(n1-1-cnt[a]>ind1[a]+1) ret=0;
else ret=1;
c=3;
}
if(ind1[a]==-1 && n1-1-cnt[a]==ind-cnt2[a]+1) {
ret=1;
ind1[a]=ind;
for(int j=0;j<n1;j++) {
if(bio[j][a]) cnt2[j]+=1;
}
ind+=1;
c=1;
}
if(ind1[b]==-1 && n1-1-cnt[b]==ind-cnt2[b]+1) {
ret=1;
ind1[b]=ind;
for(int j=0;j<n1;j++) {
if(bio[j][b]) cnt2[j]+=1;
}
ind+=1;
c=2;
}
if(!c) ret=0;
cnt[a]+=1;
cnt[b]+=1;
return ret;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |