Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
27916 liuyile 【BJ】T2 C++ 运行超时 55 1000 MS 2224 KB 1443 2024-03-31 14:13:20

Tests(11/20):


#include <bits/stdc++.h> using namespace std; #define int long long #define double long double #define endl "\n" #define pii pair<int,int> #define p1(x) x.first #define p2(x) x.second int n,q; int a[50030]; pii Sl[50030],Sr[500300]; int tpl,tpr; inline void insl(int x){Sl[tpl+1]={x,p2(Sl[tpl])|x};tpl++;} inline void insr(int x){Sr[tpr+1]={x,p2(Sr[tpr])|x};tpr++;} inline void sp(){ if(tpl)return ; while(tpr) insl(p1(Sr[tpr--])); } signed main(){ ios::sync_with_stdio(0); // freopen("beaco.in","r",stdin); // freopen("beaco.out","w",stdout); cin>>n>>q; for(int i=1;i<=n;i++)cin>>a[i]; a[n+1]=(1ll<<31)-1; while(q--){ int op; cin>>op; if(op==1){ int x,y; cin>>x>>y; a[x]=y; } else{ int k=0; cin>>k; int r=0; int res=-1; Sl[tpl=0]={0,0}; insl(0); Sr[tpr=0]={0,0}; for(int i=1;i<=n;i++){ sp(); --tpl; while((p2(Sl[tpl])|p2(Sr[tpr]))<k)insr(a[++r]); // cout<<i<<" "<<r<<" "<<p2(Sl[tpl])<<" "<<p2(Sr[tpr])<<"xx"; if(r>n)break; int w=tpl+tpr; if(res==-1||w<res)res=w; } cout<<res<<endl; } } cout.flush(); return 0; }


测评信息: