QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#281731 | #5302. Useful Algorithm | Crying | AC ✓ | 2009ms | 324292kb | C++17 | 2.4kb | 2023-12-10 16:57:36 | 2023-12-10 16:57:36 |
Judging History
answer
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define op(x) ((x&1)?x+1:x-1)
#define odd(x) (x&1)
#define even(x) (!odd(x))
#define lc(x) (x<<1)
#define rc(x) (lc(x)|1)
#define lowbit(x) (x&-x)
#define mp(x,y) make_pair(x,y)
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
using namespace std;
const ll MAXN = 1e5+10,M = 16,INF = 3e18,V = 2e9;
void tomax(ll& x,ll y){x = max(x,y);}
int n,m,q,pw[M+1];
ll w[M+1],c[MAXN],d[MAXN],lst;
struct PQ{ //可删堆
priority_queue<ll>p,q;
void ins(ll x){p.push(x);}
void rmv(ll x){q.push(x);}
int sz(){while(p.size() && q.size() && p.top()==q.top())p.pop(),q.pop();return p.size();}
ll top(){return p.top();}
}a[M+1][1<<M],b[M+1][1<<M];
#define mid ((l+r)>>1)
struct Seg{
ll t[1<<(M+2)],a[1<<(M+2)],b[1<<(M+2)];
void pu(int x){
t[x] = max({t[lc(x)],t[rc(x)],b[lc(x)]+a[rc(x)]});
a[x] = max(a[lc(x)],a[rc(x)]);
b[x] = max(b[lc(x)],b[rc(x)]);
}
void build(int x,int l,int r){
a[x] = b[x] = -V;
if(l==r)return;
build(lc(x),l,mid);build(rc(x),mid+1,r);
}
void mdf(int x,int l,int r,int pos,ll val,int tag){
if(l==r){
if(tag==1)a[x] = val;
else if(tag==2)b[x] = val;
else assert(0);
t[x] = a[x]+b[x];
return;
}
(pos<=mid)?(mdf(lc(x),l,mid,pos,val,tag)):(mdf(rc(x),mid+1,r,pos,val,tag));
pu(x);
}
}seg[M+1];
#undef mid
void mdf(ll c,ll d,ll tag){
rep(x,1,m){
ll val=c%pw[x];
if(tag==1){
a[x][val].ins(d);
if(val)b[x][pw[x]-val].ins(d);
}else{
a[x][val].rmv(d);
if(val)b[x][pw[x]-val].rmv(d);
}
ll tmp = (a[x][val].sz()) ? (a[x][val].top()) : (-V);
seg[x].mdf(1,0,pw[x]-1,val,tmp,1);
if(val){
ll tmp = (b[x][pw[x]-val].sz()) ? (b[x][pw[x]-val].top()) : (-V);
seg[x].mdf(1,0,pw[x]-1,pw[x]-val,tmp,2);
}
}
}
ll calc(){
ll ans = 0;
rep(x,1,m){
ll sum = seg[x].t[1];
tomax(ans,sum * w[x]);
}
return ans;
}
int main(){
ios::sync_with_stdio(false);cin.tie(0);
cin>>n>>m>>q;
pw[0]=1;
rep(i,1,m)cin>>w[i],pw[i]=pw[i-1]*2;
rep(i,1,n)cin>>c[i];
rep(i,1,n)cin>>d[i];
rep(i,1,m)seg[i].build(1,0,pw[i]-1);
rep(i,1,n)mdf(c[i],d[i],1);
lst = calc();
cout<<lst<<"\n";
rep(i,1,q){
ll x,u,v; cin>>x>>u>>v;
x ^= lst,u ^= lst,v ^= lst;
mdf(c[x],d[x],-1);
c[x] = u,d[x] = v;
mdf(c[x],d[x],1);
lst = calc();
cout<<lst<<"\n";
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 22ms
memory: 155060kb
input:
5 3 3 1 2 4 0 0 1 2 7 10 10 5 3 1 27 24 29 20 16 19 13 8 9
output:
24 16 8 0
result:
ok 4 number(s): "24 16 8 0"
Test #2:
score: 0
Accepted
time: 19ms
memory: 157228kb
input:
10 3 10 927067928 939794644 439925712 4 7 6 2 4 2 0 7 0 7 207761141 796144622 434713413 101162902 804840394 950218456 666995722 154361380 192946720 522277478 1786020431157499334 1786020431157499335 1786020431397722754 1496424903210009138 1496424903210009136 1496424902707960940 981667153012455665 981...
output:
1786020431157499328 1496424903210009136 981667153012455664 981667153012455664 817082674424719944 1083086338546577104 1186096888772143904 1186096888772143904 1186096888772143904 768437095486384888 848350340146561056
result:
ok 11 numbers
Test #3:
score: 0
Accepted
time: 16ms
memory: 167636kb
input:
100 5 100 90634477 839424973 368714032 715789796 976912516 14 25 23 26 21 6 18 25 13 16 1 11 6 19 23 30 20 16 9 5 15 14 18 25 20 21 16 20 1 17 5 20 29 21 23 30 14 21 16 25 0 10 30 15 5 18 20 15 16 14 8 13 25 3 19 1 28 25 20 4 25 31 13 22 21 5 4 27 24 0 3 25 14 9 25 27 6 31 23 17 22 0 20 14 20 20 10 ...
output:
1948430837606303184 1925731571920031664 1925731571920031664 1918610389626725016 1918610389626725016 1912989537852540976 1912989537852540976 1943875008041762216 1880564337285514332 1872790752298860048 1872790752298860048 1872790752298860048 1860886514497440896 1840781733071162176 1840781733071162176 ...
result:
ok 101 numbers
Test #4:
score: 0
Accepted
time: 19ms
memory: 200160kb
input:
200 10 200 686225366 625898088 889833199 755030970 349397678 32982490 273727441 273558302 259659090 988780410 764 308 833 222 75 641 80 22 298 315 295 545 284 459 960 884 566 848 491 631 930 542 972 519 28 570 603 1013 120 480 482 900 538 1022 131 1007 380 694 176 737 172 480 945 763 459 389 34 593 ...
output:
1976367332381717700 1976367332381717700 1976367332381717700 1919420428070056950 1896682288410976680 1851396613326110610 1848014565081016770 1848014565081016770 1844553517236285570 1844515090263211740 1839357062871524190 1835762131192937760 1831576340926210500 1820368528821786240 1813214370325218480 ...
result:
ok 201 numbers
Test #5:
score: 0
Accepted
time: 28ms
memory: 200636kb
input:
1000 10 1000 634018763 100170818 567660357 254302610 840960097 802296108 283969325 368515437 441547602 397000462 612 405 890 783 513 253 461 140 625 8 464 401 1011 271 27 355 794 222 734 246 846 310 88 374 330 844 353 706 415 584 993 492 816 456 342 954 436 90 339 808 56 517 1019 996 922 705 138 209...
output:
1681866301913143852 1681866301913143852 1680999430153635088 1676312717485049238 1674196766011546180 1673931937585479716 1673454371483675162 1672867243418513254 1672867243418513254 1672867243418513254 1672669252819036156 1671478710655473838 1671478710655473838 1665328148837561252 1665328148837561252 ...
result:
ok 1001 numbers
Test #6:
score: 0
Accepted
time: 2009ms
memory: 302880kb
input:
100000 16 100000 427137788 524903900 786287591 199228679 318168922 101722889 789810886 488566259 846829249 575667147 767258103 63802528 801156446 519047646 781774765 555029219 4621 48336 12816 52645 55523 30344 27584 3940 41894 60346 15947 30387 19024 31860 33462 13493 28048 58004 12794 7590 22857 6...
output:
1693617423394106504 1693589359472794644 1693492085043791263 1693480115112356648 1693470840638421600 1693453134285654259 1693444900564866232 1693444900564866232 1693416918785991525 1693393685178715961 1693387980090065448 1693380527992674248 1693380527992674248 1693380527992674248 1693380527992674248 ...
result:
ok 100001 numbers
Test #7:
score: 0
Accepted
time: 12ms
memory: 157264kb
input:
10 3 10 6 10 28 2 1 6 4 1 6 4 5 6 6 6 9 11 3 11 10 7 20 9 12 1128 1122 1128 675 673 681 674 679 695 1282 1289 1283 1290 1295 1309 1178 1180 1182 566 560 561 510 507 488 693 698 695 754 752 753
output:
1120 672 672 1288 1288 1176 560 504 700 756 616
result:
ok 11 numbers
Test #8:
score: 0
Accepted
time: 18ms
memory: 169424kb
input:
100 5 100 3 12 29 85 248 19 16 18 16 1 2 2 13 21 2 12 28 5 16 4 25 10 11 25 21 10 1 26 25 26 16 6 16 17 10 26 1 17 5 7 16 5 16 2 0 21 9 16 20 4 10 16 14 21 18 17 3 12 10 16 25 16 22 8 12 26 8 8 18 16 25 21 25 11 8 28 22 28 2 18 20 3 20 2 14 4 9 11 26 25 13 21 8 2 14 28 25 26 1 13 9 7 5 17 18 60 2 21...
output:
29760 29016 31248 31248 31248 31248 29016 28272 27776 27776 27032 27032 27032 27032 27528 27528 26784 28520 28272 26536 28024 28024 28024 28024 26536 25792 25792 25792 27528 27528 27528 27032 25792 25792 27032 25792 25544 25544 26288 25296 25296 25048 25048 25048 24800 23808 23808 23312 26288 26288 ...
result:
ok 101 numbers
Test #9:
score: 0
Accepted
time: 12ms
memory: 198484kb
input:
200 10 200 4 13 32 82 247 734 2192 6565 19688 59054 0 0 130 320 40 10 2 80 33 384 128 32 160 768 32 2 144 34 80 640 528 96 768 272 0 6 384 3 36 256 96 514 65 320 258 192 24 514 128 132 256 2 132 512 128 10 6 65 513 128 80 129 66 5 384 3 136 72 65 2 768 272 257 10 10 512 65 48 512 4 24 128 4 48 1 384...
output:
122005564 122005564 122005564 122005564 121887456 121769348 121651240 121651240 121415024 121415024 62124808 62065754 62006700 62006700 62006700 62006700 62183862 61947646 61829538 61829538 61770484 61770484 61593322 61593322 61652376 61534268 61534268 61475214 61061836 61061836 61061836 61061836 61...
result:
ok 201 numbers
Test #10:
score: 0
Accepted
time: 15ms
memory: 200628kb
input:
1000 10 1000 3 11 31 82 247 731 2188 6561 19687 59053 36 2 384 258 256 544 258 1 18 16 128 32 80 257 260 260 144 68 192 384 65 17 2 1 512 272 129 136 576 320 516 260 132 4 32 16 3 72 36 192 528 272 513 9 18 40 256 1 384 16 32 4 1 130 80 3 544 80 264 96 528 768 80 9 16 8 257 256 516 72 144 48 0 4 192...
output:
122121604 122121604 122003498 122003498 122003498 122003498 122003498 122003498 122003498 122003498 122003498 122003498 122003498 122003498 121885392 121885392 121885392 121767286 121767286 121649180 121531074 121412968 121412968 121294862 121294862 121294862 121294862 121294862 121294862 62064703 6...
result:
ok 1001 numbers
Test #11:
score: 0
Accepted
time: 1789ms
memory: 318876kb
input:
99999 16 100000 3 9 32 84 245 733 2190 6561 19683 59050 177152 531443 1594327 4782974 14348909 43046726 1642 55940 57776 65132 11056 61383 22142 32537 3694 43670 31968 28464 563 7983 37096 38110 62735 44622 4563 27145 2059 2313 17509 2943 891 19910 6214 51250 31187 25848 9982 56902 33266 21910 25578...
output:
11287626398268 11286808510474 11286679370296 11286679370296 11286507183392 11285732342324 11285732342324 11285560155420 11285517108694 11285474061968 11285431015242 11285431015242 11285431015242 11285431015242 11285129688160 11285043594708 11285043594708 11285043594708 11284914454530 11284914454530 ...
result:
ok 100001 numbers
Test #12:
score: 0
Accepted
time: 1643ms
memory: 324292kb
input:
100000 16 100000 8 11 30 86 244 733 2192 6563 19688 59049 177151 531442 1594325 4782969 14348910 43046723 2143 19651 46093 32788 44162 7792 49357 50724 6403 43320 4614 42188 33125 16678 49920 17737 1577 1448 3589 53456 25892 9378 6934 42440 6368 54324 46112 17184 21345 6413 50416 488 7826 5408 49664...
output:
11110617486638 11110273112854 11109842645624 11109842645624 11109756552178 11109670458732 11109670458732 11022285611042 11021812097089 11021726003643 11021467723305 11021381629859 11021381629859 11021381629859 10977861392906 10977861392906 10977689206014 10977603112568 10977603112568 10977603112568 ...
result:
ok 100001 numbers
Test #13:
score: 0
Accepted
time: 1779ms
memory: 317628kb
input:
100000 16 100000 3 14 28 86 245 731 2190 6566 19684 59050 177149 531446 1594327 4782974 14348911 43046721 35585 48946 4169 49124 37720 2526 14618 34754 63357 59952 7239 15556 60707 22083 46332 38928 53901 45284 39992 22205 11543 11287 28497 17497 63406 64402 34412 5476 16722 22336 64262 4563 7067 19...
output:
11288399928156 11287625087178 11287625087178 11287582040457 11287538993736 11287194619968 11286979386363 11286979386363 11286505872432 11286505872432 11286505872432 11286505872432 11286462825711 11286462825711 11286419778990 11286290638827 11286075405222 11285903218338 11285903218338 11285903218338 ...
result:
ok 100001 numbers
Test #14:
score: 0
Accepted
time: 1289ms
memory: 311696kb
input:
99999 15 100000 8 12 32 85 245 732 2191 6565 19686 59050 177149 531445 1594327 4782972 14348911 2310 16737 25888 676 18978 48 29186 9800 3340 8642 1330 1442 386 12816 8408 417 20483 13336 818 20644 5456 8362 3110 9250 8236 28673 4188 41 3596 1283 8288 16903 3076 3338 3649 4122 7170 18848 4720 6472 2...
output:
1763796837942 1763796837942 1763796837942 1763739442298 1763739442298 1763739442298 1763710744476 1763710744476 1763710744476 1763682046654 1763682046654 1763624651010 1763624651010 1763595953188 1763595953188 1763595953188 1763595953188 1763595953188 1763595953188 1763567255366 1763567255366 176356...
result:
ok 100001 numbers
Test #15:
score: 0
Accepted
time: 1130ms
memory: 308724kb
input:
100000 16 100000 6 12 30 86 246 729 2189 6563 19684 59049 177151 531446 1594328 4782970 14348911 43046725 8224 9216 5 6 32896 1025 4608 1032 1026 66 2560 2304 32768 258 80 4112 40 16385 9 320 32768 2304 2560 384 12 8196 1024 4608 4100 66 6 4096 6144 260 3 1280 80 12288 2052 33 3 1032 96 272 32 40 64...
output:
5643253460600 5643253460600 5643253460600 5643253460600 5643253460600 5643253460600 5643253460600 5643253460600 5643253460600 5643253460600 5643253460600 5643253460600 5643253460600 5643253460600 5643253460600 5643253460600 5643253460600 5643253460600 5643253460600 5643253460600 5643253460600 564325...
result:
ok 100001 numbers
Test #16:
score: 0
Accepted
time: 1779ms
memory: 306028kb
input:
99999 16 100000 14349541 616 353 177444 7279 511 507 4783666 457 531483 2933 729 1124 1594718 59971 19687 17570 20019 20455 4413 33746 33720 24030 9441 57585 24783 37529 52321 17802 61469 9782 3667 29619 40902 51073 57698 55286 52544 57893 52345 31528 20804 24499 6465 39750 64956 19162 57057 1549 45...
output:
3762449650200 3762306154790 3762047863052 3761990464888 3761933066724 3761846969478 3761846969478 3761732173150 3761646075904 3761617376822 3761416483248 3761387784166 3761387784166 3761387784166 3761272987838 3761244288756 3761244288756 3761158191510 3761043395182 3761014696100 3760899899772 376089...
result:
ok 100001 numbers
Test #17:
score: 0
Accepted
time: 963ms
memory: 287500kb
input:
100000 16 100000 124 982 2191 243 20 531828 14349477 245 1594739 177857 940 7387 20339 59670 714 4783306 1 4 8 32 256 2048 32 256 1024 0 4 8192 1024 2 16 256 64 64 0 32768 2048 512 8 4096 0 0 16 8192 16384 256 16 512 512 32768 4096 8192 16 32 128 0 256 128 256 8192 64 2 16384 4 32 2 4 4 2 8 4 8 32 0...
output:
200892678 200892678 200892678 200892678 200892678 200892678 200892678 200892678 200892678 200892678 200892678 200892678 200892678 200892678 200892678 200892678 200892678 200892678 200892678 200892678 200892678 200892678 200892678 200892678 200892678 200892678 200892678 200892678 200892678 200892678 ...
result:
ok 100001 numbers
Test #18:
score: 0
Accepted
time: 1778ms
memory: 304756kb
input:
100000 16 100000 7175 527 59959 14349732 255 2608 5 1594685 4783340 1556 708 531765 422 637 177561 20324 41088 45384 12182 21333 29701 3975 54781 63144 40231 37774 42270 30386 25885 26371 16122 19448 18771 9443 2310 41357 52710 12286 42666 37787 8232 22902 17348 48609 35106 55108 44834 6704 45069 35...
output:
3762829774236 3762829774236 3762815424504 3762786725040 3762758025576 3762700626648 3762671927184 3762528429864 3762485380668 3762456681204 3762456681204 3762456681204 3762456681204 3762370582812 3762327533616 3762270134688 3762270134688 3762270134688 3762241435224 3762227085492 3762155336832 376215...
result:
ok 100001 numbers
Test #19:
score: 0
Accepted
time: 1106ms
memory: 292036kb
input:
99999 15 100000 37 376 4783689 59806 605 1594793 177668 734 7428 20509 961 532288 734 2649 727 8384 133 1064 8224 2058 2336 4096 8208 8197 768 2112 16448 3136 161 20480 20488 16640 80 100 352 1 2208 552 16449 24580 36 81 16448 10368 529 14336 21504 168 529 16394 2176 16520 266 16514 146 4128 16480 4...
output:
509592038103 509587254414 509587254414 509587254414 509587254414 509587254414 509582470725 509582470725 509582470725 509582470725 509577687036 509577687036 509577687036 509577687036 509577687036 509577687036 509577687036 509577687036 509577687036 509577687036 509577687036 509577687036 509577687036 5...
result:
ok 100001 numbers
Test #20:
score: 0
Accepted
time: 1102ms
memory: 297160kb
input:
100000 16 100000 6815 177235 4783963 926 59409 532008 745 14349155 1001 241 2225 479 20270 1594629 764 763 12288 32800 32784 129 5 1032 272 6144 48 288 17408 49152 32768 5120 32770 2560 8256 16416 33 544 12 3 1026 1152 33280 2049 1025 5 49152 12288 48 12288 20 129 4128 48 513 576 32784 258 33280 327...
output:
1881116823880 1881116823880 1881116823880 1881116823880 1881116823880 1881116823880 1881116823880 1881116823880 1881116823880 1881116823880 1881116823880 1881116823880 1881116823880 1881116823880 1881116823880 1881116823880 1881116823880 1881116823880 1881116823880 1881116823880 1881116823880 188111...
result:
ok 100001 numbers