Submission #925995

# Submission time Handle Problem Language Result Execution time Memory
925995 2024-02-12T12:36:35 Z vjudge1 Joker (BOI20_joker) C++17
39 / 100
2000 ms 49276 KB
#pragma GCC optimize("O3", "unroll-loops") // "Ofast" 	
#pragma GCC target("avx2", "bmi", "bmi2", "lzcnt", "popcnt") 

#include <bits/stdc++.h>

//#define int long long
#define vt vector
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define f first
#define s second
#define dbg(x) cerr << #x << " = " << x << '\n'
#define bit(x, i) ((x) >> (i) & 1)

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;

const int N = 1e6 + 5, mod = 1e9 + 7;
const ll inf = 1e18 + 7;
const ld eps = 1e-6;

ll add (ll a, ll b) {
	a += b;
	if (a < 0) a += mod;
	if (a >= mod) a -= mod;
	return a;
}

ll mul (ll a, ll b) {
	a *= b;
	if (a >= mod) a %= mod;
	return a;
}

int n, m, Q;
vt<int> g[N];
int used[N];

struct Data {
	int x, y, id;
}edge[N];

string get (int l, int r) {
    for (int i = 1; i <= n; i++) used[i] = 0, g[i].clear();
	for (int i = 1; i <= m; i++) {
		int x = edge[i].x, y = edge[i].y, id = edge[i].id;
		if (!(id >= l && id <= r)) g[x].pb(y), g[y].pb(x);
	}
	bool ok = 1;
	queue<int> q;
	for (int i = 1; i <= n; i++) {
		if (!used[i]) {
			q.push(i);
			used[i] = 1;
			while (!q.empty()) {
				int v = q.front();
				q.pop();
				for (auto to: g[v]) {
					if (!used[to]) {
						used[to] = 3 - used[v];
						q.push(to);
					}
					else if (used[to] == used[v]) ok = 0;
				}
			}
		}
	}
	return (!ok ? "YES" : "NO");
}

void solve () {
	cin >> n >> m >> Q;
	for (int i = 1; i <= m; i++) {
		int x, y;
		cin >> x >> y;
		edge[i] = {x, y, i};
	}
	string s[m + 2];
	int L = 1, R = m, pos = -1;
	while (L <= R) {
		int mid = L + R >> 1;
		if (get(1, mid - 1) == "YES") pos = mid, L = mid + 1;
		else R = mid - 1;
	}
	fill(s, s + m + 2, "NO");
	for (int i = 1; i <= pos; i++) s[i] = "YES";
	while (Q--) {
		int l, r;
		cin >> l >> r;
		if (l == 1) cout << s[r + 1] << '\n';
		else cout << get(l, r) << '\n';
	}
	cout << '\n';
}

bool testcases = 0;

signed main() {
#ifdef AMIR
	freopen(".in", "r", stdin);
	freopen(".out", "w", stdout);
#endif
	cin.tie(0) -> sync_with_stdio(0);
	int test = 1;
	if (testcases) cin >> test;
	for (int cs = 1; cs <= test; cs++) {
		solve();
	}
}

Compilation message

Joker.cpp: In function 'void solve()':
Joker.cpp:84:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   84 |   int mid = L + R >> 1;
      |             ~~^~~
# Verdict Execution time Memory Grader output
1 Correct 8 ms 26968 KB Output is correct
2 Correct 7 ms 26972 KB Output is correct
3 Correct 8 ms 26972 KB Output is correct
4 Correct 8 ms 27084 KB Output is correct
5 Correct 8 ms 26972 KB Output is correct
6 Correct 7 ms 27040 KB Output is correct
7 Correct 8 ms 26972 KB Output is correct
8 Correct 8 ms 26972 KB Output is correct
9 Correct 8 ms 27052 KB Output is correct
10 Correct 8 ms 26968 KB Output is correct
11 Correct 9 ms 27128 KB Output is correct
12 Correct 8 ms 26884 KB Output is correct
13 Correct 8 ms 26972 KB Output is correct
14 Correct 9 ms 27224 KB Output is correct
15 Correct 9 ms 26972 KB Output is correct
16 Correct 8 ms 26972 KB Output is correct
17 Correct 9 ms 26972 KB Output is correct
18 Correct 8 ms 26972 KB Output is correct
19 Correct 8 ms 26968 KB Output is correct
20 Correct 8 ms 26972 KB Output is correct
21 Correct 8 ms 26972 KB Output is correct
22 Correct 10 ms 27016 KB Output is correct
23 Correct 9 ms 27124 KB Output is correct
24 Correct 8 ms 26968 KB Output is correct
25 Correct 8 ms 26968 KB Output is correct
26 Correct 8 ms 27168 KB Output is correct
27 Correct 8 ms 26972 KB Output is correct
28 Correct 8 ms 26972 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 26968 KB Output is correct
2 Correct 7 ms 26972 KB Output is correct
3 Correct 8 ms 26972 KB Output is correct
4 Correct 8 ms 27084 KB Output is correct
5 Correct 8 ms 26972 KB Output is correct
6 Correct 7 ms 27040 KB Output is correct
7 Correct 8 ms 26972 KB Output is correct
8 Correct 8 ms 26972 KB Output is correct
9 Correct 8 ms 27052 KB Output is correct
10 Correct 8 ms 26968 KB Output is correct
11 Correct 9 ms 27128 KB Output is correct
12 Correct 8 ms 26884 KB Output is correct
13 Correct 8 ms 26972 KB Output is correct
14 Correct 9 ms 27224 KB Output is correct
15 Correct 9 ms 26972 KB Output is correct
16 Correct 8 ms 26972 KB Output is correct
17 Correct 9 ms 26972 KB Output is correct
18 Correct 8 ms 26972 KB Output is correct
19 Correct 8 ms 26968 KB Output is correct
20 Correct 8 ms 26972 KB Output is correct
21 Correct 8 ms 26972 KB Output is correct
22 Correct 10 ms 27016 KB Output is correct
23 Correct 9 ms 27124 KB Output is correct
24 Correct 8 ms 26968 KB Output is correct
25 Correct 8 ms 26968 KB Output is correct
26 Correct 8 ms 27168 KB Output is correct
27 Correct 8 ms 26972 KB Output is correct
28 Correct 8 ms 26972 KB Output is correct
29 Correct 57 ms 26972 KB Output is correct
30 Correct 94 ms 27256 KB Output is correct
31 Correct 87 ms 27272 KB Output is correct
32 Correct 65 ms 27224 KB Output is correct
33 Correct 47 ms 27224 KB Output is correct
34 Correct 93 ms 27156 KB Output is correct
35 Correct 97 ms 27228 KB Output is correct
36 Correct 37 ms 27224 KB Output is correct
37 Correct 73 ms 27224 KB Output is correct
38 Correct 58 ms 27228 KB Output is correct
39 Correct 71 ms 27228 KB Output is correct
40 Correct 57 ms 27228 KB Output is correct
41 Correct 57 ms 27280 KB Output is correct
42 Correct 57 ms 27228 KB Output is correct
43 Correct 40 ms 27224 KB Output is correct
44 Correct 52 ms 27280 KB Output is correct
45 Correct 66 ms 27228 KB Output is correct
46 Correct 75 ms 27272 KB Output is correct
47 Correct 51 ms 27380 KB Output is correct
48 Correct 59 ms 27224 KB Output is correct
49 Correct 71 ms 27264 KB Output is correct
50 Correct 91 ms 27228 KB Output is correct
51 Correct 55 ms 27228 KB Output is correct
52 Correct 63 ms 27228 KB Output is correct
53 Correct 78 ms 27224 KB Output is correct
54 Correct 99 ms 27272 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 26968 KB Output is correct
2 Correct 7 ms 26972 KB Output is correct
3 Correct 122 ms 43592 KB Output is correct
4 Correct 213 ms 48408 KB Output is correct
5 Correct 122 ms 43856 KB Output is correct
6 Correct 124 ms 43388 KB Output is correct
7 Correct 116 ms 43604 KB Output is correct
8 Correct 120 ms 43872 KB Output is correct
9 Correct 154 ms 44504 KB Output is correct
10 Correct 206 ms 48976 KB Output is correct
11 Correct 150 ms 45712 KB Output is correct
12 Correct 199 ms 47076 KB Output is correct
13 Correct 103 ms 43604 KB Output is correct
14 Correct 132 ms 44436 KB Output is correct
15 Correct 200 ms 46412 KB Output is correct
16 Correct 219 ms 49276 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 26968 KB Output is correct
2 Correct 7 ms 26972 KB Output is correct
3 Correct 8 ms 26972 KB Output is correct
4 Correct 8 ms 27084 KB Output is correct
5 Correct 8 ms 26972 KB Output is correct
6 Correct 7 ms 27040 KB Output is correct
7 Correct 8 ms 26972 KB Output is correct
8 Correct 8 ms 26972 KB Output is correct
9 Correct 8 ms 27052 KB Output is correct
10 Correct 8 ms 26968 KB Output is correct
11 Correct 9 ms 27128 KB Output is correct
12 Correct 8 ms 26884 KB Output is correct
13 Correct 8 ms 26972 KB Output is correct
14 Correct 9 ms 27224 KB Output is correct
15 Correct 9 ms 26972 KB Output is correct
16 Correct 8 ms 26972 KB Output is correct
17 Correct 9 ms 26972 KB Output is correct
18 Correct 8 ms 26972 KB Output is correct
19 Correct 8 ms 26968 KB Output is correct
20 Correct 8 ms 26972 KB Output is correct
21 Correct 8 ms 26972 KB Output is correct
22 Correct 10 ms 27016 KB Output is correct
23 Correct 9 ms 27124 KB Output is correct
24 Correct 8 ms 26968 KB Output is correct
25 Correct 8 ms 26968 KB Output is correct
26 Correct 8 ms 27168 KB Output is correct
27 Correct 8 ms 26972 KB Output is correct
28 Correct 8 ms 26972 KB Output is correct
29 Correct 122 ms 43592 KB Output is correct
30 Correct 213 ms 48408 KB Output is correct
31 Correct 122 ms 43856 KB Output is correct
32 Correct 124 ms 43388 KB Output is correct
33 Correct 116 ms 43604 KB Output is correct
34 Correct 120 ms 43872 KB Output is correct
35 Correct 154 ms 44504 KB Output is correct
36 Correct 206 ms 48976 KB Output is correct
37 Correct 150 ms 45712 KB Output is correct
38 Correct 199 ms 47076 KB Output is correct
39 Correct 103 ms 43604 KB Output is correct
40 Correct 132 ms 44436 KB Output is correct
41 Correct 200 ms 46412 KB Output is correct
42 Correct 219 ms 49276 KB Output is correct
43 Execution timed out 2076 ms 43300 KB Time limit exceeded
44 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 26968 KB Output is correct
2 Correct 7 ms 26972 KB Output is correct
3 Correct 8 ms 26972 KB Output is correct
4 Correct 8 ms 27084 KB Output is correct
5 Correct 8 ms 26972 KB Output is correct
6 Correct 7 ms 27040 KB Output is correct
7 Correct 8 ms 26972 KB Output is correct
8 Correct 8 ms 26972 KB Output is correct
9 Correct 8 ms 27052 KB Output is correct
10 Correct 8 ms 26968 KB Output is correct
11 Correct 9 ms 27128 KB Output is correct
12 Correct 8 ms 26884 KB Output is correct
13 Correct 8 ms 26972 KB Output is correct
14 Correct 9 ms 27224 KB Output is correct
15 Correct 9 ms 26972 KB Output is correct
16 Correct 8 ms 26972 KB Output is correct
17 Correct 9 ms 26972 KB Output is correct
18 Correct 8 ms 26972 KB Output is correct
19 Correct 8 ms 26968 KB Output is correct
20 Correct 8 ms 26972 KB Output is correct
21 Correct 8 ms 26972 KB Output is correct
22 Correct 10 ms 27016 KB Output is correct
23 Correct 9 ms 27124 KB Output is correct
24 Correct 8 ms 26968 KB Output is correct
25 Correct 8 ms 26968 KB Output is correct
26 Correct 8 ms 27168 KB Output is correct
27 Correct 8 ms 26972 KB Output is correct
28 Correct 8 ms 26972 KB Output is correct
29 Correct 57 ms 26972 KB Output is correct
30 Correct 94 ms 27256 KB Output is correct
31 Correct 87 ms 27272 KB Output is correct
32 Correct 65 ms 27224 KB Output is correct
33 Correct 47 ms 27224 KB Output is correct
34 Correct 93 ms 27156 KB Output is correct
35 Correct 97 ms 27228 KB Output is correct
36 Correct 37 ms 27224 KB Output is correct
37 Correct 73 ms 27224 KB Output is correct
38 Correct 58 ms 27228 KB Output is correct
39 Correct 71 ms 27228 KB Output is correct
40 Correct 57 ms 27228 KB Output is correct
41 Correct 57 ms 27280 KB Output is correct
42 Correct 57 ms 27228 KB Output is correct
43 Correct 40 ms 27224 KB Output is correct
44 Correct 52 ms 27280 KB Output is correct
45 Correct 66 ms 27228 KB Output is correct
46 Correct 75 ms 27272 KB Output is correct
47 Correct 51 ms 27380 KB Output is correct
48 Correct 59 ms 27224 KB Output is correct
49 Correct 71 ms 27264 KB Output is correct
50 Correct 91 ms 27228 KB Output is correct
51 Correct 55 ms 27228 KB Output is correct
52 Correct 63 ms 27228 KB Output is correct
53 Correct 78 ms 27224 KB Output is correct
54 Correct 99 ms 27272 KB Output is correct
55 Execution timed out 2032 ms 42548 KB Time limit exceeded
56 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 26968 KB Output is correct
2 Correct 7 ms 26972 KB Output is correct
3 Correct 8 ms 26972 KB Output is correct
4 Correct 8 ms 27084 KB Output is correct
5 Correct 8 ms 26972 KB Output is correct
6 Correct 7 ms 27040 KB Output is correct
7 Correct 8 ms 26972 KB Output is correct
8 Correct 8 ms 26972 KB Output is correct
9 Correct 8 ms 27052 KB Output is correct
10 Correct 8 ms 26968 KB Output is correct
11 Correct 9 ms 27128 KB Output is correct
12 Correct 8 ms 26884 KB Output is correct
13 Correct 8 ms 26972 KB Output is correct
14 Correct 9 ms 27224 KB Output is correct
15 Correct 9 ms 26972 KB Output is correct
16 Correct 8 ms 26972 KB Output is correct
17 Correct 9 ms 26972 KB Output is correct
18 Correct 8 ms 26972 KB Output is correct
19 Correct 8 ms 26968 KB Output is correct
20 Correct 8 ms 26972 KB Output is correct
21 Correct 8 ms 26972 KB Output is correct
22 Correct 10 ms 27016 KB Output is correct
23 Correct 9 ms 27124 KB Output is correct
24 Correct 8 ms 26968 KB Output is correct
25 Correct 8 ms 26968 KB Output is correct
26 Correct 8 ms 27168 KB Output is correct
27 Correct 8 ms 26972 KB Output is correct
28 Correct 8 ms 26972 KB Output is correct
29 Correct 57 ms 26972 KB Output is correct
30 Correct 94 ms 27256 KB Output is correct
31 Correct 87 ms 27272 KB Output is correct
32 Correct 65 ms 27224 KB Output is correct
33 Correct 47 ms 27224 KB Output is correct
34 Correct 93 ms 27156 KB Output is correct
35 Correct 97 ms 27228 KB Output is correct
36 Correct 37 ms 27224 KB Output is correct
37 Correct 73 ms 27224 KB Output is correct
38 Correct 58 ms 27228 KB Output is correct
39 Correct 71 ms 27228 KB Output is correct
40 Correct 57 ms 27228 KB Output is correct
41 Correct 57 ms 27280 KB Output is correct
42 Correct 57 ms 27228 KB Output is correct
43 Correct 40 ms 27224 KB Output is correct
44 Correct 52 ms 27280 KB Output is correct
45 Correct 66 ms 27228 KB Output is correct
46 Correct 75 ms 27272 KB Output is correct
47 Correct 51 ms 27380 KB Output is correct
48 Correct 59 ms 27224 KB Output is correct
49 Correct 71 ms 27264 KB Output is correct
50 Correct 91 ms 27228 KB Output is correct
51 Correct 55 ms 27228 KB Output is correct
52 Correct 63 ms 27228 KB Output is correct
53 Correct 78 ms 27224 KB Output is correct
54 Correct 99 ms 27272 KB Output is correct
55 Correct 122 ms 43592 KB Output is correct
56 Correct 213 ms 48408 KB Output is correct
57 Correct 122 ms 43856 KB Output is correct
58 Correct 124 ms 43388 KB Output is correct
59 Correct 116 ms 43604 KB Output is correct
60 Correct 120 ms 43872 KB Output is correct
61 Correct 154 ms 44504 KB Output is correct
62 Correct 206 ms 48976 KB Output is correct
63 Correct 150 ms 45712 KB Output is correct
64 Correct 199 ms 47076 KB Output is correct
65 Correct 103 ms 43604 KB Output is correct
66 Correct 132 ms 44436 KB Output is correct
67 Correct 200 ms 46412 KB Output is correct
68 Correct 219 ms 49276 KB Output is correct
69 Execution timed out 2076 ms 43300 KB Time limit exceeded
70 Halted 0 ms 0 KB -