이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
const int N = 2e5;
vector<pair<int, int> > g[N+1];
int n, m, q, timer = 1;
int used[N+1];
int l, r, ok = 0;
void dfs(int v, int len){
if(ok) return;
used[v] = timer;
for(auto [to, idx] : g[v]){
if(used[to] == timer && (idx < l or idx > r)){
if(len % 2 == 1){
ok = 1;
return;
}
}else if(used[to] < timer && (idx < l or idx > r)){
dfs(to, len + 1);
}
}
used[v] = timer + 1;
}
main(){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n >> m >> q;
for(int i = 0;i < m; i++){
int a, b; cin >> a >> b;
g[a].push_back({b, i + 1});
g[b].push_back({a, i + 1});
}
while(q--){
cin >> l >> r;
ok = 0;
for(int i = 1;i <= n; i++){
if(used[i] < timer){
dfs(i, 1);
}
}
cout << (ok ? "YES" : "NO") << '\n';
timer+= 2;
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
Joker.cpp:28:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
28 | main(){
| ^~~~
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |