Submission #514945

# Submission time Handle Problem Language Result Execution time Memory
514945 2022-01-18T21:18:26 Z kostia244 Minerals (JOI19_minerals) C++17
80 / 100
43 ms 2540 KB
#include "minerals.h"
#include<bits/stdc++.h>
using namespace std;
bitset<90000> on;
int uwusgi(int x) {
	on.flip(x);
	return Query(x);
}
#define Query uwusgi
void Solve(int N) {
	vector<int> A, B, C(N), V;
	for(int lst = 0, i = 1; i <= 2*N; i++) {
		int cc = Query(i);
		if(cc == lst) {
			V.push_back(A.size());
		}
		(cc==lst ? B : A).push_back(i);
			
		lst = cc;
	}
	// int CC = 0;
	for(int b = 0; b < 16; b++) {
		int lst = 0;
		for(int i = 0; i < N; i++)
			if(((i>>b)&1)^on[A[i]])
				lst = Query(A[i]);
		vector<int> cnt(1<<16), cnto(1<<16);
		for(auto i : C) cnt[i]++;
		for(int i = 0; i < 1<<b; i++) {
			for(int j = 0; j < 1<<(16-b); j++) {
				int c = i | (j<<b);
				if(c<N)
					cnto[i] += j&1;
			}
		}
		for(int i = 0; i < N; i++) {
			if((C[i]|(1<<b)) > V[i]) continue;
			if(--cnt[C[i]]) {
				int qq = Query(B[i]);
				if(lst == qq) cnto[C[i]]--;
				C[i] |= (lst == qq)<<b;
				lst = qq;
			} else {
				C[i] |= cnto[C[i]]<<b;
			}
		}
		// for(auto i : C) cout << i << " "; cout << endl;
	}
	for(int i = 0; i < N; i++)
		Answer(A[C[i]], B[i]);

}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 712 KB Output is correct
2 Correct 3 ms 712 KB Output is correct
3 Correct 3 ms 832 KB Output is correct
4 Correct 4 ms 840 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 840 KB Output is correct
2 Correct 5 ms 840 KB Output is correct
3 Correct 6 ms 992 KB Output is correct
4 Correct 9 ms 1152 KB Output is correct
5 Correct 14 ms 1352 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 712 KB Output is correct
2 Correct 3 ms 712 KB Output is correct
3 Correct 3 ms 832 KB Output is correct
4 Correct 4 ms 840 KB Output is correct
5 Correct 4 ms 840 KB Output is correct
6 Correct 5 ms 840 KB Output is correct
7 Correct 6 ms 992 KB Output is correct
8 Correct 9 ms 1152 KB Output is correct
9 Correct 14 ms 1352 KB Output is correct
10 Correct 4 ms 840 KB Output is correct
11 Correct 10 ms 1304 KB Output is correct
12 Correct 17 ms 1480 KB Output is correct
13 Correct 12 ms 1496 KB Output is correct
14 Correct 13 ms 1496 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 712 KB Output is correct
2 Correct 3 ms 712 KB Output is correct
3 Correct 3 ms 832 KB Output is correct
4 Correct 4 ms 840 KB Output is correct
5 Correct 4 ms 840 KB Output is correct
6 Correct 5 ms 840 KB Output is correct
7 Correct 6 ms 992 KB Output is correct
8 Correct 9 ms 1152 KB Output is correct
9 Correct 14 ms 1352 KB Output is correct
10 Correct 4 ms 840 KB Output is correct
11 Correct 10 ms 1304 KB Output is correct
12 Correct 17 ms 1480 KB Output is correct
13 Correct 12 ms 1496 KB Output is correct
14 Correct 13 ms 1496 KB Output is correct
15 Correct 38 ms 2408 KB Output is correct
16 Correct 33 ms 2412 KB Output is correct
17 Correct 27 ms 2408 KB Output is correct
18 Correct 28 ms 2188 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 712 KB Output is correct
2 Correct 3 ms 712 KB Output is correct
3 Correct 3 ms 832 KB Output is correct
4 Correct 4 ms 840 KB Output is correct
5 Correct 4 ms 840 KB Output is correct
6 Correct 5 ms 840 KB Output is correct
7 Correct 6 ms 992 KB Output is correct
8 Correct 9 ms 1152 KB Output is correct
9 Correct 14 ms 1352 KB Output is correct
10 Correct 4 ms 840 KB Output is correct
11 Correct 10 ms 1304 KB Output is correct
12 Correct 17 ms 1480 KB Output is correct
13 Correct 12 ms 1496 KB Output is correct
14 Correct 13 ms 1496 KB Output is correct
15 Correct 38 ms 2408 KB Output is correct
16 Correct 33 ms 2412 KB Output is correct
17 Correct 27 ms 2408 KB Output is correct
18 Correct 28 ms 2188 KB Output is correct
19 Correct 32 ms 2432 KB Output is correct
20 Correct 32 ms 2416 KB Output is correct
21 Correct 27 ms 2508 KB Output is correct
22 Correct 27 ms 2208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 712 KB Output is correct
2 Correct 3 ms 712 KB Output is correct
3 Correct 3 ms 832 KB Output is correct
4 Correct 4 ms 840 KB Output is correct
5 Correct 4 ms 840 KB Output is correct
6 Correct 5 ms 840 KB Output is correct
7 Correct 6 ms 992 KB Output is correct
8 Correct 9 ms 1152 KB Output is correct
9 Correct 14 ms 1352 KB Output is correct
10 Correct 4 ms 840 KB Output is correct
11 Correct 10 ms 1304 KB Output is correct
12 Correct 17 ms 1480 KB Output is correct
13 Correct 12 ms 1496 KB Output is correct
14 Correct 13 ms 1496 KB Output is correct
15 Correct 38 ms 2408 KB Output is correct
16 Correct 33 ms 2412 KB Output is correct
17 Correct 27 ms 2408 KB Output is correct
18 Correct 28 ms 2188 KB Output is correct
19 Correct 32 ms 2432 KB Output is correct
20 Correct 32 ms 2416 KB Output is correct
21 Correct 27 ms 2508 KB Output is correct
22 Correct 27 ms 2208 KB Output is correct
23 Correct 38 ms 2420 KB Output is correct
24 Correct 33 ms 2448 KB Output is correct
25 Correct 30 ms 2520 KB Output is correct
26 Correct 30 ms 2212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 712 KB Output is correct
2 Correct 3 ms 712 KB Output is correct
3 Correct 3 ms 832 KB Output is correct
4 Correct 4 ms 840 KB Output is correct
5 Correct 4 ms 840 KB Output is correct
6 Correct 5 ms 840 KB Output is correct
7 Correct 6 ms 992 KB Output is correct
8 Correct 9 ms 1152 KB Output is correct
9 Correct 14 ms 1352 KB Output is correct
10 Correct 4 ms 840 KB Output is correct
11 Correct 10 ms 1304 KB Output is correct
12 Correct 17 ms 1480 KB Output is correct
13 Correct 12 ms 1496 KB Output is correct
14 Correct 13 ms 1496 KB Output is correct
15 Correct 38 ms 2408 KB Output is correct
16 Correct 33 ms 2412 KB Output is correct
17 Correct 27 ms 2408 KB Output is correct
18 Correct 28 ms 2188 KB Output is correct
19 Correct 32 ms 2432 KB Output is correct
20 Correct 32 ms 2416 KB Output is correct
21 Correct 27 ms 2508 KB Output is correct
22 Correct 27 ms 2208 KB Output is correct
23 Correct 38 ms 2420 KB Output is correct
24 Correct 33 ms 2448 KB Output is correct
25 Correct 30 ms 2520 KB Output is correct
26 Correct 30 ms 2212 KB Output is correct
27 Incorrect 43 ms 2540 KB Wrong Answer [2]
28 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 712 KB Output is correct
2 Correct 3 ms 712 KB Output is correct
3 Correct 3 ms 832 KB Output is correct
4 Correct 4 ms 840 KB Output is correct
5 Correct 4 ms 840 KB Output is correct
6 Correct 5 ms 840 KB Output is correct
7 Correct 6 ms 992 KB Output is correct
8 Correct 9 ms 1152 KB Output is correct
9 Correct 14 ms 1352 KB Output is correct
10 Correct 4 ms 840 KB Output is correct
11 Correct 10 ms 1304 KB Output is correct
12 Correct 17 ms 1480 KB Output is correct
13 Correct 12 ms 1496 KB Output is correct
14 Correct 13 ms 1496 KB Output is correct
15 Correct 38 ms 2408 KB Output is correct
16 Correct 33 ms 2412 KB Output is correct
17 Correct 27 ms 2408 KB Output is correct
18 Correct 28 ms 2188 KB Output is correct
19 Correct 32 ms 2432 KB Output is correct
20 Correct 32 ms 2416 KB Output is correct
21 Correct 27 ms 2508 KB Output is correct
22 Correct 27 ms 2208 KB Output is correct
23 Correct 38 ms 2420 KB Output is correct
24 Correct 33 ms 2448 KB Output is correct
25 Correct 30 ms 2520 KB Output is correct
26 Correct 30 ms 2212 KB Output is correct
27 Incorrect 43 ms 2540 KB Wrong Answer [2]
28 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 712 KB Output is correct
2 Correct 3 ms 712 KB Output is correct
3 Correct 3 ms 832 KB Output is correct
4 Correct 4 ms 840 KB Output is correct
5 Correct 4 ms 840 KB Output is correct
6 Correct 5 ms 840 KB Output is correct
7 Correct 6 ms 992 KB Output is correct
8 Correct 9 ms 1152 KB Output is correct
9 Correct 14 ms 1352 KB Output is correct
10 Correct 4 ms 840 KB Output is correct
11 Correct 10 ms 1304 KB Output is correct
12 Correct 17 ms 1480 KB Output is correct
13 Correct 12 ms 1496 KB Output is correct
14 Correct 13 ms 1496 KB Output is correct
15 Correct 38 ms 2408 KB Output is correct
16 Correct 33 ms 2412 KB Output is correct
17 Correct 27 ms 2408 KB Output is correct
18 Correct 28 ms 2188 KB Output is correct
19 Correct 32 ms 2432 KB Output is correct
20 Correct 32 ms 2416 KB Output is correct
21 Correct 27 ms 2508 KB Output is correct
22 Correct 27 ms 2208 KB Output is correct
23 Correct 38 ms 2420 KB Output is correct
24 Correct 33 ms 2448 KB Output is correct
25 Correct 30 ms 2520 KB Output is correct
26 Correct 30 ms 2212 KB Output is correct
27 Incorrect 43 ms 2540 KB Wrong Answer [2]
28 Halted 0 ms 0 KB -