# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
726917 |
2023-04-19T14:51:53 Z |
Vu_CG_Coder |
Game (APIO22_game) |
C++17 |
|
4000 ms |
41488 KB |
/* [Author : Hoang Duy Vu] - THPT Chuyen Nguyen Du */
//#pragma GCC optimize(" unroll-loops")
//#pragma gcc optimize("Ofast")
//#pragma GCC optimization("Ofast")
//#pragma optimize(Ofast)
#include "game.h"
#include <bits/stdc++.h>
#define All(x) (x).begin(),(x).end()
#define ll long long
#define C make_pair
#define fi first
#define se second
#define two second.first
#define thr second.second
#define TASK "txt"
using namespace std;
template<typename T> bool maximize(T &res, const T &val) {
if (res < val) { res = val; return true; } return false; }
template<typename T> bool minimize(T &res, const T &val) {
if (res > val) { res = val; return true; } return false; }
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
const int LOG = 20;
const int INF = 1e9 + 7;
const ll LNF = 1e18 + 7;
const int mod = 1e9 + 7;
const int Nx = 3e5 + 100;
int val[2][Nx];
vector <int> a[2][Nx];
int n , k;
int ok;
void init(int _n , int _k)
{
n = _n;
k = _k;
for (int i = 0 ; i < k ; i++)
{
val[0][i] = i;
val[1][i] = i - 1;
}
for (int i = k ; i <= n ; i++)
{
val[0][i] = INF;
val[1][i] = -INF;
}
}
void dfs(int id , int u, int gt)
{
// cout << id << " " << u << " " << gt << " " << val[id][u] << "\n";
int old = val[id][u];
if (id) maximize(val[id][u],gt);
else minimize(val[id][u],gt);
if (val[1][u] >= val[0][u]) {
ok = 1;
return ;
}
if (old == val[id][u]) return ;
for (int v : a[id][u])
dfs(id,v,gt);
}
int add_teleporter(int u, int v)
{
if (u > v && u < k) return 1;
a[1][u].push_back(v);
a[0][v].push_back(u);
ok = 0;
int gt = val[1][u];
if (u < k) gt = u;
dfs(1,v,gt);
gt = val[0][v];
if (v < k) gt = v;
dfs(0,u,gt);
if (ok == 1) return 1;
return 0;
}
// int main()
// {
// if(fopen(TASK".inp", "r")){
// freopen(TASK".inp","r",stdin);
// freopen(TASK".out","w",stdout);
// }
// int x , y , z;
// cin >> x >> y >> z;
// init(x,y);
// for (int i = 1 ; i <= z ; i++)
// {
// int a , b;
// cin >> a >> b;
// if (add_teleporter(a,b))
// {
// (cout << i);
// return 0;
// }
// }
// return 0;
// }
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
14288 KB |
Output is correct |
2 |
Correct |
8 ms |
14288 KB |
Output is correct |
3 |
Correct |
9 ms |
14288 KB |
Output is correct |
4 |
Correct |
8 ms |
14288 KB |
Output is correct |
5 |
Correct |
9 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 |
9 ms |
14288 KB |
Output is correct |
2 |
Correct |
8 ms |
14288 KB |
Output is correct |
3 |
Correct |
9 ms |
14288 KB |
Output is correct |
4 |
Correct |
8 ms |
14288 KB |
Output is correct |
5 |
Correct |
9 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 |
8 ms |
14288 KB |
Output is correct |
9 |
Correct |
9 ms |
14288 KB |
Output is correct |
10 |
Correct |
7 ms |
14400 KB |
Output is correct |
11 |
Correct |
8 ms |
14288 KB |
Output is correct |
12 |
Correct |
9 ms |
14288 KB |
Output is correct |
13 |
Correct |
10 ms |
14332 KB |
Output is correct |
14 |
Correct |
8 ms |
14288 KB |
Output is correct |
15 |
Correct |
9 ms |
14416 KB |
Output is correct |
16 |
Correct |
9 ms |
14296 KB |
Output is correct |
17 |
Correct |
10 ms |
14288 KB |
Output is correct |
18 |
Correct |
9 ms |
14288 KB |
Output is correct |
19 |
Correct |
9 ms |
14356 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
14288 KB |
Output is correct |
2 |
Correct |
8 ms |
14288 KB |
Output is correct |
3 |
Correct |
9 ms |
14288 KB |
Output is correct |
4 |
Correct |
8 ms |
14288 KB |
Output is correct |
5 |
Correct |
9 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 |
8 ms |
14288 KB |
Output is correct |
9 |
Correct |
9 ms |
14288 KB |
Output is correct |
10 |
Correct |
7 ms |
14400 KB |
Output is correct |
11 |
Correct |
8 ms |
14288 KB |
Output is correct |
12 |
Correct |
9 ms |
14288 KB |
Output is correct |
13 |
Correct |
10 ms |
14332 KB |
Output is correct |
14 |
Correct |
8 ms |
14288 KB |
Output is correct |
15 |
Correct |
9 ms |
14416 KB |
Output is correct |
16 |
Correct |
9 ms |
14296 KB |
Output is correct |
17 |
Correct |
10 ms |
14288 KB |
Output is correct |
18 |
Correct |
9 ms |
14288 KB |
Output is correct |
19 |
Correct |
9 ms |
14356 KB |
Output is correct |
20 |
Correct |
9 ms |
14416 KB |
Output is correct |
21 |
Correct |
8 ms |
14324 KB |
Output is correct |
22 |
Correct |
8 ms |
14416 KB |
Output is correct |
23 |
Correct |
10 ms |
14356 KB |
Output is correct |
24 |
Correct |
12 ms |
14416 KB |
Output is correct |
25 |
Correct |
12 ms |
14496 KB |
Output is correct |
26 |
Correct |
11 ms |
14424 KB |
Output is correct |
27 |
Correct |
12 ms |
14420 KB |
Output is correct |
28 |
Correct |
11 ms |
14440 KB |
Output is correct |
29 |
Correct |
11 ms |
14432 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
14288 KB |
Output is correct |
2 |
Correct |
8 ms |
14288 KB |
Output is correct |
3 |
Correct |
9 ms |
14288 KB |
Output is correct |
4 |
Correct |
8 ms |
14288 KB |
Output is correct |
5 |
Correct |
9 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 |
8 ms |
14288 KB |
Output is correct |
9 |
Correct |
9 ms |
14288 KB |
Output is correct |
10 |
Correct |
7 ms |
14400 KB |
Output is correct |
11 |
Correct |
8 ms |
14288 KB |
Output is correct |
12 |
Correct |
9 ms |
14288 KB |
Output is correct |
13 |
Correct |
10 ms |
14332 KB |
Output is correct |
14 |
Correct |
8 ms |
14288 KB |
Output is correct |
15 |
Correct |
9 ms |
14416 KB |
Output is correct |
16 |
Correct |
9 ms |
14296 KB |
Output is correct |
17 |
Correct |
10 ms |
14288 KB |
Output is correct |
18 |
Correct |
9 ms |
14288 KB |
Output is correct |
19 |
Correct |
9 ms |
14356 KB |
Output is correct |
20 |
Correct |
9 ms |
14416 KB |
Output is correct |
21 |
Correct |
8 ms |
14324 KB |
Output is correct |
22 |
Correct |
8 ms |
14416 KB |
Output is correct |
23 |
Correct |
10 ms |
14356 KB |
Output is correct |
24 |
Correct |
12 ms |
14416 KB |
Output is correct |
25 |
Correct |
12 ms |
14496 KB |
Output is correct |
26 |
Correct |
11 ms |
14424 KB |
Output is correct |
27 |
Correct |
12 ms |
14420 KB |
Output is correct |
28 |
Correct |
11 ms |
14440 KB |
Output is correct |
29 |
Correct |
11 ms |
14432 KB |
Output is correct |
30 |
Correct |
33 ms |
15776 KB |
Output is correct |
31 |
Correct |
12 ms |
14940 KB |
Output is correct |
32 |
Correct |
27 ms |
16656 KB |
Output is correct |
33 |
Correct |
26 ms |
16388 KB |
Output is correct |
34 |
Correct |
1490 ms |
17936 KB |
Output is correct |
35 |
Correct |
386 ms |
17024 KB |
Output is correct |
36 |
Correct |
59 ms |
16464 KB |
Output is correct |
37 |
Correct |
45 ms |
16360 KB |
Output is correct |
38 |
Correct |
36 ms |
16128 KB |
Output is correct |
39 |
Correct |
58 ms |
16180 KB |
Output is correct |
40 |
Correct |
1058 ms |
18020 KB |
Output is correct |
41 |
Correct |
192 ms |
16624 KB |
Output is correct |
42 |
Correct |
133 ms |
16464 KB |
Output is correct |
43 |
Correct |
63 ms |
17332 KB |
Output is correct |
44 |
Correct |
1165 ms |
17952 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
14288 KB |
Output is correct |
2 |
Correct |
8 ms |
14288 KB |
Output is correct |
3 |
Correct |
9 ms |
14288 KB |
Output is correct |
4 |
Correct |
8 ms |
14288 KB |
Output is correct |
5 |
Correct |
9 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 |
8 ms |
14288 KB |
Output is correct |
9 |
Correct |
9 ms |
14288 KB |
Output is correct |
10 |
Correct |
7 ms |
14400 KB |
Output is correct |
11 |
Correct |
8 ms |
14288 KB |
Output is correct |
12 |
Correct |
9 ms |
14288 KB |
Output is correct |
13 |
Correct |
10 ms |
14332 KB |
Output is correct |
14 |
Correct |
8 ms |
14288 KB |
Output is correct |
15 |
Correct |
9 ms |
14416 KB |
Output is correct |
16 |
Correct |
9 ms |
14296 KB |
Output is correct |
17 |
Correct |
10 ms |
14288 KB |
Output is correct |
18 |
Correct |
9 ms |
14288 KB |
Output is correct |
19 |
Correct |
9 ms |
14356 KB |
Output is correct |
20 |
Correct |
9 ms |
14416 KB |
Output is correct |
21 |
Correct |
8 ms |
14324 KB |
Output is correct |
22 |
Correct |
8 ms |
14416 KB |
Output is correct |
23 |
Correct |
10 ms |
14356 KB |
Output is correct |
24 |
Correct |
12 ms |
14416 KB |
Output is correct |
25 |
Correct |
12 ms |
14496 KB |
Output is correct |
26 |
Correct |
11 ms |
14424 KB |
Output is correct |
27 |
Correct |
12 ms |
14420 KB |
Output is correct |
28 |
Correct |
11 ms |
14440 KB |
Output is correct |
29 |
Correct |
11 ms |
14432 KB |
Output is correct |
30 |
Correct |
33 ms |
15776 KB |
Output is correct |
31 |
Correct |
12 ms |
14940 KB |
Output is correct |
32 |
Correct |
27 ms |
16656 KB |
Output is correct |
33 |
Correct |
26 ms |
16388 KB |
Output is correct |
34 |
Correct |
1490 ms |
17936 KB |
Output is correct |
35 |
Correct |
386 ms |
17024 KB |
Output is correct |
36 |
Correct |
59 ms |
16464 KB |
Output is correct |
37 |
Correct |
45 ms |
16360 KB |
Output is correct |
38 |
Correct |
36 ms |
16128 KB |
Output is correct |
39 |
Correct |
58 ms |
16180 KB |
Output is correct |
40 |
Correct |
1058 ms |
18020 KB |
Output is correct |
41 |
Correct |
192 ms |
16624 KB |
Output is correct |
42 |
Correct |
133 ms |
16464 KB |
Output is correct |
43 |
Correct |
63 ms |
17332 KB |
Output is correct |
44 |
Correct |
1165 ms |
17952 KB |
Output is correct |
45 |
Correct |
265 ms |
28024 KB |
Output is correct |
46 |
Correct |
14 ms |
17132 KB |
Output is correct |
47 |
Correct |
14 ms |
17104 KB |
Output is correct |
48 |
Correct |
336 ms |
41488 KB |
Output is correct |
49 |
Correct |
313 ms |
35492 KB |
Output is correct |
50 |
Execution timed out |
4010 ms |
33160 KB |
Time limit exceeded |
51 |
Halted |
0 ms |
0 KB |
- |