# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
576004 |
2022-06-12T04:26:38 Z |
WongChun1234 |
Game (APIO22_game) |
C++17 |
|
9 ms |
14288 KB |
#include "game.h"
#include<bits/stdc++.h>
using namespace std;
const int N=300050;
int n,k,l[N],r[N];
vector<int> adj[N],radj[N];
void init(int nn, int kk) {
n=nn; k=kk;
for (int i=0;i<=k;i++) l[i]=i,r[i]=i+1;
for (int i=k+1;i<=n;i++) l[i]=0,r[i]=k-1;
for (int i=0;i<=n;i++) adj[i].clear(),radj[i].clear();
}
bool addedge(int u,int v){
//cerr<<u<<":"<<l[u]<<"-"<<r[u]<<"->"<<v<<":"<<l[v]<<"-"<<r[v]<<"\n";
if (r[u]<=l[v]) return 0;
if (l[u]>=r[v]) return 1;
if (r[v]<=(l[u]+r[u])/2){
r[u]=(l[u]+r[u])/2;
for (int i:radj[u]) if (addedge(i,u)) return 1;
}else if (l[u]>(l[v]+r[v])/2){
l[v]=(l[v]+r[v])/2+1;
for (int i:adj[v]) if (addedge(v,i)) return 1;
}
return 0;
}
int add_teleporter(int u, int v) {
u++;
if (v>=k) v++;
adj[u].push_back(v);
radj[v].push_back(u);
return addedge(u,v);
}
/*
6 5 3
3 4
5 0
4 5
5 3
1 4
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
14288 KB |
Output is correct |
2 |
Correct |
8 ms |
14288 KB |
Output is correct |
3 |
Correct |
8 ms |
14288 KB |
Output is correct |
4 |
Correct |
8 ms |
14288 KB |
Output is correct |
5 |
Correct |
8 ms |
14288 KB |
Output is correct |
6 |
Correct |
9 ms |
14288 KB |
Output is correct |
7 |
Correct |
9 ms |
14288 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
14288 KB |
Output is correct |
2 |
Correct |
8 ms |
14288 KB |
Output is correct |
3 |
Correct |
8 ms |
14288 KB |
Output is correct |
4 |
Correct |
8 ms |
14288 KB |
Output is correct |
5 |
Correct |
8 ms |
14288 KB |
Output is correct |
6 |
Correct |
9 ms |
14288 KB |
Output is correct |
7 |
Correct |
9 ms |
14288 KB |
Output is correct |
8 |
Correct |
7 ms |
14288 KB |
Output is correct |
9 |
Correct |
7 ms |
14288 KB |
Output is correct |
10 |
Incorrect |
8 ms |
14276 KB |
Wrong Answer[1] |
11 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
14288 KB |
Output is correct |
2 |
Correct |
8 ms |
14288 KB |
Output is correct |
3 |
Correct |
8 ms |
14288 KB |
Output is correct |
4 |
Correct |
8 ms |
14288 KB |
Output is correct |
5 |
Correct |
8 ms |
14288 KB |
Output is correct |
6 |
Correct |
9 ms |
14288 KB |
Output is correct |
7 |
Correct |
9 ms |
14288 KB |
Output is correct |
8 |
Correct |
7 ms |
14288 KB |
Output is correct |
9 |
Correct |
7 ms |
14288 KB |
Output is correct |
10 |
Incorrect |
8 ms |
14276 KB |
Wrong Answer[1] |
11 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
14288 KB |
Output is correct |
2 |
Correct |
8 ms |
14288 KB |
Output is correct |
3 |
Correct |
8 ms |
14288 KB |
Output is correct |
4 |
Correct |
8 ms |
14288 KB |
Output is correct |
5 |
Correct |
8 ms |
14288 KB |
Output is correct |
6 |
Correct |
9 ms |
14288 KB |
Output is correct |
7 |
Correct |
9 ms |
14288 KB |
Output is correct |
8 |
Correct |
7 ms |
14288 KB |
Output is correct |
9 |
Correct |
7 ms |
14288 KB |
Output is correct |
10 |
Incorrect |
8 ms |
14276 KB |
Wrong Answer[1] |
11 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
14288 KB |
Output is correct |
2 |
Correct |
8 ms |
14288 KB |
Output is correct |
3 |
Correct |
8 ms |
14288 KB |
Output is correct |
4 |
Correct |
8 ms |
14288 KB |
Output is correct |
5 |
Correct |
8 ms |
14288 KB |
Output is correct |
6 |
Correct |
9 ms |
14288 KB |
Output is correct |
7 |
Correct |
9 ms |
14288 KB |
Output is correct |
8 |
Correct |
7 ms |
14288 KB |
Output is correct |
9 |
Correct |
7 ms |
14288 KB |
Output is correct |
10 |
Incorrect |
8 ms |
14276 KB |
Wrong Answer[1] |
11 |
Halted |
0 ms |
0 KB |
- |