QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#763483 | #9745. 递增序列 | UESTC_NLNS# | WA | 28ms | 3660kb | C++17 | 1.5kb | 2024-11-19 20:34:17 | 2024-11-19 20:34:17 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ldb = long double;
using ll = long long;
vector<int> k(64);
vector<ll> a;
int f = 1;
ll k_mx;
ll cnt(int bit,bool limit){
if(bit==-1)return 1;
if(!limit){
ll ans = 1;
for(int i = 0;i<=bit;++i){if(k[i]==2)ans*=2;};
// cout << bit << ":" << limit << ':' << ans << '\n';
return ans;
}
int tmp = k_mx >> bit & 1;
int v0 = 1,v1 = 1;
ll ans = 0;
v1 &= k[bit]!=0 && tmp==1;
v0 &= k[bit]!=1;
if(v1) ans += cnt(bit-1,1);
if(v0) ans += cnt(bit-1,tmp ? 0:1);
// cout<<bit<<":"<<limit<<':'<<ans<<'\n';
return ans;
}
void update(int l,int r,int bit){
if(f==0)return;
if(l==r) return;
if(bit == -1)return;
int tmp = 0;
for(int i = l + 1;i<=r;++i){
if((a[i-1]>>bit&1)!=(a[i]>>bit&1)){
tmp = 1;
int v = a[i-1] >> bit & 1;
if(k[bit] == 2){k[bit]=v;}
else if(k[bit]!=v){f=0;return;}
update(l,i-1,bit-1);
update(i,r,bit-1);
}
}
if(tmp==0)update(l,r,bit-1);
}
void solve() {
k.assign(64,2);
a.clear();
ll n;
cin>>n>>k_mx;
a.resize(n);
for(int i = 0;i<n;++i)cin>>a[i];
update(0,n-1,63);
if(f==0)cout<<0<<'\n';
else cout<<cnt(63,1)<<"\n";
}
int main() {
cin.tie(0), cout.tie(0), ios::sync_with_stdio(0);
int t;
cin >> t;
while (t--) solve();
}
/*
1
4 63
3 2 5 16
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3568kb
input:
1 4 17 3 2 5 16
output:
4
result:
ok single line: '4'
Test #2:
score: -100
Wrong Answer
time: 28ms
memory: 3660kb
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 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 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 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...
result:
wrong answer 3rd lines differ - expected: '432345564227567616', found: '0'