# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
974633 | IUA_Hasin | Game (APIO22_game) | C++17 | 3 ms | 9816 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "game.h"
#include <bits/stdc++.h>
#define endl "\n"
#define ll long long
using namespace std;
const ll N = 3e5+10;
ll NN, K;
std::vector<ll> graph[N];
ll vis[N];
ll vis2[N];
void dfs(ll vertex){
if(vis[vertex]==1){
return;
} else {
vis[vertex] = 1;
// cout << vertex << " ";
for(auto u : graph[vertex]){
dfs(u);
}
return;
}
}
void init(int n, int k) {
NN = n;
K = k;
for(int i=0; i<=k-2; i++){
graph[i].push_back(i+1);
// cout << i << " " << i+1 << endl;
}
}
int add_teleporter(int u, int v) {
graph[u].push_back(v);
for(int i=0; i<=NN+5; i++){
vis[i] = 0;
}
dfs(0);
std::vector<ll> last;
for(int i=0; i<=NN+5; i++){
if(vis[i]==1){
last.push_back(i);
// cout<<i<<" ";
}
}
cout<<endl;
if(u>=K && v<K){
vis2[u] = 1;
// cout << u << " " << 59 << endl;
}
if(u>=v && u<K){
return 1;
} else {
for(int i=0; i<last.size(); i++){
if(vis2[last[i]]==1){
return 1;
}
}
return 0;
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |