Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
35000 | LYLAKIOI | 【S】T3 | C++ | 通过 | 100 | 15 MS | 340 KB | 1506 | 2024-11-21 13:47:19 |
#include<bits/stdc++.h> #define up(i,l,r) for(int i=(l);i<=(r);++i) #define down(i,l,r) for(int i=(l);i>=(r);--i) #define pi pair<int,int> #define p1 first #define p2 second #define m_p make_pair #define p_b push_back typedef long long ll; using namespace std; const int mod=1e9+7; inline ll read(){ ll x=0;short t=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')t=-1;ch=getchar();} while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar(); return x*t; } int n;ll a[105],f[105][105]; struct node { ll t[70]; void init(ll x){ down(i,60,0)if((x>>(ll)i)&1){if(!t[i]){t[i]=x;break;}x^=t[i];} } ll calc(int p,ll x){ down(i,p,0)if((x>>(ll)i)&1)x^=t[i]; return x; } ll qry(ll L,ll x){ down(i,60,0)if(t[i]){ if((x>>i)&1){if(calc(i-1,x^t[i])>L)x^=t[i];} else {if(calc(i-1,x)<=L)x^=t[i];} }if(x>=L)return x; return 3e18; } }T; void slv(){ n=read();up(i,1,n)a[i]=read(); up(i,0,n)up(j,0,n)f[i][j]=3e18; f[0][0]=-1; up(i,1,n){ up(j,0,n){ f[i][j]=f[i-1][j]; if(j)f[i][j]=min(f[i][j],T.qry(f[i-1][j-1],a[i])); //printf("f[%d][%d]=%lld\n",i,j,f[i][j]); }T.init(a[i]); }down(i,n,0)if(f[n][i]<3e18){printf("%d\n",i);return;} } int main(){ //freopen("balala.in","r",stdin); //freopen("balala.out","w",stdout); slv(); fclose(stdin); fclose(stdout); return 0; }