QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#763400#9745. 递增序列tianxiawoyou#WA 33ms3716kbC++141.2kb2024-11-19 20:04:372024-11-19 20:04:38

Judging History

你现在查看的是最新测评结果

  • [2024-11-19 20:04:38]
  • 评测
  • 测评结果:WA
  • 用时:33ms
  • 内存:3716kb
  • [2024-11-19 20:04:37]
  • 提交

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]):1);
        else if(h[i][0]){as+=(i>=1?(1ll<<sum[i-1]):1);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: 3716kb

input:

1
4 17
3 2 5 16

output:

4

result:

ok single line: '4'

Test #2:

score: -100
Wrong Answer
time: 33ms
memory: 3616kb

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'