# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
599446 |
2022-07-19T14:11:56 Z |
DanerZein |
Game (APIO22_game) |
C++17 |
|
2 ms |
1496 KB |
#include "game.h"
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
const int MAX_N=3e5+10;
vector<vi> I;
vector<vi> G;
int fr[MAX_N];
int to[MAX_N];
int K,N;
void init(int n, int k) {
K=k;
N=n;
G.resize(n+1);
I.resize(n+1);
for(int i=0;i<=n;i++) fr[i]=1e9;
memset(to,-1,sizeof to);
}
bool updateG(int u){
bool ans=0;
if(to[u]>=fr[u]) return 1;
for(auto &v:G[u]){
int val;
if(u<K) val=u;
else val=to[u];
if(to[v]<val){
to[v]=val;
ans|=updateG(v);
}
}
return ans;
}
bool updateI(int u){
bool ans=0;
if(to[u]>=fr[u]) return 1;
for(auto &v:I[u]){
int val;
if(u<K) val=u;
else val=fr[u];
if(val<fr[v]){
fr[v]=val;
ans|=updateI(v);
}
}
return ans;
}
int add_teleporter(int u, int v) {
if(u<K && v<K){
if(u>=v) return 1;
return 0;
}
G[u].push_back(v);
I[v].push_back(u);
if(u<K){
to[v]=max(to[v],u);
}
if(v<K){
fr[u]=min(fr[u],v);
}
bool s1=updateG(u);
bool s2=updateI(v);
return s1|s2;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1360 KB |
Output is correct |
2 |
Correct |
2 ms |
1360 KB |
Output is correct |
3 |
Correct |
1 ms |
1360 KB |
Output is correct |
4 |
Correct |
1 ms |
1360 KB |
Output is correct |
5 |
Correct |
1 ms |
1360 KB |
Output is correct |
6 |
Correct |
1 ms |
1360 KB |
Output is correct |
7 |
Correct |
1 ms |
1360 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1360 KB |
Output is correct |
2 |
Correct |
2 ms |
1360 KB |
Output is correct |
3 |
Correct |
1 ms |
1360 KB |
Output is correct |
4 |
Correct |
1 ms |
1360 KB |
Output is correct |
5 |
Correct |
1 ms |
1360 KB |
Output is correct |
6 |
Correct |
1 ms |
1360 KB |
Output is correct |
7 |
Correct |
1 ms |
1360 KB |
Output is correct |
8 |
Correct |
1 ms |
1360 KB |
Output is correct |
9 |
Correct |
1 ms |
1360 KB |
Output is correct |
10 |
Correct |
1 ms |
1360 KB |
Output is correct |
11 |
Correct |
1 ms |
1360 KB |
Output is correct |
12 |
Correct |
1 ms |
1496 KB |
Output is correct |
13 |
Incorrect |
2 ms |
1488 KB |
Wrong Answer[1] |
14 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1360 KB |
Output is correct |
2 |
Correct |
2 ms |
1360 KB |
Output is correct |
3 |
Correct |
1 ms |
1360 KB |
Output is correct |
4 |
Correct |
1 ms |
1360 KB |
Output is correct |
5 |
Correct |
1 ms |
1360 KB |
Output is correct |
6 |
Correct |
1 ms |
1360 KB |
Output is correct |
7 |
Correct |
1 ms |
1360 KB |
Output is correct |
8 |
Correct |
1 ms |
1360 KB |
Output is correct |
9 |
Correct |
1 ms |
1360 KB |
Output is correct |
10 |
Correct |
1 ms |
1360 KB |
Output is correct |
11 |
Correct |
1 ms |
1360 KB |
Output is correct |
12 |
Correct |
1 ms |
1496 KB |
Output is correct |
13 |
Incorrect |
2 ms |
1488 KB |
Wrong Answer[1] |
14 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1360 KB |
Output is correct |
2 |
Correct |
2 ms |
1360 KB |
Output is correct |
3 |
Correct |
1 ms |
1360 KB |
Output is correct |
4 |
Correct |
1 ms |
1360 KB |
Output is correct |
5 |
Correct |
1 ms |
1360 KB |
Output is correct |
6 |
Correct |
1 ms |
1360 KB |
Output is correct |
7 |
Correct |
1 ms |
1360 KB |
Output is correct |
8 |
Correct |
1 ms |
1360 KB |
Output is correct |
9 |
Correct |
1 ms |
1360 KB |
Output is correct |
10 |
Correct |
1 ms |
1360 KB |
Output is correct |
11 |
Correct |
1 ms |
1360 KB |
Output is correct |
12 |
Correct |
1 ms |
1496 KB |
Output is correct |
13 |
Incorrect |
2 ms |
1488 KB |
Wrong Answer[1] |
14 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1360 KB |
Output is correct |
2 |
Correct |
2 ms |
1360 KB |
Output is correct |
3 |
Correct |
1 ms |
1360 KB |
Output is correct |
4 |
Correct |
1 ms |
1360 KB |
Output is correct |
5 |
Correct |
1 ms |
1360 KB |
Output is correct |
6 |
Correct |
1 ms |
1360 KB |
Output is correct |
7 |
Correct |
1 ms |
1360 KB |
Output is correct |
8 |
Correct |
1 ms |
1360 KB |
Output is correct |
9 |
Correct |
1 ms |
1360 KB |
Output is correct |
10 |
Correct |
1 ms |
1360 KB |
Output is correct |
11 |
Correct |
1 ms |
1360 KB |
Output is correct |
12 |
Correct |
1 ms |
1496 KB |
Output is correct |
13 |
Incorrect |
2 ms |
1488 KB |
Wrong Answer[1] |
14 |
Halted |
0 ms |
0 KB |
- |