Submission #836182

# Submission time Handle Problem Language Result Execution time Memory
836182 2023-08-24T08:27:38 Z gustason Minerals (JOI19_minerals) C++14
90 / 100
44 ms 3796 KB
#include <bits/stdc++.h>
#include "minerals.h"

using namespace std;

int last = 0;

bool ask(int x) {
	int now = Query(x);
	bool ar_naujas = (now != last);
	last = now;
	return ar_naujas;
}

#define p(x) cout << (#x) << ":\n";print(x)

void print(vector<int>& a) {
	for(int i : a) {
		cout << i << " ";
	} 
	cout << "\n";
}

void go(vector<int> pirmas, vector<int> antras, bool flag=false) {
	int n = pirmas.size(), m = (int) ceil((double) n * 0.4);
	//p(pirmas);
	//p(antras);
	
	assert(n != 0);
	if (n == 1) {
		Answer(pirmas[0], antras[0]);
		return;
	}
	
	if (flag) {
		m = n - m;
		for(int i = m; i < n; i++) {
			ask(pirmas[i]);
		}
	}
	else {
		for(int i = 0; i < m; i++) {
			ask(pirmas[i]);
		}
	}
	
	vector<int> naujas_pirmas, naujas_antras;
	random_shuffle(antras.begin(), antras.end());
	for(const auto& i : antras) {
		if ((int) naujas_pirmas.size() == n) {
			naujas_antras.push_back(i);
		}
		else if ((int) naujas_antras.size() == n-m) {
			naujas_pirmas.push_back(i);
		}
		else if (ask(i)) {
			naujas_antras.push_back(i);
		}
		else {
			naujas_pirmas.push_back(i);
		}
	}
	
	vector<int> half, other_half;
	for(int i = 0; i < n; i++) {
		if (i < m) {
			half.push_back(pirmas[i]);
		}
		else {
			other_half.push_back(pirmas[i]);
		}
	}
	
	//p(half);
	//p(naujas_pirmas);
	//p(other_half);
	//p(naujas_antras);
	
	go(half, naujas_pirmas, true);
	go(other_half, naujas_antras);
}

void Solve(int N) {
	vector<int> pirmas, antras;
	for(int i = 1; i <= 2*N; i++) {
		if (ask(i)) {
			pirmas.push_back(i);
		}
		else {
			antras.push_back(i);
		}
	}
	
	go(pirmas, antras, true);
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 2 ms 464 KB Output is correct
3 Correct 3 ms 592 KB Output is correct
4 Correct 7 ms 976 KB Output is correct
5 Correct 13 ms 1488 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 2 ms 464 KB Output is correct
7 Correct 3 ms 592 KB Output is correct
8 Correct 7 ms 976 KB Output is correct
9 Correct 13 ms 1488 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 10 ms 1232 KB Output is correct
12 Correct 13 ms 1488 KB Output is correct
13 Correct 14 ms 1488 KB Output is correct
14 Correct 13 ms 1488 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 2 ms 464 KB Output is correct
7 Correct 3 ms 592 KB Output is correct
8 Correct 7 ms 976 KB Output is correct
9 Correct 13 ms 1488 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 10 ms 1232 KB Output is correct
12 Correct 13 ms 1488 KB Output is correct
13 Correct 14 ms 1488 KB Output is correct
14 Correct 13 ms 1488 KB Output is correct
15 Correct 35 ms 3412 KB Output is correct
16 Correct 35 ms 3408 KB Output is correct
17 Correct 35 ms 3356 KB Output is correct
18 Correct 33 ms 3272 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 2 ms 464 KB Output is correct
7 Correct 3 ms 592 KB Output is correct
8 Correct 7 ms 976 KB Output is correct
9 Correct 13 ms 1488 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 10 ms 1232 KB Output is correct
12 Correct 13 ms 1488 KB Output is correct
13 Correct 14 ms 1488 KB Output is correct
14 Correct 13 ms 1488 KB Output is correct
15 Correct 35 ms 3412 KB Output is correct
16 Correct 35 ms 3408 KB Output is correct
17 Correct 35 ms 3356 KB Output is correct
18 Correct 33 ms 3272 KB Output is correct
19 Correct 41 ms 3536 KB Output is correct
20 Correct 40 ms 3496 KB Output is correct
21 Correct 35 ms 3504 KB Output is correct
22 Correct 35 ms 3312 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 2 ms 464 KB Output is correct
7 Correct 3 ms 592 KB Output is correct
8 Correct 7 ms 976 KB Output is correct
9 Correct 13 ms 1488 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 10 ms 1232 KB Output is correct
12 Correct 13 ms 1488 KB Output is correct
13 Correct 14 ms 1488 KB Output is correct
14 Correct 13 ms 1488 KB Output is correct
15 Correct 35 ms 3412 KB Output is correct
16 Correct 35 ms 3408 KB Output is correct
17 Correct 35 ms 3356 KB Output is correct
18 Correct 33 ms 3272 KB Output is correct
19 Correct 41 ms 3536 KB Output is correct
20 Correct 40 ms 3496 KB Output is correct
21 Correct 35 ms 3504 KB Output is correct
22 Correct 35 ms 3312 KB Output is correct
23 Correct 37 ms 3592 KB Output is correct
24 Correct 37 ms 3616 KB Output is correct
25 Correct 40 ms 3536 KB Output is correct
26 Correct 35 ms 3408 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 2 ms 464 KB Output is correct
7 Correct 3 ms 592 KB Output is correct
8 Correct 7 ms 976 KB Output is correct
9 Correct 13 ms 1488 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 10 ms 1232 KB Output is correct
12 Correct 13 ms 1488 KB Output is correct
13 Correct 14 ms 1488 KB Output is correct
14 Correct 13 ms 1488 KB Output is correct
15 Correct 35 ms 3412 KB Output is correct
16 Correct 35 ms 3408 KB Output is correct
17 Correct 35 ms 3356 KB Output is correct
18 Correct 33 ms 3272 KB Output is correct
19 Correct 41 ms 3536 KB Output is correct
20 Correct 40 ms 3496 KB Output is correct
21 Correct 35 ms 3504 KB Output is correct
22 Correct 35 ms 3312 KB Output is correct
23 Correct 37 ms 3592 KB Output is correct
24 Correct 37 ms 3616 KB Output is correct
25 Correct 40 ms 3536 KB Output is correct
26 Correct 35 ms 3408 KB Output is correct
27 Correct 38 ms 3792 KB Output is correct
28 Correct 38 ms 3664 KB Output is correct
29 Correct 37 ms 3732 KB Output is correct
30 Correct 36 ms 3528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 2 ms 464 KB Output is correct
7 Correct 3 ms 592 KB Output is correct
8 Correct 7 ms 976 KB Output is correct
9 Correct 13 ms 1488 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 10 ms 1232 KB Output is correct
12 Correct 13 ms 1488 KB Output is correct
13 Correct 14 ms 1488 KB Output is correct
14 Correct 13 ms 1488 KB Output is correct
15 Correct 35 ms 3412 KB Output is correct
16 Correct 35 ms 3408 KB Output is correct
17 Correct 35 ms 3356 KB Output is correct
18 Correct 33 ms 3272 KB Output is correct
19 Correct 41 ms 3536 KB Output is correct
20 Correct 40 ms 3496 KB Output is correct
21 Correct 35 ms 3504 KB Output is correct
22 Correct 35 ms 3312 KB Output is correct
23 Correct 37 ms 3592 KB Output is correct
24 Correct 37 ms 3616 KB Output is correct
25 Correct 40 ms 3536 KB Output is correct
26 Correct 35 ms 3408 KB Output is correct
27 Correct 38 ms 3792 KB Output is correct
28 Correct 38 ms 3664 KB Output is correct
29 Correct 37 ms 3732 KB Output is correct
30 Correct 36 ms 3528 KB Output is correct
31 Correct 44 ms 3792 KB Output is correct
32 Correct 38 ms 3796 KB Output is correct
33 Correct 37 ms 3776 KB Output is correct
34 Correct 37 ms 3624 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 2 ms 464 KB Output is correct
7 Correct 3 ms 592 KB Output is correct
8 Correct 7 ms 976 KB Output is correct
9 Correct 13 ms 1488 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 10 ms 1232 KB Output is correct
12 Correct 13 ms 1488 KB Output is correct
13 Correct 14 ms 1488 KB Output is correct
14 Correct 13 ms 1488 KB Output is correct
15 Correct 35 ms 3412 KB Output is correct
16 Correct 35 ms 3408 KB Output is correct
17 Correct 35 ms 3356 KB Output is correct
18 Correct 33 ms 3272 KB Output is correct
19 Correct 41 ms 3536 KB Output is correct
20 Correct 40 ms 3496 KB Output is correct
21 Correct 35 ms 3504 KB Output is correct
22 Correct 35 ms 3312 KB Output is correct
23 Correct 37 ms 3592 KB Output is correct
24 Correct 37 ms 3616 KB Output is correct
25 Correct 40 ms 3536 KB Output is correct
26 Correct 35 ms 3408 KB Output is correct
27 Correct 38 ms 3792 KB Output is correct
28 Correct 38 ms 3664 KB Output is correct
29 Correct 37 ms 3732 KB Output is correct
30 Correct 36 ms 3528 KB Output is correct
31 Correct 44 ms 3792 KB Output is correct
32 Correct 38 ms 3796 KB Output is correct
33 Correct 37 ms 3776 KB Output is correct
34 Correct 37 ms 3624 KB Output is correct
35 Incorrect 41 ms 3792 KB Wrong Answer [2]
36 Halted 0 ms 0 KB -