#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#include "../Library/debug.h"
#else
#define dbg(x...)
// #define cin fin
// #define cout fout
// const string FILE_NAME = ""; ifstream fin(FILE_NAME + ".in"); ofstream fout(FILE_NAME + ".out");
#endif
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define F0R(i, a) for (int i = 0; i < (a); ++i)
#define FORd(i, a, b) for (int i = (b) - 1; i >= (a); --i)
#define F0Rd(i, a) for (int i = (a) - 1; i >= 0; --i)
#define trav(a, x) for (auto& a : x)
#define f first
#define s second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
const char nl = '\n';
const int INF = 1e9;
const int MOD = 1e9 + 7;
vector<vi> adj;
vi edges, good;
vi color;
bool cycle = false;
void dfs(int u, int p, int c){
if(color[u] != -1 && color[u] != c){
cycle = true;
return;
}
if(color[u] != -1)
return;
color[u] = c;
trav(id, adj[u]){
if(!good[id]) continue;
int v = edges[id] ^ u;
if(v == p)
continue;
dfs(v, u, c ^ 1);
}
}
void solve(){
int n, m, q;
cin >> n >> m >> q;
adj.resize(n);
edges.resize(m);
F0R(i, m){
int a, b;
cin >> a >> b;
--a, --b;
edges[i] = a ^ b;
adj[a].pb(i);
adj[b].pb(i);
}
color.resize(n);
good.resize(m);
while(q--){
int a, b;
cin >> a >> b;
a--, b--;
color = vector<int>(n, -1);
F0R(i, m){
if(i >= a && i <= b)
good[i] = false;
else good[i] = true;
}
cycle = false;
F0R(i, n){
if(color[i] == -1)
dfs(i, -1, 1);
}
if(cycle)
cout << "YES\n";
else cout << "NO\n";
dbg(color)
}
}
int32_t main(){
ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int TC = 1;
// cin >> TC;
while(TC--){
solve();
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
376 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
344 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
456 KB |
Output is correct |
20 |
Correct |
1 ms |
344 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
344 KB |
Output is correct |
25 |
Correct |
1 ms |
348 KB |
Output is correct |
26 |
Correct |
1 ms |
348 KB |
Output is correct |
27 |
Correct |
1 ms |
348 KB |
Output is correct |
28 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
376 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
344 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
456 KB |
Output is correct |
20 |
Correct |
1 ms |
344 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
344 KB |
Output is correct |
25 |
Correct |
1 ms |
348 KB |
Output is correct |
26 |
Correct |
1 ms |
348 KB |
Output is correct |
27 |
Correct |
1 ms |
348 KB |
Output is correct |
28 |
Correct |
1 ms |
348 KB |
Output is correct |
29 |
Correct |
32 ms |
580 KB |
Output is correct |
30 |
Correct |
78 ms |
600 KB |
Output is correct |
31 |
Correct |
79 ms |
604 KB |
Output is correct |
32 |
Correct |
69 ms |
600 KB |
Output is correct |
33 |
Correct |
59 ms |
344 KB |
Output is correct |
34 |
Correct |
81 ms |
604 KB |
Output is correct |
35 |
Correct |
87 ms |
600 KB |
Output is correct |
36 |
Correct |
26 ms |
604 KB |
Output is correct |
37 |
Correct |
41 ms |
604 KB |
Output is correct |
38 |
Correct |
40 ms |
464 KB |
Output is correct |
39 |
Correct |
50 ms |
604 KB |
Output is correct |
40 |
Correct |
58 ms |
856 KB |
Output is correct |
41 |
Correct |
62 ms |
604 KB |
Output is correct |
42 |
Correct |
60 ms |
604 KB |
Output is correct |
43 |
Correct |
52 ms |
344 KB |
Output is correct |
44 |
Correct |
63 ms |
360 KB |
Output is correct |
45 |
Correct |
64 ms |
604 KB |
Output is correct |
46 |
Correct |
63 ms |
636 KB |
Output is correct |
47 |
Correct |
56 ms |
604 KB |
Output is correct |
48 |
Correct |
61 ms |
604 KB |
Output is correct |
49 |
Correct |
66 ms |
600 KB |
Output is correct |
50 |
Correct |
68 ms |
600 KB |
Output is correct |
51 |
Correct |
72 ms |
344 KB |
Output is correct |
52 |
Correct |
77 ms |
604 KB |
Output is correct |
53 |
Correct |
77 ms |
604 KB |
Output is correct |
54 |
Correct |
83 ms |
604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Execution timed out |
2062 ms |
12548 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
376 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
344 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
456 KB |
Output is correct |
20 |
Correct |
1 ms |
344 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
344 KB |
Output is correct |
25 |
Correct |
1 ms |
348 KB |
Output is correct |
26 |
Correct |
1 ms |
348 KB |
Output is correct |
27 |
Correct |
1 ms |
348 KB |
Output is correct |
28 |
Correct |
1 ms |
348 KB |
Output is correct |
29 |
Execution timed out |
2062 ms |
12548 KB |
Time limit exceeded |
30 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
376 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
344 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
456 KB |
Output is correct |
20 |
Correct |
1 ms |
344 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
344 KB |
Output is correct |
25 |
Correct |
1 ms |
348 KB |
Output is correct |
26 |
Correct |
1 ms |
348 KB |
Output is correct |
27 |
Correct |
1 ms |
348 KB |
Output is correct |
28 |
Correct |
1 ms |
348 KB |
Output is correct |
29 |
Correct |
32 ms |
580 KB |
Output is correct |
30 |
Correct |
78 ms |
600 KB |
Output is correct |
31 |
Correct |
79 ms |
604 KB |
Output is correct |
32 |
Correct |
69 ms |
600 KB |
Output is correct |
33 |
Correct |
59 ms |
344 KB |
Output is correct |
34 |
Correct |
81 ms |
604 KB |
Output is correct |
35 |
Correct |
87 ms |
600 KB |
Output is correct |
36 |
Correct |
26 ms |
604 KB |
Output is correct |
37 |
Correct |
41 ms |
604 KB |
Output is correct |
38 |
Correct |
40 ms |
464 KB |
Output is correct |
39 |
Correct |
50 ms |
604 KB |
Output is correct |
40 |
Correct |
58 ms |
856 KB |
Output is correct |
41 |
Correct |
62 ms |
604 KB |
Output is correct |
42 |
Correct |
60 ms |
604 KB |
Output is correct |
43 |
Correct |
52 ms |
344 KB |
Output is correct |
44 |
Correct |
63 ms |
360 KB |
Output is correct |
45 |
Correct |
64 ms |
604 KB |
Output is correct |
46 |
Correct |
63 ms |
636 KB |
Output is correct |
47 |
Correct |
56 ms |
604 KB |
Output is correct |
48 |
Correct |
61 ms |
604 KB |
Output is correct |
49 |
Correct |
66 ms |
600 KB |
Output is correct |
50 |
Correct |
68 ms |
600 KB |
Output is correct |
51 |
Correct |
72 ms |
344 KB |
Output is correct |
52 |
Correct |
77 ms |
604 KB |
Output is correct |
53 |
Correct |
77 ms |
604 KB |
Output is correct |
54 |
Correct |
83 ms |
604 KB |
Output is correct |
55 |
Execution timed out |
2060 ms |
16196 KB |
Time limit exceeded |
56 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
376 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
344 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
456 KB |
Output is correct |
20 |
Correct |
1 ms |
344 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
344 KB |
Output is correct |
25 |
Correct |
1 ms |
348 KB |
Output is correct |
26 |
Correct |
1 ms |
348 KB |
Output is correct |
27 |
Correct |
1 ms |
348 KB |
Output is correct |
28 |
Correct |
1 ms |
348 KB |
Output is correct |
29 |
Correct |
32 ms |
580 KB |
Output is correct |
30 |
Correct |
78 ms |
600 KB |
Output is correct |
31 |
Correct |
79 ms |
604 KB |
Output is correct |
32 |
Correct |
69 ms |
600 KB |
Output is correct |
33 |
Correct |
59 ms |
344 KB |
Output is correct |
34 |
Correct |
81 ms |
604 KB |
Output is correct |
35 |
Correct |
87 ms |
600 KB |
Output is correct |
36 |
Correct |
26 ms |
604 KB |
Output is correct |
37 |
Correct |
41 ms |
604 KB |
Output is correct |
38 |
Correct |
40 ms |
464 KB |
Output is correct |
39 |
Correct |
50 ms |
604 KB |
Output is correct |
40 |
Correct |
58 ms |
856 KB |
Output is correct |
41 |
Correct |
62 ms |
604 KB |
Output is correct |
42 |
Correct |
60 ms |
604 KB |
Output is correct |
43 |
Correct |
52 ms |
344 KB |
Output is correct |
44 |
Correct |
63 ms |
360 KB |
Output is correct |
45 |
Correct |
64 ms |
604 KB |
Output is correct |
46 |
Correct |
63 ms |
636 KB |
Output is correct |
47 |
Correct |
56 ms |
604 KB |
Output is correct |
48 |
Correct |
61 ms |
604 KB |
Output is correct |
49 |
Correct |
66 ms |
600 KB |
Output is correct |
50 |
Correct |
68 ms |
600 KB |
Output is correct |
51 |
Correct |
72 ms |
344 KB |
Output is correct |
52 |
Correct |
77 ms |
604 KB |
Output is correct |
53 |
Correct |
77 ms |
604 KB |
Output is correct |
54 |
Correct |
83 ms |
604 KB |
Output is correct |
55 |
Execution timed out |
2062 ms |
12548 KB |
Time limit exceeded |
56 |
Halted |
0 ms |
0 KB |
- |