Submission #969653

# Submission time Handle Problem Language Result Execution time Memory
969653 2024-04-25T12:21:13 Z anton Game (APIO22_game) C++17
30 / 100
21 ms 856 KB
#include "game.h"
#include<bits/stdc++.h>

using namespace std;
#define pii pair<int, int>

const int MAX_N = 1e3;

vector<int> adj[MAX_N];
vector<int> rev_adj[MAX_N];
int min_acc[MAX_N];
int N, K;

void rev_dfs(int u, int acc){
  min_acc[u] = acc;
  for(auto e: rev_adj[u]){
    if(min_acc[e]>acc){
      rev_dfs(e, acc);
    }
  }
}

void init(int n, int k) {
  N= n, K = k;
  for(int i = 0; i<k-1; i++){
    adj[i].push_back(i+1);
    rev_adj[i+1].push_back(i);
  }
}

int add_teleporter(int u, int v) {
  adj[u].push_back(v);
  rev_adj[v].push_back(u);

  for(int i = 0; i<N; i++){
    min_acc[i] = 1e9;
  }
  for(int i = 0; i<K; i++){
    //cout<<min_acc[i]<<" ";
    if(min_acc[i]<i){
      return 1;
    }
    else{
      for(auto e: rev_adj[i]){
        if(min_acc[e]>i){
          rev_dfs(e, i);
        }
      }
    }
    if(min_acc[i]<=i){
      return 1;
    }
  }
  //cout<<endl;
  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 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 600 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 596 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 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 600 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 596 KB Output is correct
8 Correct 0 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 0 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 1 ms 600 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 1 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 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 600 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 596 KB Output is correct
8 Correct 0 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 0 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 1 ms 600 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 1 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 2 ms 344 KB Output is correct
21 Correct 1 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 5 ms 344 KB Output is correct
25 Correct 21 ms 856 KB Output is correct
26 Correct 21 ms 344 KB Output is correct
27 Correct 21 ms 600 KB Output is correct
28 Correct 10 ms 344 KB Output is correct
29 Correct 20 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 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 600 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 596 KB Output is correct
8 Correct 0 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 0 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 1 ms 600 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 1 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 2 ms 344 KB Output is correct
21 Correct 1 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 5 ms 344 KB Output is correct
25 Correct 21 ms 856 KB Output is correct
26 Correct 21 ms 344 KB Output is correct
27 Correct 21 ms 600 KB Output is correct
28 Correct 10 ms 344 KB Output is correct
29 Correct 20 ms 600 KB Output is correct
30 Runtime error 1 ms 600 KB Execution killed with signal 11
31 Halted 0 ms 0 KB -
# 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 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 600 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 596 KB Output is correct
8 Correct 0 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 0 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 1 ms 600 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 1 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 2 ms 344 KB Output is correct
21 Correct 1 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 5 ms 344 KB Output is correct
25 Correct 21 ms 856 KB Output is correct
26 Correct 21 ms 344 KB Output is correct
27 Correct 21 ms 600 KB Output is correct
28 Correct 10 ms 344 KB Output is correct
29 Correct 20 ms 600 KB Output is correct
30 Runtime error 1 ms 600 KB Execution killed with signal 11
31 Halted 0 ms 0 KB -