QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#763423 | #9745. 递增序列 | tianxiawoyou# | WA | 36ms | 3660kb | C++14 | 1.1kb | 2024-11-19 20:12:10 | 2024-11-19 20:12:12 |
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));++k;
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]):1);
else if(h[i][0]){as+=((i>=1)?(1ll<<sum[i-1]):1);break;}
}else{
if(h[i][1])break;
}
cout<<as<<"\n";
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3660kb
input:
1 4 17 3 2 5 16
output:
4
result:
ok single line: '4'
Test #2:
score: -100
Wrong Answer
time: 36ms
memory: 3612kb
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 716398192192370638 1949654914769744 811009189367843523 0 114457959388827198 36028797018963968 0 91540211282631659 694703231769895640 144115188075855872 432345564227567616 65333152962117911 753346372609875093 18014398509481984 36458986449870805...
result:
wrong answer 2nd lines differ - expected: '0', found: '432345564227567616'