QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#774176 | #9745. 递增序列 | bluejellyfish | WA | 58ms | 3588kb | C++23 | 1.5kb | 2024-11-23 12:15:28 | 2024-11-23 12:15:28 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>
#define x first
#define y second
const int mod = 1e9 + 7;
void miss() {
int n,k;
cin >> n >> k;
vector<int>ai(n + 1),fg(66,-1);
for(int i = 1; i <= n; i++) {
cin >> ai[i];
}
auto check =[&] (int qwq,int qaq) -> bool {
for(int i = 62; ~i; i--) {
if((((qwq >> i) & 1) != ((qaq >> i) & 1))) {
if((qwq >> i) & 1) {
if(fg[i] == 1) return 0;
else fg[i] = 0;
}else {
if(!fg[i]) return 0;
else fg[i] = 1;
}
return 1;
}
}
};
for(int i = 2; i <= n; i++) {
if(!check(ai[i],ai[i - 1])) {
cout << "0\n";
return;
}
}
// int x = 268435454;
// while(x) {
// if(x & 1) cout << 1;
// else cout << 0;
// x >>= 1;
// }
//for(int i = 1; i >= 0; i--) cout << fg[i] << " ";
auto dfs =[&] (auto self,int sum,int tot) -> int {
if(sum == -1 && tot >= 0) return 1;
if(sum == -1) return 0;
int ans = 0;
if(fg[sum] == 1 ) {
ans += self(self,sum - 1,tot - (1 << sum));
}else if(fg[sum] == -1 && ((tot >> (sum + 1))) != 0) {
ans += self(self,sum - 1,tot - (1 << sum));
int x = 1;
for(int i = sum - 1; i >= 0; i--) {
if(fg[i] == -1) x <<= 1;
}
ans += x;
}else ans += self(self,sum - 1,tot);
return ans;
};
cout << dfs(dfs,62,k)<< endl;
}
signed main() {
ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int T = 1;
cin >> T;
while(T--) miss();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3480kb
input:
1 4 17 3 2 5 16
output:
4
result:
ok single line: '4'
Test #2:
score: -100
Wrong Answer
time: 58ms
memory: 3588kb
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 288230376151711744 288230376151711744 576460752303423488 0 576460752303423488 0 0 0 576460752303423488 0 0 288230376151711744 144115188075855872 72057594037927936 144115188075855872 0 72057594037927936 0 576460752303423488 144115188075855872 0 0 0 0 288230376151711744 7205759403...
result:
wrong answer 3rd lines differ - expected: '432345564227567616', found: '288230376151711744'