답안 #376081

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
376081 2021-03-10T20:31:27 Z pit4h Minerals (JOI19_minerals) C++14
100 / 100
122 ms 4964 KB
#include "minerals.h"
#include<bits/stdc++.h>
using namespace std;
using vi = vector<int>;

const int MAXN = 1e5+1;
bool on[MAXN];

int current;
int query(int x) {
	on[x] = !on[x];	
	current = Query(x);
	return current;
}
int levels = 0;
void solve(int n, vi ls, vi rs) {
	if(n==1) {
		Answer(ls[0], rs[0]);
		return;
	}
	random_shuffle(ls.begin(), ls.end());
	random_shuffle(rs.begin(), rs.end());
	vi Ls[2], Rs[2];
	int mid = max(1, n/3);
	for(int i=0; i<mid; ++i) {
		query(ls[i]);
		Ls[on[ls[i]]].push_back(ls[i]);
	}
	for(int i=mid; i<n; ++i) {
		Ls[on[ls[i]]].push_back(ls[i]);
	}
	for(int i=0; i<n; ++i) {
		int old = current;
		if(Rs[0].size() == Ls[0].size()) {
			current = old;
		}
		else if(Rs[1].size() == Ls[1].size()) {
			current--;
		}
		else {
			query(rs[i]);
		}
		if(current == old) {
			Rs[1].push_back(rs[i]);
		}
		else {
			Rs[0].push_back(rs[i]);
		}
	}
	assert(Ls[0].size() == Rs[0].size() && Ls[1].size() == Rs[1].size());

	solve(Ls[0].size(), Ls[0], Rs[0]);
	solve(Ls[1].size(), Ls[1], Rs[1]);
}

void Solve(int N) {
	vi ls={}, rs={};
	int val = 0;
	vi order;
	for(int i=1; i<=2*N; ++i) {
		order.push_back(i);
	}
	random_shuffle(order.begin(), order.end());
	for(int i: order) {
		int nval = query(i);
		if(nval == val) {
			rs.push_back(i);	
		}
		else {
			ls.push_back(i);
		}
		val = nval;
	}
	solve(N, ls, rs);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 492 KB Output is correct
2 Correct 5 ms 620 KB Output is correct
3 Correct 9 ms 748 KB Output is correct
4 Correct 16 ms 1132 KB Output is correct
5 Correct 35 ms 1900 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 2 ms 492 KB Output is correct
6 Correct 5 ms 620 KB Output is correct
7 Correct 9 ms 748 KB Output is correct
8 Correct 16 ms 1132 KB Output is correct
9 Correct 35 ms 1900 KB Output is correct
10 Correct 2 ms 492 KB Output is correct
11 Correct 23 ms 1388 KB Output is correct
12 Correct 33 ms 1900 KB Output is correct
13 Correct 32 ms 1900 KB Output is correct
14 Correct 32 ms 1900 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 2 ms 492 KB Output is correct
6 Correct 5 ms 620 KB Output is correct
7 Correct 9 ms 748 KB Output is correct
8 Correct 16 ms 1132 KB Output is correct
9 Correct 35 ms 1900 KB Output is correct
10 Correct 2 ms 492 KB Output is correct
11 Correct 23 ms 1388 KB Output is correct
12 Correct 33 ms 1900 KB Output is correct
13 Correct 32 ms 1900 KB Output is correct
14 Correct 32 ms 1900 KB Output is correct
15 Correct 92 ms 4324 KB Output is correct
16 Correct 90 ms 4324 KB Output is correct
17 Correct 92 ms 4324 KB Output is correct
18 Correct 91 ms 4324 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 2 ms 492 KB Output is correct
6 Correct 5 ms 620 KB Output is correct
7 Correct 9 ms 748 KB Output is correct
8 Correct 16 ms 1132 KB Output is correct
9 Correct 35 ms 1900 KB Output is correct
10 Correct 2 ms 492 KB Output is correct
11 Correct 23 ms 1388 KB Output is correct
12 Correct 33 ms 1900 KB Output is correct
13 Correct 32 ms 1900 KB Output is correct
14 Correct 32 ms 1900 KB Output is correct
15 Correct 92 ms 4324 KB Output is correct
16 Correct 90 ms 4324 KB Output is correct
17 Correct 92 ms 4324 KB Output is correct
18 Correct 91 ms 4324 KB Output is correct
19 Correct 94 ms 4364 KB Output is correct
20 Correct 98 ms 4460 KB Output is correct
21 Correct 99 ms 4324 KB Output is correct
22 Correct 92 ms 4324 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 2 ms 492 KB Output is correct
6 Correct 5 ms 620 KB Output is correct
7 Correct 9 ms 748 KB Output is correct
8 Correct 16 ms 1132 KB Output is correct
9 Correct 35 ms 1900 KB Output is correct
10 Correct 2 ms 492 KB Output is correct
11 Correct 23 ms 1388 KB Output is correct
12 Correct 33 ms 1900 KB Output is correct
13 Correct 32 ms 1900 KB Output is correct
14 Correct 32 ms 1900 KB Output is correct
15 Correct 92 ms 4324 KB Output is correct
16 Correct 90 ms 4324 KB Output is correct
17 Correct 92 ms 4324 KB Output is correct
18 Correct 91 ms 4324 KB Output is correct
19 Correct 94 ms 4364 KB Output is correct
20 Correct 98 ms 4460 KB Output is correct
21 Correct 99 ms 4324 KB Output is correct
22 Correct 92 ms 4324 KB Output is correct
23 Correct 103 ms 4452 KB Output is correct
24 Correct 98 ms 4580 KB Output is correct
25 Correct 105 ms 4452 KB Output is correct
26 Correct 100 ms 4324 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 2 ms 492 KB Output is correct
6 Correct 5 ms 620 KB Output is correct
7 Correct 9 ms 748 KB Output is correct
8 Correct 16 ms 1132 KB Output is correct
9 Correct 35 ms 1900 KB Output is correct
10 Correct 2 ms 492 KB Output is correct
11 Correct 23 ms 1388 KB Output is correct
12 Correct 33 ms 1900 KB Output is correct
13 Correct 32 ms 1900 KB Output is correct
14 Correct 32 ms 1900 KB Output is correct
15 Correct 92 ms 4324 KB Output is correct
16 Correct 90 ms 4324 KB Output is correct
17 Correct 92 ms 4324 KB Output is correct
18 Correct 91 ms 4324 KB Output is correct
19 Correct 94 ms 4364 KB Output is correct
20 Correct 98 ms 4460 KB Output is correct
21 Correct 99 ms 4324 KB Output is correct
22 Correct 92 ms 4324 KB Output is correct
23 Correct 103 ms 4452 KB Output is correct
24 Correct 98 ms 4580 KB Output is correct
25 Correct 105 ms 4452 KB Output is correct
26 Correct 100 ms 4324 KB Output is correct
27 Correct 100 ms 4580 KB Output is correct
28 Correct 97 ms 4580 KB Output is correct
29 Correct 106 ms 4452 KB Output is correct
30 Correct 113 ms 4452 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 2 ms 492 KB Output is correct
6 Correct 5 ms 620 KB Output is correct
7 Correct 9 ms 748 KB Output is correct
8 Correct 16 ms 1132 KB Output is correct
9 Correct 35 ms 1900 KB Output is correct
10 Correct 2 ms 492 KB Output is correct
11 Correct 23 ms 1388 KB Output is correct
12 Correct 33 ms 1900 KB Output is correct
13 Correct 32 ms 1900 KB Output is correct
14 Correct 32 ms 1900 KB Output is correct
15 Correct 92 ms 4324 KB Output is correct
16 Correct 90 ms 4324 KB Output is correct
17 Correct 92 ms 4324 KB Output is correct
18 Correct 91 ms 4324 KB Output is correct
19 Correct 94 ms 4364 KB Output is correct
20 Correct 98 ms 4460 KB Output is correct
21 Correct 99 ms 4324 KB Output is correct
22 Correct 92 ms 4324 KB Output is correct
23 Correct 103 ms 4452 KB Output is correct
24 Correct 98 ms 4580 KB Output is correct
25 Correct 105 ms 4452 KB Output is correct
26 Correct 100 ms 4324 KB Output is correct
27 Correct 100 ms 4580 KB Output is correct
28 Correct 97 ms 4580 KB Output is correct
29 Correct 106 ms 4452 KB Output is correct
30 Correct 113 ms 4452 KB Output is correct
31 Correct 104 ms 4708 KB Output is correct
32 Correct 105 ms 4708 KB Output is correct
33 Correct 116 ms 4708 KB Output is correct
34 Correct 122 ms 4496 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 2 ms 492 KB Output is correct
6 Correct 5 ms 620 KB Output is correct
7 Correct 9 ms 748 KB Output is correct
8 Correct 16 ms 1132 KB Output is correct
9 Correct 35 ms 1900 KB Output is correct
10 Correct 2 ms 492 KB Output is correct
11 Correct 23 ms 1388 KB Output is correct
12 Correct 33 ms 1900 KB Output is correct
13 Correct 32 ms 1900 KB Output is correct
14 Correct 32 ms 1900 KB Output is correct
15 Correct 92 ms 4324 KB Output is correct
16 Correct 90 ms 4324 KB Output is correct
17 Correct 92 ms 4324 KB Output is correct
18 Correct 91 ms 4324 KB Output is correct
19 Correct 94 ms 4364 KB Output is correct
20 Correct 98 ms 4460 KB Output is correct
21 Correct 99 ms 4324 KB Output is correct
22 Correct 92 ms 4324 KB Output is correct
23 Correct 103 ms 4452 KB Output is correct
24 Correct 98 ms 4580 KB Output is correct
25 Correct 105 ms 4452 KB Output is correct
26 Correct 100 ms 4324 KB Output is correct
27 Correct 100 ms 4580 KB Output is correct
28 Correct 97 ms 4580 KB Output is correct
29 Correct 106 ms 4452 KB Output is correct
30 Correct 113 ms 4452 KB Output is correct
31 Correct 104 ms 4708 KB Output is correct
32 Correct 105 ms 4708 KB Output is correct
33 Correct 116 ms 4708 KB Output is correct
34 Correct 122 ms 4496 KB Output is correct
35 Correct 104 ms 4836 KB Output is correct
36 Correct 102 ms 4708 KB Output is correct
37 Correct 108 ms 4964 KB Output is correct
38 Correct 109 ms 4580 KB Output is correct