QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#571700 | #9351. Game Store | real_sigma_team# | WA | 109ms | 3720kb | C++17 | 1.9kb | 2024-09-18 04:15:06 | 2024-09-18 04:15:06 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void solve();
int32_t main() {
#ifndef LOCAL
cin.tie(nullptr)->sync_with_stdio(false);
#endif
int t = 1;
// cin >> t;
while (t--) {
solve();
}
}
pair<ll, ll> __xor(pair<ll, ll> a, ll b) {
pair<ll, ll> res;
res.first |= (a.first & ~a.second) & ~b;
res.first |= ~a.second & b;
res.second |= (a.first & ~a.second) & b;
res.second |= a.second & ~b;
res.first |= res.second;
return res;
}
pair<ll, ll> _xor(pair<ll, ll> a, pair<ll, ll> b) {
return __xor(__xor(a, b.first), b.second);
}
using num = pair<ll, ll>;
num norm(num& x) {
num res;
res.first = x.first | x.second;
res.second = x.first & x.second;
return res;
}
void solve() {
int n;
cin >> n;
ll last = 0;
array<pair<num, int>, 60> base;
base.fill({{0, 0}, 0});
for (int i = 0; i < n; i++) {
ll x, y;
cin >> x >> y;
x ^= last;
y ^= last;
num a = {x, 0};
int b = y;
pair<int, int> mx = {0, 0};
pair<num, int> oink;
for (int j = 59; j >= 0; --j) {
if (!base[j].first.first) continue;
auto [v, c] = base[j];
if (a.first >> j & 1) {
if (make_pair(b - c, j) > mx) {
mx = make_pair(b - c, j);
oink = {a, b};
}
while (a.first >> j & 1) {
a = _xor(a, v);
}
} else {
break;
}
}
if (a.first) {
base[63 - __builtin_clzll(a.first)] = {a, b};
last += b;
} else if (mx.first > 0) {
last += mx.first;
base[mx.second] = oink;
}
cout << last << '\n';
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3720kb
input:
3 1 4 6 7 4 13
output:
4 7 14
result:
ok 3 lines
Test #2:
score: -100
Wrong Answer
time: 109ms
memory: 3680kb
input:
500000 395134631858718935 964539556 125290790696511447 743741881 68785955678986648 1867726875 774218610629433714 1107843806 251011758189826329 3218789432 712376502291877860 3368474950 237512969552427655 3307057592 26026853208103063 3366794857 904189246433646740 3824475130 105677592268903953 50111856...
output:
964539556 1319559617 1889305499 2737921248 3223119288 3371639478 3605116356 4113447281 4496890876 5146597364 5443005741 5560684788 6532334449 7521134451 8336539770 8705245338 9014268525 9265374719 9381614536 9559254162 10004316290 10462314640 10662416153 10955313276 11748683855 12256749782 129943566...
result:
wrong answer 61st lines differ - expected: '30347892936', found: '30464132753'