QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#599709 | #9351. Game Store | Macesuted | AC ✓ | 549ms | 3724kb | C++23 | 1.7kb | 2024-09-29 09:30:56 | 2024-09-29 09:30:57 |
Judging History
answer
/**
* @file 9351.cpp
* @author Macesuted ([email protected])
* @date 2024-09-29
*
* @copyright Copyright (c) 2024
*
*/
#include <bits/stdc++.h>
using namespace std;
#ifndef LOCAL
#define endl '\n'
#endif
bool mem1;
#define maxlgn 60
typedef __int128_t int128_t;
int128_t base1, base2, base[maxlgn];
int64_t wgt[maxlgn];
int128_t xor3(int128_t a, int128_t b) {
return a + b - 3 * (((a & b & base2) >> 1) | ((((a | b) & base2) >> 1) & ((a | b) & base1)));
}
void solve(void) {
int n;
cin >> n;
int64_t ans = 0;
for (int i = 0; i < maxlgn; i++) base[i] = wgt[i] = 0;
for (int i = 1; i <= n; i++) {
int64_t x, y;
cin >> x >> y, x ^= ans, y ^= ans;
int128_t v = 0;
for (int i = 0; i < maxlgn; i++) v |= int128_t(x >> i & 1) << (2 * i);
for (int i = 0; i < maxlgn; i++) {
if (!(v >> (2 * i) & 3)) continue;
if (!base[i]) {
base[i] = v, ans += wgt[i] = y;
break;
}
if (wgt[i] < y) ans += y - wgt[i], swap(base[i], v), swap(wgt[i], y);
while (v >> (2 * i) & 3) v = xor3(v, base[i]);
}
cout << ans << endl;
}
return;
}
bool mem2;
int main() {
ios::sync_with_stdio(false), cin.tie(nullptr);
#ifdef LOCAL
cerr << "Memory Cost: " << abs(&mem1 - &mem2) / 1024. / 1024. << "MB" << endl;
#endif
for (int i = 0; i < maxlgn; i++) base1 |= (int128_t)1 << (i * 2), base2 |= (int128_t)2 << (i * 2);
int _ = 1;
while (_--) solve();
#ifdef LOCAL
cerr << "Time Cost: " << clock() * 1000. / CLOCKS_PER_SEC << "MS" << endl;
#endif
return 0;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3640kb
input:
3 1 4 6 7 4 13
output:
4 7 14
result:
ok 3 lines
Test #2:
score: 0
Accepted
time: 471ms
memory: 3652kb
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:
ok 500000 lines
Test #3:
score: 0
Accepted
time: 470ms
memory: 3644kb
input:
500000 286916628637199726 365457917 455708937289588562 958017191 201613168185981955 1945259960 850497306266269521 2018031404 365326145937611014 2961810895 540573321592448582 2312352048 281383945936749558 3639402688 717805441135488426 4409106874 862319672547300376 4300865629 878112443441308853 582024...
output:
365457917 1117442391 1946382406 2152675248 2970995247 3923526990 4748798684 5248005698 6197242977 6927819663 7394772089 7638468333 8404636612 9311829298 9592935984 9889893374 10095652841 10605852111 11339100767 11722839901 12110498404 12559440527 13401397214 13897866142 14204499570 14668911011 14721...
result:
ok 500000 lines
Test #4:
score: 0
Accepted
time: 508ms
memory: 3592kb
input:
500000 741544633557490612 917926227 925666470184014871 472900723 931786637564237127 1823261724 465761563899651320 1450544758 7569785545280905 2263627296 191996113691476771 4129134435 17268820905874409 3548096942 496181567496381360 4318079201 841943092217926665 4674176664 142040259353854042 600943786...
output:
917926227 1632634483 1867303138 2827358070 3606071500 4158531707 4773358160 5274774785 6029547674 6051774157 6169542724 6382196676 6567370249 6775255842 7195897695 8109387972 8359490825 9254226054 10012267576 10714373556 11143414189 12127066873 12146433229 13066382788 13780020731 13885713803 1416745...
result:
ok 500000 lines
Test #5:
score: 0
Accepted
time: 321ms
memory: 3724kb
input:
500000 57126909032529920 248619 138624882526374699 6657824 252314185666012982 19942766 173706805715964302 26687433 115414147001759701 47348541 91436250302678205 26353865 159245843643443505 105290057 20621123253754281 73799151 81000911701779951 135657955 148884106772087291 146001029 51338972605173625...
output:
248619 6956854 29659534 35141589 48399549 106113329 107534761 142058991 148505083 155438969 163517739 165387079 168031373 174929070 247494160 296405180 341050460 349005683 389348263 398714177 409190497 410689134 419981160 420361815 423296071 519862741 566600831 656857091 663373281 680148072 70484094...
result:
ok 500000 lines
Test #6:
score: 0
Accepted
time: 322ms
memory: 3644kb
input:
500000 98302621986586624 26686850 80108861374543234 30688785 206908887190382869 29992057 225592969886807681 31824949 158400180615766325 66039363 116853733636190379 73818993 181742373356078213 121803261 10038007114144253 134244230 5047832257337464 144852002 150333341479826642 141061156 70980268222221...
output:
26686850 31107349 32355969 32891189 68169899 75924613 139106813 144021624 147682514 158502344 224701364 319810264 321914180 362743550 366856853 376051784 376329482 409734882 413330979 418189980 487548540 492888596 576269616 641505406 730425596 820468616 839094546 864469396 931600826 947253238 949767...
result:
ok 500000 lines
Test #7:
score: 0
Accepted
time: 324ms
memory: 3648kb
input:
500000 157206717082370048 66324540 286828338368219196 63544509 16659357335919805 73028849 70429625953379593 132665429 69325888135797349 139862980 257499030590280710 142444008 224248644696679924 152322938 94242581517995138 185865712 48391113780045300 189332048 37706473179121048 150251636 176660792102...
output:
66324540 70360253 77423881 135436901 139940870 142747124 169380994 186983924 194184600 251310980 260936420 267877042 314391232 401570152 455015812 461873101 561483971 599951971 649667991 749540761 841915561 849220934 850499063 853039077 953026547 957550241 957550241 1015734351 1018916260 1024635140 ...
result:
ok 500000 lines
Test #8:
score: 0
Accepted
time: 549ms
memory: 3648kb
input:
500000 440590179608950229 1402 995713047618729882 770 804170152018003484 346 251492455759652592 6828 765980203384647841 12967 299525020297657789 8722 134707348439260103 20884 886501643157073071 21953 675452125649572893 31747 546141628642120474 40116 35840656213807430 33578 846449045839712611 40620 3...
output:
1402 3058 5786 8912 13127 17564 22948 26121 32787 40122 48202 57136 66818 76852 88231 99851 112454 125885 139495 153881 168892 172505 189310 206975 224981 243683 262998 283213 283282 305072 327850 350873 374921 399265 424591 425191 451758 479048 507441 508679 538443 568557 599558 631482 664127 69710...
result:
ok 500000 lines
Test #9:
score: 0
Accepted
time: 545ms
memory: 3596kb
input:
500000 164908245892445024 1622 244323862754520966 348 332011002514422201 1246 269351898785015624 6429 10952221916788474 13355 666088097301959191 8988 863066035561474780 23603 324300744980897899 30784 907207480267118589 25584 965210789677413120 48046 572428029325660249 39348 192804596527622329 50552 ...
output:
1622 3424 5918 9505 13867 19298 25267 32166 39932 48206 57928 67960 78961 87693 100735 114497 128806 144075 159811 177054 194936 196944 216651 237106 258303 280221 284810 308018 332263 357300 383112 409702 437385 466110 495730 525532 556036 559262 591649 625276 659268 694419 730385 767149 804636 842...
result:
ok 500000 lines
Test #10:
score: 0
Accepted
time: 475ms
memory: 3584kb
input:
500000 328040399490832977 277000243 788376087486540432 7860 821863429743941430 830993871 681930688756481674 554344587 963776764982168728 1384651841 426303996187639432 1108343797 838035802859861019 1938989458 216911731921531703 1661994558 866902019476467838 2215991986 643561632836480693 2492987660 67...
output:
277000243 554000058 830999087 1107997907 1384996197 1661993973 1938990684 2215986878 2215994058 2492989072 2769983832 3046978243 3323971781 3600965046 3877957499 4154949734 4431941207 4708931909 4985922421 5262912377 5539901425 5816890302 5816891490 6093879223 6370866314 6647852574 6924838326 720182...
result:
ok 500000 lines
Test #11:
score: 0
Accepted
time: 473ms
memory: 3680kb
input:
500000 784081507314547094 398500100 616708017572310307 16259 109367722695822733 943825869 167448881002616802 1350648432 52709030481040548 1220731862 247782799871645619 1627627304 407014444251836861 2571309049 141077627199343581 2978266366 328141272588525806 3187974009 764907451877511889 2848217384 6...
output:
398500100 796999563 1195498449 1593996658 1992494102 2390990676 2789486593 3187981568 3187990393 3586483658 3984976343 4383468266 4781959005 5180449128 5578938753 5977427155 5977437043 6375923775 6774409726 7172895110 7571379468 7969862835 8368345510 8766827353 8766832304 9165312704 9563792220 99622...
result:
ok 500000 lines
Extra Test:
score: 0
Extra Test Passed