QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#578686 | #9351. Game Store | psycho# | TL | 0ms | 3824kb | C++20 | 1.8kb | 2024-09-20 20:48:33 | 2024-09-20 20:48:33 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define vc vector
#define pii pair <int, int>
//#define int long long
using ld = long double;
using ll = long long;
const int inf = 1e9;
template<class T>
bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<class T>
bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
typedef vector<short> koks;
koks operator*(koks a, short b) {
#pragma ivdep
for (int i = 0; i < a.size(); ++i) a[i] *= b;
#pragma ivdep
for (int i = 0; i < a.size(); ++i) a[i] %= 3;
return a;
}
koks operator+(koks a, koks b) {
#pragma ivdep
for (int i = 0; i < a.size(); ++i) a[i] += b[i];
#pragma ivdep
for (int i = 0; i < a.size(); ++i) a[i] %= 3;
return a;
}
void solve_case() {
int n;
cin >> n;
long long ans = 0;
vector<pair<koks, long long>> bas(60);
for (auto &[x, y] : bas) x.resize(60);
for (int i = 0; i < n; ++i) {
long long a, b;
cin >> a >> b;
a ^= ans, b ^= ans;
koks x;
x.resize(60);
for (int i = 0; i < 60; ++i) x[i] = a >> i & 1ll;
for (int i = 0; i < bas.size(); ++i) {
if (!x[i]) continue;
if (!bas[i].second) {
bas[i] = {x, b};
break;
} else {
if (bas[i].second < b) swap(bas[i].first, x), swap(bas[i].second, b);
if (x[i] == bas[i].first[i]) x = x * 2;
x = x + bas[i].first;
}
}
ans = 0;
for (auto &[x, y] : bas) ans += y;
cout << ans << '\n';
}
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T = 1;
while (T--) solve_case();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3824kb
input:
3 1 4 6 7 4 13
output:
4 7 14
result:
ok 3 lines
Test #2:
score: -100
Time Limit Exceeded
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...