Submission #167316

# Submission time Handle Problem Language Result Execution time Memory
167316 2019-12-07T09:46:27 Z maruii Minerals (JOI19_minerals) C++14
70 / 100
47 ms 2424 KB
#include "minerals.h"
#include <bits/stdc++.h>
using namespace std;

int A[43005], S[43005];
void Solve(int N) {
	vector<int> X, Y;
	for (int i = 1, v = 0; i <= 2 * N; ++i) {
		int t = Query(i);
		if (t > v) X.push_back(i);
		else Y.push_back(i);
		v = t;
	}
	for (int i = 0; i < N; ++i) S[i] = 1;
	for (int i = 0; i < 16; ++i) {
		int v = 0, t = 0, cnt = 0;
		for (int j = 0; j < N; ++j) if (S[j] ^ (j >> i) & 1) cnt++;
		if (cnt < N - cnt) t = 1;
		for (int j = 0; j < N; ++j) if (t ^ S[j] ^ (j >> i) & 1) {
			v = Query(X[j]);
			S[j] ^= 1;
		}
		for (int j = 0; j < N; ++j) {
			int a = Query(Y[j]);
			if ((v == a) ^ t) A[j] |= 1 << i;
			v = a;
		}
	}
	for (int i = 0; i < N; ++i) Answer(Y[i], X[A[i]]);
}

Compilation message

minerals.cpp: In function 'void Solve(int)':
minerals.cpp:17:51: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   for (int j = 0; j < N; ++j) if (S[j] ^ (j >> i) & 1) cnt++;
                                          ~~~~~~~~~^~~
minerals.cpp:19:55: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   for (int j = 0; j < N; ++j) if (t ^ S[j] ^ (j >> i) & 1) {
                                              ~~~~~~~~~^~~
# Verdict Execution time Memory Grader output
1 Correct 6 ms 248 KB Output is correct
2 Correct 2 ms 248 KB Output is correct
3 Correct 2 ms 248 KB Output is correct
4 Correct 2 ms 248 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 5 ms 504 KB Output is correct
4 Correct 7 ms 632 KB Output is correct
5 Correct 13 ms 1144 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 248 KB Output is correct
2 Correct 2 ms 248 KB Output is correct
3 Correct 2 ms 248 KB Output is correct
4 Correct 2 ms 248 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 3 ms 376 KB Output is correct
7 Correct 5 ms 504 KB Output is correct
8 Correct 7 ms 632 KB Output is correct
9 Correct 13 ms 1144 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 10 ms 876 KB Output is correct
12 Correct 13 ms 1016 KB Output is correct
13 Correct 11 ms 1144 KB Output is correct
14 Correct 10 ms 1016 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 248 KB Output is correct
2 Correct 2 ms 248 KB Output is correct
3 Correct 2 ms 248 KB Output is correct
4 Correct 2 ms 248 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 3 ms 376 KB Output is correct
7 Correct 5 ms 504 KB Output is correct
8 Correct 7 ms 632 KB Output is correct
9 Correct 13 ms 1144 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 10 ms 876 KB Output is correct
12 Correct 13 ms 1016 KB Output is correct
13 Correct 11 ms 1144 KB Output is correct
14 Correct 10 ms 1016 KB Output is correct
15 Correct 37 ms 2292 KB Output is correct
16 Correct 47 ms 2212 KB Output is correct
17 Correct 24 ms 2424 KB Output is correct
18 Correct 25 ms 2036 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 248 KB Output is correct
2 Correct 2 ms 248 KB Output is correct
3 Correct 2 ms 248 KB Output is correct
4 Correct 2 ms 248 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 3 ms 376 KB Output is correct
7 Correct 5 ms 504 KB Output is correct
8 Correct 7 ms 632 KB Output is correct
9 Correct 13 ms 1144 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 10 ms 876 KB Output is correct
12 Correct 13 ms 1016 KB Output is correct
13 Correct 11 ms 1144 KB Output is correct
14 Correct 10 ms 1016 KB Output is correct
15 Correct 37 ms 2292 KB Output is correct
16 Correct 47 ms 2212 KB Output is correct
17 Correct 24 ms 2424 KB Output is correct
18 Correct 25 ms 2036 KB Output is correct
19 Incorrect 32 ms 1920 KB Wrong Answer [2]
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 248 KB Output is correct
2 Correct 2 ms 248 KB Output is correct
3 Correct 2 ms 248 KB Output is correct
4 Correct 2 ms 248 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 3 ms 376 KB Output is correct
7 Correct 5 ms 504 KB Output is correct
8 Correct 7 ms 632 KB Output is correct
9 Correct 13 ms 1144 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 10 ms 876 KB Output is correct
12 Correct 13 ms 1016 KB Output is correct
13 Correct 11 ms 1144 KB Output is correct
14 Correct 10 ms 1016 KB Output is correct
15 Correct 37 ms 2292 KB Output is correct
16 Correct 47 ms 2212 KB Output is correct
17 Correct 24 ms 2424 KB Output is correct
18 Correct 25 ms 2036 KB Output is correct
19 Incorrect 32 ms 1920 KB Wrong Answer [2]
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 248 KB Output is correct
2 Correct 2 ms 248 KB Output is correct
3 Correct 2 ms 248 KB Output is correct
4 Correct 2 ms 248 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 3 ms 376 KB Output is correct
7 Correct 5 ms 504 KB Output is correct
8 Correct 7 ms 632 KB Output is correct
9 Correct 13 ms 1144 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 10 ms 876 KB Output is correct
12 Correct 13 ms 1016 KB Output is correct
13 Correct 11 ms 1144 KB Output is correct
14 Correct 10 ms 1016 KB Output is correct
15 Correct 37 ms 2292 KB Output is correct
16 Correct 47 ms 2212 KB Output is correct
17 Correct 24 ms 2424 KB Output is correct
18 Correct 25 ms 2036 KB Output is correct
19 Incorrect 32 ms 1920 KB Wrong Answer [2]
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 248 KB Output is correct
2 Correct 2 ms 248 KB Output is correct
3 Correct 2 ms 248 KB Output is correct
4 Correct 2 ms 248 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 3 ms 376 KB Output is correct
7 Correct 5 ms 504 KB Output is correct
8 Correct 7 ms 632 KB Output is correct
9 Correct 13 ms 1144 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 10 ms 876 KB Output is correct
12 Correct 13 ms 1016 KB Output is correct
13 Correct 11 ms 1144 KB Output is correct
14 Correct 10 ms 1016 KB Output is correct
15 Correct 37 ms 2292 KB Output is correct
16 Correct 47 ms 2212 KB Output is correct
17 Correct 24 ms 2424 KB Output is correct
18 Correct 25 ms 2036 KB Output is correct
19 Incorrect 32 ms 1920 KB Wrong Answer [2]
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 248 KB Output is correct
2 Correct 2 ms 248 KB Output is correct
3 Correct 2 ms 248 KB Output is correct
4 Correct 2 ms 248 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 3 ms 376 KB Output is correct
7 Correct 5 ms 504 KB Output is correct
8 Correct 7 ms 632 KB Output is correct
9 Correct 13 ms 1144 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 10 ms 876 KB Output is correct
12 Correct 13 ms 1016 KB Output is correct
13 Correct 11 ms 1144 KB Output is correct
14 Correct 10 ms 1016 KB Output is correct
15 Correct 37 ms 2292 KB Output is correct
16 Correct 47 ms 2212 KB Output is correct
17 Correct 24 ms 2424 KB Output is correct
18 Correct 25 ms 2036 KB Output is correct
19 Incorrect 32 ms 1920 KB Wrong Answer [2]
20 Halted 0 ms 0 KB -