# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
982837 |
2024-05-14T19:29:21 Z |
vjudge1 |
Game (APIO22_game) |
C++17 |
|
3 ms |
16728 KB |
#include <bits/stdc++.h>
#define endl '\n'
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define fo(i,n) for(auto i =0 ; i < n;i++)
#define fore(i,l,r) for(auto i = l; i < r;i++)
#define forex(i,r,l) for(auto i = r; i >= l; i--)
#define ffo(i,n) forex(i,n-1,0)
#define all(x) x.begin(),x.end()
#define lsb(x) x&(-x)
#define sz(x) (int)x.size()
#define gcd(a,b) __gcd(a,b)
#define vii vector<ii>
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>;using ii = pair<int,int>;using mii = map<int,int>;
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
const int N = 3e5 + 5;
int n,k;
int vis[N], timer = 0;
vi graph[N], graphinv[N];
// mn[i] la minima a la que puede llegar el nodo i
// mx[i] la maxima <= k que puede llegar al nodo i
int mx[N], mn[N];
void init(int N, int K){
n=N,k=K;
fo(i, n){
mx[i] = -1;
mn[i] = 1e9;
// i no puede llegar a i, a menos que hagas edge(i,i)
// entonces la minima es i+1 y max i-1
if(i>0 and k>1){mx[i]=i-1;graphinv[i].pb(i-1);}
if(i<k-1){mn[i]=i+1;graph[i].pb(i+1);}
}
}
bool ya = 0;
int add_teleporter(int u, int v){
if(mn[v]<=mx[u])ya=1;
if(ya) return 1;
graph[u].pb(v);graphinv[v].pb(u);
queue<int> q;timer++;
q.push(u);
while(!q.empty()){
int nodo = q.front();q.pop();
if(ya) return 1;
mn[nodo] = min(mn[nodo], mn[v]);
if(mn[nodo]<=mx[nodo]){ya=1;return 1;}
for(int v : graphinv[nodo]){
if(vis[v] == timer) continue;
vis[v] = timer;
q.push(v);
}
}timer++;
q.push(v);
while(!q.empty()){
int nodo = q.front(); q.pop();
if(ya) return 1;
mx[nodo] = max(mx[nodo] , mx[u]);
if(mn[nodo] <= mx[nodo]){ya = 1; return 1;}
for(int v : graph[nodo]){
if(vis[v] == timer)continue;
vis[v] = timer;
q.push(v);
}
}
if(mn[v]<=mx[u])ya=1;
fo(i, k) if(mn[i] <= mx[i] ){ya =1; break;}
if(ya)return 1;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
16728 KB |
Wrong Answer[1] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
16728 KB |
Wrong Answer[1] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
16728 KB |
Wrong Answer[1] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
16728 KB |
Wrong Answer[1] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
16728 KB |
Wrong Answer[1] |
2 |
Halted |
0 ms |
0 KB |
- |