Submission #502660

# Submission time Handle Problem Language Result Execution time Memory
502660 2022-01-06T11:57:54 Z sidon Minerals (JOI19_minerals) C++17
40 / 100
24 ms 2760 KB
#include "minerals.h"
#include <bits/stdc++.h>
using namespace std;

const int LIM = 43e3;

int A[LIM], range[2*LIM+1], L, R = -1;

void extend(int lv, int rv) {
	for(int _ : {1, 0}){
		for(int i = L; i <= R; ++i) 
			if(!(lv <= i && i <= rv)) Query(A[i]);
		if(_) swap(L, lv), swap(R, rv);
	}
}

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

	int m = (l + r) / 2;
	if(r - m > m - l) ++m;

	extend(l, m-1);


	vector<int> bL, bR;

	for(int &i : b) {
		if((int)size(bL) == m - l) bR.push_back(i);
		else if(range[i] < m || (int)size(bR) == r - m) bL.push_back(i);
		else
			(Query(i) == Query(i) ? bL : bR).push_back(i);
	}

	dfs(l, m, bL);
	dfs(m, r, bR);
}

void Solve(int N) {
	vector<int> b;

	for(int i = 1; i <= N * 2; ++i) {
		if(R == N - 1 || Query(i) < R + 2) {
			b.push_back(i);
			Query(i);
			range[i] = R;
		} else A[++R] = i;
	}
	dfs(0, N, b);
}
# Verdict Execution time Memory 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
# Verdict Execution time Memory Grader output
1 Correct 1 ms 328 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 3 ms 456 KB Output is correct
4 Correct 6 ms 732 KB Output is correct
5 Correct 13 ms 1140 KB Output is correct
# Verdict Execution time Memory 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 1 ms 328 KB Output is correct
7 Correct 3 ms 456 KB Output is correct
8 Correct 6 ms 732 KB Output is correct
9 Correct 13 ms 1140 KB Output is correct
10 Correct 2 ms 328 KB Output is correct
11 Correct 9 ms 840 KB Output is correct
12 Correct 14 ms 1176 KB Output is correct
13 Correct 8 ms 1224 KB Output is correct
14 Correct 8 ms 1096 KB Output is correct
# Verdict Execution time Memory 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 1 ms 328 KB Output is correct
7 Correct 3 ms 456 KB Output is correct
8 Correct 6 ms 732 KB Output is correct
9 Correct 13 ms 1140 KB Output is correct
10 Correct 2 ms 328 KB Output is correct
11 Correct 9 ms 840 KB Output is correct
12 Correct 14 ms 1176 KB Output is correct
13 Correct 8 ms 1224 KB Output is correct
14 Correct 8 ms 1096 KB Output is correct
15 Incorrect 24 ms 2760 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 1 ms 328 KB Output is correct
7 Correct 3 ms 456 KB Output is correct
8 Correct 6 ms 732 KB Output is correct
9 Correct 13 ms 1140 KB Output is correct
10 Correct 2 ms 328 KB Output is correct
11 Correct 9 ms 840 KB Output is correct
12 Correct 14 ms 1176 KB Output is correct
13 Correct 8 ms 1224 KB Output is correct
14 Correct 8 ms 1096 KB Output is correct
15 Incorrect 24 ms 2760 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 1 ms 328 KB Output is correct
7 Correct 3 ms 456 KB Output is correct
8 Correct 6 ms 732 KB Output is correct
9 Correct 13 ms 1140 KB Output is correct
10 Correct 2 ms 328 KB Output is correct
11 Correct 9 ms 840 KB Output is correct
12 Correct 14 ms 1176 KB Output is correct
13 Correct 8 ms 1224 KB Output is correct
14 Correct 8 ms 1096 KB Output is correct
15 Incorrect 24 ms 2760 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 1 ms 328 KB Output is correct
7 Correct 3 ms 456 KB Output is correct
8 Correct 6 ms 732 KB Output is correct
9 Correct 13 ms 1140 KB Output is correct
10 Correct 2 ms 328 KB Output is correct
11 Correct 9 ms 840 KB Output is correct
12 Correct 14 ms 1176 KB Output is correct
13 Correct 8 ms 1224 KB Output is correct
14 Correct 8 ms 1096 KB Output is correct
15 Incorrect 24 ms 2760 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 1 ms 328 KB Output is correct
7 Correct 3 ms 456 KB Output is correct
8 Correct 6 ms 732 KB Output is correct
9 Correct 13 ms 1140 KB Output is correct
10 Correct 2 ms 328 KB Output is correct
11 Correct 9 ms 840 KB Output is correct
12 Correct 14 ms 1176 KB Output is correct
13 Correct 8 ms 1224 KB Output is correct
14 Correct 8 ms 1096 KB Output is correct
15 Incorrect 24 ms 2760 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 1 ms 328 KB Output is correct
7 Correct 3 ms 456 KB Output is correct
8 Correct 6 ms 732 KB Output is correct
9 Correct 13 ms 1140 KB Output is correct
10 Correct 2 ms 328 KB Output is correct
11 Correct 9 ms 840 KB Output is correct
12 Correct 14 ms 1176 KB Output is correct
13 Correct 8 ms 1224 KB Output is correct
14 Correct 8 ms 1096 KB Output is correct
15 Incorrect 24 ms 2760 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -