제출 #982745

#제출 시각아이디문제언어결과실행 시간메모리
982745vjudge1게임 (APIO22_game)C++17
0 / 100
0 ms344 KiB
#include "game.h" #include<bits/stdc++.h> using namespace std; #define pb push_back int K; int N; vector<int> mini; vector<int> maxi; vector<vector<int>> teapuntan; vector<vector<int>> apuntas; void init(int n, int k) { N=n; K=k; mini.resize( n, 1e9); maxi.resize(n, -1); teapuntan.resize(n); apuntas.resize(n); } int add_teleporter(int u, int v) { if(u<K && v<K) return 1; if(u<K){ queue<int> q; q.push(v); while(!q.empty()){ int x=q.front(); q.pop(); if(maxi[x]>u) continue; maxi[x]=u; if(maxi[x]>=mini[x]) return 1; for(int y: apuntas[x]){ q.push(y); } } } else if(v<K){ queue<int> q; q.push(u); while(!q.empty()){ int x=q.front(); q.pop(); if(mini[x]<v) continue; mini[x]=v; if(maxi[x]>=mini[x]) return 1; for(int y:teapuntan[x]){ q.push(y); } } } else{ apuntas[u].pb(v); teapuntan[v].pb(u); queue<int> q; q.push(v); vector<bool> visited1 (N, false); while(!q.empty()){ int x=q.front(); q.pop(); if(visited1[x]) continue; visited1[x]=1; if(maxi[x]>maxi[u]) continue; maxi[x]=maxi[u]; if(maxi[x]>=mini[x]) return 1; for(int y: apuntas[x]){ if(visited1[y]) continue; q.push(y); } } vector<bool> visited2 (N, 0); q.push(u); while(!q.empty()){ int x=q.front(); q.pop(); if(visited2[x]) continue; visited2[x]=1; if(mini[x]<mini[v]) continue; mini[x]=mini[v]; if(maxi[x]>=mini[x]) return 1; for(int y:teapuntan[x]){ if(visited2[y]) continue; q.push(y); } } } 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...