QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#758576 | #9745. 递增序列 | fstqwq# | WA | 521ms | 3628kb | C++20 | 2.1kb | 2024-11-17 18:53:14 | 2024-11-17 18:53:14 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 5;
void work() {
int n; LL k;
cin >> n >> k;
vector <LL> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
LL mask = 0, yes = 0;
vector < vector <LL> > segments = {a};
for (int i = 61; i >= 0; i--) {
vector < vector <LL> > ns;
bool must = 0;
LL val = 0;
for (auto &s : segments) {
vector <LL> s0, s1;
LL pref = (s[0] >> i) & 1;
for (auto x : s) {
if (x >> i & 1) s1.push_back(x);
else s0.push_back(x);
if ((x == pref) && s0.size() && s1.size()) {
cout << 0 << '\n';
return;
}
}
if (s0.size() && s1.size()) {
if (must && val != pref) {
cout << 0 << '\n';
return;
}
must = 1;
val = pref;
}
if (s0.size() > 0) ns.push_back(s0);
if (s1.size() > 0) ns.push_back(s1);
}
if (must) {
mask |= 1LL << i;
yes |= val << i;
}
segments = move(ns);
}
auto canbe = [&](int p, int x) {
if (mask >> p & 1) {
return (yes >> p & 1) == x;
}
return true;
};
LL ans = 0, end = 1;
for (int i = 61; i >= 0; i--) {
if ((k >> i) & 1) {
if (canbe(i, 0)) {
LL cur = 1;
for (int j = i - 1; j >= 0; j--) {
cur *= (canbe(j, 0) + canbe(j, 1));
}
ans += cur;
}
if (!canbe(i, 1)) {
end = 0;
break;
}
} else {
if (!canbe(i, 0)) {
end = 0;
break;
}
}
}
cout << ans + end << '\n';
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int T; cin >> T;
while (T--) work();
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3564kb
input:
1 4 17 3 2 5 16
output:
4
result:
ok single line: '4'
Test #2:
score: -100
Wrong Answer
time: 521ms
memory: 3628kb
input:
36156 2 732025001343805266 563399128172323734 55283226774627822 7 388099190813067712 564150557919527813 457487771983557281 332055400678110195 760833651510929158 785768483273197875 690506113272551236 463276585748519124 2 798714574862593347 426890163990834364 434764725667883272 1 414708220571820990 42...
output:
288230376151711744 18014398509481984 432345564227567616 414708220571820991 716398192192370638 0 1949654914769744 0 18014398509481984 0 811009189367843523 0 0 0 114457959388827198 36028797018963968 0 0 91540211282631659 0 694703231769895640 144115188075855872 0 18014398509481984 144115188075855872 72...
result:
wrong answer 2nd lines differ - expected: '0', found: '18014398509481984'