Submission #975915

#TimeUsernameProblemLanguageResultExecution timeMemory
975915phoenix0423Game (APIO22_game)C++17
60 / 100
4081 ms19124 KiB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
#define fastio ios::sync_with_stdio(false), cin.tie(0)
#define pb push_back
#define eb emplace_back
#define f first
#define s second
#include "game.h"
const int maxn = 3e5 + 5;
vector<int> adj[maxn];
int mx[maxn];
int n, k;

void init(int _n, int _k) {
  n = _n, k = _k;
  for(int i = 0; i < n; i++){
    if(i < k) mx[i] = i - 1;
    else mx[i] = -1;
  }
  for(int i = 0; i < k - 1; i++) adj[i].pb(i + 1);
} 

int add_teleporter(int u, int v) {
  adj[u].pb(v);
  queue<int> q;
  q.push(u);
  while(!q.empty()){
    int pos = q.front(); q.pop();
    int c = (u < k ? u : mx[u]);
    for(auto x : adj[pos]){
      if(c > mx[x]){
        mx[x] = c;
        if(x < k && c >= x) return 1;
        q.push(x);
      }
    }
  }
  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...