답안 #1046154

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1046154 2024-08-06T10:44:04 Z ksun69(#11074) Ancient Machine 2 (JOI23_ancient2) C++17
98 / 100
27 ms 856 KB
#include "ancient2.h"
#include <bits/stdc++.h>

namespace {
	using namespace std;

	const int S = 1000;
	using bs = bitset<S>;
	string my_solve(int N){
		int M = 108;
		int nq = 0;
		vector<bs> basis(S);
		vector<int> result(S, 0);
		int rank = 0;

		for(int i = 0; i < 100; i++){
			int Q = i + 3;
			vector<int> A(Q), B(Q);
			for(int j = 0; j < i; j++){
				A[j] = B[j] = j+1;
			}
			A[i] = i+1;
			B[i] = i+2;
			A[i+1] = B[i+1] = i+1;
			A[i+2] = B[i+2] = i+2;
			int res = Query(Q, A, B);
			basis[i][i] = 1;
			result[i] = res - (i+1);
			rank++;
		}

		for(int L = M/2; L > 0; L--){
			for(int d = 0; d < L; d++){
				if(nq >= S) break;
				bs mask;
				for(int x = d; x < S; x += L) mask[x] = 1;

				bs r = mask;
				int b;
				int prev_result = 0;
				for(b = 0; b < S; b++){
					if(r[b]){
						r ^= basis[b];
						prev_result ^= result[b];
					}
					if(r[b] && !basis[b].any()){
						basis[b] = r;
						break;
					}
				}
				if(!r.any()) continue;
				rank++;
				nq++;
				int Q = L*2;
				vector<int> A(Q), B(Q);
				for(int i = 0; i < L; i++){
					int nxt = (i+1) % L;
					if(i == d){
						A[2*i] = 2*nxt;
						A[2*i+1] = 2*nxt+1;
						B[2*i] = 2*nxt+1;
						B[2*i+1] = 2*nxt;
					} else {
						A[2*i] = 2*nxt;
						A[2*i+1] = 2*nxt+1;
						B[2*i] = 2*nxt;
						B[2*i+1] = 2*nxt+1;
					}
				}
				int res = Query(Q, A, B);
				result[b] = (res % 2) ^ prev_result;
			}
		}

		string ans(N, '0');
		for(int i = N-1; i >= 0; i--){
			int v = result[i];
			for(int j = 0; j < N; j++){
				if(ans[j] == '1' && basis[i][j]) v ^= 1;
			}
			ans[i] = '0' + v;
		}
		cerr << "rank = " << rank << '\n';
		cerr << ans << '\n';
		return ans;
	}

}  // namespace

std::string Solve(int N) {
	return my_solve(N);
}
# 결과 실행 시간 메모리 Grader output
1 Partially correct 19 ms 588 KB Output is partially correct
2 Partially correct 18 ms 344 KB Output is partially correct
3 Partially correct 20 ms 568 KB Output is partially correct
4 Partially correct 18 ms 856 KB Output is partially correct
5 Partially correct 16 ms 340 KB Output is partially correct
6 Partially correct 16 ms 344 KB Output is partially correct
7 Partially correct 15 ms 344 KB Output is partially correct
8 Partially correct 17 ms 344 KB Output is partially correct
9 Partially correct 26 ms 344 KB Output is partially correct
10 Partially correct 16 ms 584 KB Output is partially correct
11 Partially correct 23 ms 344 KB Output is partially correct
12 Partially correct 18 ms 344 KB Output is partially correct
13 Partially correct 16 ms 344 KB Output is partially correct
14 Partially correct 16 ms 584 KB Output is partially correct
15 Partially correct 15 ms 344 KB Output is partially correct
16 Partially correct 15 ms 344 KB Output is partially correct
17 Partially correct 15 ms 344 KB Output is partially correct
18 Partially correct 23 ms 568 KB Output is partially correct
19 Partially correct 17 ms 592 KB Output is partially correct
20 Partially correct 17 ms 344 KB Output is partially correct
21 Partially correct 17 ms 344 KB Output is partially correct
22 Partially correct 16 ms 564 KB Output is partially correct
23 Partially correct 19 ms 344 KB Output is partially correct
24 Partially correct 23 ms 344 KB Output is partially correct
25 Partially correct 17 ms 584 KB Output is partially correct
26 Partially correct 16 ms 344 KB Output is partially correct
27 Partially correct 16 ms 344 KB Output is partially correct
28 Partially correct 15 ms 344 KB Output is partially correct
29 Partially correct 15 ms 344 KB Output is partially correct
30 Partially correct 23 ms 856 KB Output is partially correct
31 Partially correct 15 ms 344 KB Output is partially correct
32 Partially correct 16 ms 576 KB Output is partially correct
33 Partially correct 19 ms 344 KB Output is partially correct
34 Partially correct 17 ms 600 KB Output is partially correct
35 Partially correct 23 ms 344 KB Output is partially correct
36 Partially correct 23 ms 344 KB Output is partially correct
37 Partially correct 16 ms 344 KB Output is partially correct
38 Partially correct 19 ms 584 KB Output is partially correct
39 Partially correct 16 ms 592 KB Output is partially correct
40 Partially correct 19 ms 584 KB Output is partially correct
41 Partially correct 18 ms 344 KB Output is partially correct
42 Partially correct 16 ms 344 KB Output is partially correct
43 Partially correct 23 ms 344 KB Output is partially correct
44 Partially correct 19 ms 600 KB Output is partially correct
45 Partially correct 24 ms 564 KB Output is partially correct
46 Partially correct 18 ms 344 KB Output is partially correct
47 Partially correct 18 ms 564 KB Output is partially correct
48 Partially correct 16 ms 344 KB Output is partially correct
49 Partially correct 27 ms 340 KB Output is partially correct
50 Partially correct 18 ms 344 KB Output is partially correct
51 Partially correct 16 ms 344 KB Output is partially correct
52 Partially correct 23 ms 344 KB Output is partially correct
53 Partially correct 19 ms 344 KB Output is partially correct
54 Partially correct 18 ms 344 KB Output is partially correct
55 Partially correct 16 ms 344 KB Output is partially correct
56 Partially correct 16 ms 344 KB Output is partially correct
57 Partially correct 17 ms 568 KB Output is partially correct
58 Partially correct 15 ms 344 KB Output is partially correct
59 Partially correct 15 ms 588 KB Output is partially correct
60 Partially correct 26 ms 572 KB Output is partially correct
61 Partially correct 18 ms 588 KB Output is partially correct
62 Partially correct 17 ms 584 KB Output is partially correct
63 Partially correct 16 ms 344 KB Output is partially correct