답안 #900054

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
900054 2024-01-07T14:06:26 Z weajink Ancient Machine 2 (JOI23_ancient2) C++17
98 / 100
35 ms 2024 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";
	}
}
void stworz_automat2(int k){
	bitset<M> wy;
	wy[k] = 1;
	vector<int> A,B;
	for (int i = 0; i < k; i++){
		A.push_back(i+1);
		B.push_back(i+1);
	}
	A.push_back(k+1);
	B.push_back(k+2);
	A.push_back(k+1);
	B.push_back(k+1);
	A.push_back(k+2);
	B.push_back(k+2);
	wy[M-1] = (Query(k+3,A,B) > k+1);
	gauss(wy);
}
string Solve(int n){
	for (int i = 0; i < 99; i++) stworz_automat2(i);
	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;
}
# 결과 실행 시간 메모리 Grader output
1 Partially correct 30 ms 1520 KB Output is partially correct
2 Partially correct 29 ms 1296 KB Output is partially correct
3 Partially correct 29 ms 1440 KB Output is partially correct
4 Partially correct 29 ms 968 KB Output is partially correct
5 Partially correct 30 ms 1772 KB Output is partially correct
6 Partially correct 30 ms 1016 KB Output is partially correct
7 Partially correct 31 ms 1520 KB Output is partially correct
8 Partially correct 33 ms 1996 KB Output is partially correct
9 Partially correct 29 ms 1260 KB Output is partially correct
10 Partially correct 30 ms 1516 KB Output is partially correct
11 Partially correct 31 ms 1248 KB Output is partially correct
12 Partially correct 33 ms 1372 KB Output is partially correct
13 Partially correct 29 ms 1228 KB Output is partially correct
14 Partially correct 29 ms 1256 KB Output is partially correct
15 Partially correct 29 ms 1068 KB Output is partially correct
16 Partially correct 29 ms 972 KB Output is partially correct
17 Partially correct 29 ms 1476 KB Output is partially correct
18 Partially correct 29 ms 1528 KB Output is partially correct
19 Partially correct 29 ms 884 KB Output is partially correct
20 Partially correct 32 ms 1512 KB Output is partially correct
21 Partially correct 30 ms 1244 KB Output is partially correct
22 Partially correct 32 ms 1528 KB Output is partially correct
23 Partially correct 29 ms 1528 KB Output is partially correct
24 Partially correct 29 ms 964 KB Output is partially correct
25 Partially correct 29 ms 812 KB Output is partially correct
26 Partially correct 35 ms 1544 KB Output is partially correct
27 Partially correct 30 ms 1752 KB Output is partially correct
28 Partially correct 31 ms 1260 KB Output is partially correct
29 Partially correct 31 ms 1244 KB Output is partially correct
30 Partially correct 29 ms 1468 KB Output is partially correct
31 Partially correct 31 ms 968 KB Output is partially correct
32 Partially correct 32 ms 1260 KB Output is partially correct
33 Partially correct 31 ms 1500 KB Output is partially correct
34 Partially correct 29 ms 1032 KB Output is partially correct
35 Partially correct 34 ms 1544 KB Output is partially correct
36 Partially correct 32 ms 1528 KB Output is partially correct
37 Partially correct 32 ms 1736 KB Output is partially correct
38 Partially correct 31 ms 1780 KB Output is partially correct
39 Partially correct 29 ms 1228 KB Output is partially correct
40 Partially correct 29 ms 784 KB Output is partially correct
41 Partially correct 31 ms 1020 KB Output is partially correct
42 Partially correct 30 ms 1532 KB Output is partially correct
43 Partially correct 29 ms 1724 KB Output is partially correct
44 Partially correct 30 ms 1216 KB Output is partially correct
45 Partially correct 30 ms 1536 KB Output is partially correct
46 Partially correct 31 ms 1672 KB Output is partially correct
47 Partially correct 29 ms 1220 KB Output is partially correct
48 Partially correct 29 ms 1280 KB Output is partially correct
49 Partially correct 33 ms 2024 KB Output is partially correct
50 Partially correct 31 ms 1280 KB Output is partially correct
51 Partially correct 31 ms 1540 KB Output is partially correct
52 Partially correct 32 ms 1680 KB Output is partially correct
53 Partially correct 29 ms 1028 KB Output is partially correct
54 Partially correct 30 ms 1736 KB Output is partially correct
55 Partially correct 32 ms 1544 KB Output is partially correct
56 Partially correct 29 ms 1500 KB Output is partially correct
57 Partially correct 29 ms 1076 KB Output is partially correct
58 Partially correct 29 ms 984 KB Output is partially correct
59 Partially correct 29 ms 980 KB Output is partially correct
60 Partially correct 29 ms 1232 KB Output is partially correct
61 Partially correct 29 ms 792 KB Output is partially correct
62 Partially correct 30 ms 984 KB Output is partially correct
63 Partially correct 32 ms 1788 KB Output is partially correct