# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
442911 |
2021-07-09T10:45:09 Z |
algorithm16 |
Game (IOI14_game) |
C++14 |
|
1 ms |
332 KB |
#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 |
1 |
Correct |
1 ms |
324 KB |
Output is correct |
2 |
Correct |
1 ms |
296 KB |
Output is correct |
3 |
Correct |
1 ms |
280 KB |
Output is correct |
4 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
300 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |