#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;
}
Compilation message
Joker.cpp:28:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
28 | main(){
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
5724 KB |
Output is correct |
2 |
Correct |
1 ms |
5760 KB |
Output is correct |
3 |
Correct |
1 ms |
5724 KB |
Output is correct |
4 |
Correct |
2 ms |
5724 KB |
Output is correct |
5 |
Incorrect |
1 ms |
5724 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
5724 KB |
Output is correct |
2 |
Correct |
1 ms |
5760 KB |
Output is correct |
3 |
Correct |
1 ms |
5724 KB |
Output is correct |
4 |
Correct |
2 ms |
5724 KB |
Output is correct |
5 |
Incorrect |
1 ms |
5724 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
5724 KB |
Output is correct |
2 |
Correct |
1 ms |
5760 KB |
Output is correct |
3 |
Execution timed out |
2041 ms |
17364 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
5724 KB |
Output is correct |
2 |
Correct |
1 ms |
5760 KB |
Output is correct |
3 |
Correct |
1 ms |
5724 KB |
Output is correct |
4 |
Correct |
2 ms |
5724 KB |
Output is correct |
5 |
Incorrect |
1 ms |
5724 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
5724 KB |
Output is correct |
2 |
Correct |
1 ms |
5760 KB |
Output is correct |
3 |
Correct |
1 ms |
5724 KB |
Output is correct |
4 |
Correct |
2 ms |
5724 KB |
Output is correct |
5 |
Incorrect |
1 ms |
5724 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
5724 KB |
Output is correct |
2 |
Correct |
1 ms |
5760 KB |
Output is correct |
3 |
Correct |
1 ms |
5724 KB |
Output is correct |
4 |
Correct |
2 ms |
5724 KB |
Output is correct |
5 |
Incorrect |
1 ms |
5724 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |