QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#763389 | #9745. 递增序列 | tianxiawoyou# | WA | 33ms | 3760kb | C++14 | 1.2kb | 2024-11-19 19:59:44 | 2024-11-19 19:59:44 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=1000005;
int t,n,a[N];
int h[65][2],sum[65],as,k;
signed main(){
// freopen("1.in","r",stdin);
cin.tie(0),cout.tie(0),ios::sync_with_stdio(0);
cin>>t;
while(t--){
cin>>n>>k;as=0;memset(h,0,sizeof(h));
memset(sum,0,sizeof(sum));
for(int i=1;i<=n;++i)cin>>a[i];
for(int o=1;o<n;++o){
int x=a[o],y=a[o+1],p,q;
for(int i=62;i>=0;--i){
if((1ll<<i)&x)p=1;else p=0;
if((1ll<<i)&y)q=1;else q=0;
if(p==q)continue;
if(p<q)h[i][0]=1;
else h[i][1]=1;
break;
}
}
for(int i=62;i>=0;--i)if(h[i][0]&&h[i][1])as=-1;
if(as==-1){puts("0");continue;}
sum[0]=(h[0][0]==0&&h[0][1]==0);
for(int i=1;i<=62;++i)sum[i]=sum[i-1]+(h[i][0]==0&&h[i][1]==0);
for(int i=62;i>=0;--i)if((1ll<<i)&k){
if(!h[i][0]&&!h[i][1])as+=(i>=1?(1ll<<sum[i-1]):0);
else if(h[i][0]){as+=(i>=1?(1ll<<sum[i-1]):0);break;}
}else{
if(h[i][1])break;
}
for(int i=1;i<=n;++i)a[i]^=k;int bj=1;
for(int i=2;i<=n;++i)if(a[i]<a[i-1])bj=0;
if(bj)++as;
cout<<as<<"\n";
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3600kb
input:
1 4 17 3 2 5 16
output:
4
result:
ok single line: '4'
Test #2:
score: -100
Wrong Answer
time: 33ms
memory: 3760kb
input:
36156 2 732025001343805266 563399128172323734 55283226774627822 7 388099190813067712 564150557919527813 457487771983557281 332055400678110195 760833651510929158 785768483273197875 690506113272551236 463276585748519124 2 798714574862593347 426890163990834364 434764725667883272 1 414708220571820990 42...
output:
288230376151711744 432345564227567616 414708220571820991 716398192192370637 1949654914769743 811009189367843523 0 114457959388827197 36028797018963968 0 91540211282631659 694703231769895639 144115188075855872 432345564227567616 65333152962117911 753346372609875093 18014398509481984 36458986449870805...
result:
wrong answer 2nd lines differ - expected: '0', found: '432345564227567616'