Submission #523281

# Submission time Handle Problem Language Result Execution time Memory
523281 2022-02-07T10:17:50 Z valerikk Minerals (JOI19_minerals) C++17
40 / 100
40 ms 3228 KB
#include "minerals.h"

#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>

using namespace std;

void Solve(int N) {
	vector<int> a, b;
	int lst = 0;
	for (int i = 1; i <= 2 * N; ++i) {
		int x = Query(i);
		if (x != lst) {
			lst = x;
			a.push_back(i);
		} else {
			Query(i);
			b.push_back(i);
		}
	}
	for (int i : a) {
		lst = Query(i);
	}

	vector<int> l(N, 0), r(N, N);
	for (int it = 0; it < 16; ++it) {
		vector<int> m(N);
		vector<vector<int>> here(N + 1);
		bool ok = true;
		for (int i = 0; i < N; ++i) {
			if (r[i] - l[i] != 1) {
				m[i] = (l[i] + r[i]) / 2;
				here[m[i]].push_back(i);
				ok = false;
			}
		}
		if (ok) break;

		if (it & 1) {
			for (int i = N; i >= 0; --i) {
				for (int j : here[i]) {
					int x = Query(b[j]);
					if (x == lst) {
						r[j] = m[j];
					} else {
						l[j] = m[j];
					}
					lst = x;
				}
				if (i != 0) lst = Query(a[i - 1]);
			}
		} else {
			for (int i = 0; i <= N; ++i) {
				for (int j : here[i]) {
					int x = Query(b[j]);
					if (x == lst) {
						r[j] = m[j];
					} else {
						l[j] = m[j];
					}
					lst = x;
				}
				if (i != N) lst = Query(a[i]);
			}
		}
	}

	for (int i = 0; i < N; ++i) {
		Answer(a[l[i]], b[i]);
	}
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
3 Correct 1 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 2 ms 456 KB Output is correct
3 Correct 4 ms 584 KB Output is correct
4 Correct 10 ms 908 KB Output is correct
5 Correct 17 ms 1588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
3 Correct 1 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 10 ms 908 KB Output is correct
9 Correct 17 ms 1588 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 11 ms 1084 KB Output is correct
12 Correct 17 ms 1576 KB Output is correct
13 Correct 14 ms 1640 KB Output is correct
14 Correct 12 ms 1512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
3 Correct 1 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 10 ms 908 KB Output is correct
9 Correct 17 ms 1588 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 11 ms 1084 KB Output is correct
12 Correct 17 ms 1576 KB Output is correct
13 Correct 14 ms 1640 KB Output is correct
14 Correct 12 ms 1512 KB Output is correct
15 Incorrect 40 ms 3228 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
3 Correct 1 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 10 ms 908 KB Output is correct
9 Correct 17 ms 1588 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 11 ms 1084 KB Output is correct
12 Correct 17 ms 1576 KB Output is correct
13 Correct 14 ms 1640 KB Output is correct
14 Correct 12 ms 1512 KB Output is correct
15 Incorrect 40 ms 3228 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
3 Correct 1 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 10 ms 908 KB Output is correct
9 Correct 17 ms 1588 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 11 ms 1084 KB Output is correct
12 Correct 17 ms 1576 KB Output is correct
13 Correct 14 ms 1640 KB Output is correct
14 Correct 12 ms 1512 KB Output is correct
15 Incorrect 40 ms 3228 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
3 Correct 1 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 10 ms 908 KB Output is correct
9 Correct 17 ms 1588 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 11 ms 1084 KB Output is correct
12 Correct 17 ms 1576 KB Output is correct
13 Correct 14 ms 1640 KB Output is correct
14 Correct 12 ms 1512 KB Output is correct
15 Incorrect 40 ms 3228 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
3 Correct 1 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 10 ms 908 KB Output is correct
9 Correct 17 ms 1588 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 11 ms 1084 KB Output is correct
12 Correct 17 ms 1576 KB Output is correct
13 Correct 14 ms 1640 KB Output is correct
14 Correct 12 ms 1512 KB Output is correct
15 Incorrect 40 ms 3228 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
3 Correct 1 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 10 ms 908 KB Output is correct
9 Correct 17 ms 1588 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 11 ms 1084 KB Output is correct
12 Correct 17 ms 1576 KB Output is correct
13 Correct 14 ms 1640 KB Output is correct
14 Correct 12 ms 1512 KB Output is correct
15 Incorrect 40 ms 3228 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -