# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
982781 |
2024-05-14T17:51:00 Z |
vjudge1 |
Game (APIO22_game) |
C++17 |
|
4000 ms |
40376 KB |
#include "game.h"
#include <bits/stdc++.h>
#define range(it, a, b) for (ll it = a; it < b; it++)
#define all(x) begin(x), end(x)
#define ll long long
#define ull unsigned long long
#define INF64 ((ll) 1 << 62)
#define INF32 (1 << 30)
#define mset multiset
#define uset unordered_set
#define umap unordered_map
#define pqueue priority_queue
#define ptr(A) shared_ptr<A>
using namespace std;
vector<vector<int>> adj;
vector<vector<int>> inv_adj;
vector<int> source;
vector<int> destiny;
int K, N;
bool isCycled = 0;
void init(int n, int k) {
adj.resize(n);
inv_adj.resize(n);
destiny.resize(n, INF32);
source.resize(n, -1);
K = k;
N = n;
range(i, 0, k) {
if (i < k-1) {
adj[i].push_back(i+1);
inv_adj[i+1].push_back(i);
}
if (i)
source[i] = i-1;
if (i < k-1)
destiny[i] = i+1;
}
}
void furthest_source (int i, int& x) {
if (x <= source[i])
return;
source[i] = x;
if (source[i] >= destiny[i]) {
isCycled = 1;
return;
}
for (int& it : adj[i])
furthest_source(it, x);
}
void nearest_destiny(int i, int& x) {
if (x >= destiny[i])
return;
destiny[i] = x;
if (source[i] >= destiny[i]) {
isCycled = 1;
return;
}
for (int& it : inv_adj[i])
nearest_destiny(it, x);
}
int add_teleporter(int u, int v) {
adj[u].push_back(v);
inv_adj[v].push_back(u);
if (u == v && u < K)
return 1;
if (u < K)
furthest_source(v, u);
furthest_source(v, source[u]);
if (isCycled)
return 1;
if (v < K)
nearest_destiny(u, v);
nearest_destiny(u, destiny[v]);
if (isCycled)
return 1;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
0 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
0 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
356 KB |
Output is correct |
16 |
Correct |
0 ms |
344 KB |
Output is correct |
17 |
Correct |
0 ms |
344 KB |
Output is correct |
18 |
Correct |
1 ms |
344 KB |
Output is correct |
19 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
0 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
0 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
356 KB |
Output is correct |
16 |
Correct |
0 ms |
344 KB |
Output is correct |
17 |
Correct |
0 ms |
344 KB |
Output is correct |
18 |
Correct |
1 ms |
344 KB |
Output is correct |
19 |
Correct |
0 ms |
344 KB |
Output is correct |
20 |
Correct |
1 ms |
344 KB |
Output is correct |
21 |
Correct |
0 ms |
344 KB |
Output is correct |
22 |
Correct |
1 ms |
344 KB |
Output is correct |
23 |
Correct |
1 ms |
344 KB |
Output is correct |
24 |
Correct |
3 ms |
344 KB |
Output is correct |
25 |
Correct |
2 ms |
344 KB |
Output is correct |
26 |
Correct |
2 ms |
344 KB |
Output is correct |
27 |
Correct |
2 ms |
596 KB |
Output is correct |
28 |
Correct |
1 ms |
344 KB |
Output is correct |
29 |
Correct |
2 ms |
600 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
0 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
0 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
356 KB |
Output is correct |
16 |
Correct |
0 ms |
344 KB |
Output is correct |
17 |
Correct |
0 ms |
344 KB |
Output is correct |
18 |
Correct |
1 ms |
344 KB |
Output is correct |
19 |
Correct |
0 ms |
344 KB |
Output is correct |
20 |
Correct |
1 ms |
344 KB |
Output is correct |
21 |
Correct |
0 ms |
344 KB |
Output is correct |
22 |
Correct |
1 ms |
344 KB |
Output is correct |
23 |
Correct |
1 ms |
344 KB |
Output is correct |
24 |
Correct |
3 ms |
344 KB |
Output is correct |
25 |
Correct |
2 ms |
344 KB |
Output is correct |
26 |
Correct |
2 ms |
344 KB |
Output is correct |
27 |
Correct |
2 ms |
596 KB |
Output is correct |
28 |
Correct |
1 ms |
344 KB |
Output is correct |
29 |
Correct |
2 ms |
600 KB |
Output is correct |
30 |
Correct |
12 ms |
3128 KB |
Output is correct |
31 |
Correct |
5 ms |
2676 KB |
Output is correct |
32 |
Correct |
15 ms |
4352 KB |
Output is correct |
33 |
Correct |
15 ms |
4524 KB |
Output is correct |
34 |
Correct |
875 ms |
5104 KB |
Output is correct |
35 |
Correct |
309 ms |
4696 KB |
Output is correct |
36 |
Correct |
40 ms |
5024 KB |
Output is correct |
37 |
Correct |
23 ms |
4488 KB |
Output is correct |
38 |
Correct |
26 ms |
3928 KB |
Output is correct |
39 |
Correct |
23 ms |
3952 KB |
Output is correct |
40 |
Correct |
718 ms |
5380 KB |
Output is correct |
41 |
Correct |
135 ms |
3996 KB |
Output is correct |
42 |
Correct |
102 ms |
4408 KB |
Output is correct |
43 |
Correct |
32 ms |
4780 KB |
Output is correct |
44 |
Correct |
637 ms |
5464 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
0 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
0 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
356 KB |
Output is correct |
16 |
Correct |
0 ms |
344 KB |
Output is correct |
17 |
Correct |
0 ms |
344 KB |
Output is correct |
18 |
Correct |
1 ms |
344 KB |
Output is correct |
19 |
Correct |
0 ms |
344 KB |
Output is correct |
20 |
Correct |
1 ms |
344 KB |
Output is correct |
21 |
Correct |
0 ms |
344 KB |
Output is correct |
22 |
Correct |
1 ms |
344 KB |
Output is correct |
23 |
Correct |
1 ms |
344 KB |
Output is correct |
24 |
Correct |
3 ms |
344 KB |
Output is correct |
25 |
Correct |
2 ms |
344 KB |
Output is correct |
26 |
Correct |
2 ms |
344 KB |
Output is correct |
27 |
Correct |
2 ms |
596 KB |
Output is correct |
28 |
Correct |
1 ms |
344 KB |
Output is correct |
29 |
Correct |
2 ms |
600 KB |
Output is correct |
30 |
Correct |
12 ms |
3128 KB |
Output is correct |
31 |
Correct |
5 ms |
2676 KB |
Output is correct |
32 |
Correct |
15 ms |
4352 KB |
Output is correct |
33 |
Correct |
15 ms |
4524 KB |
Output is correct |
34 |
Correct |
875 ms |
5104 KB |
Output is correct |
35 |
Correct |
309 ms |
4696 KB |
Output is correct |
36 |
Correct |
40 ms |
5024 KB |
Output is correct |
37 |
Correct |
23 ms |
4488 KB |
Output is correct |
38 |
Correct |
26 ms |
3928 KB |
Output is correct |
39 |
Correct |
23 ms |
3952 KB |
Output is correct |
40 |
Correct |
718 ms |
5380 KB |
Output is correct |
41 |
Correct |
135 ms |
3996 KB |
Output is correct |
42 |
Correct |
102 ms |
4408 KB |
Output is correct |
43 |
Correct |
32 ms |
4780 KB |
Output is correct |
44 |
Correct |
637 ms |
5464 KB |
Output is correct |
45 |
Correct |
205 ms |
28948 KB |
Output is correct |
46 |
Correct |
10 ms |
17492 KB |
Output is correct |
47 |
Correct |
11 ms |
17768 KB |
Output is correct |
48 |
Correct |
270 ms |
40060 KB |
Output is correct |
49 |
Correct |
208 ms |
36020 KB |
Output is correct |
50 |
Execution timed out |
4008 ms |
40376 KB |
Time limit exceeded |
51 |
Halted |
0 ms |
0 KB |
- |