Submission #910899

#TimeUsernameProblemLanguageResultExecution timeMemory
910899efedmrlrGame (APIO22_game)C++17
30 / 100
4014 ms3156 KiB
#include "game.h"

// #pragma GCC optimize("O3,Ofast,unroll-loops")
// #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include <bits/stdc++.h>

using namespace std;


#define lli long long int
#define MP make_pair
#define pb push_back
#define REP(i,n) for(int i = 0; (i) < (n); (i)++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()


void fastio() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}


const double EPS = 0.00001;
const int INF = 1e9+500;
const int ALPH = 26;
const int LGN = 25;
constexpr int MOD = 1e9+7;
int N,K;
vector<vector<int> > adj;
vector<int> vis;
bool res = 0;
void init(int n, int k) {
  N = n; K = k;
  adj.resize(n + 1, vector<int>());
  
}

void dfs(int node, int t) {
  if(node < t || (node == t && vis[node])) {
    res = 1;
    return;
  } 

  if(vis[node]) return;
  vis[node] = 1;
  for(auto c : adj[node]) {
    dfs(c, t);
  }
  
}

int add_teleporter(int u, int v) {
  vis.assign(N + 1, 0);
  adj[u].pb(v);
  res = 0;
  for(int i = K - 1; i>=0; i--) {
    dfs(i, i);
    if(res) return 1;
  }
  
  return 0;
}
#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...