Submission #925603

# Submission time Handle Problem Language Result Execution time Memory
925603 2024-02-12T06:11:42 Z vjudge1 Joker (BOI20_joker) C++17
39 / 100
2000 ms 19540 KB
#include<iostream>
#include<cassert>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<stack>
#include<set>
#include<queue>
#include<map>

using namespace std;

const int N = (int)2e5 + 7;
const int inf = (int)1e9 + 7;
const int MOD = (int)998244353;
const long long INF = (long long)1e18 + 7; 

int mult(int x, int y) {
	return 1ll*x*y%MOD;
}

int sum(int x, int y) {
	x += y;
	if(x >= MOD) {
		x -= MOD;
	}
	return x;
}

int sub(int x, int y) {
	x -= y;
	if(x < 0) {
		x += MOD;
	}
	return x;
}

int n, m, q;
pair<int, int> e[N];
vector<int> g[N];
int used[N];

bool dfs(int v) {
	for(auto to : g[v]) {
		if(!used[to]) {
			used[to] = 3-used[v];
			if(dfs(to)) {
				return 1;
			}
		} else if(used[to] == used[v]) {
			return 1;
		}
	}
	return 0;
}

bool solve(int l, int r) {
	for(int i = 1; i <= n; ++i) {
		g[i].clear();
		used[i] = 0;
	}
	for(int i = 1; i <= m; ++i) {
		if(i >= l && i <= r) {
			continue;
		}
		int u = e[i].first;
		int v = e[i].second;
		g[u].push_back(v);
		g[v].push_back(u);
	}             
	for(int i = 1; i <= n; ++i) {
		if(!used[i]) {
			used[i] = 1;
			if(dfs(i)) {
				return 1;
			}			
		}
	}
	return 0;
}

bool ans[N];

void init() {
	int l = 1, r = m, id = 0;
	while(l <= r) {
		int mid = (l+r)>>1;
   		if(solve(1, mid-1)) {
   			id = mid;
			l = mid+1;   			
   		} else {
   			r = mid-1;
   		}
	}
	for(int i = 1; i <= id; ++i) {
		ans[i] = 1;
	}
}

int main() {	
	ios_base::sync_with_stdio(NULL);
	cin.tie(0);
	cin >> n >> m >> q;
	for(int i = 1; i <= m; ++i) {
		cin >> e[i].first >> e[i].second;
	}       
	init();
	for(int i = 1; i <= q; ++i) {
		int l, r;
		cin >> l >> r;
		if(l == 1) {
			cout << (ans[r+1] ? "YES\n" : "NO\n");
			continue;
		}
		cout << (solve(l, r) ? "YES\n" : "NO\n");
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6492 KB Output is correct
2 Correct 2 ms 6492 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 1 ms 6492 KB Output is correct
6 Correct 2 ms 6492 KB Output is correct
7 Correct 2 ms 6492 KB Output is correct
8 Correct 2 ms 6492 KB Output is correct
9 Correct 2 ms 6492 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
11 Correct 2 ms 6492 KB Output is correct
12 Correct 2 ms 6492 KB Output is correct
13 Correct 2 ms 6492 KB Output is correct
14 Correct 2 ms 6492 KB Output is correct
15 Correct 2 ms 6492 KB Output is correct
16 Correct 2 ms 6492 KB Output is correct
17 Correct 2 ms 6488 KB Output is correct
18 Correct 2 ms 6492 KB Output is correct
19 Correct 2 ms 6492 KB Output is correct
20 Correct 2 ms 6492 KB Output is correct
21 Correct 1 ms 6492 KB Output is correct
22 Correct 2 ms 6492 KB Output is correct
23 Correct 2 ms 6492 KB Output is correct
24 Correct 2 ms 6492 KB Output is correct
25 Correct 2 ms 6492 KB Output is correct
26 Correct 2 ms 6492 KB Output is correct
27 Correct 2 ms 6492 KB Output is correct
28 Correct 2 ms 6584 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6492 KB Output is correct
2 Correct 2 ms 6492 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 1 ms 6492 KB Output is correct
6 Correct 2 ms 6492 KB Output is correct
7 Correct 2 ms 6492 KB Output is correct
8 Correct 2 ms 6492 KB Output is correct
9 Correct 2 ms 6492 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
11 Correct 2 ms 6492 KB Output is correct
12 Correct 2 ms 6492 KB Output is correct
13 Correct 2 ms 6492 KB Output is correct
14 Correct 2 ms 6492 KB Output is correct
15 Correct 2 ms 6492 KB Output is correct
16 Correct 2 ms 6492 KB Output is correct
17 Correct 2 ms 6488 KB Output is correct
18 Correct 2 ms 6492 KB Output is correct
19 Correct 2 ms 6492 KB Output is correct
20 Correct 2 ms 6492 KB Output is correct
21 Correct 1 ms 6492 KB Output is correct
22 Correct 2 ms 6492 KB Output is correct
23 Correct 2 ms 6492 KB Output is correct
24 Correct 2 ms 6492 KB Output is correct
25 Correct 2 ms 6492 KB Output is correct
26 Correct 2 ms 6492 KB Output is correct
27 Correct 2 ms 6492 KB Output is correct
28 Correct 2 ms 6584 KB Output is correct
29 Correct 49 ms 6492 KB Output is correct
30 Correct 49 ms 6492 KB Output is correct
31 Correct 37 ms 6680 KB Output is correct
32 Correct 27 ms 6672 KB Output is correct
33 Correct 15 ms 6492 KB Output is correct
34 Correct 41 ms 6492 KB Output is correct
35 Correct 51 ms 6488 KB Output is correct
36 Correct 24 ms 6488 KB Output is correct
37 Correct 58 ms 6704 KB Output is correct
38 Correct 51 ms 6488 KB Output is correct
39 Correct 45 ms 6744 KB Output is correct
40 Correct 25 ms 6488 KB Output is correct
41 Correct 23 ms 6488 KB Output is correct
42 Correct 25 ms 6492 KB Output is correct
43 Correct 23 ms 6924 KB Output is correct
44 Correct 20 ms 6492 KB Output is correct
45 Correct 23 ms 6492 KB Output is correct
46 Correct 34 ms 6488 KB Output is correct
47 Correct 28 ms 6488 KB Output is correct
48 Correct 26 ms 6492 KB Output is correct
49 Correct 36 ms 6492 KB Output is correct
50 Correct 45 ms 6492 KB Output is correct
51 Correct 24 ms 6496 KB Output is correct
52 Correct 28 ms 6656 KB Output is correct
53 Correct 35 ms 6492 KB Output is correct
54 Correct 49 ms 6492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6492 KB Output is correct
2 Correct 2 ms 6492 KB Output is correct
3 Correct 97 ms 15972 KB Output is correct
4 Correct 173 ms 19540 KB Output is correct
5 Correct 82 ms 15780 KB Output is correct
6 Correct 105 ms 15996 KB Output is correct
7 Correct 109 ms 15444 KB Output is correct
8 Correct 111 ms 15372 KB Output is correct
9 Correct 128 ms 15700 KB Output is correct
10 Correct 131 ms 16976 KB Output is correct
11 Correct 86 ms 15696 KB Output is correct
12 Correct 108 ms 16932 KB Output is correct
13 Correct 83 ms 14268 KB Output is correct
14 Correct 112 ms 15696 KB Output is correct
15 Correct 112 ms 16980 KB Output is correct
16 Correct 124 ms 17380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6492 KB Output is correct
2 Correct 2 ms 6492 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 1 ms 6492 KB Output is correct
6 Correct 2 ms 6492 KB Output is correct
7 Correct 2 ms 6492 KB Output is correct
8 Correct 2 ms 6492 KB Output is correct
9 Correct 2 ms 6492 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
11 Correct 2 ms 6492 KB Output is correct
12 Correct 2 ms 6492 KB Output is correct
13 Correct 2 ms 6492 KB Output is correct
14 Correct 2 ms 6492 KB Output is correct
15 Correct 2 ms 6492 KB Output is correct
16 Correct 2 ms 6492 KB Output is correct
17 Correct 2 ms 6488 KB Output is correct
18 Correct 2 ms 6492 KB Output is correct
19 Correct 2 ms 6492 KB Output is correct
20 Correct 2 ms 6492 KB Output is correct
21 Correct 1 ms 6492 KB Output is correct
22 Correct 2 ms 6492 KB Output is correct
23 Correct 2 ms 6492 KB Output is correct
24 Correct 2 ms 6492 KB Output is correct
25 Correct 2 ms 6492 KB Output is correct
26 Correct 2 ms 6492 KB Output is correct
27 Correct 2 ms 6492 KB Output is correct
28 Correct 2 ms 6584 KB Output is correct
29 Correct 97 ms 15972 KB Output is correct
30 Correct 173 ms 19540 KB Output is correct
31 Correct 82 ms 15780 KB Output is correct
32 Correct 105 ms 15996 KB Output is correct
33 Correct 109 ms 15444 KB Output is correct
34 Correct 111 ms 15372 KB Output is correct
35 Correct 128 ms 15700 KB Output is correct
36 Correct 131 ms 16976 KB Output is correct
37 Correct 86 ms 15696 KB Output is correct
38 Correct 108 ms 16932 KB Output is correct
39 Correct 83 ms 14268 KB Output is correct
40 Correct 112 ms 15696 KB Output is correct
41 Correct 112 ms 16980 KB Output is correct
42 Correct 124 ms 17380 KB Output is correct
43 Execution timed out 2050 ms 17728 KB Time limit exceeded
44 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6492 KB Output is correct
2 Correct 2 ms 6492 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 1 ms 6492 KB Output is correct
6 Correct 2 ms 6492 KB Output is correct
7 Correct 2 ms 6492 KB Output is correct
8 Correct 2 ms 6492 KB Output is correct
9 Correct 2 ms 6492 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
11 Correct 2 ms 6492 KB Output is correct
12 Correct 2 ms 6492 KB Output is correct
13 Correct 2 ms 6492 KB Output is correct
14 Correct 2 ms 6492 KB Output is correct
15 Correct 2 ms 6492 KB Output is correct
16 Correct 2 ms 6492 KB Output is correct
17 Correct 2 ms 6488 KB Output is correct
18 Correct 2 ms 6492 KB Output is correct
19 Correct 2 ms 6492 KB Output is correct
20 Correct 2 ms 6492 KB Output is correct
21 Correct 1 ms 6492 KB Output is correct
22 Correct 2 ms 6492 KB Output is correct
23 Correct 2 ms 6492 KB Output is correct
24 Correct 2 ms 6492 KB Output is correct
25 Correct 2 ms 6492 KB Output is correct
26 Correct 2 ms 6492 KB Output is correct
27 Correct 2 ms 6492 KB Output is correct
28 Correct 2 ms 6584 KB Output is correct
29 Correct 49 ms 6492 KB Output is correct
30 Correct 49 ms 6492 KB Output is correct
31 Correct 37 ms 6680 KB Output is correct
32 Correct 27 ms 6672 KB Output is correct
33 Correct 15 ms 6492 KB Output is correct
34 Correct 41 ms 6492 KB Output is correct
35 Correct 51 ms 6488 KB Output is correct
36 Correct 24 ms 6488 KB Output is correct
37 Correct 58 ms 6704 KB Output is correct
38 Correct 51 ms 6488 KB Output is correct
39 Correct 45 ms 6744 KB Output is correct
40 Correct 25 ms 6488 KB Output is correct
41 Correct 23 ms 6488 KB Output is correct
42 Correct 25 ms 6492 KB Output is correct
43 Correct 23 ms 6924 KB Output is correct
44 Correct 20 ms 6492 KB Output is correct
45 Correct 23 ms 6492 KB Output is correct
46 Correct 34 ms 6488 KB Output is correct
47 Correct 28 ms 6488 KB Output is correct
48 Correct 26 ms 6492 KB Output is correct
49 Correct 36 ms 6492 KB Output is correct
50 Correct 45 ms 6492 KB Output is correct
51 Correct 24 ms 6496 KB Output is correct
52 Correct 28 ms 6656 KB Output is correct
53 Correct 35 ms 6492 KB Output is correct
54 Correct 49 ms 6492 KB Output is correct
55 Execution timed out 2045 ms 15236 KB Time limit exceeded
56 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6492 KB Output is correct
2 Correct 2 ms 6492 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 1 ms 6492 KB Output is correct
6 Correct 2 ms 6492 KB Output is correct
7 Correct 2 ms 6492 KB Output is correct
8 Correct 2 ms 6492 KB Output is correct
9 Correct 2 ms 6492 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
11 Correct 2 ms 6492 KB Output is correct
12 Correct 2 ms 6492 KB Output is correct
13 Correct 2 ms 6492 KB Output is correct
14 Correct 2 ms 6492 KB Output is correct
15 Correct 2 ms 6492 KB Output is correct
16 Correct 2 ms 6492 KB Output is correct
17 Correct 2 ms 6488 KB Output is correct
18 Correct 2 ms 6492 KB Output is correct
19 Correct 2 ms 6492 KB Output is correct
20 Correct 2 ms 6492 KB Output is correct
21 Correct 1 ms 6492 KB Output is correct
22 Correct 2 ms 6492 KB Output is correct
23 Correct 2 ms 6492 KB Output is correct
24 Correct 2 ms 6492 KB Output is correct
25 Correct 2 ms 6492 KB Output is correct
26 Correct 2 ms 6492 KB Output is correct
27 Correct 2 ms 6492 KB Output is correct
28 Correct 2 ms 6584 KB Output is correct
29 Correct 49 ms 6492 KB Output is correct
30 Correct 49 ms 6492 KB Output is correct
31 Correct 37 ms 6680 KB Output is correct
32 Correct 27 ms 6672 KB Output is correct
33 Correct 15 ms 6492 KB Output is correct
34 Correct 41 ms 6492 KB Output is correct
35 Correct 51 ms 6488 KB Output is correct
36 Correct 24 ms 6488 KB Output is correct
37 Correct 58 ms 6704 KB Output is correct
38 Correct 51 ms 6488 KB Output is correct
39 Correct 45 ms 6744 KB Output is correct
40 Correct 25 ms 6488 KB Output is correct
41 Correct 23 ms 6488 KB Output is correct
42 Correct 25 ms 6492 KB Output is correct
43 Correct 23 ms 6924 KB Output is correct
44 Correct 20 ms 6492 KB Output is correct
45 Correct 23 ms 6492 KB Output is correct
46 Correct 34 ms 6488 KB Output is correct
47 Correct 28 ms 6488 KB Output is correct
48 Correct 26 ms 6492 KB Output is correct
49 Correct 36 ms 6492 KB Output is correct
50 Correct 45 ms 6492 KB Output is correct
51 Correct 24 ms 6496 KB Output is correct
52 Correct 28 ms 6656 KB Output is correct
53 Correct 35 ms 6492 KB Output is correct
54 Correct 49 ms 6492 KB Output is correct
55 Correct 97 ms 15972 KB Output is correct
56 Correct 173 ms 19540 KB Output is correct
57 Correct 82 ms 15780 KB Output is correct
58 Correct 105 ms 15996 KB Output is correct
59 Correct 109 ms 15444 KB Output is correct
60 Correct 111 ms 15372 KB Output is correct
61 Correct 128 ms 15700 KB Output is correct
62 Correct 131 ms 16976 KB Output is correct
63 Correct 86 ms 15696 KB Output is correct
64 Correct 108 ms 16932 KB Output is correct
65 Correct 83 ms 14268 KB Output is correct
66 Correct 112 ms 15696 KB Output is correct
67 Correct 112 ms 16980 KB Output is correct
68 Correct 124 ms 17380 KB Output is correct
69 Execution timed out 2050 ms 17728 KB Time limit exceeded
70 Halted 0 ms 0 KB -