Submission #925595

# Submission time Handle Problem Language Result Execution time Memory
925595 2024-02-12T05:54:45 Z vjudge1 Joker (BOI20_joker) C++17
14 / 100
2000 ms 17088 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;
}

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;
	}
	for(int i = 1; i <= q; ++i) {
		int l, r;
		cin >> l >> r;
		cout << (solve(l, r) ? "YES\n" : "NO\n");
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 6492 KB Output is correct
2 Correct 1 ms 6580 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6624 KB Output is correct
5 Correct 2 ms 6492 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 2 ms 6492 KB Output is correct
8 Correct 3 ms 6492 KB Output is correct
9 Correct 2 ms 6596 KB Output is correct
10 Correct 2 ms 6492 KB Output is correct
11 Correct 2 ms 6488 KB Output is correct
12 Correct 2 ms 6628 KB Output is correct
13 Correct 2 ms 6492 KB Output is correct
14 Correct 2 ms 6488 KB Output is correct
15 Correct 2 ms 6488 KB Output is correct
16 Correct 2 ms 6492 KB Output is correct
17 Correct 2 ms 6492 KB Output is correct
18 Correct 2 ms 6492 KB Output is correct
19 Correct 2 ms 6620 KB Output is correct
20 Correct 2 ms 6492 KB Output is correct
21 Correct 2 ms 6492 KB Output is correct
22 Correct 2 ms 6492 KB Output is correct
23 Correct 2 ms 6632 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 6612 KB Output is correct
27 Correct 2 ms 6492 KB Output is correct
28 Correct 2 ms 6616 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 6492 KB Output is correct
2 Correct 1 ms 6580 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6624 KB Output is correct
5 Correct 2 ms 6492 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 2 ms 6492 KB Output is correct
8 Correct 3 ms 6492 KB Output is correct
9 Correct 2 ms 6596 KB Output is correct
10 Correct 2 ms 6492 KB Output is correct
11 Correct 2 ms 6488 KB Output is correct
12 Correct 2 ms 6628 KB Output is correct
13 Correct 2 ms 6492 KB Output is correct
14 Correct 2 ms 6488 KB Output is correct
15 Correct 2 ms 6488 KB Output is correct
16 Correct 2 ms 6492 KB Output is correct
17 Correct 2 ms 6492 KB Output is correct
18 Correct 2 ms 6492 KB Output is correct
19 Correct 2 ms 6620 KB Output is correct
20 Correct 2 ms 6492 KB Output is correct
21 Correct 2 ms 6492 KB Output is correct
22 Correct 2 ms 6492 KB Output is correct
23 Correct 2 ms 6632 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 6612 KB Output is correct
27 Correct 2 ms 6492 KB Output is correct
28 Correct 2 ms 6616 KB Output is correct
29 Correct 52 ms 6492 KB Output is correct
30 Correct 53 ms 6700 KB Output is correct
31 Correct 39 ms 6748 KB Output is correct
32 Correct 29 ms 6488 KB Output is correct
33 Correct 20 ms 6492 KB Output is correct
34 Correct 44 ms 6728 KB Output is correct
35 Correct 65 ms 6492 KB Output is correct
36 Correct 31 ms 6488 KB Output is correct
37 Correct 63 ms 6748 KB Output is correct
38 Correct 66 ms 6740 KB Output is correct
39 Correct 46 ms 6492 KB Output is correct
40 Correct 37 ms 6628 KB Output is correct
41 Correct 25 ms 6492 KB Output is correct
42 Correct 31 ms 6492 KB Output is correct
43 Correct 29 ms 6488 KB Output is correct
44 Correct 33 ms 6488 KB Output is correct
45 Correct 23 ms 6492 KB Output is correct
46 Correct 43 ms 6488 KB Output is correct
47 Correct 28 ms 6492 KB Output is correct
48 Correct 34 ms 6636 KB Output is correct
49 Correct 42 ms 6744 KB Output is correct
50 Correct 47 ms 6492 KB Output is correct
51 Correct 34 ms 6492 KB Output is correct
52 Correct 38 ms 6492 KB Output is correct
53 Correct 48 ms 6492 KB Output is correct
54 Correct 56 ms 6492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 6492 KB Output is correct
2 Correct 1 ms 6580 KB Output is correct
3 Execution timed out 2028 ms 16364 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 6492 KB Output is correct
2 Correct 1 ms 6580 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6624 KB Output is correct
5 Correct 2 ms 6492 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 2 ms 6492 KB Output is correct
8 Correct 3 ms 6492 KB Output is correct
9 Correct 2 ms 6596 KB Output is correct
10 Correct 2 ms 6492 KB Output is correct
11 Correct 2 ms 6488 KB Output is correct
12 Correct 2 ms 6628 KB Output is correct
13 Correct 2 ms 6492 KB Output is correct
14 Correct 2 ms 6488 KB Output is correct
15 Correct 2 ms 6488 KB Output is correct
16 Correct 2 ms 6492 KB Output is correct
17 Correct 2 ms 6492 KB Output is correct
18 Correct 2 ms 6492 KB Output is correct
19 Correct 2 ms 6620 KB Output is correct
20 Correct 2 ms 6492 KB Output is correct
21 Correct 2 ms 6492 KB Output is correct
22 Correct 2 ms 6492 KB Output is correct
23 Correct 2 ms 6632 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 6612 KB Output is correct
27 Correct 2 ms 6492 KB Output is correct
28 Correct 2 ms 6616 KB Output is correct
29 Execution timed out 2028 ms 16364 KB Time limit exceeded
30 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 6492 KB Output is correct
2 Correct 1 ms 6580 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6624 KB Output is correct
5 Correct 2 ms 6492 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 2 ms 6492 KB Output is correct
8 Correct 3 ms 6492 KB Output is correct
9 Correct 2 ms 6596 KB Output is correct
10 Correct 2 ms 6492 KB Output is correct
11 Correct 2 ms 6488 KB Output is correct
12 Correct 2 ms 6628 KB Output is correct
13 Correct 2 ms 6492 KB Output is correct
14 Correct 2 ms 6488 KB Output is correct
15 Correct 2 ms 6488 KB Output is correct
16 Correct 2 ms 6492 KB Output is correct
17 Correct 2 ms 6492 KB Output is correct
18 Correct 2 ms 6492 KB Output is correct
19 Correct 2 ms 6620 KB Output is correct
20 Correct 2 ms 6492 KB Output is correct
21 Correct 2 ms 6492 KB Output is correct
22 Correct 2 ms 6492 KB Output is correct
23 Correct 2 ms 6632 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 6612 KB Output is correct
27 Correct 2 ms 6492 KB Output is correct
28 Correct 2 ms 6616 KB Output is correct
29 Correct 52 ms 6492 KB Output is correct
30 Correct 53 ms 6700 KB Output is correct
31 Correct 39 ms 6748 KB Output is correct
32 Correct 29 ms 6488 KB Output is correct
33 Correct 20 ms 6492 KB Output is correct
34 Correct 44 ms 6728 KB Output is correct
35 Correct 65 ms 6492 KB Output is correct
36 Correct 31 ms 6488 KB Output is correct
37 Correct 63 ms 6748 KB Output is correct
38 Correct 66 ms 6740 KB Output is correct
39 Correct 46 ms 6492 KB Output is correct
40 Correct 37 ms 6628 KB Output is correct
41 Correct 25 ms 6492 KB Output is correct
42 Correct 31 ms 6492 KB Output is correct
43 Correct 29 ms 6488 KB Output is correct
44 Correct 33 ms 6488 KB Output is correct
45 Correct 23 ms 6492 KB Output is correct
46 Correct 43 ms 6488 KB Output is correct
47 Correct 28 ms 6492 KB Output is correct
48 Correct 34 ms 6636 KB Output is correct
49 Correct 42 ms 6744 KB Output is correct
50 Correct 47 ms 6492 KB Output is correct
51 Correct 34 ms 6492 KB Output is correct
52 Correct 38 ms 6492 KB Output is correct
53 Correct 48 ms 6492 KB Output is correct
54 Correct 56 ms 6492 KB Output is correct
55 Execution timed out 2024 ms 17088 KB Time limit exceeded
56 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 6492 KB Output is correct
2 Correct 1 ms 6580 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6624 KB Output is correct
5 Correct 2 ms 6492 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 2 ms 6492 KB Output is correct
8 Correct 3 ms 6492 KB Output is correct
9 Correct 2 ms 6596 KB Output is correct
10 Correct 2 ms 6492 KB Output is correct
11 Correct 2 ms 6488 KB Output is correct
12 Correct 2 ms 6628 KB Output is correct
13 Correct 2 ms 6492 KB Output is correct
14 Correct 2 ms 6488 KB Output is correct
15 Correct 2 ms 6488 KB Output is correct
16 Correct 2 ms 6492 KB Output is correct
17 Correct 2 ms 6492 KB Output is correct
18 Correct 2 ms 6492 KB Output is correct
19 Correct 2 ms 6620 KB Output is correct
20 Correct 2 ms 6492 KB Output is correct
21 Correct 2 ms 6492 KB Output is correct
22 Correct 2 ms 6492 KB Output is correct
23 Correct 2 ms 6632 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 6612 KB Output is correct
27 Correct 2 ms 6492 KB Output is correct
28 Correct 2 ms 6616 KB Output is correct
29 Correct 52 ms 6492 KB Output is correct
30 Correct 53 ms 6700 KB Output is correct
31 Correct 39 ms 6748 KB Output is correct
32 Correct 29 ms 6488 KB Output is correct
33 Correct 20 ms 6492 KB Output is correct
34 Correct 44 ms 6728 KB Output is correct
35 Correct 65 ms 6492 KB Output is correct
36 Correct 31 ms 6488 KB Output is correct
37 Correct 63 ms 6748 KB Output is correct
38 Correct 66 ms 6740 KB Output is correct
39 Correct 46 ms 6492 KB Output is correct
40 Correct 37 ms 6628 KB Output is correct
41 Correct 25 ms 6492 KB Output is correct
42 Correct 31 ms 6492 KB Output is correct
43 Correct 29 ms 6488 KB Output is correct
44 Correct 33 ms 6488 KB Output is correct
45 Correct 23 ms 6492 KB Output is correct
46 Correct 43 ms 6488 KB Output is correct
47 Correct 28 ms 6492 KB Output is correct
48 Correct 34 ms 6636 KB Output is correct
49 Correct 42 ms 6744 KB Output is correct
50 Correct 47 ms 6492 KB Output is correct
51 Correct 34 ms 6492 KB Output is correct
52 Correct 38 ms 6492 KB Output is correct
53 Correct 48 ms 6492 KB Output is correct
54 Correct 56 ms 6492 KB Output is correct
55 Execution timed out 2028 ms 16364 KB Time limit exceeded
56 Halted 0 ms 0 KB -