# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
630442 |
2022-08-16T11:20:10 Z |
Ooops_sorry |
Game (APIO22_game) |
C++17 |
|
4000 ms |
42640 KB |
#include<bits/stdc++.h>
using namespace std;
mt19937 rnd(51);
#define ll long long
#define pb push_back
#define ld long double
const int N = 3e5 + 10, INF = 1e9;
int n, k, in[N], out[N];
vector<int> g[N], gr[N];
bool cycle = 0;
void dfs(int v) {
if (v >= k && out[v] <= in[v]) {
cycle = 1;
}
for (auto to : g[v]) {
if (in[v] > in[to]) {
in[to] = in[v];
dfs(to);
}
}
}
void zhfs(int v) {
if (v >= k && out[v] <= in[v]) {
cycle = 1;
}
for (auto to : gr[v]) {
if (out[v] < out[to]) {
out[to] = out[v];
zhfs(to);
}
}
}
int add_teleporter(int u, int v) {
if (max(u, v) < k) {
if (u >= v) {
cycle = 1;
}
} else {
g[u].pb(v);
gr[v].pb(u);
if (in[v] < in[u]) {
in[v] = in[u];
dfs(v);
}
if (out[u] > out[v]) {
out[u] = out[v];
zhfs(u);
}
}
return cycle;
}
void init(int n_, int k_) {
n = n_, k = k_;
for (int i = 0; i < n; i++) {
in[i] = -INF, out[i] = INF;
}
for (int i = 0; i < k; i++) {
in[i] = out[i] = i;
if (i + 1 < k) {
add_teleporter(i, i + 1);
}
}
}
#ifdef LOCAL
signed main() {
#ifdef LOCAL
freopen("input.txt", "r", stdin);
#endif // LOCAL
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, m, k;
cin >> n >> m >> k;
vector<pair<int,int>> e(m);
for (int i = 0; i < m; i++) {
cin >> e[i].first >> e[i].second;
}
init(n, k);
int i;
for (i = 0; i < m; i++) {
int res = add_teleporter(e[i].first, e[i].second);
assert(res == 0 || res == 1);
if (res == 1) {
break;
}
}
cout << i << endl;
return 0;
}
#endif // LOCAL
# |
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 |
7 ms |
14288 KB |
Output is correct |
4 |
Correct |
7 ms |
14304 KB |
Output is correct |
5 |
Correct |
9 ms |
14288 KB |
Output is correct |
6 |
Correct |
8 ms |
14288 KB |
Output is correct |
7 |
Correct |
8 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 |
7 ms |
14288 KB |
Output is correct |
4 |
Correct |
7 ms |
14304 KB |
Output is correct |
5 |
Correct |
9 ms |
14288 KB |
Output is correct |
6 |
Correct |
8 ms |
14288 KB |
Output is correct |
7 |
Correct |
8 ms |
14288 KB |
Output is correct |
8 |
Correct |
7 ms |
14288 KB |
Output is correct |
9 |
Correct |
7 ms |
14352 KB |
Output is correct |
10 |
Correct |
7 ms |
14288 KB |
Output is correct |
11 |
Correct |
9 ms |
14292 KB |
Output is correct |
12 |
Correct |
9 ms |
14288 KB |
Output is correct |
13 |
Correct |
7 ms |
14288 KB |
Output is correct |
14 |
Correct |
7 ms |
14288 KB |
Output is correct |
15 |
Correct |
7 ms |
14288 KB |
Output is correct |
16 |
Correct |
8 ms |
14288 KB |
Output is correct |
17 |
Correct |
9 ms |
14372 KB |
Output is correct |
18 |
Correct |
9 ms |
14288 KB |
Output is correct |
19 |
Correct |
9 ms |
14412 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 |
7 ms |
14288 KB |
Output is correct |
4 |
Correct |
7 ms |
14304 KB |
Output is correct |
5 |
Correct |
9 ms |
14288 KB |
Output is correct |
6 |
Correct |
8 ms |
14288 KB |
Output is correct |
7 |
Correct |
8 ms |
14288 KB |
Output is correct |
8 |
Correct |
7 ms |
14288 KB |
Output is correct |
9 |
Correct |
7 ms |
14352 KB |
Output is correct |
10 |
Correct |
7 ms |
14288 KB |
Output is correct |
11 |
Correct |
9 ms |
14292 KB |
Output is correct |
12 |
Correct |
9 ms |
14288 KB |
Output is correct |
13 |
Correct |
7 ms |
14288 KB |
Output is correct |
14 |
Correct |
7 ms |
14288 KB |
Output is correct |
15 |
Correct |
7 ms |
14288 KB |
Output is correct |
16 |
Correct |
8 ms |
14288 KB |
Output is correct |
17 |
Correct |
9 ms |
14372 KB |
Output is correct |
18 |
Correct |
9 ms |
14288 KB |
Output is correct |
19 |
Correct |
9 ms |
14412 KB |
Output is correct |
20 |
Correct |
8 ms |
14416 KB |
Output is correct |
21 |
Correct |
8 ms |
14356 KB |
Output is correct |
22 |
Correct |
9 ms |
14368 KB |
Output is correct |
23 |
Correct |
8 ms |
14416 KB |
Output is correct |
24 |
Correct |
11 ms |
14416 KB |
Output is correct |
25 |
Correct |
10 ms |
14416 KB |
Output is correct |
26 |
Correct |
10 ms |
14416 KB |
Output is correct |
27 |
Correct |
11 ms |
14416 KB |
Output is correct |
28 |
Correct |
9 ms |
14440 KB |
Output is correct |
29 |
Correct |
9 ms |
14416 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 |
7 ms |
14288 KB |
Output is correct |
4 |
Correct |
7 ms |
14304 KB |
Output is correct |
5 |
Correct |
9 ms |
14288 KB |
Output is correct |
6 |
Correct |
8 ms |
14288 KB |
Output is correct |
7 |
Correct |
8 ms |
14288 KB |
Output is correct |
8 |
Correct |
7 ms |
14288 KB |
Output is correct |
9 |
Correct |
7 ms |
14352 KB |
Output is correct |
10 |
Correct |
7 ms |
14288 KB |
Output is correct |
11 |
Correct |
9 ms |
14292 KB |
Output is correct |
12 |
Correct |
9 ms |
14288 KB |
Output is correct |
13 |
Correct |
7 ms |
14288 KB |
Output is correct |
14 |
Correct |
7 ms |
14288 KB |
Output is correct |
15 |
Correct |
7 ms |
14288 KB |
Output is correct |
16 |
Correct |
8 ms |
14288 KB |
Output is correct |
17 |
Correct |
9 ms |
14372 KB |
Output is correct |
18 |
Correct |
9 ms |
14288 KB |
Output is correct |
19 |
Correct |
9 ms |
14412 KB |
Output is correct |
20 |
Correct |
8 ms |
14416 KB |
Output is correct |
21 |
Correct |
8 ms |
14356 KB |
Output is correct |
22 |
Correct |
9 ms |
14368 KB |
Output is correct |
23 |
Correct |
8 ms |
14416 KB |
Output is correct |
24 |
Correct |
11 ms |
14416 KB |
Output is correct |
25 |
Correct |
10 ms |
14416 KB |
Output is correct |
26 |
Correct |
10 ms |
14416 KB |
Output is correct |
27 |
Correct |
11 ms |
14416 KB |
Output is correct |
28 |
Correct |
9 ms |
14440 KB |
Output is correct |
29 |
Correct |
9 ms |
14416 KB |
Output is correct |
30 |
Correct |
32 ms |
15704 KB |
Output is correct |
31 |
Correct |
12 ms |
14980 KB |
Output is correct |
32 |
Correct |
25 ms |
17096 KB |
Output is correct |
33 |
Correct |
23 ms |
16456 KB |
Output is correct |
34 |
Correct |
1073 ms |
17832 KB |
Output is correct |
35 |
Correct |
366 ms |
17052 KB |
Output is correct |
36 |
Correct |
45 ms |
16428 KB |
Output is correct |
37 |
Correct |
43 ms |
16412 KB |
Output is correct |
38 |
Correct |
43 ms |
16184 KB |
Output is correct |
39 |
Correct |
38 ms |
16264 KB |
Output is correct |
40 |
Correct |
884 ms |
18012 KB |
Output is correct |
41 |
Correct |
158 ms |
16628 KB |
Output is correct |
42 |
Correct |
122 ms |
16448 KB |
Output is correct |
43 |
Correct |
54 ms |
17888 KB |
Output is correct |
44 |
Correct |
756 ms |
17840 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 |
7 ms |
14288 KB |
Output is correct |
4 |
Correct |
7 ms |
14304 KB |
Output is correct |
5 |
Correct |
9 ms |
14288 KB |
Output is correct |
6 |
Correct |
8 ms |
14288 KB |
Output is correct |
7 |
Correct |
8 ms |
14288 KB |
Output is correct |
8 |
Correct |
7 ms |
14288 KB |
Output is correct |
9 |
Correct |
7 ms |
14352 KB |
Output is correct |
10 |
Correct |
7 ms |
14288 KB |
Output is correct |
11 |
Correct |
9 ms |
14292 KB |
Output is correct |
12 |
Correct |
9 ms |
14288 KB |
Output is correct |
13 |
Correct |
7 ms |
14288 KB |
Output is correct |
14 |
Correct |
7 ms |
14288 KB |
Output is correct |
15 |
Correct |
7 ms |
14288 KB |
Output is correct |
16 |
Correct |
8 ms |
14288 KB |
Output is correct |
17 |
Correct |
9 ms |
14372 KB |
Output is correct |
18 |
Correct |
9 ms |
14288 KB |
Output is correct |
19 |
Correct |
9 ms |
14412 KB |
Output is correct |
20 |
Correct |
8 ms |
14416 KB |
Output is correct |
21 |
Correct |
8 ms |
14356 KB |
Output is correct |
22 |
Correct |
9 ms |
14368 KB |
Output is correct |
23 |
Correct |
8 ms |
14416 KB |
Output is correct |
24 |
Correct |
11 ms |
14416 KB |
Output is correct |
25 |
Correct |
10 ms |
14416 KB |
Output is correct |
26 |
Correct |
10 ms |
14416 KB |
Output is correct |
27 |
Correct |
11 ms |
14416 KB |
Output is correct |
28 |
Correct |
9 ms |
14440 KB |
Output is correct |
29 |
Correct |
9 ms |
14416 KB |
Output is correct |
30 |
Correct |
32 ms |
15704 KB |
Output is correct |
31 |
Correct |
12 ms |
14980 KB |
Output is correct |
32 |
Correct |
25 ms |
17096 KB |
Output is correct |
33 |
Correct |
23 ms |
16456 KB |
Output is correct |
34 |
Correct |
1073 ms |
17832 KB |
Output is correct |
35 |
Correct |
366 ms |
17052 KB |
Output is correct |
36 |
Correct |
45 ms |
16428 KB |
Output is correct |
37 |
Correct |
43 ms |
16412 KB |
Output is correct |
38 |
Correct |
43 ms |
16184 KB |
Output is correct |
39 |
Correct |
38 ms |
16264 KB |
Output is correct |
40 |
Correct |
884 ms |
18012 KB |
Output is correct |
41 |
Correct |
158 ms |
16628 KB |
Output is correct |
42 |
Correct |
122 ms |
16448 KB |
Output is correct |
43 |
Correct |
54 ms |
17888 KB |
Output is correct |
44 |
Correct |
756 ms |
17840 KB |
Output is correct |
45 |
Correct |
244 ms |
28068 KB |
Output is correct |
46 |
Correct |
16 ms |
17104 KB |
Output is correct |
47 |
Correct |
14 ms |
17104 KB |
Output is correct |
48 |
Correct |
378 ms |
42640 KB |
Output is correct |
49 |
Correct |
269 ms |
35520 KB |
Output is correct |
50 |
Execution timed out |
4090 ms |
33060 KB |
Time limit exceeded |
51 |
Halted |
0 ms |
0 KB |
- |