이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#include "game.h"
int k1,n1;
vector<vector<int>> G,Grev, DAG;
vector<int> top,used,scc;
int act = 0;
void dfs(int u){
if(used[u]) return;
used[u] = 1;
for(int v : G[u]) dfs(v);
top.push_back(u);
}
void dfs1(int u){
if(used[u]) return;
used[u] = 1;
for(int v : Grev[u]){
dfs1(v);
}
scc[u] = act;
}
void init(int n, int k) {
k1 = k; n1 = n;
G.assign(n,vector<int>());
Grev = G;
for(int i = 0; i<k-1; i++){
G[i].push_back(i+1);
Grev[i+1].push_back(i);
}
}
int add_teleporter(int u, int v) {
G[u].push_back(v);
Grev[v].push_back(u);
used.assign(n1,0);
scc.assign(n1,-1);
top.clear();
dfs(0);
used.assign(n1,0);
act = 0;
for(int i = top.size()-1; i>=0; i--){
if(!used[i]) act++, scc[i] = act;
}
set<int> hv;
for(int i = 0; i<k1; i++) hv.insert(scc[i]);
for(int i = k1; i<n1; i++){
if(hv.count(scc[i])) return 1;
}
return 0;
}
# | 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... |