Submission #530329

# Submission time Handle Problem Language Result Execution time Memory
530329 2022-02-25T05:21:14 Z fhvirus Minerals (JOI19_minerals) C++17
85 / 100
59 ms 3284 KB
#include "minerals.h"
#include <bits/stdc++.h>
using namespace std;

namespace {

bool query(int x) {
	static int lst = 0;
	int cur = Query(x);
	int ans = lst ^ cur;
	lst = cur;
	return ans;
}

void solve(vector<int> a, vector<int> b, bool in) {
	int n = a.size(), m = floor(n * .38);
	if (n == 0) return;
	if (n == 1) { Answer(a[0], b[0]); return; }
	if (in) for (int i = n - 1; i > m; --i) query(a[i]);
	else    for (int i = 0; i <= m; ++i) query(a[i]);
	random_shuffle(begin(b), end(b));
	vector<int> bl, br;
	for (const int& i: b) {
		bool go_l = (bl.size() <= m and (br.size() == n - m - 1 or !query(i)));
		(go_l ? bl : br).emplace_back(i);
	}
	solve(vector<int>(begin(a), begin(a) + m + 1), bl, true);
	solve(vector<int>(begin(a) + m + 1, end(a)), br, false);
}

}

void Solve(int N) {
	vector<int> a, b;
	for (int i = 1; i <= N * 2; ++i)
		(query(i) ? b : a).emplace_back(i);
	solve(a, b, true);
}

Compilation message

minerals.cpp: In function 'void {anonymous}::solve(std::vector<int>, std::vector<int>, bool)':
minerals.cpp:24:26: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   24 |   bool go_l = (bl.size() <= m and (br.size() == n - m - 1 or !query(i)));
      |                ~~~~~~~~~~^~~~
minerals.cpp:24:46: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   24 |   bool go_l = (bl.size() <= m and (br.size() == n - m - 1 or !query(i)));
      |                                    ~~~~~~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 1 ms 200 KB Output is correct
4 Correct 0 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 328 KB Output is correct
2 Correct 2 ms 456 KB Output is correct
3 Correct 4 ms 584 KB Output is correct
4 Correct 8 ms 872 KB Output is correct
5 Correct 15 ms 1308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 1 ms 200 KB Output is correct
4 Correct 0 ms 200 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 2 ms 456 KB Output is correct
7 Correct 4 ms 584 KB Output is correct
8 Correct 8 ms 872 KB Output is correct
9 Correct 15 ms 1308 KB Output is correct
10 Correct 2 ms 328 KB Output is correct
11 Correct 10 ms 936 KB Output is correct
12 Correct 16 ms 1324 KB Output is correct
13 Correct 16 ms 1352 KB Output is correct
14 Correct 18 ms 1316 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 1 ms 200 KB Output is correct
4 Correct 0 ms 200 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 2 ms 456 KB Output is correct
7 Correct 4 ms 584 KB Output is correct
8 Correct 8 ms 872 KB Output is correct
9 Correct 15 ms 1308 KB Output is correct
10 Correct 2 ms 328 KB Output is correct
11 Correct 10 ms 936 KB Output is correct
12 Correct 16 ms 1324 KB Output is correct
13 Correct 16 ms 1352 KB Output is correct
14 Correct 18 ms 1316 KB Output is correct
15 Correct 54 ms 3052 KB Output is correct
16 Correct 49 ms 3056 KB Output is correct
17 Correct 40 ms 2952 KB Output is correct
18 Correct 42 ms 2916 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 1 ms 200 KB Output is correct
4 Correct 0 ms 200 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 2 ms 456 KB Output is correct
7 Correct 4 ms 584 KB Output is correct
8 Correct 8 ms 872 KB Output is correct
9 Correct 15 ms 1308 KB Output is correct
10 Correct 2 ms 328 KB Output is correct
11 Correct 10 ms 936 KB Output is correct
12 Correct 16 ms 1324 KB Output is correct
13 Correct 16 ms 1352 KB Output is correct
14 Correct 18 ms 1316 KB Output is correct
15 Correct 54 ms 3052 KB Output is correct
16 Correct 49 ms 3056 KB Output is correct
17 Correct 40 ms 2952 KB Output is correct
18 Correct 42 ms 2916 KB Output is correct
19 Correct 43 ms 3028 KB Output is correct
20 Correct 59 ms 3116 KB Output is correct
21 Correct 45 ms 3040 KB Output is correct
22 Correct 42 ms 2884 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 1 ms 200 KB Output is correct
4 Correct 0 ms 200 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 2 ms 456 KB Output is correct
7 Correct 4 ms 584 KB Output is correct
8 Correct 8 ms 872 KB Output is correct
9 Correct 15 ms 1308 KB Output is correct
10 Correct 2 ms 328 KB Output is correct
11 Correct 10 ms 936 KB Output is correct
12 Correct 16 ms 1324 KB Output is correct
13 Correct 16 ms 1352 KB Output is correct
14 Correct 18 ms 1316 KB Output is correct
15 Correct 54 ms 3052 KB Output is correct
16 Correct 49 ms 3056 KB Output is correct
17 Correct 40 ms 2952 KB Output is correct
18 Correct 42 ms 2916 KB Output is correct
19 Correct 43 ms 3028 KB Output is correct
20 Correct 59 ms 3116 KB Output is correct
21 Correct 45 ms 3040 KB Output is correct
22 Correct 42 ms 2884 KB Output is correct
23 Correct 45 ms 3136 KB Output is correct
24 Correct 46 ms 3136 KB Output is correct
25 Correct 44 ms 3224 KB Output is correct
26 Correct 55 ms 2968 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 1 ms 200 KB Output is correct
4 Correct 0 ms 200 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 2 ms 456 KB Output is correct
7 Correct 4 ms 584 KB Output is correct
8 Correct 8 ms 872 KB Output is correct
9 Correct 15 ms 1308 KB Output is correct
10 Correct 2 ms 328 KB Output is correct
11 Correct 10 ms 936 KB Output is correct
12 Correct 16 ms 1324 KB Output is correct
13 Correct 16 ms 1352 KB Output is correct
14 Correct 18 ms 1316 KB Output is correct
15 Correct 54 ms 3052 KB Output is correct
16 Correct 49 ms 3056 KB Output is correct
17 Correct 40 ms 2952 KB Output is correct
18 Correct 42 ms 2916 KB Output is correct
19 Correct 43 ms 3028 KB Output is correct
20 Correct 59 ms 3116 KB Output is correct
21 Correct 45 ms 3040 KB Output is correct
22 Correct 42 ms 2884 KB Output is correct
23 Correct 45 ms 3136 KB Output is correct
24 Correct 46 ms 3136 KB Output is correct
25 Correct 44 ms 3224 KB Output is correct
26 Correct 55 ms 2968 KB Output is correct
27 Correct 51 ms 3280 KB Output is correct
28 Correct 55 ms 3280 KB Output is correct
29 Correct 44 ms 3248 KB Output is correct
30 Correct 44 ms 3020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 1 ms 200 KB Output is correct
4 Correct 0 ms 200 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 2 ms 456 KB Output is correct
7 Correct 4 ms 584 KB Output is correct
8 Correct 8 ms 872 KB Output is correct
9 Correct 15 ms 1308 KB Output is correct
10 Correct 2 ms 328 KB Output is correct
11 Correct 10 ms 936 KB Output is correct
12 Correct 16 ms 1324 KB Output is correct
13 Correct 16 ms 1352 KB Output is correct
14 Correct 18 ms 1316 KB Output is correct
15 Correct 54 ms 3052 KB Output is correct
16 Correct 49 ms 3056 KB Output is correct
17 Correct 40 ms 2952 KB Output is correct
18 Correct 42 ms 2916 KB Output is correct
19 Correct 43 ms 3028 KB Output is correct
20 Correct 59 ms 3116 KB Output is correct
21 Correct 45 ms 3040 KB Output is correct
22 Correct 42 ms 2884 KB Output is correct
23 Correct 45 ms 3136 KB Output is correct
24 Correct 46 ms 3136 KB Output is correct
25 Correct 44 ms 3224 KB Output is correct
26 Correct 55 ms 2968 KB Output is correct
27 Correct 51 ms 3280 KB Output is correct
28 Correct 55 ms 3280 KB Output is correct
29 Correct 44 ms 3248 KB Output is correct
30 Correct 44 ms 3020 KB Output is correct
31 Incorrect 48 ms 3284 KB Wrong Answer [2]
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 1 ms 200 KB Output is correct
4 Correct 0 ms 200 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 2 ms 456 KB Output is correct
7 Correct 4 ms 584 KB Output is correct
8 Correct 8 ms 872 KB Output is correct
9 Correct 15 ms 1308 KB Output is correct
10 Correct 2 ms 328 KB Output is correct
11 Correct 10 ms 936 KB Output is correct
12 Correct 16 ms 1324 KB Output is correct
13 Correct 16 ms 1352 KB Output is correct
14 Correct 18 ms 1316 KB Output is correct
15 Correct 54 ms 3052 KB Output is correct
16 Correct 49 ms 3056 KB Output is correct
17 Correct 40 ms 2952 KB Output is correct
18 Correct 42 ms 2916 KB Output is correct
19 Correct 43 ms 3028 KB Output is correct
20 Correct 59 ms 3116 KB Output is correct
21 Correct 45 ms 3040 KB Output is correct
22 Correct 42 ms 2884 KB Output is correct
23 Correct 45 ms 3136 KB Output is correct
24 Correct 46 ms 3136 KB Output is correct
25 Correct 44 ms 3224 KB Output is correct
26 Correct 55 ms 2968 KB Output is correct
27 Correct 51 ms 3280 KB Output is correct
28 Correct 55 ms 3280 KB Output is correct
29 Correct 44 ms 3248 KB Output is correct
30 Correct 44 ms 3020 KB Output is correct
31 Incorrect 48 ms 3284 KB Wrong Answer [2]
32 Halted 0 ms 0 KB -