Submission #830185

# Submission time Handle Problem Language Result Execution time Memory
830185 2023-08-18T23:17:54 Z ikaurov Ancient Machine 2 (JOI23_ancient2) C++17
97 / 100
41 ms 696 KB
#include "ancient2.h"
#include <bits/stdc++.h>
using namespace std;
#define all(arr) (arr).begin(), (arr).end()
#define ll long long
#define ld long double
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define endl '\n'

const int N = 1000;

bitset<N> basisx[N], basisy[N];
bool res[N], val[N];
vector<pair<int, int>> pairs;

void try_add(int q, int p){
  bitset<N> curx, cury;
  for (int i = q; i < N; i += p) curx.set(i);
  for (int i = N - 1; i >= 0; i--){
    if (!curx.test(i)) continue;
    if (!basisx[i].any()){
      cury.set(sz(pairs));
      pairs.pb({q, p});
      basisx[i] = curx, basisy[i] = cury;
      return;
    }
    curx ^= basisx[i], cury ^= basisy[i];
  }
}

void precalc(){
  for (int p = 1;; p++){
    for (int q = 0; q < p; q++){
      try_add(q, p);
      if (sz(pairs) == N) return;
    }
  }
}

std::string Solve(int n) {
  precalc();
  for (int i = 0; i < N; i++){
    auto [q, p] = pairs[i];
    vector<int> a(2 * p), b(2 * p);
    iota(all(a), 1);
    iota(all(b), 1);
    a[p - 1] = 0, a[2 * p - 1] = p;
    b[p - 1] = 0, b[2 * p - 1] = p;
    b[q] = p + (q + 1) % p, b[p + q] = (q + 1) % p;
    res[i] = (Query(2 * p, a, b) >= p);
  }
  string ans;
  for (int i = 0; i < n; i++){
    for (int j = 0; j < N; j++){
      if (basisy[i].test(j)) val[i] ^= res[j];
      if (j < i && basisx[i].test(j)) val[i] ^= val[j];
    }
    ans.pb('0' + val[i]);
  }
  return ans;
}
# Verdict Execution time Memory Grader output
1 Partially correct 37 ms 556 KB Output is partially correct
2 Partially correct 34 ms 696 KB Output is partially correct
3 Partially correct 31 ms 568 KB Output is partially correct
4 Partially correct 34 ms 568 KB Output is partially correct
5 Partially correct 33 ms 464 KB Output is partially correct
6 Partially correct 33 ms 560 KB Output is partially correct
7 Partially correct 37 ms 556 KB Output is partially correct
8 Partially correct 38 ms 568 KB Output is partially correct
9 Partially correct 33 ms 572 KB Output is partially correct
10 Partially correct 33 ms 564 KB Output is partially correct
11 Partially correct 35 ms 556 KB Output is partially correct
12 Partially correct 30 ms 572 KB Output is partially correct
13 Partially correct 28 ms 572 KB Output is partially correct
14 Partially correct 35 ms 568 KB Output is partially correct
15 Partially correct 35 ms 584 KB Output is partially correct
16 Partially correct 37 ms 564 KB Output is partially correct
17 Partially correct 27 ms 568 KB Output is partially correct
18 Partially correct 33 ms 572 KB Output is partially correct
19 Partially correct 30 ms 464 KB Output is partially correct
20 Partially correct 36 ms 560 KB Output is partially correct
21 Partially correct 28 ms 568 KB Output is partially correct
22 Partially correct 33 ms 568 KB Output is partially correct
23 Partially correct 33 ms 464 KB Output is partially correct
24 Partially correct 36 ms 564 KB Output is partially correct
25 Partially correct 32 ms 468 KB Output is partially correct
26 Partially correct 33 ms 564 KB Output is partially correct
27 Partially correct 33 ms 564 KB Output is partially correct
28 Partially correct 33 ms 568 KB Output is partially correct
29 Partially correct 28 ms 580 KB Output is partially correct
30 Partially correct 38 ms 568 KB Output is partially correct
31 Partially correct 32 ms 572 KB Output is partially correct
32 Partially correct 41 ms 572 KB Output is partially correct
33 Partially correct 31 ms 564 KB Output is partially correct
34 Partially correct 33 ms 464 KB Output is partially correct
35 Partially correct 33 ms 696 KB Output is partially correct
36 Partially correct 30 ms 576 KB Output is partially correct
37 Partially correct 35 ms 548 KB Output is partially correct
38 Partially correct 33 ms 572 KB Output is partially correct
39 Partially correct 34 ms 564 KB Output is partially correct
40 Partially correct 38 ms 464 KB Output is partially correct
41 Partially correct 38 ms 680 KB Output is partially correct
42 Partially correct 33 ms 560 KB Output is partially correct
43 Partially correct 30 ms 564 KB Output is partially correct
44 Partially correct 34 ms 564 KB Output is partially correct
45 Partially correct 37 ms 496 KB Output is partially correct
46 Partially correct 31 ms 576 KB Output is partially correct
47 Partially correct 37 ms 580 KB Output is partially correct
48 Partially correct 33 ms 584 KB Output is partially correct
49 Partially correct 38 ms 464 KB Output is partially correct
50 Partially correct 33 ms 592 KB Output is partially correct
51 Partially correct 37 ms 564 KB Output is partially correct
52 Partially correct 38 ms 560 KB Output is partially correct
53 Partially correct 38 ms 568 KB Output is partially correct
54 Partially correct 32 ms 684 KB Output is partially correct
55 Partially correct 31 ms 576 KB Output is partially correct
56 Partially correct 32 ms 568 KB Output is partially correct
57 Partially correct 30 ms 568 KB Output is partially correct
58 Partially correct 29 ms 560 KB Output is partially correct
59 Partially correct 33 ms 568 KB Output is partially correct
60 Partially correct 36 ms 572 KB Output is partially correct
61 Partially correct 29 ms 572 KB Output is partially correct
62 Partially correct 27 ms 584 KB Output is partially correct
63 Partially correct 33 ms 572 KB Output is partially correct