# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
815294 | 2023-08-08T14:01:07 Z | minhcool | Ancient Machine 2 (JOI23_ancient2) | C++17 | 39 ms | 624 KB |
//#define local #ifndef local #include "ancient2.h" #endif #include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; using namespace std; //#define int long long #define fi first #define se second #define pb push_back #define mp make_pair typedef pair<int, int> ii; typedef pair<ii, int> iii; typedef pair<ii, ii> iiii; const int N = 3e5 + 5; const int oo = 1e18 + 7, mod = 1e9 + 7; mt19937 rng(1); int rnd(int l, int r){ int temp = rng() % (r - l + 1); return abs(temp) + l; } int n; bitset<1005> basis[1005]; bool vis[1005]; bool ck[1005]; string cor; #ifdef local int Query(int m, vector<int> a, vector<int> b){ int itr = 0; for(int i = 0; i < 1000; i++){ if(cor[i] == '0') itr = a[itr]; else itr = b[itr]; //if(itr == 100) cout << itr << "\n"; } } #endif bool ckk(int p, int q){ assert(p > q); int m = 2 * p; vector<int> vc1(m), vc2(m); for(int i = 0; i < m; i++) vc1[i] = i + 1; vc1[2 * p - 1] = p, vc1[p - 1] = 0; vc2 = vc1; vc2[q] += p, vc2[q + p] -= p; //for(auto it : vc1) assert(it >= 0 && it < m); //for(auto it : vc2) assert(it >= 0 && it < m); int temp = Query(m, vc1, vc2); return (temp >= p); } int in(bitset<1005> bts){ bool temp = 0; for(int i = 0; i < 1000; i++){ if(!bts[i]) continue; if(!vis[i]){ vis[i] = 1; ck[i] = temp; basis[i] = bts; return i; } bts ^= basis[i]; temp ^= ck[i]; } return -1; } int cal(bitset<1005> bts){ bool ans = 0; for(int i = 0; i < 1000; i++){ if(!bts[i]) continue; bts ^= basis[i]; ans ^= ck[i]; } assert(ans == 0 || ans == 1); return ans; } string s; string Solve(int N){ n = N; s.resize(n); int p = 55; for(int itr = 0; itr < 100; itr++){ vector<int> a(itr + 3), b(itr + 3); for(int i = 0; i < itr; i++) a[i] = b[i] = i + 1; a[itr] = itr + 1; b[itr] = itr + 2; a[itr + 1] = b[itr + 1] = itr + 1; a[itr + 2] = b[itr + 2] = itr + 2; int temp = Query(itr + 3, a, b); if(temp == itr + 1) s[itr] = '0'; else s[itr] = '1'; } //return ""; /* for(int itr = 100; itr < 200; itr++){ vector<int> a(101), b(101); for(int i = 0; i < 99; i++) a[i] = b[i] = i + 1; a[99] = b[99] = 0; if(s[itr - 100] == '0') b[itr - 100] = 100; else a[itr - 100] = 100; a[100] = b[100] = 100; int temp = Query(101, a, b); cout << itr << " " << temp << "\n"; if(temp == 100) s[itr] = char(97 - s[itr - 100]); else s[itr] = s[itr - 100]; }*/ //return ""; for(int itr = 0; itr < 100; itr++){ bitset<1005> bts; for(int i = 0; i <= 1000; i++) bts[i] = 0; bts[itr] = 1; int pos = in(bts); if(pos < 0) continue; if(s[itr] == '1') ck[itr] ^= 1; } //return ""; int cnt = 0; for(int l = 1; l <= 55; l++){ for(int r = 0; r < l; r++){ bitset<1005> bts; for(int i = 0; i <= 1000; i++) bts[i] = 0; for(int i = r; i <= 1000; i += l) bts[i] = 1; int temp = in(bts); if(temp < 0) continue; //cout << l << " " << r << "\n"; cnt++; bool temp2 = ckk(l, r); ck[temp] ^= temp2; if(cnt == 900) break; } // cout << l << " " << cnt << "\n"; if(cnt == 900) break; } //cout << cnt << "\n"; for(int i = 100; i < 1000; i++){ bitset<1005> bts; bts[i] = 1; s[i] = char(48 + cal(bts)); } //for(int i = 0; i < 200; i++) assert(s[i] >= '0' && s[i] <= '1'); return s; } #ifdef local void process(){ cor = "1111111111111010101111111111111111111100000000001111010101010010000000001111110000000001000000011110011111111000111111111101101000000111111111010101010101111111111010101010111111111101010100000000000101010111111111111100000000000000011110111111110111111100000100000000000011100000000000000000000000000000111111010000000001010101000000000000000010101111111111111000000010000000001000000001010101010101000000011111110101010101101010100000000010101011111111111111100000000000000111110101010010101010000000101111111111111111111100001010101111111111111111011111111111010101010101111111111101010101010101010111111111110000000000101011000000011111111101111100000000000000000000000111111100000000011111111110000111111100000000000000000010101010100000000001010100010101011111111111111111101010101010000110100010101001111111111110101000000000000000000000000000000011111111111100001111111101010101010000011111111111000111111100000000011111111111100111111100000000101001011010101111111100000101010101000000000000"; cout << cor.substr(100) << "\n"; cout << Solve(1000).substr(100) << "\n"; } signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); process(); } #endif
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Partially correct | 31 ms | 428 KB | Output is partially correct |
2 | Partially correct | 29 ms | 384 KB | Output is partially correct |
3 | Partially correct | 29 ms | 384 KB | Output is partially correct |
4 | Partially correct | 30 ms | 372 KB | Output is partially correct |
5 | Partially correct | 28 ms | 392 KB | Output is partially correct |
6 | Partially correct | 31 ms | 400 KB | Output is partially correct |
7 | Partially correct | 33 ms | 612 KB | Output is partially correct |
8 | Partially correct | 29 ms | 336 KB | Output is partially correct |
9 | Partially correct | 29 ms | 392 KB | Output is partially correct |
10 | Partially correct | 30 ms | 396 KB | Output is partially correct |
11 | Partially correct | 30 ms | 380 KB | Output is partially correct |
12 | Partially correct | 30 ms | 388 KB | Output is partially correct |
13 | Partially correct | 30 ms | 412 KB | Output is partially correct |
14 | Partially correct | 30 ms | 384 KB | Output is partially correct |
15 | Partially correct | 38 ms | 336 KB | Output is partially correct |
16 | Partially correct | 30 ms | 388 KB | Output is partially correct |
17 | Partially correct | 38 ms | 360 KB | Output is partially correct |
18 | Partially correct | 39 ms | 352 KB | Output is partially correct |
19 | Partially correct | 30 ms | 336 KB | Output is partially correct |
20 | Partially correct | 30 ms | 436 KB | Output is partially correct |
21 | Partially correct | 39 ms | 456 KB | Output is partially correct |
22 | Partially correct | 29 ms | 388 KB | Output is partially correct |
23 | Partially correct | 30 ms | 336 KB | Output is partially correct |
24 | Partially correct | 30 ms | 424 KB | Output is partially correct |
25 | Partially correct | 39 ms | 392 KB | Output is partially correct |
26 | Partially correct | 35 ms | 396 KB | Output is partially correct |
27 | Partially correct | 30 ms | 420 KB | Output is partially correct |
28 | Partially correct | 29 ms | 384 KB | Output is partially correct |
29 | Partially correct | 30 ms | 424 KB | Output is partially correct |
30 | Partially correct | 29 ms | 424 KB | Output is partially correct |
31 | Partially correct | 33 ms | 388 KB | Output is partially correct |
32 | Partially correct | 30 ms | 336 KB | Output is partially correct |
33 | Partially correct | 29 ms | 400 KB | Output is partially correct |
34 | Partially correct | 30 ms | 336 KB | Output is partially correct |
35 | Partially correct | 39 ms | 384 KB | Output is partially correct |
36 | Partially correct | 28 ms | 428 KB | Output is partially correct |
37 | Partially correct | 29 ms | 384 KB | Output is partially correct |
38 | Partially correct | 29 ms | 420 KB | Output is partially correct |
39 | Partially correct | 30 ms | 416 KB | Output is partially correct |
40 | Partially correct | 30 ms | 432 KB | Output is partially correct |
41 | Partially correct | 30 ms | 352 KB | Output is partially correct |
42 | Partially correct | 35 ms | 404 KB | Output is partially correct |
43 | Partially correct | 29 ms | 348 KB | Output is partially correct |
44 | Partially correct | 29 ms | 376 KB | Output is partially correct |
45 | Partially correct | 35 ms | 504 KB | Output is partially correct |
46 | Partially correct | 33 ms | 424 KB | Output is partially correct |
47 | Partially correct | 29 ms | 400 KB | Output is partially correct |
48 | Partially correct | 26 ms | 448 KB | Output is partially correct |
49 | Partially correct | 29 ms | 432 KB | Output is partially correct |
50 | Partially correct | 31 ms | 424 KB | Output is partially correct |
51 | Partially correct | 30 ms | 376 KB | Output is partially correct |
52 | Partially correct | 29 ms | 384 KB | Output is partially correct |
53 | Partially correct | 34 ms | 364 KB | Output is partially correct |
54 | Partially correct | 34 ms | 420 KB | Output is partially correct |
55 | Partially correct | 29 ms | 408 KB | Output is partially correct |
56 | Partially correct | 30 ms | 372 KB | Output is partially correct |
57 | Partially correct | 33 ms | 624 KB | Output is partially correct |
58 | Partially correct | 36 ms | 384 KB | Output is partially correct |
59 | Partially correct | 29 ms | 500 KB | Output is partially correct |
60 | Partially correct | 29 ms | 336 KB | Output is partially correct |
61 | Partially correct | 35 ms | 364 KB | Output is partially correct |
62 | Partially correct | 29 ms | 416 KB | Output is partially correct |
63 | Partially correct | 30 ms | 384 KB | Output is partially correct |