QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#385232 | #7765. Xor Master | valeriu# | 0 | 1549ms | 4624kb | C++20 | 2.8kb | 2024-04-10 16:47:53 | 2024-07-04 03:33:54 |
Judging History
answer
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
//#define int ll
#define sz(x) ((int)(x).size())
using pii = pair<int,int>;
using tii = tuple<int,int,int>;
const int bmax = 64;
namespace Basis {
ull pivot[bmax];
ull contrmsk[bmax];
ull control = 0;
bool add(ull x) {
for(int i = bmax - 1; i >= 0; i--) {
if(pivot[i] == 0 && ((1ull << i) & x)) {
pivot[i] = x;
break;
}
else if(pivot[i] != 0 && ((1ull << i) & x))
x ^= pivot[i];
}
if(x == 0) return 0;
for(int i = 0; i < bmax; i++) {
if(pivot[i] == 0) continue;
for(int j = i + 1; j < bmax; j++) {
if(pivot[j] & (1ull << i))
pivot[j] ^= pivot[i];
}
}
control = 0;
for(int contra = 0; contra < bmax; contra++) {
if(pivot[contra] != 0) {
contrmsk[contra] = 0;
control |= (1ull << contra);
continue;
}
for(int i = contra + 1; i < bmax; i++)
if(pivot[i] & (1ull << contra)) contrmsk[contra] |= (1ull << i);
}
return 1;
}
ull get_val(ull a) {
ull R = 0;
for(int i = 0; i < bmax; i++) {
if(pivot[i] != 0) continue;
R |= ((ull)((__builtin_popcountll(a & contrmsk[i]) & 1)
^ (__builtin_popcountll(contrmsk[i]) & 1)
^ ((a & (1ull << i))? 1 : 0))) << i;
}
return R;
}
}
signed main() {
cin.tie(0) -> sync_with_stdio(0);
int n, q;
cin >> n >> q;
vector<ull> v(n + 1), real(n + 1);
for(auto &x : v | views::drop(1)) cin >> x;
real = v;
auto update = [&](int p, ull x) {
v[p] ^= Basis::get_val(x);
real[p] ^= x;
};
auto reformat = [&]() {
for(int i = 1; i <= n; i++) v[i] = Basis::get_val(real[i]);
return;
};
auto query = [&](int l, int r) -> ull {
ull rez = 0, part = 0;
for(int i = l; i <= r; i++)
part ^= v[i],
rez += part;
return rez;
};
for(int i = 0; i < q; i++) {
int T;
cin >> T;
if(T == 1) {
int p;
ull x;
cin >> p >> x;
update(p, x);
}
else if(T == 2) {
ull x;
cin >> x;
if(Basis::add(x)) {
reformat();
}
}
else {
int l, r;
cin >> l >> r;
cout << query(l, r) + Basis::control * (ull)(r - l + 1) << '\n';
}
}
}
/**
Anul asta nu se da centroid
-- Rugaciunile mele
*/
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 3560kb
input:
2000 2000 1860495733 462603674 3739839441 759356520 47330263 550811730 2301200895 989240351 2499503801 2624225494 2123076812 1180966826 238739434 488666688 784742950 2583466952 4111371941 2335988605 2583741355 933716686 1644403538 1970423306 304500250 905101643 1814942168 1136358764 88729799 1577263...
output:
867006634793 3418049036989 1658469159497 794670034691 239792547603 1587489101990 592222190840 1343829229567 971235609706 571701308760 1219913933321 588622962923 2129364200509 1007100395808 3134493164996 3145027621038 2599298085956 1729302186341 837940435945 242569415869 2908005634977 1692554597386 1...
result:
wrong answer 24th lines differ - expected: '1870376108278', found: '1869972343054'
Subtask #2:
score: 0
Time Limit Exceeded
Test #5:
score: 0
Time Limit Exceeded
input:
500000 100000 12261386944926786495 7846697792998647383 16622924885320463714 170129022271213944 12625257523700625864 7684671687986103560 11532026873918423068 1131776055566669037 8263146651412710501 17872572061246021001 5017109039248728310 11088626167542318645 13810119722795416818 10928315716094262229...
output:
12337138966997790840 11593856511006775316 5653988472748567965 6281173414355612100 18027435777450732541 2903343914316621940 9422461876307420631 76690753587353877 798850376670823348 10137130634921141648 13914431888234873359 10192090671035653185 11569745711967074397 12303071505845046803 637460082558284...
result:
Subtask #3:
score: 0
Skipped
Dependency #2:
0%
Subtask #4:
score: 0
Wrong Answer
Test #15:
score: 0
Wrong Answer
time: 1549ms
memory: 4624kb
input:
100000 100000 860905160 3192911636 290327446 2020707113 959258245 454185039 421895589 1070265496 2218913641 1684685660 1206723673 2606734467 4247254571 3341954386 3805299640 1702270353 2472053741 2816060613 1307901348 2702949728 879391505 884661815 330738731 1575749344 1239158446 2099693858 67466644...
output:
208850661211321 125437627681115 162403457716877 63123265692583 33026732316991 89306551164325 36797686363855 40774372735902 13922167514639 267287536820212 192012766560090 276346312013230 11190422279392 133872370392306 92664486229410 179295642780970 46156540478905 232640800325745 184977510249728 11022...
result:
wrong answer 1st lines differ - expected: '208755389215975', found: '208850661211321'
Subtask #5:
score: 0
Skipped
Dependency #4:
0%
Subtask #6:
score: 0
Skipped
Dependency #1:
0%
Subtask #7:
score: 0
Skipped
Dependency #1:
0%