답안 #502708

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
502708 2022-01-06T13:21:43 Z sidon Minerals (JOI19_minerals) C++17
90 / 100
59 ms 3396 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;
	if(l < m-1 && m - l + 1 == r - m) --m;
	if(l < m-1 && m - l + 2 == r - m) --m;
	if(l < m-1 && m - l + 3 == r - m) --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 2 ms 328 KB Output is correct
2 Correct 3 ms 328 KB Output is correct
3 Correct 5 ms 564 KB Output is correct
4 Correct 8 ms 840 KB Output is correct
5 Correct 14 ms 1224 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 2 ms 328 KB Output is correct
6 Correct 3 ms 328 KB Output is correct
7 Correct 5 ms 564 KB Output is correct
8 Correct 8 ms 840 KB Output is correct
9 Correct 14 ms 1224 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 10 ms 1044 KB Output is correct
12 Correct 14 ms 1388 KB Output is correct
13 Correct 13 ms 1376 KB Output is correct
14 Correct 14 ms 1288 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 2 ms 328 KB Output is correct
6 Correct 3 ms 328 KB Output is correct
7 Correct 5 ms 564 KB Output is correct
8 Correct 8 ms 840 KB Output is correct
9 Correct 14 ms 1224 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 10 ms 1044 KB Output is correct
12 Correct 14 ms 1388 KB Output is correct
13 Correct 13 ms 1376 KB Output is correct
14 Correct 14 ms 1288 KB Output is correct
15 Correct 42 ms 3092 KB Output is correct
16 Correct 43 ms 3008 KB Output is correct
17 Correct 41 ms 3004 KB Output is correct
18 Correct 44 ms 2904 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 2 ms 328 KB Output is correct
6 Correct 3 ms 328 KB Output is correct
7 Correct 5 ms 564 KB Output is correct
8 Correct 8 ms 840 KB Output is correct
9 Correct 14 ms 1224 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 10 ms 1044 KB Output is correct
12 Correct 14 ms 1388 KB Output is correct
13 Correct 13 ms 1376 KB Output is correct
14 Correct 14 ms 1288 KB Output is correct
15 Correct 42 ms 3092 KB Output is correct
16 Correct 43 ms 3008 KB Output is correct
17 Correct 41 ms 3004 KB Output is correct
18 Correct 44 ms 2904 KB Output is correct
19 Correct 43 ms 3244 KB Output is correct
20 Correct 44 ms 3144 KB Output is correct
21 Correct 36 ms 3124 KB Output is correct
22 Correct 46 ms 3000 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 2 ms 328 KB Output is correct
6 Correct 3 ms 328 KB Output is correct
7 Correct 5 ms 564 KB Output is correct
8 Correct 8 ms 840 KB Output is correct
9 Correct 14 ms 1224 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 10 ms 1044 KB Output is correct
12 Correct 14 ms 1388 KB Output is correct
13 Correct 13 ms 1376 KB Output is correct
14 Correct 14 ms 1288 KB Output is correct
15 Correct 42 ms 3092 KB Output is correct
16 Correct 43 ms 3008 KB Output is correct
17 Correct 41 ms 3004 KB Output is correct
18 Correct 44 ms 2904 KB Output is correct
19 Correct 43 ms 3244 KB Output is correct
20 Correct 44 ms 3144 KB Output is correct
21 Correct 36 ms 3124 KB Output is correct
22 Correct 46 ms 3000 KB Output is correct
23 Correct 47 ms 3220 KB Output is correct
24 Correct 44 ms 3156 KB Output is correct
25 Correct 43 ms 3132 KB Output is correct
26 Correct 49 ms 3128 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 2 ms 328 KB Output is correct
6 Correct 3 ms 328 KB Output is correct
7 Correct 5 ms 564 KB Output is correct
8 Correct 8 ms 840 KB Output is correct
9 Correct 14 ms 1224 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 10 ms 1044 KB Output is correct
12 Correct 14 ms 1388 KB Output is correct
13 Correct 13 ms 1376 KB Output is correct
14 Correct 14 ms 1288 KB Output is correct
15 Correct 42 ms 3092 KB Output is correct
16 Correct 43 ms 3008 KB Output is correct
17 Correct 41 ms 3004 KB Output is correct
18 Correct 44 ms 2904 KB Output is correct
19 Correct 43 ms 3244 KB Output is correct
20 Correct 44 ms 3144 KB Output is correct
21 Correct 36 ms 3124 KB Output is correct
22 Correct 46 ms 3000 KB Output is correct
23 Correct 47 ms 3220 KB Output is correct
24 Correct 44 ms 3156 KB Output is correct
25 Correct 43 ms 3132 KB Output is correct
26 Correct 49 ms 3128 KB Output is correct
27 Correct 57 ms 3288 KB Output is correct
28 Correct 59 ms 3284 KB Output is correct
29 Correct 39 ms 3164 KB Output is correct
30 Correct 50 ms 3024 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 2 ms 328 KB Output is correct
6 Correct 3 ms 328 KB Output is correct
7 Correct 5 ms 564 KB Output is correct
8 Correct 8 ms 840 KB Output is correct
9 Correct 14 ms 1224 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 10 ms 1044 KB Output is correct
12 Correct 14 ms 1388 KB Output is correct
13 Correct 13 ms 1376 KB Output is correct
14 Correct 14 ms 1288 KB Output is correct
15 Correct 42 ms 3092 KB Output is correct
16 Correct 43 ms 3008 KB Output is correct
17 Correct 41 ms 3004 KB Output is correct
18 Correct 44 ms 2904 KB Output is correct
19 Correct 43 ms 3244 KB Output is correct
20 Correct 44 ms 3144 KB Output is correct
21 Correct 36 ms 3124 KB Output is correct
22 Correct 46 ms 3000 KB Output is correct
23 Correct 47 ms 3220 KB Output is correct
24 Correct 44 ms 3156 KB Output is correct
25 Correct 43 ms 3132 KB Output is correct
26 Correct 49 ms 3128 KB Output is correct
27 Correct 57 ms 3288 KB Output is correct
28 Correct 59 ms 3284 KB Output is correct
29 Correct 39 ms 3164 KB Output is correct
30 Correct 50 ms 3024 KB Output is correct
31 Correct 51 ms 3300 KB Output is correct
32 Correct 46 ms 3304 KB Output is correct
33 Correct 41 ms 3320 KB Output is correct
34 Correct 49 ms 3184 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 2 ms 328 KB Output is correct
6 Correct 3 ms 328 KB Output is correct
7 Correct 5 ms 564 KB Output is correct
8 Correct 8 ms 840 KB Output is correct
9 Correct 14 ms 1224 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 10 ms 1044 KB Output is correct
12 Correct 14 ms 1388 KB Output is correct
13 Correct 13 ms 1376 KB Output is correct
14 Correct 14 ms 1288 KB Output is correct
15 Correct 42 ms 3092 KB Output is correct
16 Correct 43 ms 3008 KB Output is correct
17 Correct 41 ms 3004 KB Output is correct
18 Correct 44 ms 2904 KB Output is correct
19 Correct 43 ms 3244 KB Output is correct
20 Correct 44 ms 3144 KB Output is correct
21 Correct 36 ms 3124 KB Output is correct
22 Correct 46 ms 3000 KB Output is correct
23 Correct 47 ms 3220 KB Output is correct
24 Correct 44 ms 3156 KB Output is correct
25 Correct 43 ms 3132 KB Output is correct
26 Correct 49 ms 3128 KB Output is correct
27 Correct 57 ms 3288 KB Output is correct
28 Correct 59 ms 3284 KB Output is correct
29 Correct 39 ms 3164 KB Output is correct
30 Correct 50 ms 3024 KB Output is correct
31 Correct 51 ms 3300 KB Output is correct
32 Correct 46 ms 3304 KB Output is correct
33 Correct 41 ms 3320 KB Output is correct
34 Correct 49 ms 3184 KB Output is correct
35 Incorrect 48 ms 3396 KB Wrong Answer [2]
36 Halted 0 ms 0 KB -