답안 #896902

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
896902 2024-01-02T10:55:39 Z vjudge1 게임 (APIO22_game) C++17
30 / 100
4000 ms 5216 KB
#include <bits/stdc++.h>
#include "game.h"

using namespace std;

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

mt19937 rng(time(nullptr));

bool cycle;
int n, k, nodes[X];
vector<int> adj[N], adj2[N];
bitset<N> st, nd, sp;
bitset<K> bt[X];

void dfs2(int u) {
  st[u] = 1;
  for (int& v : adj2[u]) {
    if (st[v]) continue;
    dfs2(v);
  }
}

void dfs(int u) {
  nd[u] = 1;
  for (int& v : adj[u]) {
    if (nd[v]) continue;
    dfs(v);
  }
}

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

  for (int i = 0; i < n; i++) {
    adj[i].clear();
    adj2[i].clear();
  }

  for (int i = 0; i+1 < k; i++) {
    adj[i].push_back(i+1);
    adj2[i+1].push_back(i); 
  }

  sp.reset();
  for (int i = 0; i < X; i++) {
    bt[i].reset();
    nodes[i] = rng() % n;
    sp[nodes[i]] = 1;
  }
}

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

  adj[u].push_back(v);
  adj2[v].push_back(u);

  st.reset();
  nd.reset();

  dfs(v);
  dfs2(u);

  bool b = 0;
  for (int i = 0; i < k; i++) {
    if (st[i] && st[i] == nd[i]) b = 1;
  }

  return cycle = b;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1880 KB Output is correct
2 Correct 3 ms 1880 KB Output is correct
3 Correct 2 ms 1880 KB Output is correct
4 Correct 1 ms 1880 KB Output is correct
5 Correct 2 ms 1880 KB Output is correct
6 Correct 1 ms 1880 KB Output is correct
7 Correct 1 ms 1880 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1880 KB Output is correct
2 Correct 3 ms 1880 KB Output is correct
3 Correct 2 ms 1880 KB Output is correct
4 Correct 1 ms 1880 KB Output is correct
5 Correct 2 ms 1880 KB Output is correct
6 Correct 1 ms 1880 KB Output is correct
7 Correct 1 ms 1880 KB Output is correct
8 Correct 1 ms 1880 KB Output is correct
9 Correct 1 ms 1880 KB Output is correct
10 Correct 1 ms 2132 KB Output is correct
11 Correct 1 ms 1880 KB Output is correct
12 Correct 1 ms 1880 KB Output is correct
13 Correct 1 ms 1880 KB Output is correct
14 Correct 2 ms 1880 KB Output is correct
15 Correct 1 ms 1880 KB Output is correct
16 Correct 1 ms 1880 KB Output is correct
17 Correct 1 ms 1880 KB Output is correct
18 Correct 1 ms 1880 KB Output is correct
19 Correct 1 ms 1880 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1880 KB Output is correct
2 Correct 3 ms 1880 KB Output is correct
3 Correct 2 ms 1880 KB Output is correct
4 Correct 1 ms 1880 KB Output is correct
5 Correct 2 ms 1880 KB Output is correct
6 Correct 1 ms 1880 KB Output is correct
7 Correct 1 ms 1880 KB Output is correct
8 Correct 1 ms 1880 KB Output is correct
9 Correct 1 ms 1880 KB Output is correct
10 Correct 1 ms 2132 KB Output is correct
11 Correct 1 ms 1880 KB Output is correct
12 Correct 1 ms 1880 KB Output is correct
13 Correct 1 ms 1880 KB Output is correct
14 Correct 2 ms 1880 KB Output is correct
15 Correct 1 ms 1880 KB Output is correct
16 Correct 1 ms 1880 KB Output is correct
17 Correct 1 ms 1880 KB Output is correct
18 Correct 1 ms 1880 KB Output is correct
19 Correct 1 ms 1880 KB Output is correct
20 Correct 2 ms 1880 KB Output is correct
21 Correct 1 ms 1880 KB Output is correct
22 Correct 2 ms 1880 KB Output is correct
23 Correct 2 ms 1880 KB Output is correct
24 Correct 5 ms 1896 KB Output is correct
25 Correct 18 ms 2136 KB Output is correct
26 Correct 22 ms 2136 KB Output is correct
27 Correct 13 ms 2136 KB Output is correct
28 Correct 8 ms 1880 KB Output is correct
29 Correct 16 ms 2320 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1880 KB Output is correct
2 Correct 3 ms 1880 KB Output is correct
3 Correct 2 ms 1880 KB Output is correct
4 Correct 1 ms 1880 KB Output is correct
5 Correct 2 ms 1880 KB Output is correct
6 Correct 1 ms 1880 KB Output is correct
7 Correct 1 ms 1880 KB Output is correct
8 Correct 1 ms 1880 KB Output is correct
9 Correct 1 ms 1880 KB Output is correct
10 Correct 1 ms 2132 KB Output is correct
11 Correct 1 ms 1880 KB Output is correct
12 Correct 1 ms 1880 KB Output is correct
13 Correct 1 ms 1880 KB Output is correct
14 Correct 2 ms 1880 KB Output is correct
15 Correct 1 ms 1880 KB Output is correct
16 Correct 1 ms 1880 KB Output is correct
17 Correct 1 ms 1880 KB Output is correct
18 Correct 1 ms 1880 KB Output is correct
19 Correct 1 ms 1880 KB Output is correct
20 Correct 2 ms 1880 KB Output is correct
21 Correct 1 ms 1880 KB Output is correct
22 Correct 2 ms 1880 KB Output is correct
23 Correct 2 ms 1880 KB Output is correct
24 Correct 5 ms 1896 KB Output is correct
25 Correct 18 ms 2136 KB Output is correct
26 Correct 22 ms 2136 KB Output is correct
27 Correct 13 ms 2136 KB Output is correct
28 Correct 8 ms 1880 KB Output is correct
29 Correct 16 ms 2320 KB Output is correct
30 Correct 29 ms 3568 KB Output is correct
31 Correct 13 ms 2648 KB Output is correct
32 Correct 52 ms 4548 KB Output is correct
33 Correct 47 ms 3920 KB Output is correct
34 Correct 1040 ms 5208 KB Output is correct
35 Correct 3841 ms 4944 KB Output is correct
36 Correct 1969 ms 4084 KB Output is correct
37 Correct 1103 ms 4268 KB Output is correct
38 Correct 1352 ms 3944 KB Output is correct
39 Correct 1209 ms 4136 KB Output is correct
40 Correct 1168 ms 5216 KB Output is correct
41 Execution timed out 4009 ms 4356 KB Time limit exceeded
42 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1880 KB Output is correct
2 Correct 3 ms 1880 KB Output is correct
3 Correct 2 ms 1880 KB Output is correct
4 Correct 1 ms 1880 KB Output is correct
5 Correct 2 ms 1880 KB Output is correct
6 Correct 1 ms 1880 KB Output is correct
7 Correct 1 ms 1880 KB Output is correct
8 Correct 1 ms 1880 KB Output is correct
9 Correct 1 ms 1880 KB Output is correct
10 Correct 1 ms 2132 KB Output is correct
11 Correct 1 ms 1880 KB Output is correct
12 Correct 1 ms 1880 KB Output is correct
13 Correct 1 ms 1880 KB Output is correct
14 Correct 2 ms 1880 KB Output is correct
15 Correct 1 ms 1880 KB Output is correct
16 Correct 1 ms 1880 KB Output is correct
17 Correct 1 ms 1880 KB Output is correct
18 Correct 1 ms 1880 KB Output is correct
19 Correct 1 ms 1880 KB Output is correct
20 Correct 2 ms 1880 KB Output is correct
21 Correct 1 ms 1880 KB Output is correct
22 Correct 2 ms 1880 KB Output is correct
23 Correct 2 ms 1880 KB Output is correct
24 Correct 5 ms 1896 KB Output is correct
25 Correct 18 ms 2136 KB Output is correct
26 Correct 22 ms 2136 KB Output is correct
27 Correct 13 ms 2136 KB Output is correct
28 Correct 8 ms 1880 KB Output is correct
29 Correct 16 ms 2320 KB Output is correct
30 Correct 29 ms 3568 KB Output is correct
31 Correct 13 ms 2648 KB Output is correct
32 Correct 52 ms 4548 KB Output is correct
33 Correct 47 ms 3920 KB Output is correct
34 Correct 1040 ms 5208 KB Output is correct
35 Correct 3841 ms 4944 KB Output is correct
36 Correct 1969 ms 4084 KB Output is correct
37 Correct 1103 ms 4268 KB Output is correct
38 Correct 1352 ms 3944 KB Output is correct
39 Correct 1209 ms 4136 KB Output is correct
40 Correct 1168 ms 5216 KB Output is correct
41 Execution timed out 4009 ms 4356 KB Time limit exceeded
42 Halted 0 ms 0 KB -