Submission #897778

# Submission time Handle Problem Language Result Execution time Memory
897778 2024-01-03T16:33:18 Z AdamGS Ancient Machine 2 (JOI23_ancient2) C++17
98 / 100
38 ms 1104 KB
#include "ancient2.h"
#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
bitset<1001>B[1000];
bool dodaj(bitset<1001>T) {
  rep(i, 1000) if(T[i]) {
    if(!B[i][i]) {
      B[i]=T;
      return true;
    }
    T^=B[i];
  }
  return false;
}
char znajdz(int x) {
  bitset<1001>T;
  T[x]=1;
  rep(i, 1000) if(T[i]) T^=B[i];
  return T[1000]+'0';
}
string Solve(int n) {
  vector<pair<int,int>>baza;
  int ile=0;
  rep(i, 100) {
    bitset<1001>T;
    T[i]=1;
    if(dodaj(T)) ++ile;
  }
  for(int i=1; ile<1000; ++i) {
    rep(j, i) {
      bitset<1001>T;
      for(int p=j; p<1000; p+=i) T[p]=1;
      if(dodaj(T)) {
        baza.pb({i, j});
        ++ile;
      }
    }
  }
  rep(i, 1000) rep(j, 1001) B[i][j]=0;
  rep(i, 100) {
    vector<int>a(i+3), b(i+3);
    rep(j, i) a[j]=b[j]=j+1;
    a[i]=i+1;
    b[i]=i+2;
    a[i+1]=b[i+1]=i+1;
    a[i+2]=b[i+2]=i+2;
    bitset<1001>T;
    T[i]=1;
    if(Query(i+3, a, b)==i+2) T[1000]=1;
    dodaj(T);
  }
  for(auto i : baza) {
    vector<int>a(2*i.st), b(2*i.st);
    rep(j, i.st) {
      a[j]=b[j]=(j+1)%i.st;
      a[j+i.st]=b[j+i.st]=(j+1)%i.st+i.st;
      if(j==i.nd) {
        b[j]+=i.st;
        b[j+i.st]-=i.st;
      }
    }
    bitset<1001>T;
    for(int p=i.nd; p<1000; p+=i.st) T[p]=1;
    if(Query(2*i.st, a, b)>=i.st) T[1000]=1;
    dodaj(T);
  }
  string ans="";
  rep(i, 1000) ans+=znajdz(i);
  return ans;
}
# Verdict Execution time Memory Grader output
1 Partially correct 31 ms 856 KB Output is partially correct
2 Partially correct 32 ms 844 KB Output is partially correct
3 Partially correct 32 ms 864 KB Output is partially correct
4 Partially correct 31 ms 868 KB Output is partially correct
5 Partially correct 30 ms 860 KB Output is partially correct
6 Partially correct 31 ms 828 KB Output is partially correct
7 Partially correct 31 ms 836 KB Output is partially correct
8 Partially correct 34 ms 840 KB Output is partially correct
9 Partially correct 33 ms 580 KB Output is partially correct
10 Partially correct 31 ms 820 KB Output is partially correct
11 Partially correct 33 ms 864 KB Output is partially correct
12 Partially correct 36 ms 584 KB Output is partially correct
13 Partially correct 32 ms 840 KB Output is partially correct
14 Partially correct 31 ms 608 KB Output is partially correct
15 Partially correct 30 ms 832 KB Output is partially correct
16 Partially correct 38 ms 824 KB Output is partially correct
17 Partially correct 31 ms 612 KB Output is partially correct
18 Partially correct 31 ms 612 KB Output is partially correct
19 Partially correct 31 ms 860 KB Output is partially correct
20 Partially correct 32 ms 604 KB Output is partially correct
21 Partially correct 33 ms 608 KB Output is partially correct
22 Partially correct 32 ms 608 KB Output is partially correct
23 Partially correct 31 ms 852 KB Output is partially correct
24 Partially correct 31 ms 824 KB Output is partially correct
25 Partially correct 31 ms 856 KB Output is partially correct
26 Partially correct 31 ms 616 KB Output is partially correct
27 Partially correct 30 ms 860 KB Output is partially correct
28 Partially correct 31 ms 836 KB Output is partially correct
29 Partially correct 30 ms 580 KB Output is partially correct
30 Partially correct 31 ms 820 KB Output is partially correct
31 Partially correct 32 ms 864 KB Output is partially correct
32 Partially correct 33 ms 1080 KB Output is partially correct
33 Partially correct 32 ms 836 KB Output is partially correct
34 Partially correct 30 ms 828 KB Output is partially correct
35 Partially correct 30 ms 592 KB Output is partially correct
36 Partially correct 30 ms 856 KB Output is partially correct
37 Partially correct 31 ms 580 KB Output is partially correct
38 Partially correct 32 ms 864 KB Output is partially correct
39 Partially correct 30 ms 608 KB Output is partially correct
40 Partially correct 31 ms 856 KB Output is partially correct
41 Partially correct 31 ms 832 KB Output is partially correct
42 Partially correct 32 ms 816 KB Output is partially correct
43 Partially correct 32 ms 584 KB Output is partially correct
44 Partially correct 30 ms 812 KB Output is partially correct
45 Partially correct 31 ms 828 KB Output is partially correct
46 Partially correct 31 ms 584 KB Output is partially correct
47 Partially correct 31 ms 1104 KB Output is partially correct
48 Partially correct 31 ms 840 KB Output is partially correct
49 Partially correct 37 ms 836 KB Output is partially correct
50 Partially correct 31 ms 836 KB Output is partially correct
51 Partially correct 31 ms 612 KB Output is partially correct
52 Partially correct 32 ms 612 KB Output is partially correct
53 Partially correct 31 ms 612 KB Output is partially correct
54 Partially correct 31 ms 832 KB Output is partially correct
55 Partially correct 31 ms 836 KB Output is partially correct
56 Partially correct 34 ms 612 KB Output is partially correct
57 Partially correct 34 ms 868 KB Output is partially correct
58 Partially correct 31 ms 612 KB Output is partially correct
59 Partially correct 31 ms 584 KB Output is partially correct
60 Partially correct 34 ms 836 KB Output is partially correct
61 Partially correct 36 ms 868 KB Output is partially correct
62 Partially correct 31 ms 864 KB Output is partially correct
63 Partially correct 31 ms 612 KB Output is partially correct