Submission #897077

# Submission time Handle Problem Language Result Execution time Memory
897077 2024-01-02T14:03:18 Z vjudge1 Game (APIO22_game) C++17
2 / 100
1 ms 2648 KB
#include <bits/stdc++.h>
#include "game.h"

using namespace std;

const int N = 3e4+4, K = 1e3+3, inf = INT_MAX;

bool cycle;
int n, k, mx[N], mn[N];
bitset<N> bt[K];

void init(int N, int K) {
  n = N;
  k = K;
  cycle = 0;

  for (int i = 0; i < n; i++) {
    mn[i] = inf;
    mx[i] = -inf;
  }

  for (int i = 0; i < k; i++) {
    bt[i].reset();
  }
}

int add_teleporter(int u, int v) {
  if (cycle) return 1;

  if (u < k && u == v) return cycle = 1;

  if (min(u, v) >= k) {
    for (int i = 0; i < k; i++) {
      if (!bt[i][u]) continue;
      bt[i][v] = 1;
      mx[v] = max(mx[v], i);
    }
  }
  else if (u < k && v < k) {
    if (u < v) return 0;
    else return cycle = 1;
  }
  else if (u < k) {
    bt[u][v] = 1;
    mx[v] = max(mx[v], u);
  }
  else {
    mn[u] = min(mn[u], v);
  }

  if (mn[u] <= mx[u]) cycle = 1;
  else if (mn[v] <= mx[v]) cycle = 1;
  
  return cycle;
}
# 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 2648 KB Output is correct
4 Correct 0 ms 600 KB Output is correct
5 Correct 1 ms 2648 KB Output is correct
6 Correct 1 ms 2648 KB Output is correct
7 Correct 1 ms 2648 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 2648 KB Output is correct
4 Correct 0 ms 600 KB Output is correct
5 Correct 1 ms 2648 KB Output is correct
6 Correct 1 ms 2648 KB Output is correct
7 Correct 1 ms 2648 KB Output is correct
8 Incorrect 1 ms 344 KB Wrong Answer[1]
9 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 2648 KB Output is correct
4 Correct 0 ms 600 KB Output is correct
5 Correct 1 ms 2648 KB Output is correct
6 Correct 1 ms 2648 KB Output is correct
7 Correct 1 ms 2648 KB Output is correct
8 Incorrect 1 ms 344 KB Wrong Answer[1]
9 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 2648 KB Output is correct
4 Correct 0 ms 600 KB Output is correct
5 Correct 1 ms 2648 KB Output is correct
6 Correct 1 ms 2648 KB Output is correct
7 Correct 1 ms 2648 KB Output is correct
8 Incorrect 1 ms 344 KB Wrong Answer[1]
9 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 2648 KB Output is correct
4 Correct 0 ms 600 KB Output is correct
5 Correct 1 ms 2648 KB Output is correct
6 Correct 1 ms 2648 KB Output is correct
7 Correct 1 ms 2648 KB Output is correct
8 Incorrect 1 ms 344 KB Wrong Answer[1]
9 Halted 0 ms 0 KB -