Submission #982367

# Submission time Handle Problem Language Result Execution time Memory
982367 2024-05-14T07:30:09 Z nnin Game (APIO22_game) C++17
60 / 100
4000 ms 45204 KB
#include "game.h"
#include<bits/stdc++.h>
using namespace std;

int n, k, ret;
int st[300005], en[300005], diff[300005];
vector<int> adj[300005], rev[300005];

void func(int u) {
  if(st[u]>=en[u]) ret = 1;
  if(ret) return;
  int d = en[u]-st[u];
  if(d<diff[u]) diff[u] = d;
  else return;
  for(int v:adj[u]) {
    st[v] = max(st[v], st[u]);
    func(v);
  }
  for(int v:rev[u]) {
    en[v] = min(en[v], en[u]);
    func(v);
  }
}

void init(int N, int K) {
  n = N; k = K;
  for(int i=0;i<k;i++) {
    st[i] = i;
    en[i] = i+1;
  }
  for(int i=k;i<n;i++) {
    st[i] = -1;
    en[i] = k;
  }
  for(int i=0;i<n;i++) {
    diff[i] = en[i]-st[i];
  }
}

int add_teleporter(int u, int v) {
  adj[u].push_back(v);
  rev[v].push_back(u);
  st[v] = max(st[v], st[u]);
  en[u] = min(en[u], en[v]);
  if(u<k) st[v] = max(st[v], u);
  if(v<k) en[u] = min(en[u], v);
  func(v);
  func(u);
  return ret;
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 16984 KB Output is correct
2 Correct 5 ms 16984 KB Output is correct
3 Correct 4 ms 16984 KB Output is correct
4 Correct 3 ms 16984 KB Output is correct
5 Correct 5 ms 16984 KB Output is correct
6 Correct 5 ms 16984 KB Output is correct
7 Correct 5 ms 17024 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 16984 KB Output is correct
2 Correct 5 ms 16984 KB Output is correct
3 Correct 4 ms 16984 KB Output is correct
4 Correct 3 ms 16984 KB Output is correct
5 Correct 5 ms 16984 KB Output is correct
6 Correct 5 ms 16984 KB Output is correct
7 Correct 5 ms 17024 KB Output is correct
8 Correct 3 ms 16984 KB Output is correct
9 Correct 4 ms 16984 KB Output is correct
10 Correct 4 ms 16984 KB Output is correct
11 Correct 4 ms 16984 KB Output is correct
12 Correct 3 ms 16984 KB Output is correct
13 Correct 3 ms 16984 KB Output is correct
14 Correct 4 ms 16984 KB Output is correct
15 Correct 4 ms 16984 KB Output is correct
16 Correct 3 ms 16984 KB Output is correct
17 Correct 3 ms 16984 KB Output is correct
18 Correct 4 ms 16984 KB Output is correct
19 Correct 3 ms 16984 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 16984 KB Output is correct
2 Correct 5 ms 16984 KB Output is correct
3 Correct 4 ms 16984 KB Output is correct
4 Correct 3 ms 16984 KB Output is correct
5 Correct 5 ms 16984 KB Output is correct
6 Correct 5 ms 16984 KB Output is correct
7 Correct 5 ms 17024 KB Output is correct
8 Correct 3 ms 16984 KB Output is correct
9 Correct 4 ms 16984 KB Output is correct
10 Correct 4 ms 16984 KB Output is correct
11 Correct 4 ms 16984 KB Output is correct
12 Correct 3 ms 16984 KB Output is correct
13 Correct 3 ms 16984 KB Output is correct
14 Correct 4 ms 16984 KB Output is correct
15 Correct 4 ms 16984 KB Output is correct
16 Correct 3 ms 16984 KB Output is correct
17 Correct 3 ms 16984 KB Output is correct
18 Correct 4 ms 16984 KB Output is correct
19 Correct 3 ms 16984 KB Output is correct
20 Correct 4 ms 16984 KB Output is correct
21 Correct 4 ms 16984 KB Output is correct
22 Correct 4 ms 17496 KB Output is correct
23 Correct 5 ms 17240 KB Output is correct
24 Correct 9 ms 17240 KB Output is correct
25 Correct 6 ms 16984 KB Output is correct
26 Correct 6 ms 17240 KB Output is correct
27 Correct 5 ms 17240 KB Output is correct
28 Correct 4 ms 17024 KB Output is correct
29 Correct 7 ms 16984 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 16984 KB Output is correct
2 Correct 5 ms 16984 KB Output is correct
3 Correct 4 ms 16984 KB Output is correct
4 Correct 3 ms 16984 KB Output is correct
5 Correct 5 ms 16984 KB Output is correct
6 Correct 5 ms 16984 KB Output is correct
7 Correct 5 ms 17024 KB Output is correct
8 Correct 3 ms 16984 KB Output is correct
9 Correct 4 ms 16984 KB Output is correct
10 Correct 4 ms 16984 KB Output is correct
11 Correct 4 ms 16984 KB Output is correct
12 Correct 3 ms 16984 KB Output is correct
13 Correct 3 ms 16984 KB Output is correct
14 Correct 4 ms 16984 KB Output is correct
15 Correct 4 ms 16984 KB Output is correct
16 Correct 3 ms 16984 KB Output is correct
17 Correct 3 ms 16984 KB Output is correct
18 Correct 4 ms 16984 KB Output is correct
19 Correct 3 ms 16984 KB Output is correct
20 Correct 4 ms 16984 KB Output is correct
21 Correct 4 ms 16984 KB Output is correct
22 Correct 4 ms 17496 KB Output is correct
23 Correct 5 ms 17240 KB Output is correct
24 Correct 9 ms 17240 KB Output is correct
25 Correct 6 ms 16984 KB Output is correct
26 Correct 6 ms 17240 KB Output is correct
27 Correct 5 ms 17240 KB Output is correct
28 Correct 4 ms 17024 KB Output is correct
29 Correct 7 ms 16984 KB Output is correct
30 Correct 19 ms 18520 KB Output is correct
31 Correct 8 ms 17496 KB Output is correct
32 Correct 24 ms 19664 KB Output is correct
33 Correct 19 ms 19040 KB Output is correct
34 Correct 1164 ms 21088 KB Output is correct
35 Correct 453 ms 19692 KB Output is correct
36 Correct 30 ms 18776 KB Output is correct
37 Correct 37 ms 19012 KB Output is correct
38 Correct 28 ms 18972 KB Output is correct
39 Correct 27 ms 19184 KB Output is correct
40 Correct 1113 ms 21356 KB Output is correct
41 Correct 176 ms 19544 KB Output is correct
42 Correct 135 ms 19072 KB Output is correct
43 Correct 41 ms 20592 KB Output is correct
44 Correct 976 ms 21704 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 16984 KB Output is correct
2 Correct 5 ms 16984 KB Output is correct
3 Correct 4 ms 16984 KB Output is correct
4 Correct 3 ms 16984 KB Output is correct
5 Correct 5 ms 16984 KB Output is correct
6 Correct 5 ms 16984 KB Output is correct
7 Correct 5 ms 17024 KB Output is correct
8 Correct 3 ms 16984 KB Output is correct
9 Correct 4 ms 16984 KB Output is correct
10 Correct 4 ms 16984 KB Output is correct
11 Correct 4 ms 16984 KB Output is correct
12 Correct 3 ms 16984 KB Output is correct
13 Correct 3 ms 16984 KB Output is correct
14 Correct 4 ms 16984 KB Output is correct
15 Correct 4 ms 16984 KB Output is correct
16 Correct 3 ms 16984 KB Output is correct
17 Correct 3 ms 16984 KB Output is correct
18 Correct 4 ms 16984 KB Output is correct
19 Correct 3 ms 16984 KB Output is correct
20 Correct 4 ms 16984 KB Output is correct
21 Correct 4 ms 16984 KB Output is correct
22 Correct 4 ms 17496 KB Output is correct
23 Correct 5 ms 17240 KB Output is correct
24 Correct 9 ms 17240 KB Output is correct
25 Correct 6 ms 16984 KB Output is correct
26 Correct 6 ms 17240 KB Output is correct
27 Correct 5 ms 17240 KB Output is correct
28 Correct 4 ms 17024 KB Output is correct
29 Correct 7 ms 16984 KB Output is correct
30 Correct 19 ms 18520 KB Output is correct
31 Correct 8 ms 17496 KB Output is correct
32 Correct 24 ms 19664 KB Output is correct
33 Correct 19 ms 19040 KB Output is correct
34 Correct 1164 ms 21088 KB Output is correct
35 Correct 453 ms 19692 KB Output is correct
36 Correct 30 ms 18776 KB Output is correct
37 Correct 37 ms 19012 KB Output is correct
38 Correct 28 ms 18972 KB Output is correct
39 Correct 27 ms 19184 KB Output is correct
40 Correct 1113 ms 21356 KB Output is correct
41 Correct 176 ms 19544 KB Output is correct
42 Correct 135 ms 19072 KB Output is correct
43 Correct 41 ms 20592 KB Output is correct
44 Correct 976 ms 21704 KB Output is correct
45 Correct 209 ms 30240 KB Output is correct
46 Correct 9 ms 18520 KB Output is correct
47 Correct 9 ms 18520 KB Output is correct
48 Correct 305 ms 45204 KB Output is correct
49 Correct 224 ms 37380 KB Output is correct
50 Execution timed out 4018 ms 37220 KB Time limit exceeded
51 Halted 0 ms 0 KB -