Submission #899127

# Submission time Handle Problem Language Result Execution time Memory
899127 2024-01-05T13:51:31 Z weajink Ancient Machine 2 (JOI23_ancient2) C++17
97 / 100
50 ms 1884 KB
#include "ancient2.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//Autor: Michał Szeliga
#ifdef LOCAL
#define debug(...) __VA_ARGS__;
#else
#define debug(...) {}
#endif
#define read(...) debug((void)!freopen(__VA_ARGS__,"r",stdin););

const int M = 1001;
bitset<M> akt[M-1];
int ile = 0;
int gauss(bitset<M> x){
	int i;
	for (i = 0; i < M-1; i++){
		if (x[i]){
			if (!akt[i][i]){
				//cout<<i<<" # "<<x<<"\n";
				akt[i] = x;
				ile++;
				return i;
			}
			x ^= akt[i];
		}
	}
	return -1;
}
bool policz(int x){
	bitset<M> wy;
	wy[x] = 1;
	for (int i = 0; i < M-1; i++){
		if (wy[i]) wy ^= akt[i];
	}
	return wy[M-1];
}
void stworz_automat(int c, int r){
	bitset<M> wy;
	for (int i = r; i < M-1; i += c) wy[i] = 1;
	int id = gauss(wy);
	if (id != -1){
		int m = 2*c;
		vector<int> A,B;
		for (int i = 0; i < c; i++){
			if (i%c == r){
				A.push_back((r+1)%c);
				B.push_back(c+(r+1)%c);
			}else{
				A.push_back((i+1)%c);
				B.push_back((i+1)%c);
			}
		}
		for (int i = c; i < 2*c; i++){
			if (i%c == r){
				A.push_back(c+(r+1)%c);
				B.push_back((r+1)%c);
			}else{
				A.push_back(c+(i+1)%c);
				B.push_back(c+(i+1)%c);
			}
		}
		/*cout<<"Zapytanie o "<<c<<" "<<r<<"\n";
		for (int j = 0; j < m; j++){
			cout<<A[j]<<" "<<B[j]<<"\n";
		}*/
		akt[id][M-1] = akt[id][M-1]^(Query(m,A,B) >= c);
		//cout<<id<<" "<<akt[id]<<"\n";
	}
}
string Solve(int n){
	for (int c = 1; c < M-1; c++){
		for (int r = 0; r < c; r++){
			stworz_automat(c,r);
			if (ile == M-1) break;
		}
	} 
	string wy;
	for (int i = 0; i < n; i++){
		if (policz(i)) wy += '1';
		else wy += '0';
	}
	return wy;
}
# Verdict Execution time Memory Grader output
1 Partially correct 38 ms 944 KB Output is partially correct
2 Partially correct 37 ms 1652 KB Output is partially correct
3 Partially correct 46 ms 920 KB Output is partially correct
4 Partially correct 45 ms 1284 KB Output is partially correct
5 Partially correct 40 ms 1252 KB Output is partially correct
6 Partially correct 39 ms 1200 KB Output is partially correct
7 Partially correct 42 ms 1288 KB Output is partially correct
8 Partially correct 39 ms 1032 KB Output is partially correct
9 Partially correct 38 ms 1244 KB Output is partially correct
10 Partially correct 46 ms 1292 KB Output is partially correct
11 Partially correct 43 ms 1184 KB Output is partially correct
12 Partially correct 40 ms 780 KB Output is partially correct
13 Partially correct 40 ms 1528 KB Output is partially correct
14 Partially correct 44 ms 920 KB Output is partially correct
15 Partially correct 41 ms 1500 KB Output is partially correct
16 Partially correct 39 ms 1540 KB Output is partially correct
17 Partially correct 41 ms 1284 KB Output is partially correct
18 Partially correct 41 ms 1032 KB Output is partially correct
19 Partially correct 41 ms 1376 KB Output is partially correct
20 Partially correct 42 ms 1656 KB Output is partially correct
21 Partially correct 37 ms 920 KB Output is partially correct
22 Partially correct 42 ms 1008 KB Output is partially correct
23 Partially correct 50 ms 1660 KB Output is partially correct
24 Partially correct 41 ms 1120 KB Output is partially correct
25 Partially correct 36 ms 1252 KB Output is partially correct
26 Partially correct 37 ms 1392 KB Output is partially correct
27 Partially correct 38 ms 1544 KB Output is partially correct
28 Partially correct 40 ms 1544 KB Output is partially correct
29 Partially correct 37 ms 1284 KB Output is partially correct
30 Partially correct 37 ms 864 KB Output is partially correct
31 Partially correct 36 ms 1256 KB Output is partially correct
32 Partially correct 44 ms 1288 KB Output is partially correct
33 Partially correct 41 ms 1752 KB Output is partially correct
34 Partially correct 37 ms 1268 KB Output is partially correct
35 Partially correct 37 ms 1280 KB Output is partially correct
36 Partially correct 38 ms 956 KB Output is partially correct
37 Partially correct 36 ms 1412 KB Output is partially correct
38 Partially correct 38 ms 1776 KB Output is partially correct
39 Partially correct 40 ms 1412 KB Output is partially correct
40 Partially correct 38 ms 1224 KB Output is partially correct
41 Partially correct 36 ms 1232 KB Output is partially correct
42 Partially correct 41 ms 1184 KB Output is partially correct
43 Partially correct 41 ms 1380 KB Output is partially correct
44 Partially correct 37 ms 1236 KB Output is partially correct
45 Partially correct 37 ms 1032 KB Output is partially correct
46 Partially correct 37 ms 1260 KB Output is partially correct
47 Partially correct 40 ms 1036 KB Output is partially correct
48 Partially correct 37 ms 1640 KB Output is partially correct
49 Partially correct 37 ms 1020 KB Output is partially correct
50 Partially correct 38 ms 1408 KB Output is partially correct
51 Partially correct 40 ms 1532 KB Output is partially correct
52 Partially correct 41 ms 1264 KB Output is partially correct
53 Partially correct 37 ms 1392 KB Output is partially correct
54 Partially correct 37 ms 1520 KB Output is partially correct
55 Partially correct 37 ms 684 KB Output is partially correct
56 Partially correct 37 ms 1548 KB Output is partially correct
57 Partially correct 41 ms 1244 KB Output is partially correct
58 Partially correct 38 ms 1536 KB Output is partially correct
59 Partially correct 37 ms 1884 KB Output is partially correct
60 Partially correct 41 ms 1496 KB Output is partially correct
61 Partially correct 37 ms 776 KB Output is partially correct
62 Partially correct 40 ms 1416 KB Output is partially correct
63 Partially correct 37 ms 1392 KB Output is partially correct