Submission #118863

# Submission time Handle Problem Language Result Execution time Memory
118863 2019-06-20T00:07:55 Z tmwilliamlin168 Minerals (JOI19_minerals) C++14
100 / 100
71 ms 3372 KB
#include "minerals.h"
#include <bits/stdc++.h>
using namespace std;

bool qry(int x) {
	static int lst=0;
	int ans=Query(x), c=lst^ans;
	lst=ans;
	return c;
}

void solve(vector<int> l, vector<int> r, bool f) {
	int n=l.size(), m=floor(0.35*n);
	if(n<2) {
		Answer(l[0], r[0]);
		return;
	}
	if(f) {
		m=n-m-2;
		for(int i=n-1; i>m; --i)
			qry(l[i]);
	} else
		for(int i=0; i<=m; ++i)
			qry(l[i]);
	vector<int> v[2];
	random_shuffle(r.begin(), r.end());
	for(int x : r)
		v[v[0].size()>m||v[1].size()<n-m-1&&qry(x)].push_back(x);
	solve(vector<int>(l.begin(), l.begin()+m+1), v[0], 1);
	solve(vector<int>(l.begin()+m+1, l.end()), v[1], 0);
}

void Solve(int n) {
	vector<int> v[2];
	for(int i=1; i<=2*n; ++i)
		v[qry(i)].push_back(i);
	solve(v[0], v[1], 1);
}

Compilation message

minerals.cpp: In function 'void solve(std::vector<int>, std::vector<int>, bool)':
minerals.cpp:28:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   v[v[0].size()>m||v[1].size()<n-m-1&&qry(x)].push_back(x);
     ~~~~~~~~~~~^~
minerals.cpp:28:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   v[v[0].size()>m||v[1].size()<n-m-1&&qry(x)].push_back(x);
                    ~~~~~~~~~~~^~~~~~
minerals.cpp:28:37: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   v[v[0].size()>m||v[1].size()<n-m-1&&qry(x)].push_back(x);
                    ~~~~~~~~~~~~~~~~~^~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 328 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 4 ms 512 KB Output is correct
3 Correct 7 ms 640 KB Output is correct
4 Correct 12 ms 984 KB Output is correct
5 Correct 21 ms 1328 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 328 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 4 ms 512 KB Output is correct
7 Correct 7 ms 640 KB Output is correct
8 Correct 12 ms 984 KB Output is correct
9 Correct 21 ms 1328 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 14 ms 1024 KB Output is correct
12 Correct 22 ms 1364 KB Output is correct
13 Correct 21 ms 1464 KB Output is correct
14 Correct 20 ms 1328 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 328 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 4 ms 512 KB Output is correct
7 Correct 7 ms 640 KB Output is correct
8 Correct 12 ms 984 KB Output is correct
9 Correct 21 ms 1328 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 14 ms 1024 KB Output is correct
12 Correct 22 ms 1364 KB Output is correct
13 Correct 21 ms 1464 KB Output is correct
14 Correct 20 ms 1328 KB Output is correct
15 Correct 58 ms 3192 KB Output is correct
16 Correct 58 ms 2996 KB Output is correct
17 Correct 52 ms 2932 KB Output is correct
18 Correct 51 ms 2844 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 328 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 4 ms 512 KB Output is correct
7 Correct 7 ms 640 KB Output is correct
8 Correct 12 ms 984 KB Output is correct
9 Correct 21 ms 1328 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 14 ms 1024 KB Output is correct
12 Correct 22 ms 1364 KB Output is correct
13 Correct 21 ms 1464 KB Output is correct
14 Correct 20 ms 1328 KB Output is correct
15 Correct 58 ms 3192 KB Output is correct
16 Correct 58 ms 2996 KB Output is correct
17 Correct 52 ms 2932 KB Output is correct
18 Correct 51 ms 2844 KB Output is correct
19 Correct 60 ms 3060 KB Output is correct
20 Correct 58 ms 3124 KB Output is correct
21 Correct 52 ms 2932 KB Output is correct
22 Correct 53 ms 2832 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 328 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 4 ms 512 KB Output is correct
7 Correct 7 ms 640 KB Output is correct
8 Correct 12 ms 984 KB Output is correct
9 Correct 21 ms 1328 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 14 ms 1024 KB Output is correct
12 Correct 22 ms 1364 KB Output is correct
13 Correct 21 ms 1464 KB Output is correct
14 Correct 20 ms 1328 KB Output is correct
15 Correct 58 ms 3192 KB Output is correct
16 Correct 58 ms 2996 KB Output is correct
17 Correct 52 ms 2932 KB Output is correct
18 Correct 51 ms 2844 KB Output is correct
19 Correct 60 ms 3060 KB Output is correct
20 Correct 58 ms 3124 KB Output is correct
21 Correct 52 ms 2932 KB Output is correct
22 Correct 53 ms 2832 KB Output is correct
23 Correct 60 ms 3216 KB Output is correct
24 Correct 62 ms 3192 KB Output is correct
25 Correct 55 ms 3060 KB Output is correct
26 Correct 53 ms 2932 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 328 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 4 ms 512 KB Output is correct
7 Correct 7 ms 640 KB Output is correct
8 Correct 12 ms 984 KB Output is correct
9 Correct 21 ms 1328 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 14 ms 1024 KB Output is correct
12 Correct 22 ms 1364 KB Output is correct
13 Correct 21 ms 1464 KB Output is correct
14 Correct 20 ms 1328 KB Output is correct
15 Correct 58 ms 3192 KB Output is correct
16 Correct 58 ms 2996 KB Output is correct
17 Correct 52 ms 2932 KB Output is correct
18 Correct 51 ms 2844 KB Output is correct
19 Correct 60 ms 3060 KB Output is correct
20 Correct 58 ms 3124 KB Output is correct
21 Correct 52 ms 2932 KB Output is correct
22 Correct 53 ms 2832 KB Output is correct
23 Correct 60 ms 3216 KB Output is correct
24 Correct 62 ms 3192 KB Output is correct
25 Correct 55 ms 3060 KB Output is correct
26 Correct 53 ms 2932 KB Output is correct
27 Correct 66 ms 3152 KB Output is correct
28 Correct 62 ms 3156 KB Output is correct
29 Correct 57 ms 3188 KB Output is correct
30 Correct 57 ms 2872 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 328 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 4 ms 512 KB Output is correct
7 Correct 7 ms 640 KB Output is correct
8 Correct 12 ms 984 KB Output is correct
9 Correct 21 ms 1328 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 14 ms 1024 KB Output is correct
12 Correct 22 ms 1364 KB Output is correct
13 Correct 21 ms 1464 KB Output is correct
14 Correct 20 ms 1328 KB Output is correct
15 Correct 58 ms 3192 KB Output is correct
16 Correct 58 ms 2996 KB Output is correct
17 Correct 52 ms 2932 KB Output is correct
18 Correct 51 ms 2844 KB Output is correct
19 Correct 60 ms 3060 KB Output is correct
20 Correct 58 ms 3124 KB Output is correct
21 Correct 52 ms 2932 KB Output is correct
22 Correct 53 ms 2832 KB Output is correct
23 Correct 60 ms 3216 KB Output is correct
24 Correct 62 ms 3192 KB Output is correct
25 Correct 55 ms 3060 KB Output is correct
26 Correct 53 ms 2932 KB Output is correct
27 Correct 66 ms 3152 KB Output is correct
28 Correct 62 ms 3156 KB Output is correct
29 Correct 57 ms 3188 KB Output is correct
30 Correct 57 ms 2872 KB Output is correct
31 Correct 66 ms 3372 KB Output is correct
32 Correct 66 ms 3208 KB Output is correct
33 Correct 58 ms 3316 KB Output is correct
34 Correct 58 ms 3012 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 328 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 4 ms 512 KB Output is correct
7 Correct 7 ms 640 KB Output is correct
8 Correct 12 ms 984 KB Output is correct
9 Correct 21 ms 1328 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 14 ms 1024 KB Output is correct
12 Correct 22 ms 1364 KB Output is correct
13 Correct 21 ms 1464 KB Output is correct
14 Correct 20 ms 1328 KB Output is correct
15 Correct 58 ms 3192 KB Output is correct
16 Correct 58 ms 2996 KB Output is correct
17 Correct 52 ms 2932 KB Output is correct
18 Correct 51 ms 2844 KB Output is correct
19 Correct 60 ms 3060 KB Output is correct
20 Correct 58 ms 3124 KB Output is correct
21 Correct 52 ms 2932 KB Output is correct
22 Correct 53 ms 2832 KB Output is correct
23 Correct 60 ms 3216 KB Output is correct
24 Correct 62 ms 3192 KB Output is correct
25 Correct 55 ms 3060 KB Output is correct
26 Correct 53 ms 2932 KB Output is correct
27 Correct 66 ms 3152 KB Output is correct
28 Correct 62 ms 3156 KB Output is correct
29 Correct 57 ms 3188 KB Output is correct
30 Correct 57 ms 2872 KB Output is correct
31 Correct 66 ms 3372 KB Output is correct
32 Correct 66 ms 3208 KB Output is correct
33 Correct 58 ms 3316 KB Output is correct
34 Correct 58 ms 3012 KB Output is correct
35 Correct 71 ms 3280 KB Output is correct
36 Correct 69 ms 3316 KB Output is correct
37 Correct 59 ms 3204 KB Output is correct
38 Correct 59 ms 3268 KB Output is correct