Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
36205 | hshh | 【S】T1 | C++ | 运行超时 | 8 | 4000 MS | 8060 KB | 1091 | 2025-02-10 13:12:23 |
#include<bits/stdc++.h> using namespace std; long long x[1000010],a,b,m,m1; int n,q; string a1,x1,x2; bool l; long long find(string x,string y){ long long s=max(x.length(),y.length()); long long q,qq=0; while(s>0){ if(x[s-1]==y[s-1]){ q=0; } else{ q=1; } qq=qq*2+q; s--; } return qq; } string g(long long n){ if(n==0) return "0"; string h= ""; while(n > 0){ h+=(n&1)?'1':'0'; n>>=1; } reverse(h.begin(),h.end()); return h; } int main(){ cin>>n>>q; for(int i=1;i<=n;i++){ cin>>x[i]; } for(int j=1;j<=q;j++){ cin>>a>>b; l=0; for(int i=1;i<n;i++){ a1=g(a); x1=g(x[i]); m=find(a1,x1)-b; x2=g(x[i+1]); m1=find(x2,a1)-b; if(m*m1<=0){ cout<<i<<endl; l=1; break; } } if(l==0) cout<<"-1"<<endl; } return 0; }