답안 #502721

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
502721 2022-01-06T13:50:57 Z sidon Minerals (JOI19_minerals) C++17
100 / 100
57 ms 3460 KB
#include "minerals.h"
#include <bits/stdc++.h>
using namespace std;

const int LIM = 43e3;

int A[LIM], L, R = -1, last;

#define ask(Z) (last = Query(Z))

void dfs(int l, int r, vector<int> b, bool on) {
	if(r - l < 1) return;
	if(r - l < 2) return Answer(A[l], b[0]);

	int m = (l + r) / 2;
	if(l < m-1 && m - l == r - m) --m;

	while(__builtin_popcount(m-l) > 2)
		--m;

	for(int i = l; i < m; ++i)
		ask(A[i]);

	vector<int> bL, bR;

	for(int &i : b) {
		if((int)size(bL) == m - l) {
			bR.push_back(i);
			continue;
		}
		if((int)size(bR) == r - m) {
			bL.push_back(i);
			continue;
		}
		int prev = last;
		((prev == ask(i)) ^ on ? bL : bR).push_back(i);
	}

	dfs(l, m, bL, on ^ 1);
	dfs(m, r, bR, on);
}

void Solve(int N) {

	array<int, 2> s[N+N];
	for(unsigned int i = 0, j = 12345; int(i) < N + N; ++i)
		s[i] = {int((j *= 3) >> 1), int(i)+1};
	sort(s, s+N+N);

	vector<int> b;

	for(auto &[_, i] : s) {
		if(R == N - 1 || ask(i) < R + 2) {
			b.push_back(i);
		} else A[++R] = i;
	}
	dfs(0, N, b, 1);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 0 ms 200 KB Output is correct
4 Correct 0 ms 200 KB Output is correct
# 결과 실행 시간 메모리 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 11 ms 864 KB Output is correct
5 Correct 14 ms 1352 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 0 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 11 ms 864 KB Output is correct
9 Correct 14 ms 1352 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 9 ms 1012 KB Output is correct
12 Correct 16 ms 1436 KB Output is correct
13 Correct 14 ms 1448 KB Output is correct
14 Correct 14 ms 1352 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 0 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 11 ms 864 KB Output is correct
9 Correct 14 ms 1352 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 9 ms 1012 KB Output is correct
12 Correct 16 ms 1436 KB Output is correct
13 Correct 14 ms 1448 KB Output is correct
14 Correct 14 ms 1352 KB Output is correct
15 Correct 44 ms 3128 KB Output is correct
16 Correct 41 ms 3088 KB Output is correct
17 Correct 35 ms 3068 KB Output is correct
18 Correct 41 ms 2936 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 0 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 11 ms 864 KB Output is correct
9 Correct 14 ms 1352 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 9 ms 1012 KB Output is correct
12 Correct 16 ms 1436 KB Output is correct
13 Correct 14 ms 1448 KB Output is correct
14 Correct 14 ms 1352 KB Output is correct
15 Correct 44 ms 3128 KB Output is correct
16 Correct 41 ms 3088 KB Output is correct
17 Correct 35 ms 3068 KB Output is correct
18 Correct 41 ms 2936 KB Output is correct
19 Correct 43 ms 3116 KB Output is correct
20 Correct 51 ms 3244 KB Output is correct
21 Correct 37 ms 3156 KB Output is correct
22 Correct 43 ms 2988 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 0 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 11 ms 864 KB Output is correct
9 Correct 14 ms 1352 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 9 ms 1012 KB Output is correct
12 Correct 16 ms 1436 KB Output is correct
13 Correct 14 ms 1448 KB Output is correct
14 Correct 14 ms 1352 KB Output is correct
15 Correct 44 ms 3128 KB Output is correct
16 Correct 41 ms 3088 KB Output is correct
17 Correct 35 ms 3068 KB Output is correct
18 Correct 41 ms 2936 KB Output is correct
19 Correct 43 ms 3116 KB Output is correct
20 Correct 51 ms 3244 KB Output is correct
21 Correct 37 ms 3156 KB Output is correct
22 Correct 43 ms 2988 KB Output is correct
23 Correct 43 ms 3232 KB Output is correct
24 Correct 48 ms 3160 KB Output is correct
25 Correct 38 ms 3152 KB Output is correct
26 Correct 57 ms 3004 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 0 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 11 ms 864 KB Output is correct
9 Correct 14 ms 1352 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 9 ms 1012 KB Output is correct
12 Correct 16 ms 1436 KB Output is correct
13 Correct 14 ms 1448 KB Output is correct
14 Correct 14 ms 1352 KB Output is correct
15 Correct 44 ms 3128 KB Output is correct
16 Correct 41 ms 3088 KB Output is correct
17 Correct 35 ms 3068 KB Output is correct
18 Correct 41 ms 2936 KB Output is correct
19 Correct 43 ms 3116 KB Output is correct
20 Correct 51 ms 3244 KB Output is correct
21 Correct 37 ms 3156 KB Output is correct
22 Correct 43 ms 2988 KB Output is correct
23 Correct 43 ms 3232 KB Output is correct
24 Correct 48 ms 3160 KB Output is correct
25 Correct 38 ms 3152 KB Output is correct
26 Correct 57 ms 3004 KB Output is correct
27 Correct 47 ms 3288 KB Output is correct
28 Correct 45 ms 3292 KB Output is correct
29 Correct 38 ms 3292 KB Output is correct
30 Correct 43 ms 3136 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 0 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 11 ms 864 KB Output is correct
9 Correct 14 ms 1352 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 9 ms 1012 KB Output is correct
12 Correct 16 ms 1436 KB Output is correct
13 Correct 14 ms 1448 KB Output is correct
14 Correct 14 ms 1352 KB Output is correct
15 Correct 44 ms 3128 KB Output is correct
16 Correct 41 ms 3088 KB Output is correct
17 Correct 35 ms 3068 KB Output is correct
18 Correct 41 ms 2936 KB Output is correct
19 Correct 43 ms 3116 KB Output is correct
20 Correct 51 ms 3244 KB Output is correct
21 Correct 37 ms 3156 KB Output is correct
22 Correct 43 ms 2988 KB Output is correct
23 Correct 43 ms 3232 KB Output is correct
24 Correct 48 ms 3160 KB Output is correct
25 Correct 38 ms 3152 KB Output is correct
26 Correct 57 ms 3004 KB Output is correct
27 Correct 47 ms 3288 KB Output is correct
28 Correct 45 ms 3292 KB Output is correct
29 Correct 38 ms 3292 KB Output is correct
30 Correct 43 ms 3136 KB Output is correct
31 Correct 47 ms 3332 KB Output is correct
32 Correct 45 ms 3308 KB Output is correct
33 Correct 44 ms 3260 KB Output is correct
34 Correct 45 ms 3172 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 0 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 11 ms 864 KB Output is correct
9 Correct 14 ms 1352 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 9 ms 1012 KB Output is correct
12 Correct 16 ms 1436 KB Output is correct
13 Correct 14 ms 1448 KB Output is correct
14 Correct 14 ms 1352 KB Output is correct
15 Correct 44 ms 3128 KB Output is correct
16 Correct 41 ms 3088 KB Output is correct
17 Correct 35 ms 3068 KB Output is correct
18 Correct 41 ms 2936 KB Output is correct
19 Correct 43 ms 3116 KB Output is correct
20 Correct 51 ms 3244 KB Output is correct
21 Correct 37 ms 3156 KB Output is correct
22 Correct 43 ms 2988 KB Output is correct
23 Correct 43 ms 3232 KB Output is correct
24 Correct 48 ms 3160 KB Output is correct
25 Correct 38 ms 3152 KB Output is correct
26 Correct 57 ms 3004 KB Output is correct
27 Correct 47 ms 3288 KB Output is correct
28 Correct 45 ms 3292 KB Output is correct
29 Correct 38 ms 3292 KB Output is correct
30 Correct 43 ms 3136 KB Output is correct
31 Correct 47 ms 3332 KB Output is correct
32 Correct 45 ms 3308 KB Output is correct
33 Correct 44 ms 3260 KB Output is correct
34 Correct 45 ms 3172 KB Output is correct
35 Correct 46 ms 3460 KB Output is correct
36 Correct 52 ms 3388 KB Output is correct
37 Correct 41 ms 3448 KB Output is correct
38 Correct 49 ms 3304 KB Output is correct