Submission #607064

# Submission time Handle Problem Language Result Execution time Memory
607064 2022-07-26T11:37:25 Z loctildore Game (APIO22_game) C++17
60 / 100
4000 ms 45516 KB
#include "game.h"
#include <bits/stdc++.h>
using namespace std;
// trans rights
#define ll long long
#define f first
#define s second
#define endl '\n'
#define all(x) begin(x), end(x)
#define bkt 1069
int n,k;
bool flag;
vector<int> grph[300069],revs[300069];
int lft[300069],rht[300069];
void init(int N, int K) {
  n=N;
  k=K;
  for (int i = 0; i < k; i++) {
    lft[i]=i/bkt;
    rht[i]=i;
  }
  for (int i = k; i < n; i++) {
    lft[i]=-1;
    rht[i]=k;
  }
}
void dfs(int x) {
  for (int i : grph[x]) {
    if (i<k&&i/bkt<lft[x]) {
      flag=true;
    }
    if (lft[i]<lft[x]) {
      lft[i]=lft[x];
      dfs(i);
    }
    if (x<k&&x>=rht[i]) {
      flag=true;
    }
    if (rht[x]>rht[i]&&rht[i]/bkt==lft[x]) {
      rht[x]=rht[i];
    }
  }
}
void rdfs(int x) {
  for (int i : revs[x]) {
    if (i<k&&i>=rht[x]) {
      flag=true;
    }
    if (rht[i]>rht[x]&&rht[x]/bkt==lft[i]) {
      rht[i]=rht[x];
      rdfs(i);
    }
  }
}
int add_teleporter(int u, int v) {
  grph[u].push_back(v);
  revs[v].push_back(u);
  dfs(u);
  rdfs(u);
  /*for (int i = 0; i < n; i++) {
    cout<<lft[i]<<' '<<rht[i]<<endl;
  }
  cout<<endl;*/
  return flag;
}
# Verdict Execution time Memory Grader output
1 Correct 7 ms 14288 KB Output is correct
2 Correct 9 ms 14360 KB Output is correct
3 Correct 9 ms 14328 KB Output is correct
4 Correct 7 ms 14288 KB Output is correct
5 Correct 7 ms 14288 KB Output is correct
6 Correct 9 ms 14352 KB Output is correct
7 Correct 8 ms 14416 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 14288 KB Output is correct
2 Correct 9 ms 14360 KB Output is correct
3 Correct 9 ms 14328 KB Output is correct
4 Correct 7 ms 14288 KB Output is correct
5 Correct 7 ms 14288 KB Output is correct
6 Correct 9 ms 14352 KB Output is correct
7 Correct 8 ms 14416 KB Output is correct
8 Correct 7 ms 14288 KB Output is correct
9 Correct 10 ms 14288 KB Output is correct
10 Correct 9 ms 14288 KB Output is correct
11 Correct 10 ms 14288 KB Output is correct
12 Correct 9 ms 14304 KB Output is correct
13 Correct 8 ms 14292 KB Output is correct
14 Correct 7 ms 14400 KB Output is correct
15 Correct 8 ms 14288 KB Output is correct
16 Correct 8 ms 14288 KB Output is correct
17 Correct 7 ms 14288 KB Output is correct
18 Correct 7 ms 14288 KB Output is correct
19 Correct 9 ms 14288 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 14288 KB Output is correct
2 Correct 9 ms 14360 KB Output is correct
3 Correct 9 ms 14328 KB Output is correct
4 Correct 7 ms 14288 KB Output is correct
5 Correct 7 ms 14288 KB Output is correct
6 Correct 9 ms 14352 KB Output is correct
7 Correct 8 ms 14416 KB Output is correct
8 Correct 7 ms 14288 KB Output is correct
9 Correct 10 ms 14288 KB Output is correct
10 Correct 9 ms 14288 KB Output is correct
11 Correct 10 ms 14288 KB Output is correct
12 Correct 9 ms 14304 KB Output is correct
13 Correct 8 ms 14292 KB Output is correct
14 Correct 7 ms 14400 KB Output is correct
15 Correct 8 ms 14288 KB Output is correct
16 Correct 8 ms 14288 KB Output is correct
17 Correct 7 ms 14288 KB Output is correct
18 Correct 7 ms 14288 KB Output is correct
19 Correct 9 ms 14288 KB Output is correct
20 Correct 8 ms 14416 KB Output is correct
21 Correct 8 ms 14416 KB Output is correct
22 Correct 8 ms 14416 KB Output is correct
23 Correct 9 ms 14416 KB Output is correct
24 Correct 9 ms 14484 KB Output is correct
25 Correct 11 ms 14416 KB Output is correct
26 Correct 11 ms 14488 KB Output is correct
27 Correct 10 ms 14464 KB Output is correct
28 Correct 9 ms 14348 KB Output is correct
29 Correct 12 ms 14424 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 14288 KB Output is correct
2 Correct 9 ms 14360 KB Output is correct
3 Correct 9 ms 14328 KB Output is correct
4 Correct 7 ms 14288 KB Output is correct
5 Correct 7 ms 14288 KB Output is correct
6 Correct 9 ms 14352 KB Output is correct
7 Correct 8 ms 14416 KB Output is correct
8 Correct 7 ms 14288 KB Output is correct
9 Correct 10 ms 14288 KB Output is correct
10 Correct 9 ms 14288 KB Output is correct
11 Correct 10 ms 14288 KB Output is correct
12 Correct 9 ms 14304 KB Output is correct
13 Correct 8 ms 14292 KB Output is correct
14 Correct 7 ms 14400 KB Output is correct
15 Correct 8 ms 14288 KB Output is correct
16 Correct 8 ms 14288 KB Output is correct
17 Correct 7 ms 14288 KB Output is correct
18 Correct 7 ms 14288 KB Output is correct
19 Correct 9 ms 14288 KB Output is correct
20 Correct 8 ms 14416 KB Output is correct
21 Correct 8 ms 14416 KB Output is correct
22 Correct 8 ms 14416 KB Output is correct
23 Correct 9 ms 14416 KB Output is correct
24 Correct 9 ms 14484 KB Output is correct
25 Correct 11 ms 14416 KB Output is correct
26 Correct 11 ms 14488 KB Output is correct
27 Correct 10 ms 14464 KB Output is correct
28 Correct 9 ms 14348 KB Output is correct
29 Correct 12 ms 14424 KB Output is correct
30 Correct 23 ms 15688 KB Output is correct
31 Correct 12 ms 14928 KB Output is correct
32 Correct 31 ms 17168 KB Output is correct
33 Correct 24 ms 16448 KB Output is correct
34 Correct 509 ms 18724 KB Output is correct
35 Correct 211 ms 17300 KB Output is correct
36 Correct 42 ms 16428 KB Output is correct
37 Correct 38 ms 16444 KB Output is correct
38 Correct 46 ms 16176 KB Output is correct
39 Correct 43 ms 16172 KB Output is correct
40 Correct 491 ms 18816 KB Output is correct
41 Correct 98 ms 16872 KB Output is correct
42 Correct 80 ms 16620 KB Output is correct
43 Correct 62 ms 17952 KB Output is correct
44 Correct 447 ms 18344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 14288 KB Output is correct
2 Correct 9 ms 14360 KB Output is correct
3 Correct 9 ms 14328 KB Output is correct
4 Correct 7 ms 14288 KB Output is correct
5 Correct 7 ms 14288 KB Output is correct
6 Correct 9 ms 14352 KB Output is correct
7 Correct 8 ms 14416 KB Output is correct
8 Correct 7 ms 14288 KB Output is correct
9 Correct 10 ms 14288 KB Output is correct
10 Correct 9 ms 14288 KB Output is correct
11 Correct 10 ms 14288 KB Output is correct
12 Correct 9 ms 14304 KB Output is correct
13 Correct 8 ms 14292 KB Output is correct
14 Correct 7 ms 14400 KB Output is correct
15 Correct 8 ms 14288 KB Output is correct
16 Correct 8 ms 14288 KB Output is correct
17 Correct 7 ms 14288 KB Output is correct
18 Correct 7 ms 14288 KB Output is correct
19 Correct 9 ms 14288 KB Output is correct
20 Correct 8 ms 14416 KB Output is correct
21 Correct 8 ms 14416 KB Output is correct
22 Correct 8 ms 14416 KB Output is correct
23 Correct 9 ms 14416 KB Output is correct
24 Correct 9 ms 14484 KB Output is correct
25 Correct 11 ms 14416 KB Output is correct
26 Correct 11 ms 14488 KB Output is correct
27 Correct 10 ms 14464 KB Output is correct
28 Correct 9 ms 14348 KB Output is correct
29 Correct 12 ms 14424 KB Output is correct
30 Correct 23 ms 15688 KB Output is correct
31 Correct 12 ms 14928 KB Output is correct
32 Correct 31 ms 17168 KB Output is correct
33 Correct 24 ms 16448 KB Output is correct
34 Correct 509 ms 18724 KB Output is correct
35 Correct 211 ms 17300 KB Output is correct
36 Correct 42 ms 16428 KB Output is correct
37 Correct 38 ms 16444 KB Output is correct
38 Correct 46 ms 16176 KB Output is correct
39 Correct 43 ms 16172 KB Output is correct
40 Correct 491 ms 18816 KB Output is correct
41 Correct 98 ms 16872 KB Output is correct
42 Correct 80 ms 16620 KB Output is correct
43 Correct 62 ms 17952 KB Output is correct
44 Correct 447 ms 18344 KB Output is correct
45 Correct 303 ms 28108 KB Output is correct
46 Correct 14 ms 17104 KB Output is correct
47 Correct 13 ms 17036 KB Output is correct
48 Correct 431 ms 45516 KB Output is correct
49 Correct 308 ms 35500 KB Output is correct
50 Execution timed out 4077 ms 41248 KB Time limit exceeded
51 Halted 0 ms 0 KB -