QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#515815 | #6230. 水池 | Ecec243 | 100 ✓ | 151ms | 57300kb | C++17 | 3.5kb | 2024-08-12 08:54:01 | 2024-08-12 08:54:01 |
Judging History
answer
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
const int N = 2e5 + 5, inf = 2e9;
int n, q;
int h[N], rt1[N], rt2[N];
struct tree1{
#define mid ((l + r) >> 1)
int tot;
struct node{
int ls, rs, mx;
}a[N * 20];
void build(int &p, int l, int r){
p = ++tot;
if (l == r){
a[p].mx = h[l];
return;
}
build(a[p].ls, l, mid);
build(a[p].rs, mid + 1, r);
a[p].mx = max(a[a[p].ls].mx, a[a[p].rs].mx);
}
void add(int &p, int l, int r, int s, int k){
a[++tot] = a[p];
p = tot;
if (l == r) return a[p].mx = k, void();
if (s <= mid) add(a[p].ls, l, mid, s, k);
else add(a[p].rs, mid + 1, r, s, k);
a[p].mx = max(a[a[p].ls].mx, a[a[p].rs].mx);
}
int ask(int p, int l, int r, int s, int t){
if (s <= l && r <= t) return a[p].mx;
int res = 0;
if (s <= mid) res = max(ask(a[p].ls, l, mid, s, t), res);
if (t > mid) res = max(ask(a[p].rs, mid + 1, r, s, t), res);
return res;
}
int ask1(int p, int l, int r, int s, int k){
if (r <= s){
if (a[p].mx < k) return 0;
else if (l == r) return l;
else if (a[a[p].rs].mx >= k) return ask1(a[p].rs, mid + 1, r, s, k);
else return ask1(a[p].ls, l, mid, s, k);
}
int res = 0;
if (mid < s) res = ask1(a[p].rs, mid + 1, r, s, k);
if (res) return res;
else return ask1(a[p].ls, l, mid, s, k);
}
int ask2(int p, int l, int r, int s, int k){
if (s <= l){
if (a[p].mx < k) return n;
else if (l == r) return r;
else if (a[a[p].ls].mx >= k) return ask2(a[p].ls, l, mid, s, k);
else return ask2(a[p].rs, mid + 1, r, s, k);
}
int res = n;
if (s <= mid) res = ask2(a[p].ls, l, mid, s, k);
if (res < n) return res;
else return ask2(a[p].rs, mid + 1, r, s, k);
}
}T1;
struct tree2{
int tot;
struct node{
int ls, rs;
int t, tag;//t = t >> 2, type = t & 3
}a[N * 36];
void add(int &p, int l, int r, int s, int t, int _t, int _tag){
a[++tot] = a[p];
p = tot;
if (s <= l && r <= t){
a[p].t = _t, a[p].tag = _tag;
return;
}
if (s <= mid) add(a[p].ls, l, mid, s, t, _t, _tag);
if (t > mid) add(a[p].rs, mid + 1, r, s, t, _t, _tag);
}
pair<int, int> ask(int p, int l, int r, int s){
pair<int, int> res(a[p].t, a[p].tag);
if (l == r) return res;
if (s <= mid) res = max(ask(a[p].ls, l, mid, s), res);
else res = max(ask(a[p].rs, mid + 1, r, s), res);
return res;
}
#undef mid
}T2;
int aska(int i, int x){
pair<int, int> res = T2.ask(rt2[i], 0, n, x);
int t = res.first, p = res.second;
if (!t) return 0;
else if ((t & 3) == 1) return p;
else if (x == p) return 0;
else if (x < p) return T1.ask(rt1[t >> 2], 0, n, x, p - 1);
else return T1.ask(rt1[t >> 2], 0, n, p, x - 1);
}
int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
// freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
cin >> n >> q;
h[0] = h[n] = inf;
for (int i = 1; i < n; i++)
cin >> h[i];
T1.build(rt1[0], 0, n);
for (int i = 1; i <= q; i++){
int opt, t, x;
cin >> opt >> t >> x;
rt1[i] = rt1[t], rt2[i] = rt2[t];
if (opt == 0){
int y;
cin >> y;
if (aska(i, x) < y){
int l = T1.ask1(rt1[i], 0, n, x - 1, y), r = T1.ask2(rt1[i], 0, n, x, y);
T2.add(rt2[i], 0, n, l + 1, r, (i << 2) | 1, y);
}
}else if (opt == 1){
int y = aska(i, x);
int l = T1.ask1(rt1[i], 0, n, x - 1, y), r = T1.ask2(rt1[i], 0, n, x, y);
T2.add(rt2[i], 0, n, l + 1, r, (i << 2) | 2, x);
}else if (opt == 2){
cin >> h[x];
T1.add(rt1[i], 0, n, x, h[x]);
}else cout << aska(i, x) << endl;
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 10
Accepted
Test #1:
score: 10
Accepted
time: 1ms
memory: 5696kb
input:
451 469 799643869 554074088 313641255 240396194 289441005 120760635 60081214 502510219 361989963 460382686 31603393 669782854 307229342 102537485 383822174 40855518 1920840 158219655 284013679 702705326 126997001 742365412 188287595 162194743 73323070 549981194 165910073 731839013 534419392 57360831...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 594356061 0 804870752 0 804870752 0 0 0 804870752 0 0 0 0 804870752 0 0 0 0 0 804870752 0 0 0 0 0 942707062 0 759661577 804870752 0 0 0 0 0 804870752 0 0 0 0 0 0 0 0 822278415 0 0 0 0 0 0 0 0 0 0 0 799340058 0 0 0 0 0 825762297 0 0 988334505 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 109 lines
Test #2:
score: 10
Accepted
time: 1ms
memory: 3820kb
input:
500 500 110684039 714931609 533911161 0 265901115 0 251023653 590971317 277168628 585419312 487607060 435315504 0 744143837 12965575 572937978 741703253 13735189 797368949 459961108 742132282 0 531131304 366695217 338399129 193691768 0 637582051 541803135 375457677 212577416 272671034 292647642 1487...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 936016342 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 936016342 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 791442473 0 0 0 0 936016342 0 0 0 0 0 0 0 0 0 0 791442473 0 0 0 0 0 911111000 0 0 0 0 0 0 0 0 0 0 0
result:
ok 118 lines
Subtask #2:
score: 10
Accepted
Test #3:
score: 10
Accepted
time: 32ms
memory: 15124kb
input:
95763 92359 125406791 137432093 763265172 540984217 511101218 287278210 710943263 68325782 406866215 71018028 455549862 170376172 648802381 58005284 512058297 302287320 101566189 243586504 27102305 451590266 493939605 180158978 528068209 118140458 337869225 487573956 40596884 178126990 0 75901163 0 ...
output:
0 0 0 847010708 847010708 847010708 847010708 847010708 847010708 847010708 847010708 847010708 847010708 847010708 847010708 847010708 847010708 847010708 847010708 847010708 979001576 979001576 979001576 979001576 979001576 979001576 979001576 979001576 979001576 979001576 979001576 979001576 9790...
result:
ok 30924 lines
Test #4:
score: 10
Accepted
time: 34ms
memory: 17428kb
input:
100000 100000 182316754 57847370 371997054 688666687 609463280 221731325 730947425 110591072 614905016 85202512 565786410 324688115 540194644 638713991 231708549 624348478 256736039 720264041 298036855 502549155 432134123 250880358 457573593 112649815 539008726 551072540 265324815 122503149 21017445...
output:
0 0 0 0 0 0 0 0 0 984622156 984622156 984622156 984622156 984622156 984622156 984622156 984622156 984622156 984622156 984622156 984622156 984622156 984622156 984622156 984622156 984622156 984622156 984622156 984622156 984622156 984622156 984622156 984622156 984622156 984622156 984622156 984622156 98...
result:
ok 33344 lines
Subtask #3:
score: 10
Accepted
Test #5:
score: 10
Accepted
time: 65ms
memory: 26160kb
input:
191995 194162 6891432 785450979 569857716 132255242 408871731 773453690 0 725347657 721477690 100255432 288415418 189257011 618042073 105998740 571269928 163803278 735085310 341019627 86391267 213232540 520854480 535331204 295794830 534945203 582403708 799435263 94893592 454575997 290616581 76159076...
output:
0 0 0 884127445 884127445 884127445 884127445 884127445 884127445 884127445 910351084 910351084 910351084 910351084 910351084 910351084 935893688 935893688 973784603 973784603 973784603 973784603 973784603 973784603 973784603 973784603 973784603 973784603 973784603 973784603 973784603 973784603 9737...
result:
ok 64839 lines
Test #6:
score: 10
Accepted
time: 72ms
memory: 26656kb
input:
200000 200000 331609764 519737970 542759683 661337161 780296503 111617312 341044745 121460126 293351903 176782177 28743091 687291220 289926509 184245329 12289121 87979687 440078318 222463041 535563010 444391851 397642670 37645035 534850362 268288380 73231693 197995311 41607131 0 124680778 585095862 ...
output:
0 0 0 0 0 0 979323483 979323483 979323483 979323483 979323483 979323483 979323483 979323483 979323483 979323483 979323483 979323483 979323483 979323483 979323483 979323483 979323483 979323483 979323483 979323483 979323483 979323483 979323483 979323483 979323483 979323483 979323483 979323483 97932348...
result:
ok 66866 lines
Subtask #4:
score: 10
Accepted
Test #7:
score: 10
Accepted
time: 41ms
memory: 23284kb
input:
99057 99999 517200151 696399345 261176143 785161725 271341444 494132142 612344628 269719211 502358914 251918663 742118731 241849533 212679882 459839985 12090935 693695879 461541162 116365447 508973475 515271458 135064622 2780057 564671685 549876910 62487209 138469672 382327654 298983886 597058598 53...
output:
0 0 0 887051469 887051469 0 0 887051469 0 0 887051469 887051469 952407352 0 0 0 887051469 887051469 0 0 0 0 887051469 0 992313609 0 0 0 0 0 887051469 0 910902455 0 0 921403619 0 0 0 0 0 0 0 887051469 887051469 0 0 0 0 0 887051469 0 0 0 887051469 0 0 0 0 0 921403619 0 0 0 0 0 0 0 0 0 0 0 0 0 0 966047...
result:
ok 33387 lines
Test #8:
score: 10
Accepted
time: 47ms
memory: 25948kb
input:
100000 100000 461059606 540059181 7250610 204202763 787877238 472431241 101358156 0 204229822 0 621692033 171620107 86420408 764400907 170400333 678690827 230462968 396177666 341506213 94245985 715367743 280551095 466166741 47784281 786602178 108907121 204832987 716071824 227479970 70311291 25702414...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 992618692 0 0 0 0 0 0 0 915689862 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 981821779 0 0 0 0 0 0 0 0 0 0 0 800504036 0 0 0 0 0 0 0 0 0 0 0 981821779 0 0 0 0 0 0 992618692 0 0 0 992618692 0 0 0 0 0 0 0 0 0 0 0 0 0 0 893647271 0 0 0 0 800504036 0 0 0 0 0 0 0 0 0 0 0 0 0 0 915689862 ...
result:
ok 33091 lines
Subtask #5:
score: 10
Accepted
Test #9:
score: 10
Accepted
time: 91ms
memory: 36064kb
input:
181439 182363 173196455 791637307 117409078 351254963 478560653 628560153 328836651 691159128 452914849 263276613 326224528 96034236 321262200 459154368 428625104 56828416 195992385 667170842 119347528 791746400 510061732 562219507 546684168 0 0 378219232 710998173 80970604 211767056 196090065 40580...
output:
0 0 835426981 891453835 0 835426981 0 835426981 0 0 0 0 0 0 811280029 0 0 891453835 0 891453835 0 859764426 914625510 0 0 835426981 0 0 0 0 0 835426981 910021852 835426981 0 881109467 910021852 0 0 0 0 891453835 891453835 0 891453835 0 0 0 835426981 891453835 891453835 835426981 0 0 0 0 0 944598797 ...
result:
ok 60724 lines
Test #10:
score: 10
Accepted
time: 94ms
memory: 42060kb
input:
200000 200000 297437054 403025301 368090158 40940851 279326662 681701299 358384167 196990140 238228111 684919076 146001429 2169871 120615282 561896410 603331321 479661469 388977899 471343388 73406029 47308543 570843036 21701057 763085377 11111897 728503920 48557475 425363790 459563986 695136532 2100...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 824187730 824187730 928356457 0 0 0 0 824187730 0 0 0 0 0 0 0 0 0 928356457 824187730 0 0 0 824187730 928356457 0 824187730 0 824187730 0 824187730 0 0 0 0 0 0 0 0 0 0 824187730 0 0 0 0 813117933 928356457 0 824187730 0 0 0 824187730 0 0 0 0 0 0 824187730 0 0 824187...
result:
ok 66287 lines
Subtask #6:
score: 10
Accepted
Test #11:
score: 10
Accepted
time: 65ms
memory: 26264kb
input:
98129 95480 377412122 244725955 643347743 443420782 692782024 648529351 480738121 610089060 168296682 127083079 298579894 499233289 172744990 692910923 674931085 235605842 62064826 326190240 653620748 35477505 743746455 755958773 127706397 957977 19774381 761269692 390855319 499181449 309977179 1504...
output:
799853979 799853979 799991463 799882995 799991090 953748311 953748311 847547702 847547702 847547702 799937068 918190491 953459468 799974711 794595152 799974711 799979330 945858926 799991090 807846915 799869431 807846915 798774276 799990837 807846915 799974711 799974711 799829385 869140301 799974711 ...
result:
ok 23717 lines
Test #12:
score: 10
Accepted
time: 69ms
memory: 28320kb
input:
100000 100000 167477758 264267871 100124926 742554512 212332615 207962311 266287025 0 723891187 264737800 489993210 46768383 711531845 597886241 94339432 739789203 9944251 332945883 163074201 15451510 626941230 144533275 746978999 458926381 364414493 213232433 652133392 784249280 38161734 203360881 ...
output:
875557009 875557009 799965061 799997694 799590354 799815038 799983693 799590354 799815038 798814193 799997694 799952176 799997694 901186215 901186215 798093807 901186215 901186215 901186215 832154179 796655713 988184845 988184845 796353870 799295591 799814850 799554264 965413730 965413730 933272434 ...
result:
ok 24937 lines
Subtask #7:
score: 10
Accepted
Test #13:
score: 10
Accepted
time: 151ms
memory: 50252kb
input:
196745 190192 530816289 110623315 28195048 522299730 569972702 61450893 11096188 243864530 511796004 641282498 128651835 596974715 206386531 420103078 794908692 3553871 22531630 405072789 284074824 701448666 52894648 660047723 449993619 155359896 495406323 732280568 278218962 0 631425418 782081407 6...
output:
0 0 0 0 0 0 0 0 0 0 0 970084489 970084489 799989527 799997786 799988922 799839940 799997786 799988922 799969994 799931595 799969994 799854853 799088164 799922822 799565376 799942064 799955254 799948527 799931595 799948527 799955254 799904950 798510076 799955254 799862468 799805833 881681817 80481007...
result:
ok 47960 lines
Test #14:
score: 10
Accepted
time: 147ms
memory: 53276kb
input:
200000 200000 673127377 0 77451016 775484256 736601578 541744599 279188941 376199450 445000385 536297448 153534439 580187997 385793985 117159253 283715734 110189111 477062829 109589572 614350587 283219700 524348102 773262964 543305836 637637693 210841569 447471156 483271957 58427240 240140473 184516...
output:
862269466 862269466 862269466 799967081 997552036 799964703 799964703 799964703 799893079 799647832 799826182 799973810 799800846 799291812 799943676 799977716 799977716 799977716 799973810 799913333 798104330 799540484 799973810 799977716 799977716 798776407 799964703 799640647 799587455 799964703 ...
result:
ok 50277 lines
Subtask #8:
score: 10
Accepted
Test #15:
score: 10
Accepted
time: 114ms
memory: 54508kb
input:
192247 195207 283700978 375630805 304536900 656995707 349419833 708624942 672433502 520674515 764718893 239174457 133144085 330437569 746169379 70258518 594755714 90821371 135440873 284046069 13226018 205346297 580203021 165858312 328670472 369986775 626061182 147106705 233473844 284462500 125956912...
output:
0 0 0 0 0 0 0 0 946220849 946220849 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 946220849 0 0 799990822 0 0 0 0 0 0 946220849 0 799990822 0 0 0 0 0 0 799953664 0 946220849 0 0 0 0 0 799940247 0 0 0 0 0 0 0 0 0 0 799940247 0 0 0 799942744 0 0 799996570 0 0 0 940226739 0 0 0 0 0 0 0 0 0 0 0 946220849 0 0 0 94622084...
result:
ok 48681 lines
Subtask #9:
score: 10
Accepted
Test #16:
score: 10
Accepted
time: 140ms
memory: 56032kb
input:
200000 200000 528930985 235973207 466767467 402016659 317374245 250837951 507340678 253656348 258016597 272673016 79972069 655199701 467655017 688146502 333191236 297745886 269247236 233526144 566947127 342438540 474935181 287475130 95235847 489947025 608569833 225058316 314312314 672017306 34789162...
output:
805427480 0 0 805427480 0 0 0 0 964622001 0 0 0 0 0 805427480 805427480 799994308 964622001 805427480 799994308 0 0 0 964622001 0 0 0 799895625 805427480 799929656 0 0 0 805427480 799994308 805427480 0 0 0 0 0 0 0 0 799991835 921331629 799994308 799993783 805427480 0 0 805427480 0 964622001 0 0 0 0 ...
result:
ok 49987 lines
Subtask #10:
score: 10
Accepted
Test #17:
score: 10
Accepted
time: 112ms
memory: 51220kb
input:
184466 180121 569024790 424341620 582247894 789997908 153645772 751624335 110488345 438497535 636816851 719408027 662734779 195349431 490536701 88364290 270826575 500058722 422096895 323370242 726020946 132560652 77857301 685544859 898126 517051590 207213973 305119180 230392425 292421735 763994110 6...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 852790406 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 852790406 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 916697584 0 0 0 0 0 0 0 0 852790406 0 0 820039801 0 0 0 0 0 0 0 0 0 0 0 0 976709850 852790406 0 0 0 0 0 0 0 0 0 927569861 ...
result:
ok 45001 lines
Test #18:
score: 10
Accepted
time: 133ms
memory: 57300kb
input:
200000 200000 57075583 318936234 385933100 284771289 437702009 621634712 517117387 0 774832313 262099632 474490840 255576398 0 423845387 564382296 457879822 589921402 192446326 62929863 121735185 374224043 650575595 741523547 208040608 598312128 79970456 381666526 708478481 427989596 490641985 15784...
output:
0 0 0 0 0 0 811560873 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 836460368 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 818096352 0 0 0 0 818096352 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 989979212 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 963130222 0 799997224 98...
result:
ok 49831 lines