QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#588859 | #6774. Ancient Machine 2 | Kevin5307 | 0 | 0ms | 3816kb | C++20 | 1.7kb | 2024-09-25 14:56:56 | 2024-09-25 14:56:57 |
answer
//Author: Kevin
#include<bits/stdc++.h>
#include"ancient2.h"
//#pragma GCC optimize("O2")
using namespace std;
#define ll long long
#define ull unsigned ll
#define pb emplace_back
#define mp make_pair
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
#define srt(x) sort(ALL(x))
#define rev(x) reverse(ALL(x))
#define rsrt(x) sort(rALL(x))
#define sz(x) (int)(x.size())
#define inf 0x3f3f3f3f
#define pii pair<int,int>
#define lb(v,x) (int)(lower_bound(ALL(v),x)-v.begin())
#define ub(v,x) (int)(upper_bound(ALL(v),x)-v.begin())
#define uni(v) v.resize(unique(ALL(v))-v.begin())
#define longer __int128_t
void die(string S){puts(S.c_str());exit(0);}
const int n=1000;
bitset<1005> bs[1005],bs2[1005];
bool ins(bitset<1005> b)
{
for(int i=0;i<n;i++)
if(b[i])
{
if(!bs[i][i])
{
bs[i]=b;
return true;
}
b^=bs[i];
}
return false;
}
int query(int N,int x,int y)
{
int M=x*2;
vector<int> A(M),B(M);
for(int i=0;i<M;i++)
for(int j=0;j<2;j++)
{
A[i*2+j]=((i+1)%M*2+j);
if(i==y)
B[i*2+j]=((i+1)%M*2+1-j);
else
B[i*2+j]=((i+1)%M*2+j);
}
return Query(M,A,B)&1;
}
string Solve(int N)
{
int tot=0;
for(int i=1;i<=N&&tot<N;i++)
for(int j=0;j<i&&tot<N;j++)
{
bitset<1005> b;
for(int k=0;k<N;k++)
if(k%i==j)
b[k]=1;
if(ins(b))
{
bs2[++tot]=b;
bs2[tot][N]=query(N,i,j);
}
}
for(int i=0;i<N;i++)
{
if(!bs2[i][i])
{
for(int j=i+1;j<N;j++)
if(bs2[j][i])
{
swap(bs2[i],bs2[j]);
break;
}
}
for(int j=0;j<N;j++)
if(i!=j&&bs2[j][i])
bs2[j]^=bs2[i];
}
string ret;
for(int i=0;i<N;i++)
ret+=(char)('0'+bs2[i][N]);
return ret;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3816kb
input:
1000 -1
output:
6
result:
wrong answer Wrong Answer [6]