QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#773997 | #9745. 递增序列 | bluejellyfish | WA | 4ms | 3612kb | C++23 | 1.3kb | 2024-11-23 11:11:29 | 2024-11-23 11:11:30 |
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;
}
}
auto dfs =[&] (auto self,int sum,int tot) -> int {
if(sum == -1 && tot >= 0) return 1;
if(sum == -1 && tot < 0) 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) == 1) {
ans += self(self,sum - 1,tot - (1 << sum));
int x = 1;
for(int i = sum - 1; ~i; i--) {
if(fg[i] == -1) x <<= 1;
}
ans += x;
}else ans += self(self,sum - 1,tot);
return ans;
};
cout << dfs(dfs,62,k) - 1<< endl;
}
signed main() {
ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int T = 1;
//cin >> T;
while(T--) miss();
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3524kb
input:
1 4 17 3 2 5 16
output:
4
result:
ok single line: '4'
Test #2:
score: -100
Wrong Answer
time: 4ms
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:
0
result:
wrong answer 1st lines differ - expected: '288230376151711744', found: '0'