Submission #745276

# Submission time Handle Problem Language Result Execution time Memory
745276 2023-05-19T17:22:18 Z speedyArda Game (APIO22_game) C++17
60 / 100
1332 ms 32892 KB
#include "game.h"
#include "bits/stdc++.h"
using namespace std;
const int MAXN = 3e4+5;
const int MAXK = 1e3+5;
vector< vector<int> > adj(MAXN);
bool visited[MAXN][MAXK];
int ans = 0;
int special = 0;
void dfs(int v, int x)
{
  visited[v][x] = true;
  if(v <= x) // v is also a special node in this case, as we know x is special and all specials are 0, 1, 2 .... k - 1
    ans = 1; // Came to smaller special node so we can go v -> x and repeat the cycle
  for(int e : adj[v])
  {
    if(visited[e][x])
      continue;
    dfs(e, x);
  }
}

void init(int n, int k) {
  special = k;
  for(int i = 0; i < n; i++)
    adj[i].clear();
  for(int i = 0; i <= k - 2; i++)
  {
    adj[i].push_back(i + 1);
  }
  for(int i = 0; i < k - 1; i++)
    dfs(i + 1, i); // if we do i, i then it will trigger if(v <= x) in the dfs false.
} 

int add_teleporter(int u, int v) {
  adj[u].push_back(v);
  for(int i = 0; i < special; i++)
  {
    if((u == i || visited[u][i]) && !visited[v][i])
      dfs(v, i);
  }
  return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 976 KB Output is correct
2 Correct 1 ms 976 KB Output is correct
3 Correct 1 ms 1104 KB Output is correct
4 Correct 1 ms 976 KB Output is correct
5 Correct 1 ms 1104 KB Output is correct
6 Correct 1 ms 1104 KB Output is correct
7 Correct 1 ms 1104 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 976 KB Output is correct
2 Correct 1 ms 976 KB Output is correct
3 Correct 1 ms 1104 KB Output is correct
4 Correct 1 ms 976 KB Output is correct
5 Correct 1 ms 1104 KB Output is correct
6 Correct 1 ms 1104 KB Output is correct
7 Correct 1 ms 1104 KB Output is correct
8 Correct 1 ms 976 KB Output is correct
9 Correct 1 ms 976 KB Output is correct
10 Correct 1 ms 900 KB Output is correct
11 Correct 1 ms 1104 KB Output is correct
12 Correct 1 ms 1104 KB Output is correct
13 Correct 1 ms 1104 KB Output is correct
14 Correct 1 ms 1104 KB Output is correct
15 Correct 1 ms 1104 KB Output is correct
16 Correct 1 ms 1104 KB Output is correct
17 Correct 1 ms 1104 KB Output is correct
18 Correct 1 ms 1104 KB Output is correct
19 Correct 1 ms 1104 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 976 KB Output is correct
2 Correct 1 ms 976 KB Output is correct
3 Correct 1 ms 1104 KB Output is correct
4 Correct 1 ms 976 KB Output is correct
5 Correct 1 ms 1104 KB Output is correct
6 Correct 1 ms 1104 KB Output is correct
7 Correct 1 ms 1104 KB Output is correct
8 Correct 1 ms 976 KB Output is correct
9 Correct 1 ms 976 KB Output is correct
10 Correct 1 ms 900 KB Output is correct
11 Correct 1 ms 1104 KB Output is correct
12 Correct 1 ms 1104 KB Output is correct
13 Correct 1 ms 1104 KB Output is correct
14 Correct 1 ms 1104 KB Output is correct
15 Correct 1 ms 1104 KB Output is correct
16 Correct 1 ms 1104 KB Output is correct
17 Correct 1 ms 1104 KB Output is correct
18 Correct 1 ms 1104 KB Output is correct
19 Correct 1 ms 1104 KB Output is correct
20 Correct 2 ms 1488 KB Output is correct
21 Correct 1 ms 1104 KB Output is correct
22 Correct 3 ms 2000 KB Output is correct
23 Correct 2 ms 1488 KB Output is correct
24 Correct 5 ms 1944 KB Output is correct
25 Correct 6 ms 2000 KB Output is correct
26 Correct 5 ms 2000 KB Output is correct
27 Correct 9 ms 2024 KB Output is correct
28 Correct 5 ms 2000 KB Output is correct
29 Correct 7 ms 1984 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 976 KB Output is correct
2 Correct 1 ms 976 KB Output is correct
3 Correct 1 ms 1104 KB Output is correct
4 Correct 1 ms 976 KB Output is correct
5 Correct 1 ms 1104 KB Output is correct
6 Correct 1 ms 1104 KB Output is correct
7 Correct 1 ms 1104 KB Output is correct
8 Correct 1 ms 976 KB Output is correct
9 Correct 1 ms 976 KB Output is correct
10 Correct 1 ms 900 KB Output is correct
11 Correct 1 ms 1104 KB Output is correct
12 Correct 1 ms 1104 KB Output is correct
13 Correct 1 ms 1104 KB Output is correct
14 Correct 1 ms 1104 KB Output is correct
15 Correct 1 ms 1104 KB Output is correct
16 Correct 1 ms 1104 KB Output is correct
17 Correct 1 ms 1104 KB Output is correct
18 Correct 1 ms 1104 KB Output is correct
19 Correct 1 ms 1104 KB Output is correct
20 Correct 2 ms 1488 KB Output is correct
21 Correct 1 ms 1104 KB Output is correct
22 Correct 3 ms 2000 KB Output is correct
23 Correct 2 ms 1488 KB Output is correct
24 Correct 5 ms 1944 KB Output is correct
25 Correct 6 ms 2000 KB Output is correct
26 Correct 5 ms 2000 KB Output is correct
27 Correct 9 ms 2024 KB Output is correct
28 Correct 5 ms 2000 KB Output is correct
29 Correct 7 ms 1984 KB Output is correct
30 Correct 23 ms 6472 KB Output is correct
31 Correct 21 ms 3464 KB Output is correct
32 Correct 61 ms 31668 KB Output is correct
33 Correct 26 ms 7608 KB Output is correct
34 Correct 688 ms 32800 KB Output is correct
35 Correct 372 ms 31884 KB Output is correct
36 Correct 111 ms 31400 KB Output is correct
37 Correct 440 ms 31460 KB Output is correct
38 Correct 408 ms 31236 KB Output is correct
39 Correct 389 ms 31376 KB Output is correct
40 Correct 714 ms 32712 KB Output is correct
41 Correct 304 ms 30964 KB Output is correct
42 Correct 234 ms 30680 KB Output is correct
43 Correct 1332 ms 32892 KB Output is correct
44 Correct 576 ms 32836 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 976 KB Output is correct
2 Correct 1 ms 976 KB Output is correct
3 Correct 1 ms 1104 KB Output is correct
4 Correct 1 ms 976 KB Output is correct
5 Correct 1 ms 1104 KB Output is correct
6 Correct 1 ms 1104 KB Output is correct
7 Correct 1 ms 1104 KB Output is correct
8 Correct 1 ms 976 KB Output is correct
9 Correct 1 ms 976 KB Output is correct
10 Correct 1 ms 900 KB Output is correct
11 Correct 1 ms 1104 KB Output is correct
12 Correct 1 ms 1104 KB Output is correct
13 Correct 1 ms 1104 KB Output is correct
14 Correct 1 ms 1104 KB Output is correct
15 Correct 1 ms 1104 KB Output is correct
16 Correct 1 ms 1104 KB Output is correct
17 Correct 1 ms 1104 KB Output is correct
18 Correct 1 ms 1104 KB Output is correct
19 Correct 1 ms 1104 KB Output is correct
20 Correct 2 ms 1488 KB Output is correct
21 Correct 1 ms 1104 KB Output is correct
22 Correct 3 ms 2000 KB Output is correct
23 Correct 2 ms 1488 KB Output is correct
24 Correct 5 ms 1944 KB Output is correct
25 Correct 6 ms 2000 KB Output is correct
26 Correct 5 ms 2000 KB Output is correct
27 Correct 9 ms 2024 KB Output is correct
28 Correct 5 ms 2000 KB Output is correct
29 Correct 7 ms 1984 KB Output is correct
30 Correct 23 ms 6472 KB Output is correct
31 Correct 21 ms 3464 KB Output is correct
32 Correct 61 ms 31668 KB Output is correct
33 Correct 26 ms 7608 KB Output is correct
34 Correct 688 ms 32800 KB Output is correct
35 Correct 372 ms 31884 KB Output is correct
36 Correct 111 ms 31400 KB Output is correct
37 Correct 440 ms 31460 KB Output is correct
38 Correct 408 ms 31236 KB Output is correct
39 Correct 389 ms 31376 KB Output is correct
40 Correct 714 ms 32712 KB Output is correct
41 Correct 304 ms 30964 KB Output is correct
42 Correct 234 ms 30680 KB Output is correct
43 Correct 1332 ms 32892 KB Output is correct
44 Correct 576 ms 32836 KB Output is correct
45 Runtime error 2 ms 1764 KB Execution killed with signal 11
46 Halted 0 ms 0 KB -