답안 #514960

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
514960 2022-01-18T23:20:27 Z kostia244 Minerals (JOI19_minerals) C++17
90 / 100
64 ms 3456 KB
#include "minerals.h"
#include<bits/stdc++.h>
#define all(x) begin(x), end(x)
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(1<<16);
		mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	{
		vector<int> ord(2*N);
		iota(all(ord), 1);
		shuffle(all(ord), rng);
		int lst = 0;
		for(auto i : ord) {
			int cc = Query(i);
			(cc==lst ? B : A).push_back(i);
				
			lst = cc;
		}
	}
	// int CC = 0;
	auto AA = A;
	A.assign(1<<16, -1);
	vector<int> v(1<<16);
	iota(all(v), 0);
	// for(int b = 0; b < 16; b++) {
	// 	sort(all(v));
	// 	int lst = 0;
	// 	int i = 0;
	// 	while(i < N) {
	// 		int j = i;
	// 		while(j < N && v[j] == v[i]) j++;
	// 		for(int x = 0; i+x < j; x++)
	// 			v[i+x] |= ((x&1)^lst)<<b;//, cout << ((x&1)^lst) << ",";
			
	// 		int c = 0;
	// 		for(int p = i; p < j; p++) c += (v[p]>>b)&1;
	// 		// cout << lst << " " << c << " " << j-i+1 << endl;
	// 		if((i-j)%2 == 0) lst ^= 1;
	// 		i = j;
	// 	}
	// }
	for(int i = 0; i < 1<<16; i++) {
		V[i] = 1^(i&1);
		for(int b = 1; b < 16; b++) {
			V[i] += (i>>b)%2 != (i>>(b-1))%2;
		}
	}
	sort(all(v), [&](auto x, auto y) {
		return V[x] < V[y] ||
		(V[x] == V[y] && x < y);
	});
	for(int i = 0; i < N; i++)
		A[v[i]] = AA[i];
	B.resize(1<<16);
	for(int b = 0; b < 16; b++) {
		int lst = 0, ops = 0, done = 0;
		for(int i = 0; i < 1<<16; i++) if(A[i] != -1)
			ops += ((i>>b)&1)^on[A[i]];
		if(ops > N-ops)
		for(int i = 0; i < 1<<16; i++) if(i < (i^(1<<b)))
			swap(A[i], A[i^(1<<b)]);
		for(int i = 0; i < 1<<16; i++) if(A[i] != -1)
			if((((i>>b)&1)^on[A[i]])&&!(b==15&&A[i^(1<<b)]==-1))
				lst = Query(A[i]), done++;
		// cout << ops << " " << N-ops << " " << done << endl;
		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(A[c]!=-1)
					cnto[i] += j&1;
			}
		}
		for(int i = 0; i < N; i++) {
			if(!cnto[C[i]]) {cnt[C[i]]--;continue;}
			if(cnto[C[i]]) {
				int qq = -1;
				
				if(cnto[C[i]] == cnt[C[i]] && lst != qq) qq = lst;//cout << "HEY"<<endl;
				else	
				qq = Query(B[i]);
				if(lst == qq) cnto[C[i]]--;
				C[i] |= (lst == qq)<<b;
				lst = qq;
			} 
			cnt[C[i]]--;
		}
		// for(auto i : C) cout << i << " "; cout << endl;
	}
	for(int i = 0; i < N; i++)
		Answer(A[C[i]], B[i]);
 
}
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 1864 KB Output is correct
2 Correct 10 ms 1864 KB Output is correct
3 Correct 11 ms 1916 KB Output is correct
4 Correct 11 ms 1864 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 1864 KB Output is correct
2 Correct 13 ms 1956 KB Output is correct
3 Correct 14 ms 1992 KB Output is correct
4 Correct 19 ms 2144 KB Output is correct
5 Correct 24 ms 2500 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 1864 KB Output is correct
2 Correct 10 ms 1864 KB Output is correct
3 Correct 11 ms 1916 KB Output is correct
4 Correct 11 ms 1864 KB Output is correct
5 Correct 13 ms 1864 KB Output is correct
6 Correct 13 ms 1956 KB Output is correct
7 Correct 14 ms 1992 KB Output is correct
8 Correct 19 ms 2144 KB Output is correct
9 Correct 24 ms 2500 KB Output is correct
10 Correct 15 ms 1864 KB Output is correct
11 Correct 20 ms 2368 KB Output is correct
12 Correct 25 ms 2596 KB Output is correct
13 Correct 25 ms 2580 KB Output is correct
14 Correct 26 ms 2528 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 1864 KB Output is correct
2 Correct 10 ms 1864 KB Output is correct
3 Correct 11 ms 1916 KB Output is correct
4 Correct 11 ms 1864 KB Output is correct
5 Correct 13 ms 1864 KB Output is correct
6 Correct 13 ms 1956 KB Output is correct
7 Correct 14 ms 1992 KB Output is correct
8 Correct 19 ms 2144 KB Output is correct
9 Correct 24 ms 2500 KB Output is correct
10 Correct 15 ms 1864 KB Output is correct
11 Correct 20 ms 2368 KB Output is correct
12 Correct 25 ms 2596 KB Output is correct
13 Correct 25 ms 2580 KB Output is correct
14 Correct 26 ms 2528 KB Output is correct
15 Correct 51 ms 3092 KB Output is correct
16 Correct 51 ms 3076 KB Output is correct
17 Correct 48 ms 2968 KB Output is correct
18 Correct 51 ms 2804 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 1864 KB Output is correct
2 Correct 10 ms 1864 KB Output is correct
3 Correct 11 ms 1916 KB Output is correct
4 Correct 11 ms 1864 KB Output is correct
5 Correct 13 ms 1864 KB Output is correct
6 Correct 13 ms 1956 KB Output is correct
7 Correct 14 ms 1992 KB Output is correct
8 Correct 19 ms 2144 KB Output is correct
9 Correct 24 ms 2500 KB Output is correct
10 Correct 15 ms 1864 KB Output is correct
11 Correct 20 ms 2368 KB Output is correct
12 Correct 25 ms 2596 KB Output is correct
13 Correct 25 ms 2580 KB Output is correct
14 Correct 26 ms 2528 KB Output is correct
15 Correct 51 ms 3092 KB Output is correct
16 Correct 51 ms 3076 KB Output is correct
17 Correct 48 ms 2968 KB Output is correct
18 Correct 51 ms 2804 KB Output is correct
19 Correct 50 ms 2968 KB Output is correct
20 Correct 52 ms 3096 KB Output is correct
21 Correct 50 ms 3040 KB Output is correct
22 Correct 57 ms 2816 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 1864 KB Output is correct
2 Correct 10 ms 1864 KB Output is correct
3 Correct 11 ms 1916 KB Output is correct
4 Correct 11 ms 1864 KB Output is correct
5 Correct 13 ms 1864 KB Output is correct
6 Correct 13 ms 1956 KB Output is correct
7 Correct 14 ms 1992 KB Output is correct
8 Correct 19 ms 2144 KB Output is correct
9 Correct 24 ms 2500 KB Output is correct
10 Correct 15 ms 1864 KB Output is correct
11 Correct 20 ms 2368 KB Output is correct
12 Correct 25 ms 2596 KB Output is correct
13 Correct 25 ms 2580 KB Output is correct
14 Correct 26 ms 2528 KB Output is correct
15 Correct 51 ms 3092 KB Output is correct
16 Correct 51 ms 3076 KB Output is correct
17 Correct 48 ms 2968 KB Output is correct
18 Correct 51 ms 2804 KB Output is correct
19 Correct 50 ms 2968 KB Output is correct
20 Correct 52 ms 3096 KB Output is correct
21 Correct 50 ms 3040 KB Output is correct
22 Correct 57 ms 2816 KB Output is correct
23 Correct 53 ms 3084 KB Output is correct
24 Correct 52 ms 3096 KB Output is correct
25 Correct 52 ms 3088 KB Output is correct
26 Correct 53 ms 2956 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 1864 KB Output is correct
2 Correct 10 ms 1864 KB Output is correct
3 Correct 11 ms 1916 KB Output is correct
4 Correct 11 ms 1864 KB Output is correct
5 Correct 13 ms 1864 KB Output is correct
6 Correct 13 ms 1956 KB Output is correct
7 Correct 14 ms 1992 KB Output is correct
8 Correct 19 ms 2144 KB Output is correct
9 Correct 24 ms 2500 KB Output is correct
10 Correct 15 ms 1864 KB Output is correct
11 Correct 20 ms 2368 KB Output is correct
12 Correct 25 ms 2596 KB Output is correct
13 Correct 25 ms 2580 KB Output is correct
14 Correct 26 ms 2528 KB Output is correct
15 Correct 51 ms 3092 KB Output is correct
16 Correct 51 ms 3076 KB Output is correct
17 Correct 48 ms 2968 KB Output is correct
18 Correct 51 ms 2804 KB Output is correct
19 Correct 50 ms 2968 KB Output is correct
20 Correct 52 ms 3096 KB Output is correct
21 Correct 50 ms 3040 KB Output is correct
22 Correct 57 ms 2816 KB Output is correct
23 Correct 53 ms 3084 KB Output is correct
24 Correct 52 ms 3096 KB Output is correct
25 Correct 52 ms 3088 KB Output is correct
26 Correct 53 ms 2956 KB Output is correct
27 Correct 51 ms 3352 KB Output is correct
28 Correct 52 ms 3400 KB Output is correct
29 Correct 52 ms 3408 KB Output is correct
30 Correct 54 ms 3248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 1864 KB Output is correct
2 Correct 10 ms 1864 KB Output is correct
3 Correct 11 ms 1916 KB Output is correct
4 Correct 11 ms 1864 KB Output is correct
5 Correct 13 ms 1864 KB Output is correct
6 Correct 13 ms 1956 KB Output is correct
7 Correct 14 ms 1992 KB Output is correct
8 Correct 19 ms 2144 KB Output is correct
9 Correct 24 ms 2500 KB Output is correct
10 Correct 15 ms 1864 KB Output is correct
11 Correct 20 ms 2368 KB Output is correct
12 Correct 25 ms 2596 KB Output is correct
13 Correct 25 ms 2580 KB Output is correct
14 Correct 26 ms 2528 KB Output is correct
15 Correct 51 ms 3092 KB Output is correct
16 Correct 51 ms 3076 KB Output is correct
17 Correct 48 ms 2968 KB Output is correct
18 Correct 51 ms 2804 KB Output is correct
19 Correct 50 ms 2968 KB Output is correct
20 Correct 52 ms 3096 KB Output is correct
21 Correct 50 ms 3040 KB Output is correct
22 Correct 57 ms 2816 KB Output is correct
23 Correct 53 ms 3084 KB Output is correct
24 Correct 52 ms 3096 KB Output is correct
25 Correct 52 ms 3088 KB Output is correct
26 Correct 53 ms 2956 KB Output is correct
27 Correct 51 ms 3352 KB Output is correct
28 Correct 52 ms 3400 KB Output is correct
29 Correct 52 ms 3408 KB Output is correct
30 Correct 54 ms 3248 KB Output is correct
31 Correct 58 ms 3432 KB Output is correct
32 Correct 64 ms 3420 KB Output is correct
33 Correct 61 ms 3456 KB Output is correct
34 Correct 52 ms 3280 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 1864 KB Output is correct
2 Correct 10 ms 1864 KB Output is correct
3 Correct 11 ms 1916 KB Output is correct
4 Correct 11 ms 1864 KB Output is correct
5 Correct 13 ms 1864 KB Output is correct
6 Correct 13 ms 1956 KB Output is correct
7 Correct 14 ms 1992 KB Output is correct
8 Correct 19 ms 2144 KB Output is correct
9 Correct 24 ms 2500 KB Output is correct
10 Correct 15 ms 1864 KB Output is correct
11 Correct 20 ms 2368 KB Output is correct
12 Correct 25 ms 2596 KB Output is correct
13 Correct 25 ms 2580 KB Output is correct
14 Correct 26 ms 2528 KB Output is correct
15 Correct 51 ms 3092 KB Output is correct
16 Correct 51 ms 3076 KB Output is correct
17 Correct 48 ms 2968 KB Output is correct
18 Correct 51 ms 2804 KB Output is correct
19 Correct 50 ms 2968 KB Output is correct
20 Correct 52 ms 3096 KB Output is correct
21 Correct 50 ms 3040 KB Output is correct
22 Correct 57 ms 2816 KB Output is correct
23 Correct 53 ms 3084 KB Output is correct
24 Correct 52 ms 3096 KB Output is correct
25 Correct 52 ms 3088 KB Output is correct
26 Correct 53 ms 2956 KB Output is correct
27 Correct 51 ms 3352 KB Output is correct
28 Correct 52 ms 3400 KB Output is correct
29 Correct 52 ms 3408 KB Output is correct
30 Correct 54 ms 3248 KB Output is correct
31 Correct 58 ms 3432 KB Output is correct
32 Correct 64 ms 3420 KB Output is correct
33 Correct 61 ms 3456 KB Output is correct
34 Correct 52 ms 3280 KB Output is correct
35 Incorrect 51 ms 3096 KB Wrong Answer [2]
36 Halted 0 ms 0 KB -