QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#291190 | #6164. 幸运数字 | MoRanSky | 100 ✓ | 75ms | 14672kb | C++23 | 1.3kb | 2023-12-26 05:18:02 | 2023-12-26 05:18:02 |
Judging History
answer
// Skyqwq
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long LL;
const int N = 8e5 + 5, INF = 1e9;
int n, d[N], tot, c[N], X[N], Y[N], W[N], len;
int inline get(int x) {
return lower_bound(d + 1, d + 1 + tot, x) - d;
}
void inline add(int x, int y, int w) {
x = get(x), y = get(y);
c[x] ^= w, c[y] ^= w;
}
void inline push(int x) {
d[++tot] = x;
}
void inline work(int x, int y, int w) {
d[++tot] = x - 1, d[++tot] = y;
y++;
X[++len] = x, Y[len] = y, W[len] = w;
d[++tot] = x, d[++tot] = y;
}
int main() {
scanf("%d", &n);
d[++tot] = 0;
for (int i = 1; i <= n; i++) {
int op, x, y, w; scanf("%d%d", &op, &x);
if (op == 1) {
scanf("%d%d", &y, &w);
work(x, y, w);
} else if (op == 2) scanf("%d", &w), work(x, x, w);
else if (op == 3) scanf("%d", &w), work(-INF, x - 1, w), work(x + 1, INF, w);
}
sort(d + 1, d + 1 + tot);
tot = unique(d + 1, d + 1 + tot) - d - 1;
for (int i = 1; i <= len; i++) add(X[i], Y[i], W[i]);
int ans = -2e9, id = 2e9;
for (int i = 1; i <= tot; i++) {
c[i] ^= c[i - 1];
if (c[i] > ans) ans = c[i], id = d[i];
else if (c[i] == ans) {
if (abs(d[i]) < abs(id) || (abs(d[i]) == abs(id) && d[i] > id))
id = d[i];
}
}
printf("%d %d\n", ans, id);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 5
Accepted
time: 2ms
memory: 7960kb
input:
1000 3 0 116969979 3 368 180480073 3 -545 391749388 1 -6 297 176077477 3 798 108368066 2 482 675016434 3 251 536075110 2 9 706221269 3 -60 268159990 1 -60 149 8670529 3 -500 378261451 1 -332 -331 86546365 3 814 366496749 3 589 347149485 3 -610 137583463 3 -528 112400107 1 -832 989 416998222 1 500 88...
output:
1073554444 860
result:
ok 2 number(s): "1073554444 860"
Test #2:
score: 5
Accepted
time: 0ms
memory: 9784kb
input:
1000 3 -972 304988612 1 -972 81 388197706 2 700 589621513 1 400 647 37204129 1 -472 -401 201419461 3 942 692882781 1 854 874 141245452 3 -648 139801751 2 190 195088156 1 -724 676 326792421 3 -178 80721199 3 -616 308058017 2 216 160629769 3 700 210485440 2 -633 132825161 1 32 850 208796879 3 -172 243...
output:
1069100987 56
result:
ok 2 number(s): "1069100987 56"
Test #3:
score: 5
Accepted
time: 2ms
memory: 7772kb
input:
1000 3 -633 478404649 1 -633 947 21856089 1 281 992 96925280 3 691 68361274 3 -205 327955945 3 96 4892301 3 -220 819956008 3 -556 185453961 3 280 181840831 1 -408 -275 261586423 1 -822 45 296579977 1 -150 -29 87350693 1 -227 -211 37950656 1 -248 -227 278407801 2 -649 46746145 2 -457 611651881 1 207 ...
output:
1072830144 751
result:
ok 2 number(s): "1072830144 751"
Test #4:
score: 5
Accepted
time: 2ms
memory: 9800kb
input:
1000 3 828 298295581 1 -208 761 33092065 2 -64 437533 3 -608 424025829 3 172 394496809 2 648 53822464 1 203 443 397879093 1 -135 -84 110148380 2 -84 39717136 3 -330 48389515 3 -416 128451365 2 175 308523788 2 172 91439334 3 82 493161050 1 593 730 580960513 3 -651 112627149 3 -978 487839876 3 490 353...
output:
1071382241 481
result:
ok 2 number(s): "1071382241 481"
Test #5:
score: 5
Accepted
time: 2ms
memory: 7772kb
input:
1000 2 -520300352 102387889 2 17087320 617575609 3 -213670484 302384716 1 448135298 597884461 199612337 1 137210778 712960635 630354131 1 107773870 116988410 88411477 1 -148396000 59537512 209538064 1 59537512 191572513 387208256 2 716814412 185873505 1 -213623153 -162913442 412507905 3 -29432634 54...
output:
1072577055 95457914
result:
ok 2 number(s): "1072577055 95457914"
Test #6:
score: 5
Accepted
time: 2ms
memory: 9800kb
input:
1000 1 61295320 158977235 111487725 1 5266414 592731956 30915946 2 218533885 178600001 2 254433874 234795871 1 926661493 997878431 80611928 3 208905616 135113995 2 467686354 239970473 3 144978760 87726064 2 212374666 9320635 1 376774042 626507375 258124240 1 136157416 638895227 57883871 3 60693214 8...
output:
755082945 0
result:
ok 2 number(s): "755082945 0"
Test #7:
score: 5
Accepted
time: 2ms
memory: 7772kb
input:
1000 2 -231120000 212737073 1 -1493096 429328760 55441301 3 -44963864 91096766 2 173065900 31694927 2 -5448860 2538229 1 -197482496 300570294 140501469 1 38766771 96521608 8823959 2 254731166 8098650 2 7698078 53524875 3 -17150310 36466426 1 618069312 640661292 201708529 1 -112315889 14608140 121343...
output:
790817672 -1000000000
result:
ok 2 number(s): "790817672 -1000000000"
Test #8:
score: 5
Accepted
time: 2ms
memory: 9740kb
input:
1000 3 72514431 217308477 1 118653938 150657589 831803233 3 -259992018 211657909 3 -188902032 160822618 1 -792247297 -753537102 756626400 1 535671360 539537111 283023685 2 -178107244 386896859 1 274921600 555313255 436200571 1 803135760 806730955 157853557 3 132958980 224941837 2 -72418230 252950479...
output:
1073578121 326258647
result:
ok 2 number(s): "1073578121 326258647"
Test #9:
score: 5
Accepted
time: 72ms
memory: 12284kb
input:
100000 2 403699940 639028597 1 56011900 820939549 555856510 3 184368216 252747638 2 10188770 172059423 1 718698695 979360021 188927044 1 406328538 433633035 409634094 2 870861660 119140957 3 26550452 10779991 1 784462214 813407505 425916640 1 343886322 472049671 151815526 3 59013150 175825723 1 6338...
output:
1073739797 104477558
result:
ok 2 number(s): "1073739797 104477558"
Test #10:
score: 5
Accepted
time: 66ms
memory: 13680kb
input:
100000 1 -253691476 -249677621 76818851 1 -235284829 -209256670 62856921 2 -6729603 282986353 2 -897981750 632913282 3 -464024410 41995701 2 -39146250 260009941 3 -98258902 243095464 3 -31291742 128177859 1 -618389010 -129011615 224528301 3 -346456 130191681 3 -778688640 366130241 3 -381572705 83993...
output:
1073715051 -10297287
result:
ok 2 number(s): "1073715051 -10297287"
Test #11:
score: 5
Accepted
time: 72ms
memory: 14672kb
input:
100000 2 -256195790 205433295 3 -2980406 15437050 2 -244468240 109436985 2 -692307357 98222695 3 99460032 57791449 1 -211194568 688967289 107000690 1 -122480512 -71564799 42476617 1 -178700365 666291212 69644611 3 566930000 10388928 3 -65775078 77345281 2 -2058279 122469523 3 -434370706 232135432 1 ...
output:
688585642 -1000000000
result:
ok 2 number(s): "688585642 -1000000000"
Test #12:
score: 5
Accepted
time: 64ms
memory: 10632kb
input:
100000 1 118004040 555856099 39270606 3 52262352 43008535 2 -40860000 201570405 1 -55420432 633681493 53686333 2 105063035 148500102 1 165772178 267007554 6358576 1 -451201592 -213319119 8471035 3 -717226407 801111 2 449208009 158632486 3 366529044 35671955 3 333266076 111803585 2 -66051576 4542220 ...
output:
605977972 1000000000
result:
ok 2 number(s): "605977972 1000000000"
Test #13:
score: 5
Accepted
time: 68ms
memory: 14588kb
input:
100000 1 -370284743 -358477256 128949989 1 -214194196 -213617013 18078061 2 -45901170 101860597 1 -248246975 -211652022 13432885 1 -62751765 -48635138 89655177 1 -84525364 -83582931 147819729 3 -10924210 103337801 3 -462947418 171424246 3 -674558443 253849001 3 -309773170 2279376 2 -91053442 1796966...
output:
782758178 0
result:
ok 2 number(s): "782758178 0"
Test #14:
score: 5
Accepted
time: 74ms
memory: 10112kb
input:
100000 2 -341038068 209535001 3 -47763023 6937701 3 823518705 58554987 2 -68571006 321835121 1 193415136 197606317 47059258 2 148623555 163479325 3 -271765340 12594169 2 -271765340 1234927 3 -73582944 44070121 1 -66489774 31097407 229192305 1 -1323054 72350743 519607884 2 -73031161 958087426 2 -9865...
output:
1073741630 165517112
result:
ok 2 number(s): "1073741630 165517112"
Test #15:
score: 5
Accepted
time: 75ms
memory: 11700kb
input:
100000 3 676300392 597954279 2 -29581936 36531843 1 -395849904 19964755 19096449 3 19964755 64656691 1 68830239 119638288 364833424 3 81948156 255782506 3 -597414906 121865493 1 145483944 369268646 225356071 2 -152914534 59320801 3 151432317 53524453 3 -213732701 89122489 3 -331249644 31433528 2 -14...
output:
1073739655 225284125
result:
ok 2 number(s): "1073739655 225284125"
Test #16:
score: 5
Accepted
time: 70ms
memory: 10064kb
input:
100000 3 -443946096 173019082 3 69891624 478258775 2 -678057842 56125567 3 -440970952 35353761 2 -55301697 170092067 2 49117640 617736412 1 69903612 643193943 458241301 1 131846286 134407705 422909911 2 -655508958 447560114 1 -569993710 -371396115 8707121 2 -382664352 203276186 2 -9141839 771042280 ...
output:
1073726076 598939719
result:
ok 2 number(s): "1073726076 598939719"
Test #17:
score: 5
Accepted
time: 74ms
memory: 10016kb
input:
100000 3 97614192 137934921 1 -122675006 7045699 6847261 2 -680981400 387092644 1 32646768 419337489 14437709 2 137052006 19933963 3 149261190 226643530 3 -113792520 263271721 1 190190522 317274405 36763357 2 -401993928 79091776 2 -581746260 43377533 2 30467999 36155806 3 155552664 139282459 3 45754...
output:
1073730499 153828072
result:
ok 2 number(s): "1073730499 153828072"
Test #18:
score: 5
Accepted
time: 73ms
memory: 11580kb
input:
100000 3 -579864344 259666093 1 60243111 120338362 35454421 1 136187088 147059329 130539331 1 673160818 708043668 245621603 1 -239673192 306048793 207702425 3 7112076 12900469 2 251507648 521135288 2 -157248776 480902973 1 13566684 437045453 152598427 3 -20208848 124933953 1 -140052780 -43596874 354...
output:
1073740919 929008188
result:
ok 2 number(s): "1073740919 929008188"
Test #19:
score: 5
Accepted
time: 74ms
memory: 10052kb
input:
100000 1 398965375 904585172 108811501 3 -551459920 125674861 3 -555163675 253035268 3 -112095924 43593050 1 -187187175 -164995403 17593873 1 -70821876 -65999465 568753465 2 85467009 46523777 3 -160844196 250048423 1 -11294952 223776985 322198031 1 -131223048 -11294952 242629018 1 18855096 364331039...
output:
1073731008 366116570
result:
ok 2 number(s): "1073731008 366116570"
Test #20:
score: 5
Accepted
time: 71ms
memory: 10300kb
input:
100000 3 218701353 271461332 1 176330088 510206905 615603631 1 -215780796 84849901 392693281 1 201923708 918098661 247463401 3 -510998766 59355941 3 663339796 126134276 1 -411947292 -160920737 411877701 3 -39170670 425693714 1 -626893400 -616789823 247892631 1 -33760386 316945036 152361553 3 -238209...
output:
1073739406 201437466
result:
ok 2 number(s): "1073739406 201437466"
Extra Test:
score: 0
Extra Test Passed