Submission #832972

# Submission time Handle Problem Language Result Execution time Memory
832972 2023-08-21T17:32:22 Z doowey Ancient Machine 2 (JOI23_ancient2) C++17
97 / 100
36 ms 660 KB
#include "ancient2.h"
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

namespace {

int variable_example = 1;

}  // namespace


const int M = 100;
const int N = 1002;
bitset<N> eq[N]; // 0111011[1] = x1 + x2 + x3 + x5 + x6 = x[n+1]
bool has[N];
bitset<N> cur;
int n;
int id;

bool add(){
	for(int i = n - 1; i >= 0 ; i -- ){
		if(cur[i]){
			if(has[i]){
				cur ^= eq[i];
			}
			else{
				
				eq[i]=cur;
				has[i]=true;
				id = i;
				return true;
			}
		}
	}
	return false;
}

string Solve(int _n) {
	n = _n;
	string s;
	for(int i = 0 ; i < n; i ++ ){
		s.push_back('0');
	}
	id = 0;
	int total = 0;
	for(int mod = 1; mod < M; mod ++ ){
		
		for(int x = 0; x < mod ; x ++ ){
			cur.reset();
			for(int y = x; y < n; y += mod){
				cur[y]=1;
			}
			if(add()){
				total ++ ;
				vector<int> qa(mod * 2), qb(mod * 2);
				for(int i = 0 ; i < mod; i ++ ){
					qa[i] = (i + 1) % mod;
					qb[i] = (i + 1) % mod;
					
					qa[i + mod] = (i + 1) % mod + mod;
					qb[i + mod] = (i + 1) % mod + mod; // sooo we want to flip side when we arrive at i mod 
					if(i == x){
						swap(qb[i], qb[i + mod]);
					}
				}
				int send = Query(mod * 2, qa, qb);
				if(send >= mod){
					eq[id].flip(n);
				}
				if(total == n) break;
			}
		}
		if(total == n) break;
	} 
	
	for(int i = 0 ; i < n; i ++ ){
		for(int j = 0 ; j < i ; j ++ ){
			if(eq[i][j]) eq[i] ^= eq[j];
		}
		if(eq[i][n]) s[i] ++ ;
	}
	return s;
}

Compilation message

ancient2.cpp:18:5: warning: '{anonymous}::variable_example' defined but not used [-Wunused-variable]
   18 | int variable_example = 1;
      |     ^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Partially correct 23 ms 420 KB Output is partially correct
2 Partially correct 27 ms 336 KB Output is partially correct
3 Partially correct 27 ms 352 KB Output is partially correct
4 Partially correct 30 ms 396 KB Output is partially correct
5 Partially correct 33 ms 340 KB Output is partially correct
6 Partially correct 31 ms 408 KB Output is partially correct
7 Partially correct 29 ms 436 KB Output is partially correct
8 Partially correct 32 ms 380 KB Output is partially correct
9 Partially correct 33 ms 404 KB Output is partially correct
10 Partially correct 28 ms 440 KB Output is partially correct
11 Partially correct 27 ms 428 KB Output is partially correct
12 Partially correct 30 ms 416 KB Output is partially correct
13 Partially correct 34 ms 388 KB Output is partially correct
14 Partially correct 31 ms 420 KB Output is partially correct
15 Partially correct 29 ms 404 KB Output is partially correct
16 Partially correct 29 ms 380 KB Output is partially correct
17 Partially correct 32 ms 368 KB Output is partially correct
18 Partially correct 27 ms 388 KB Output is partially correct
19 Partially correct 33 ms 408 KB Output is partially correct
20 Partially correct 28 ms 432 KB Output is partially correct
21 Partially correct 26 ms 420 KB Output is partially correct
22 Partially correct 32 ms 496 KB Output is partially correct
23 Partially correct 29 ms 364 KB Output is partially correct
24 Partially correct 29 ms 552 KB Output is partially correct
25 Partially correct 28 ms 400 KB Output is partially correct
26 Partially correct 27 ms 436 KB Output is partially correct
27 Partially correct 30 ms 412 KB Output is partially correct
28 Partially correct 34 ms 340 KB Output is partially correct
29 Partially correct 30 ms 432 KB Output is partially correct
30 Partially correct 29 ms 360 KB Output is partially correct
31 Partially correct 24 ms 436 KB Output is partially correct
32 Partially correct 32 ms 432 KB Output is partially correct
33 Partially correct 27 ms 396 KB Output is partially correct
34 Partially correct 32 ms 476 KB Output is partially correct
35 Partially correct 29 ms 416 KB Output is partially correct
36 Partially correct 28 ms 472 KB Output is partially correct
37 Partially correct 32 ms 348 KB Output is partially correct
38 Partially correct 29 ms 384 KB Output is partially correct
39 Partially correct 27 ms 332 KB Output is partially correct
40 Partially correct 29 ms 424 KB Output is partially correct
41 Partially correct 30 ms 608 KB Output is partially correct
42 Partially correct 30 ms 372 KB Output is partially correct
43 Partially correct 36 ms 336 KB Output is partially correct
44 Partially correct 29 ms 380 KB Output is partially correct
45 Partially correct 30 ms 364 KB Output is partially correct
46 Partially correct 26 ms 420 KB Output is partially correct
47 Partially correct 36 ms 380 KB Output is partially correct
48 Partially correct 32 ms 356 KB Output is partially correct
49 Partially correct 32 ms 436 KB Output is partially correct
50 Partially correct 27 ms 376 KB Output is partially correct
51 Partially correct 33 ms 360 KB Output is partially correct
52 Partially correct 26 ms 336 KB Output is partially correct
53 Partially correct 29 ms 328 KB Output is partially correct
54 Partially correct 31 ms 420 KB Output is partially correct
55 Partially correct 30 ms 432 KB Output is partially correct
56 Partially correct 26 ms 396 KB Output is partially correct
57 Partially correct 27 ms 328 KB Output is partially correct
58 Partially correct 34 ms 364 KB Output is partially correct
59 Partially correct 27 ms 396 KB Output is partially correct
60 Partially correct 32 ms 404 KB Output is partially correct
61 Partially correct 29 ms 336 KB Output is partially correct
62 Partially correct 29 ms 344 KB Output is partially correct
63 Partially correct 30 ms 660 KB Output is partially correct