이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define f first
#define s second
#define ent '\n'
//#define int long long
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast,unroll-loops,fast-math,O3")
const int dx[]={-1, 1, 0, 0, 0};
const int dy[]={0, 0, 1, -1, 0};
typedef long long ll;
using namespace std;
const int mx=1e6+12;
const int mod=998244353;
const bool T=1;
vector<int> g[mx];
int used[mx];
int n,m,k;
int timer;
bool ans;
void init(int N, int K) {
n=N, k=K;
timer++;
for(int i=0;i<k-1;i++){
g[i].push_back(i+1);
}
}
bool check(int v){
used[v]=timer;
for(int to:g[v]){
if(used[to]==timer){
return 1;
}
if(used[to]<timer && check(to)){
return 1;
}
}
used[v]=timer+1;
return 0;
}
int add_teleporter(int u, int v) {
if(ans){
return 1;
}
g[u].push_back(v);
for(int i=0;i<k;i++){
if(used[i]<timer && check(i)){
ans=1;
return 1;
}
}
timer+=2;
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... |