답안 #185398

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
185398 2020-01-11T12:44:49 Z koosaga(C15-#575) Minerals (JOI19_minerals) C++17
100 / 100
105 ms 4568 KB
#include "minerals.h"
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3000005;

void dnc(vector<int> l, vector<int> r, int toggle){
	if(l.size() == 1){
		Answer(l[0], r[0]);
		return;
	}
	int m = 0.35 * l.size(), last = 0;
	vector<int> ll, lr, rr, rl;
	m = max(m, 1); m = min(m, (int)l.size() - 1);
	for(int i=0; i<m; i++){
		last = Query(l[i]);
		ll.push_back(l[i]);
	}
	for(int i=m; i<l.size(); i++){
		lr.push_back(l[i]);
	}
	for(int i=0; i<r.size(); i++){
		if(rl.size() == ll.size()){
			rr.push_back(r[i]);
			continue;
		}
		if(rr.size() == lr.size()){
			rl.push_back(r[i]);
			continue;
		}
		int nxt = Query(r[i]);
		if(toggle ^ (nxt != last)){
			rr.push_back(r[i]);
		}
		else rl.push_back(r[i]);
		last = nxt;
	}
	dnc(ll, rl, toggle ^ 1);
	dnc(lr, rr, toggle);
}


void Solve(int N) {
	srand(time(0));
	vector<int> l, r;
	vector<int> perm(2 * N);
	iota(perm.begin(), perm.end(), 1);
	random_shuffle(perm.begin(), perm.end());
	for(auto &i : perm){
		int v = Query(i);
		if(v != l.size()){
			l.push_back(i);
		}
		else{
			r.push_back(i);
		}
	}
	dnc(l, r, 1);
}

Compilation message

minerals.cpp: In function 'void dnc(std::vector<int>, std::vector<int>, int)':
minerals.cpp:18:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=m; i<l.size(); i++){
               ~^~~~~~~~~
minerals.cpp:21:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0; i<r.size(); i++){
               ~^~~~~~~~~
minerals.cpp: In function 'void Solve(int)':
minerals.cpp:50:8: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(v != l.size()){
      ~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 296 KB Output is correct
2 Correct 2 ms 248 KB Output is correct
3 Correct 2 ms 248 KB Output is correct
4 Correct 2 ms 248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 424 KB Output is correct
2 Correct 5 ms 504 KB Output is correct
3 Correct 9 ms 736 KB Output is correct
4 Correct 16 ms 1016 KB Output is correct
5 Correct 31 ms 1660 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 296 KB Output is correct
2 Correct 2 ms 248 KB Output is correct
3 Correct 2 ms 248 KB Output is correct
4 Correct 2 ms 248 KB Output is correct
5 Correct 3 ms 424 KB Output is correct
6 Correct 5 ms 504 KB Output is correct
7 Correct 9 ms 736 KB Output is correct
8 Correct 16 ms 1016 KB Output is correct
9 Correct 31 ms 1660 KB Output is correct
10 Correct 4 ms 332 KB Output is correct
11 Correct 19 ms 1496 KB Output is correct
12 Correct 30 ms 1932 KB Output is correct
13 Correct 27 ms 1676 KB Output is correct
14 Correct 28 ms 1804 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 296 KB Output is correct
2 Correct 2 ms 248 KB Output is correct
3 Correct 2 ms 248 KB Output is correct
4 Correct 2 ms 248 KB Output is correct
5 Correct 3 ms 424 KB Output is correct
6 Correct 5 ms 504 KB Output is correct
7 Correct 9 ms 736 KB Output is correct
8 Correct 16 ms 1016 KB Output is correct
9 Correct 31 ms 1660 KB Output is correct
10 Correct 4 ms 332 KB Output is correct
11 Correct 19 ms 1496 KB Output is correct
12 Correct 30 ms 1932 KB Output is correct
13 Correct 27 ms 1676 KB Output is correct
14 Correct 28 ms 1804 KB Output is correct
15 Correct 79 ms 4016 KB Output is correct
16 Correct 79 ms 4136 KB Output is correct
17 Correct 76 ms 4116 KB Output is correct
18 Correct 84 ms 3848 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 296 KB Output is correct
2 Correct 2 ms 248 KB Output is correct
3 Correct 2 ms 248 KB Output is correct
4 Correct 2 ms 248 KB Output is correct
5 Correct 3 ms 424 KB Output is correct
6 Correct 5 ms 504 KB Output is correct
7 Correct 9 ms 736 KB Output is correct
8 Correct 16 ms 1016 KB Output is correct
9 Correct 31 ms 1660 KB Output is correct
10 Correct 4 ms 332 KB Output is correct
11 Correct 19 ms 1496 KB Output is correct
12 Correct 30 ms 1932 KB Output is correct
13 Correct 27 ms 1676 KB Output is correct
14 Correct 28 ms 1804 KB Output is correct
15 Correct 79 ms 4016 KB Output is correct
16 Correct 79 ms 4136 KB Output is correct
17 Correct 76 ms 4116 KB Output is correct
18 Correct 84 ms 3848 KB Output is correct
19 Correct 93 ms 4108 KB Output is correct
20 Correct 89 ms 4132 KB Output is correct
21 Correct 85 ms 4136 KB Output is correct
22 Correct 88 ms 4008 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 296 KB Output is correct
2 Correct 2 ms 248 KB Output is correct
3 Correct 2 ms 248 KB Output is correct
4 Correct 2 ms 248 KB Output is correct
5 Correct 3 ms 424 KB Output is correct
6 Correct 5 ms 504 KB Output is correct
7 Correct 9 ms 736 KB Output is correct
8 Correct 16 ms 1016 KB Output is correct
9 Correct 31 ms 1660 KB Output is correct
10 Correct 4 ms 332 KB Output is correct
11 Correct 19 ms 1496 KB Output is correct
12 Correct 30 ms 1932 KB Output is correct
13 Correct 27 ms 1676 KB Output is correct
14 Correct 28 ms 1804 KB Output is correct
15 Correct 79 ms 4016 KB Output is correct
16 Correct 79 ms 4136 KB Output is correct
17 Correct 76 ms 4116 KB Output is correct
18 Correct 84 ms 3848 KB Output is correct
19 Correct 93 ms 4108 KB Output is correct
20 Correct 89 ms 4132 KB Output is correct
21 Correct 85 ms 4136 KB Output is correct
22 Correct 88 ms 4008 KB Output is correct
23 Correct 93 ms 4200 KB Output is correct
24 Correct 100 ms 4332 KB Output is correct
25 Correct 94 ms 4248 KB Output is correct
26 Correct 89 ms 4072 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 296 KB Output is correct
2 Correct 2 ms 248 KB Output is correct
3 Correct 2 ms 248 KB Output is correct
4 Correct 2 ms 248 KB Output is correct
5 Correct 3 ms 424 KB Output is correct
6 Correct 5 ms 504 KB Output is correct
7 Correct 9 ms 736 KB Output is correct
8 Correct 16 ms 1016 KB Output is correct
9 Correct 31 ms 1660 KB Output is correct
10 Correct 4 ms 332 KB Output is correct
11 Correct 19 ms 1496 KB Output is correct
12 Correct 30 ms 1932 KB Output is correct
13 Correct 27 ms 1676 KB Output is correct
14 Correct 28 ms 1804 KB Output is correct
15 Correct 79 ms 4016 KB Output is correct
16 Correct 79 ms 4136 KB Output is correct
17 Correct 76 ms 4116 KB Output is correct
18 Correct 84 ms 3848 KB Output is correct
19 Correct 93 ms 4108 KB Output is correct
20 Correct 89 ms 4132 KB Output is correct
21 Correct 85 ms 4136 KB Output is correct
22 Correct 88 ms 4008 KB Output is correct
23 Correct 93 ms 4200 KB Output is correct
24 Correct 100 ms 4332 KB Output is correct
25 Correct 94 ms 4248 KB Output is correct
26 Correct 89 ms 4072 KB Output is correct
27 Correct 85 ms 4284 KB Output is correct
28 Correct 83 ms 4196 KB Output is correct
29 Correct 77 ms 4368 KB Output is correct
30 Correct 81 ms 4128 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 296 KB Output is correct
2 Correct 2 ms 248 KB Output is correct
3 Correct 2 ms 248 KB Output is correct
4 Correct 2 ms 248 KB Output is correct
5 Correct 3 ms 424 KB Output is correct
6 Correct 5 ms 504 KB Output is correct
7 Correct 9 ms 736 KB Output is correct
8 Correct 16 ms 1016 KB Output is correct
9 Correct 31 ms 1660 KB Output is correct
10 Correct 4 ms 332 KB Output is correct
11 Correct 19 ms 1496 KB Output is correct
12 Correct 30 ms 1932 KB Output is correct
13 Correct 27 ms 1676 KB Output is correct
14 Correct 28 ms 1804 KB Output is correct
15 Correct 79 ms 4016 KB Output is correct
16 Correct 79 ms 4136 KB Output is correct
17 Correct 76 ms 4116 KB Output is correct
18 Correct 84 ms 3848 KB Output is correct
19 Correct 93 ms 4108 KB Output is correct
20 Correct 89 ms 4132 KB Output is correct
21 Correct 85 ms 4136 KB Output is correct
22 Correct 88 ms 4008 KB Output is correct
23 Correct 93 ms 4200 KB Output is correct
24 Correct 100 ms 4332 KB Output is correct
25 Correct 94 ms 4248 KB Output is correct
26 Correct 89 ms 4072 KB Output is correct
27 Correct 85 ms 4284 KB Output is correct
28 Correct 83 ms 4196 KB Output is correct
29 Correct 77 ms 4368 KB Output is correct
30 Correct 81 ms 4128 KB Output is correct
31 Correct 95 ms 4464 KB Output is correct
32 Correct 88 ms 4324 KB Output is correct
33 Correct 84 ms 4428 KB Output is correct
34 Correct 82 ms 4188 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 296 KB Output is correct
2 Correct 2 ms 248 KB Output is correct
3 Correct 2 ms 248 KB Output is correct
4 Correct 2 ms 248 KB Output is correct
5 Correct 3 ms 424 KB Output is correct
6 Correct 5 ms 504 KB Output is correct
7 Correct 9 ms 736 KB Output is correct
8 Correct 16 ms 1016 KB Output is correct
9 Correct 31 ms 1660 KB Output is correct
10 Correct 4 ms 332 KB Output is correct
11 Correct 19 ms 1496 KB Output is correct
12 Correct 30 ms 1932 KB Output is correct
13 Correct 27 ms 1676 KB Output is correct
14 Correct 28 ms 1804 KB Output is correct
15 Correct 79 ms 4016 KB Output is correct
16 Correct 79 ms 4136 KB Output is correct
17 Correct 76 ms 4116 KB Output is correct
18 Correct 84 ms 3848 KB Output is correct
19 Correct 93 ms 4108 KB Output is correct
20 Correct 89 ms 4132 KB Output is correct
21 Correct 85 ms 4136 KB Output is correct
22 Correct 88 ms 4008 KB Output is correct
23 Correct 93 ms 4200 KB Output is correct
24 Correct 100 ms 4332 KB Output is correct
25 Correct 94 ms 4248 KB Output is correct
26 Correct 89 ms 4072 KB Output is correct
27 Correct 85 ms 4284 KB Output is correct
28 Correct 83 ms 4196 KB Output is correct
29 Correct 77 ms 4368 KB Output is correct
30 Correct 81 ms 4128 KB Output is correct
31 Correct 95 ms 4464 KB Output is correct
32 Correct 88 ms 4324 KB Output is correct
33 Correct 84 ms 4428 KB Output is correct
34 Correct 82 ms 4188 KB Output is correct
35 Correct 105 ms 4544 KB Output is correct
36 Correct 95 ms 4568 KB Output is correct
37 Correct 103 ms 4456 KB Output is correct
38 Correct 86 ms 4184 KB Output is correct