QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#751960 | #9745. 递增序列 | doyo | WA | 28ms | 5708kb | C++20 | 1.2kb | 2024-11-15 21:25:09 | 2024-11-15 21:25:10 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,j,k) for(int i=j;i<=k;++i)
#define For(i,j,k) for(int i=j;i>=k;--i)
const int N = 2e5 + 111;
int a[N];
int son[N*60][2];
int d[65];
void sol(){
int n,m;
cin>>n>>m;
FOR(i,1,n) cin>>a[i];
int up = 60;
FOR(i,0,up) d[i]=-1;
int rt = 0;
int cnt = 0;
For(i,n,1){
int now = rt;
For(k,60,0){
int val = 0;
if(a[i]&(1ll<<k)) val = 1;
if(son[now][val^1]){
if(d[k]==-1){
d[k] = val;
}
else{
if(d[k]!=val){
return cout<<0<<'\n',void();
}
}
}
if(!son[now][val]) son[now][val] = ++cnt;
now = son[now][val];
}
}
int ans = 0;
For(k,up,-1){
if(k==-1){
++ans;
}
if(m&(1ll<<k)){
if(d[k]==-1){
int ccnt = 0;
For(j,k-1,0) if(d[j]==-1) ++ccnt;
ans += (1ll<<ccnt);
}
if(d[k]==0){
int ccnt = 0;
For(j,k-1,0) if(d[j]==-1) ++ccnt;
ans += (1ll<<ccnt);
break;
}
}
else{
if(d[k]==1){
break;
}
}
}
FOR(i,0,cnt) son[i][0] = son[i][1] = 0;
cout<<ans<<'\n';
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t;
cin>>t;
while(t--){
sol();
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 5696kb
input:
1 4 17 3 2 5 16
output:
4
result:
ok single line: '4'
Test #2:
score: -100
Wrong Answer
time: 28ms
memory: 5708kb
input:
36156 2 732025001343805266 563399128172323734 55283226774627822 7 388099190813067712 564150557919527813 457487771983557281 332055400678110195 760833651510929158 785768483273197875 690506113272551236 463276585748519124 2 798714574862593347 426890163990834364 434764725667883272 1 414708220571820990 42...
output:
288230376151711744 0 0 32 10 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0...
result:
wrong answer 3rd lines differ - expected: '432345564227567616', found: '0'