Submission #679234

# Submission time Handle Problem Language Result Execution time Memory
679234 2023-01-07T20:07:08 Z Victor Game (APIO22_game) C++17
60 / 100
4000 ms 23916 KB
// #pragma GCC target ("avx,avx2,fma")
// #pragma GCC optimize ("Ofast,inline") // O1 - O2 - O3 - Os - Ofast
// #pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define per(i, a, b) for (int i = (b)-1; i >= (a); --i)
#define trav(a, x) for (auto &a : x)

#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pb push_back
#define debug(x) cout << #x << " = " << x << endl

#define umap unordered_map
#define uset unordered_set

typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;

const int INF = 1'000'000'007;

#include "game.h"

vi graph[300005];
int max_reach[300005];
int N,K;
bool stop=0;

void dfs(int u) {
    //cout<<"u = "<<u<<" max_reach = "<<max_reach[u]<<endl;
    if(max_reach[u]>=u) {
        stop=1;
        return;
    }
    trav(v,graph[u]) if(max_reach[u]>max_reach[v]) {
        max_reach[v]=max_reach[u];
        dfs(v);
    }
}

void init(int n, int k) {
    N=n;
    K=k;
    memset(max_reach,-1,sizeof(max_reach));
}

int add_teleporter(int u, int v) {
    //cout<<"u = "<<u<<" v = "<<v<<endl;
    graph[u].pb(v);
    if(u<K) max_reach[v]=max(max_reach[v],u);
    max_reach[v]=max(max_reach[v],max_reach[u]);
    dfs(v);
    //cout<<endl;
    return stop;
}
/*
#include <cstdio>
#include <cstdlib>
#include <vector>
#include "game.h"

namespace {

int read_int() {
  int x;
  if (scanf("%d", &x) != 1) {
    fprintf(stderr, "Error while reading input\n");
    exit(1);
  }
  return x;
}

}  // namespace

int main() {
  int N = read_int();
  int M = read_int();
  int K = read_int();
  std::vector<int> u(M), v(M);
  for (int i = 0; i < M; ++i) {
    u[i] = read_int();
    v[i] = read_int();
  }

  init(N, K);
  int i;
  for (i = 0; i < M; ++i) {
    int answer = add_teleporter(u[i], v[i]);
    if (answer != 0 && answer != 1) {
      i = -1;
      break;
    } else if (answer == 1) {
      break;
    }
  }
  printf("%d\n", i);
  return 0;
}
*/
# Verdict Execution time Memory Grader output
1 Correct 6 ms 8496 KB Output is correct
2 Correct 5 ms 8400 KB Output is correct
3 Correct 4 ms 8516 KB Output is correct
4 Correct 4 ms 8400 KB Output is correct
5 Correct 4 ms 8400 KB Output is correct
6 Correct 4 ms 8436 KB Output is correct
7 Correct 4 ms 8400 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 8496 KB Output is correct
2 Correct 5 ms 8400 KB Output is correct
3 Correct 4 ms 8516 KB Output is correct
4 Correct 4 ms 8400 KB Output is correct
5 Correct 4 ms 8400 KB Output is correct
6 Correct 4 ms 8436 KB Output is correct
7 Correct 4 ms 8400 KB Output is correct
8 Correct 5 ms 8480 KB Output is correct
9 Correct 4 ms 8400 KB Output is correct
10 Correct 4 ms 8400 KB Output is correct
11 Correct 4 ms 8400 KB Output is correct
12 Correct 4 ms 8528 KB Output is correct
13 Correct 4 ms 8400 KB Output is correct
14 Correct 4 ms 8400 KB Output is correct
15 Correct 4 ms 8400 KB Output is correct
16 Correct 5 ms 8400 KB Output is correct
17 Correct 5 ms 8528 KB Output is correct
18 Correct 5 ms 8400 KB Output is correct
19 Correct 4 ms 8400 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 8496 KB Output is correct
2 Correct 5 ms 8400 KB Output is correct
3 Correct 4 ms 8516 KB Output is correct
4 Correct 4 ms 8400 KB Output is correct
5 Correct 4 ms 8400 KB Output is correct
6 Correct 4 ms 8436 KB Output is correct
7 Correct 4 ms 8400 KB Output is correct
8 Correct 5 ms 8480 KB Output is correct
9 Correct 4 ms 8400 KB Output is correct
10 Correct 4 ms 8400 KB Output is correct
11 Correct 4 ms 8400 KB Output is correct
12 Correct 4 ms 8528 KB Output is correct
13 Correct 4 ms 8400 KB Output is correct
14 Correct 4 ms 8400 KB Output is correct
15 Correct 4 ms 8400 KB Output is correct
16 Correct 5 ms 8400 KB Output is correct
17 Correct 5 ms 8528 KB Output is correct
18 Correct 5 ms 8400 KB Output is correct
19 Correct 4 ms 8400 KB Output is correct
20 Correct 5 ms 8528 KB Output is correct
21 Correct 4 ms 8400 KB Output is correct
22 Correct 5 ms 8524 KB Output is correct
23 Correct 5 ms 8504 KB Output is correct
24 Correct 6 ms 8528 KB Output is correct
25 Correct 8 ms 8528 KB Output is correct
26 Correct 6 ms 8528 KB Output is correct
27 Correct 6 ms 8520 KB Output is correct
28 Correct 5 ms 8528 KB Output is correct
29 Correct 6 ms 8528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 8496 KB Output is correct
2 Correct 5 ms 8400 KB Output is correct
3 Correct 4 ms 8516 KB Output is correct
4 Correct 4 ms 8400 KB Output is correct
5 Correct 4 ms 8400 KB Output is correct
6 Correct 4 ms 8436 KB Output is correct
7 Correct 4 ms 8400 KB Output is correct
8 Correct 5 ms 8480 KB Output is correct
9 Correct 4 ms 8400 KB Output is correct
10 Correct 4 ms 8400 KB Output is correct
11 Correct 4 ms 8400 KB Output is correct
12 Correct 4 ms 8528 KB Output is correct
13 Correct 4 ms 8400 KB Output is correct
14 Correct 4 ms 8400 KB Output is correct
15 Correct 4 ms 8400 KB Output is correct
16 Correct 5 ms 8400 KB Output is correct
17 Correct 5 ms 8528 KB Output is correct
18 Correct 5 ms 8400 KB Output is correct
19 Correct 4 ms 8400 KB Output is correct
20 Correct 5 ms 8528 KB Output is correct
21 Correct 4 ms 8400 KB Output is correct
22 Correct 5 ms 8524 KB Output is correct
23 Correct 5 ms 8504 KB Output is correct
24 Correct 6 ms 8528 KB Output is correct
25 Correct 8 ms 8528 KB Output is correct
26 Correct 6 ms 8528 KB Output is correct
27 Correct 6 ms 8520 KB Output is correct
28 Correct 5 ms 8528 KB Output is correct
29 Correct 6 ms 8528 KB Output is correct
30 Correct 15 ms 9008 KB Output is correct
31 Correct 8 ms 8656 KB Output is correct
32 Correct 22 ms 9664 KB Output is correct
33 Correct 16 ms 9416 KB Output is correct
34 Correct 505 ms 10900 KB Output is correct
35 Correct 190 ms 10060 KB Output is correct
36 Correct 27 ms 9404 KB Output is correct
37 Correct 23 ms 9428 KB Output is correct
38 Correct 25 ms 9160 KB Output is correct
39 Correct 25 ms 9128 KB Output is correct
40 Correct 408 ms 10836 KB Output is correct
41 Correct 90 ms 9688 KB Output is correct
42 Correct 65 ms 9496 KB Output is correct
43 Correct 32 ms 10832 KB Output is correct
44 Correct 293 ms 10908 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 8496 KB Output is correct
2 Correct 5 ms 8400 KB Output is correct
3 Correct 4 ms 8516 KB Output is correct
4 Correct 4 ms 8400 KB Output is correct
5 Correct 4 ms 8400 KB Output is correct
6 Correct 4 ms 8436 KB Output is correct
7 Correct 4 ms 8400 KB Output is correct
8 Correct 5 ms 8480 KB Output is correct
9 Correct 4 ms 8400 KB Output is correct
10 Correct 4 ms 8400 KB Output is correct
11 Correct 4 ms 8400 KB Output is correct
12 Correct 4 ms 8528 KB Output is correct
13 Correct 4 ms 8400 KB Output is correct
14 Correct 4 ms 8400 KB Output is correct
15 Correct 4 ms 8400 KB Output is correct
16 Correct 5 ms 8400 KB Output is correct
17 Correct 5 ms 8528 KB Output is correct
18 Correct 5 ms 8400 KB Output is correct
19 Correct 4 ms 8400 KB Output is correct
20 Correct 5 ms 8528 KB Output is correct
21 Correct 4 ms 8400 KB Output is correct
22 Correct 5 ms 8524 KB Output is correct
23 Correct 5 ms 8504 KB Output is correct
24 Correct 6 ms 8528 KB Output is correct
25 Correct 8 ms 8528 KB Output is correct
26 Correct 6 ms 8528 KB Output is correct
27 Correct 6 ms 8520 KB Output is correct
28 Correct 5 ms 8528 KB Output is correct
29 Correct 6 ms 8528 KB Output is correct
30 Correct 15 ms 9008 KB Output is correct
31 Correct 8 ms 8656 KB Output is correct
32 Correct 22 ms 9664 KB Output is correct
33 Correct 16 ms 9416 KB Output is correct
34 Correct 505 ms 10900 KB Output is correct
35 Correct 190 ms 10060 KB Output is correct
36 Correct 27 ms 9404 KB Output is correct
37 Correct 23 ms 9428 KB Output is correct
38 Correct 25 ms 9160 KB Output is correct
39 Correct 25 ms 9128 KB Output is correct
40 Correct 408 ms 10836 KB Output is correct
41 Correct 90 ms 9688 KB Output is correct
42 Correct 65 ms 9496 KB Output is correct
43 Correct 32 ms 10832 KB Output is correct
44 Correct 293 ms 10908 KB Output is correct
45 Correct 168 ms 14164 KB Output is correct
46 Correct 8 ms 8656 KB Output is correct
47 Correct 9 ms 8784 KB Output is correct
48 Correct 219 ms 23916 KB Output is correct
49 Correct 196 ms 18012 KB Output is correct
50 Execution timed out 4090 ms 20248 KB Time limit exceeded
51 Halted 0 ms 0 KB -