Submission #1220572

#TimeUsernameProblemLanguageResultExecution timeMemory
1220572guagua0407Game (APIO22_game)C++20
0 / 100
0 ms412 KiB
#include "game.h" //#include "grader.cpp" #include <bits/stdc++.h> using namespace std; #define ll long long #define pii pair<int,int> #define f first #define s second #define all(x) x.begin(),x.end() #define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); namespace{ const int inf=1e9; vector<int> l,r,lev; int n,k; vector<vector<int>> adj,adjr; } void init(int _n, int _k) { n=_n; k=_k; l=vector<int>(n+1,inf); r=vector<int>(n+1,0); lev=vector<int>(n+1,20); adj.resize(n+1); adjr.resize(n+1); for(int i=1;i<=k;i++){ if(i>1){ r[i]=i-1; } if(i<k){ l[i]=i+1; } } } int add_teleporter(int a, int b) { a++; b++; adj[a].push_back(b); adjr[b].push_back(a); { int tmp=l[b]; if(b<=k) tmp=min(tmp,b); if(tmp<l[a]){ l[a]=tmp; bool tf=false; while(lev[a]>=0 and (l[a]>>lev[a])==(r[a]>>lev[a])){ lev[a]--; tf=true; } queue<int> q; q.push(a); while(!q.empty()){ int v=q.front(); q.pop(); if(l[v]<=r[v]) return 1; for(auto u:adjr[v]){ if(l[v]<l[u]){ l[u]=l[v]; bool tf=false; while(lev[u]>=0 and (l[u]>>lev[u])==(r[u]>>lev[u])){ lev[u]--; tf=true; } q.push(u); } } } } } { int tmp=r[a]; if(a<=k) tmp=max(tmp,a); if(tmp>r[b]){ r[b]=tmp; bool tf=false; while(lev[b]>=0 and (l[b]>>lev[b])==(r[b]>>lev[b])){ lev[b]--; tf=true; } queue<int> q; q.push(b); while(!q.empty()){ int v=q.front(); q.pop(); if(l[v]<=r[v]) return 1; for(auto u:adj[v]){ if(r[v]>r[u]){ r[u]=r[v]; bool tf=false; while(lev[u]>=0 and (l[u]>>lev[u])==(r[u]>>lev[u])){ lev[u]--; tf=true; } q.push(u); } } } } } /*for(int i=1;i<=n;i++){ cout<<i-1<<' '<<l[i]-1<<' '<<r[i]-1<<' '<<lev[i]<<'\n'; } cout<<'\n';*/ 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...