QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#139176#6774. Ancient Machine 2Lynkcat#Compile Error//C++172.2kb2023-08-12 18:59:092024-07-04 01:39:58

Judging History

你现在查看的是最新测评结果

  • [2024-07-04 01:39:58]
  • 评测
  • [2023-08-12 18:59:09]
  • 提交

answer

#include<bits/stdc++.h>
#include "ancient2.h"
#define poly vector<int>
#define IOS ios::sync_with_stdio(false)
#define ll long long
#define mp make_pair
#define mt make_tuple
#define pa pair < int,int >
#define fi first
#define se second
#define inf 1e18
#define mod 998244353
#define sz(x) (int)((x).size())
//#define int ll
//#define N
using namespace std;
namespace 
{
    bitset<1005>f[1005],tmp;
    int n;
    int tot;
}
bool insbl(bitset<1005>now)
{
    for (int i=0;i<n;i++)
        if (now[i])
        {
            if (!f[i][i]) return 1;
            now^=f[i];
        }
    return 0;
}
void ins(bitset<1005>now)
{
    for (int i=0;i<n;i++)
        if (now[i])
        {
            if (!f[i][i]){
                f[i]=now;
                return;
            }
            now^=f[i];
        }
}
void qry(int x,int y)
{
    // for (int i=2;i*i<=x;i++)
    //     if (x%i==0) return;
    for (int i=0;i<=n;i++) tmp[i]=0;
    for (int i=0;i<n;i++)
        if (i%x==y) tmp[i]=1;
    if (!insbl(tmp)) return;
    ++tot;
    if (tot>1000) return;
    int m=x*2;
    vector<int>a(m,0),b(m,0);
    for (int i=0;i<x;i++)
        a[i]=(i+1)%x;
    for (int i=x;i<x+x;i++)
        a[i]=x+(i+1)%x;
    for (int i=0;i<x;i++)
        b[i]=(i+1)%x;
    for (int i=x;i<x+x;i++)
        b[i]=x+(i+1)%x;
    b[y]=x+(y+1)%x;
    b[x+y]=(y+1)%x;
    int o=Query(m,a,b);
    for (int i=0;i<=n;i++) tmp[i]=0;
    for (int i=0;i<n;i++)
        if (i%x==y) tmp[i]=1;
    if (o<x) tmp[n]=0;
    else tmp[n]=1;
    ins(tmp);
}
std::string Solve(int N)
{
    n=N;tot=0;
    for (int i=2;i<=100;i++)
    {
        for (int j=0;j<i;j++)
        {
            qry(i,j);
        }
    }
    // for (int i=0;i<n;i++)
    // {
    //     if (!f[i][i])
    //     {
    //         for (int j=i+1;j<n;j++)
    //             if (f[j][i]) 
    //             {swap(f[j],f[i]);break;
    //             }
    //     }
    //     for (int j=i+1;j<n;j++)
    //         if (f[j][i]) f[j]^=f[i];
    // }
    for (int i=n-1;i>=0;i--)
        for (int j=0;j<i;j++)
            if (f[j][i]) f[j]^=f[i];
    string ans="";
    for (int i=0;i<n;i++)
        ans+=char('0'+f[i][n]);
    return ans;
}

Details