제출 #1201572

#제출 시각아이디문제언어결과실행 시간메모리
1201572adiyerGame (APIO22_game)C++20
2 / 100
6 ms12096 KiB
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 5e5 + 11;

int n, ok;
int was[MAXN];

vector < int > g[MAXN];

bool dfs(int v){
    was[v] = 1;
    for(int u : g[v]){
        if(was[u] == 1) return 1;
        if(!was[u]){
            if(dfs(u)) return 1;
        }
    }
    was[v] = 2;
    return 0;
}

void init(int _n, int k) {
    n = _n;
    for(int i = 0; i < k - 1; i++) g[i].push_back(i + 1);
}

int add_teleporter(int u, int v){
    for(int i = 0; i < n; i++) was[i] = 0;
    g[u].push_back(v);
    return dfs(0);
}

namespace {

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

}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...