Submission #674284

# Submission time Handle Problem Language Result Execution time Memory
674284 2022-12-23T16:28:34 Z rainboy Minerals (JOI19_minerals) C++17
85 / 100
53 ms 4904 KB
#include "minerals.h"
#include <iostream>
#include <cstring>
using namespace std;

const int N = 41000, L = 18;

int k;

int Query_(int i) {
	int k_ = Query(i + 1);
	if (k_ == k)
		return 0;
	k = k_;
	return 1;
}

int tt[N * 2], ii[2][N], ii_[1 << L], nn[2], aa[N], bb[N];
int aaa[L * 2 + 2][1 << L], nn_[L * 2 + 2]; char used[1 << L];

void Solve(int n) {
	for (int i = 0; i < n * 2; i++) {
		tt[i] = !Query_(i);
		ii[tt[i]][nn[tt[i]]++] = i;
	}
	for (int a = 0; a < 1 << L; a++) {
		int k = 0, l_ = -1;
		for (int l = 0; l < L; l++)
			if ((a >> l & 1) != (l == 0 ? 0 : (a >> l - 1 & 1)))
				k++, l_ = l;
		int w = a == 0 ? 0 : k + l_ + 2;
		aaa[w][nn_[w]++] = a;
	}
	for (int i = 0, w = 0; i < n; i++) {
		while (nn_[w] == 0)
			w++;
		aa[i] = aaa[w][--nn_[w]];
	}
	for (int l = 0; l < L; l++) {
		for (int i = 0; i < n; i++)
			if ((aa[i] >> l & 1) != (l == 0 ? 0 : (aa[i] >> l - 1 & 1)))
				Query_(ii[0][i]);
		memset(used, 0, (1 << L) * sizeof *used);
		for (int i = 0; i < n; i++)
			used[aa[i] & (1 << l + 1) - 1] = 1;
		for (int i = 0; i < n; i++)
			if (!used[bb[i]] || used[bb[i] | 1 << l] && Query_(ii[1][i]))
				bb[i] |= 1 << l;
	}
	for (int i = 0; i < n; i++)
		ii_[aa[i]] = ii[0][i];
	for (int i = 0; i < n; i++)
		Answer(ii_[bb[i]] + 1, ii[1][i] + 1);
}

Compilation message

minerals.cpp: In function 'void Solve(int)':
minerals.cpp:29:46: warning: suggest parentheses around '-' inside '>>' [-Wparentheses]
   29 |    if ((a >> l & 1) != (l == 0 ? 0 : (a >> l - 1 & 1)))
      |                                            ~~^~~
minerals.cpp:41:54: warning: suggest parentheses around '-' inside '>>' [-Wparentheses]
   41 |    if ((aa[i] >> l & 1) != (l == 0 ? 0 : (aa[i] >> l - 1 & 1)))
      |                                                    ~~^~~
minerals.cpp:45:25: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
   45 |    used[aa[i] & (1 << l + 1) - 1] = 1;
      |                       ~~^~~
minerals.cpp:45:30: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
   45 |    used[aa[i] & (1 << l + 1) - 1] = 1;
      |                 ~~~~~~~~~~~~~^~~
minerals.cpp:47:45: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   47 |    if (!used[bb[i]] || used[bb[i] | 1 << l] && Query_(ii[1][i]))
      |                        ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 20 ms 1736 KB Output is correct
2 Correct 24 ms 1712 KB Output is correct
3 Correct 21 ms 1800 KB Output is correct
4 Correct 23 ms 1732 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 19 ms 1804 KB Output is correct
2 Correct 20 ms 1868 KB Output is correct
3 Correct 23 ms 2120 KB Output is correct
4 Correct 27 ms 2396 KB Output is correct
5 Correct 27 ms 3020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 20 ms 1736 KB Output is correct
2 Correct 24 ms 1712 KB Output is correct
3 Correct 21 ms 1800 KB Output is correct
4 Correct 23 ms 1732 KB Output is correct
5 Correct 19 ms 1804 KB Output is correct
6 Correct 20 ms 1868 KB Output is correct
7 Correct 23 ms 2120 KB Output is correct
8 Correct 27 ms 2396 KB Output is correct
9 Correct 27 ms 3020 KB Output is correct
10 Correct 21 ms 1824 KB Output is correct
11 Correct 24 ms 2684 KB Output is correct
12 Correct 31 ms 3152 KB Output is correct
13 Correct 28 ms 3140 KB Output is correct
14 Correct 26 ms 3008 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 20 ms 1736 KB Output is correct
2 Correct 24 ms 1712 KB Output is correct
3 Correct 21 ms 1800 KB Output is correct
4 Correct 23 ms 1732 KB Output is correct
5 Correct 19 ms 1804 KB Output is correct
6 Correct 20 ms 1868 KB Output is correct
7 Correct 23 ms 2120 KB Output is correct
8 Correct 27 ms 2396 KB Output is correct
9 Correct 27 ms 3020 KB Output is correct
10 Correct 21 ms 1824 KB Output is correct
11 Correct 24 ms 2684 KB Output is correct
12 Correct 31 ms 3152 KB Output is correct
13 Correct 28 ms 3140 KB Output is correct
14 Correct 26 ms 3008 KB Output is correct
15 Correct 43 ms 4680 KB Output is correct
16 Correct 43 ms 4676 KB Output is correct
17 Correct 38 ms 4672 KB Output is correct
18 Correct 37 ms 4584 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 20 ms 1736 KB Output is correct
2 Correct 24 ms 1712 KB Output is correct
3 Correct 21 ms 1800 KB Output is correct
4 Correct 23 ms 1732 KB Output is correct
5 Correct 19 ms 1804 KB Output is correct
6 Correct 20 ms 1868 KB Output is correct
7 Correct 23 ms 2120 KB Output is correct
8 Correct 27 ms 2396 KB Output is correct
9 Correct 27 ms 3020 KB Output is correct
10 Correct 21 ms 1824 KB Output is correct
11 Correct 24 ms 2684 KB Output is correct
12 Correct 31 ms 3152 KB Output is correct
13 Correct 28 ms 3140 KB Output is correct
14 Correct 26 ms 3008 KB Output is correct
15 Correct 43 ms 4680 KB Output is correct
16 Correct 43 ms 4676 KB Output is correct
17 Correct 38 ms 4672 KB Output is correct
18 Correct 37 ms 4584 KB Output is correct
19 Correct 44 ms 4780 KB Output is correct
20 Correct 44 ms 4700 KB Output is correct
21 Correct 39 ms 4780 KB Output is correct
22 Correct 38 ms 4556 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 20 ms 1736 KB Output is correct
2 Correct 24 ms 1712 KB Output is correct
3 Correct 21 ms 1800 KB Output is correct
4 Correct 23 ms 1732 KB Output is correct
5 Correct 19 ms 1804 KB Output is correct
6 Correct 20 ms 1868 KB Output is correct
7 Correct 23 ms 2120 KB Output is correct
8 Correct 27 ms 2396 KB Output is correct
9 Correct 27 ms 3020 KB Output is correct
10 Correct 21 ms 1824 KB Output is correct
11 Correct 24 ms 2684 KB Output is correct
12 Correct 31 ms 3152 KB Output is correct
13 Correct 28 ms 3140 KB Output is correct
14 Correct 26 ms 3008 KB Output is correct
15 Correct 43 ms 4680 KB Output is correct
16 Correct 43 ms 4676 KB Output is correct
17 Correct 38 ms 4672 KB Output is correct
18 Correct 37 ms 4584 KB Output is correct
19 Correct 44 ms 4780 KB Output is correct
20 Correct 44 ms 4700 KB Output is correct
21 Correct 39 ms 4780 KB Output is correct
22 Correct 38 ms 4556 KB Output is correct
23 Correct 43 ms 4768 KB Output is correct
24 Correct 53 ms 4832 KB Output is correct
25 Correct 46 ms 4800 KB Output is correct
26 Correct 38 ms 4640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 20 ms 1736 KB Output is correct
2 Correct 24 ms 1712 KB Output is correct
3 Correct 21 ms 1800 KB Output is correct
4 Correct 23 ms 1732 KB Output is correct
5 Correct 19 ms 1804 KB Output is correct
6 Correct 20 ms 1868 KB Output is correct
7 Correct 23 ms 2120 KB Output is correct
8 Correct 27 ms 2396 KB Output is correct
9 Correct 27 ms 3020 KB Output is correct
10 Correct 21 ms 1824 KB Output is correct
11 Correct 24 ms 2684 KB Output is correct
12 Correct 31 ms 3152 KB Output is correct
13 Correct 28 ms 3140 KB Output is correct
14 Correct 26 ms 3008 KB Output is correct
15 Correct 43 ms 4680 KB Output is correct
16 Correct 43 ms 4676 KB Output is correct
17 Correct 38 ms 4672 KB Output is correct
18 Correct 37 ms 4584 KB Output is correct
19 Correct 44 ms 4780 KB Output is correct
20 Correct 44 ms 4700 KB Output is correct
21 Correct 39 ms 4780 KB Output is correct
22 Correct 38 ms 4556 KB Output is correct
23 Correct 43 ms 4768 KB Output is correct
24 Correct 53 ms 4832 KB Output is correct
25 Correct 46 ms 4800 KB Output is correct
26 Correct 38 ms 4640 KB Output is correct
27 Correct 53 ms 4836 KB Output is correct
28 Correct 46 ms 4860 KB Output is correct
29 Correct 44 ms 4904 KB Output is correct
30 Correct 50 ms 4712 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 20 ms 1736 KB Output is correct
2 Correct 24 ms 1712 KB Output is correct
3 Correct 21 ms 1800 KB Output is correct
4 Correct 23 ms 1732 KB Output is correct
5 Correct 19 ms 1804 KB Output is correct
6 Correct 20 ms 1868 KB Output is correct
7 Correct 23 ms 2120 KB Output is correct
8 Correct 27 ms 2396 KB Output is correct
9 Correct 27 ms 3020 KB Output is correct
10 Correct 21 ms 1824 KB Output is correct
11 Correct 24 ms 2684 KB Output is correct
12 Correct 31 ms 3152 KB Output is correct
13 Correct 28 ms 3140 KB Output is correct
14 Correct 26 ms 3008 KB Output is correct
15 Correct 43 ms 4680 KB Output is correct
16 Correct 43 ms 4676 KB Output is correct
17 Correct 38 ms 4672 KB Output is correct
18 Correct 37 ms 4584 KB Output is correct
19 Correct 44 ms 4780 KB Output is correct
20 Correct 44 ms 4700 KB Output is correct
21 Correct 39 ms 4780 KB Output is correct
22 Correct 38 ms 4556 KB Output is correct
23 Correct 43 ms 4768 KB Output is correct
24 Correct 53 ms 4832 KB Output is correct
25 Correct 46 ms 4800 KB Output is correct
26 Correct 38 ms 4640 KB Output is correct
27 Correct 53 ms 4836 KB Output is correct
28 Correct 46 ms 4860 KB Output is correct
29 Correct 44 ms 4904 KB Output is correct
30 Correct 50 ms 4712 KB Output is correct
31 Incorrect 44 ms 3744 KB Wrong Answer [2]
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 20 ms 1736 KB Output is correct
2 Correct 24 ms 1712 KB Output is correct
3 Correct 21 ms 1800 KB Output is correct
4 Correct 23 ms 1732 KB Output is correct
5 Correct 19 ms 1804 KB Output is correct
6 Correct 20 ms 1868 KB Output is correct
7 Correct 23 ms 2120 KB Output is correct
8 Correct 27 ms 2396 KB Output is correct
9 Correct 27 ms 3020 KB Output is correct
10 Correct 21 ms 1824 KB Output is correct
11 Correct 24 ms 2684 KB Output is correct
12 Correct 31 ms 3152 KB Output is correct
13 Correct 28 ms 3140 KB Output is correct
14 Correct 26 ms 3008 KB Output is correct
15 Correct 43 ms 4680 KB Output is correct
16 Correct 43 ms 4676 KB Output is correct
17 Correct 38 ms 4672 KB Output is correct
18 Correct 37 ms 4584 KB Output is correct
19 Correct 44 ms 4780 KB Output is correct
20 Correct 44 ms 4700 KB Output is correct
21 Correct 39 ms 4780 KB Output is correct
22 Correct 38 ms 4556 KB Output is correct
23 Correct 43 ms 4768 KB Output is correct
24 Correct 53 ms 4832 KB Output is correct
25 Correct 46 ms 4800 KB Output is correct
26 Correct 38 ms 4640 KB Output is correct
27 Correct 53 ms 4836 KB Output is correct
28 Correct 46 ms 4860 KB Output is correct
29 Correct 44 ms 4904 KB Output is correct
30 Correct 50 ms 4712 KB Output is correct
31 Incorrect 44 ms 3744 KB Wrong Answer [2]
32 Halted 0 ms 0 KB -