QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#741806 | #7992. 【模板】线段树 | _LSA_# | WA | 2435ms | 177396kb | C++14 | 2.8kb | 2024-11-13 15:15:51 | 2024-11-13 15:15:56 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define fi first
#define se second
#define mk make_pair
using namespace std;
ll read(){
ll X = 0 ,r = 1;
char ch = getchar();
while(!isdigit(ch) && ch != '-') ch = getchar();
if(ch == '-') r = -1,ch = getchar();
while(isdigit(ch)) X = X*10+ch-'0',ch = getchar();
return X*r;
}
const int N = 2e5+10;
const int M = (1<<20)+10;
const int mod = (1<<20)-1;
unsigned pw[M][22],C[N][22];
void init(int n=2e5,int m=(1<<20)){
C[0][0] = 1;
for(int i=1;i<=n;i++){
C[i][0] = 1;
for(int j=1;j<=20;j++) C[i][j] = C[i-1][j-1]+C[i-1][j];
}
for(int i=1;i<=m;i++){
pw[i][0] = 1;
for(int j=1;j<=20;j++) pw[i][j] = pw[i][j-1]*i;
}
}
int n,q;
unsigned a[N],tag[N<<2];
struct node{
unsigned g[20];
node(){
memset(g,0,sizeof(g));
}
}t[N<<2];
node operator*(const node &x,const node &y){
node res;
for(int i=0;i<20;i++) for(int j=0;i+j<20;j++)
res.g[i+j] += x.g[i]*y.g[j];
return res;
}
#define ls rt<<1
#define rs rt<<1|1
void build(int rt,int l,int r){
if(l == r){
t[rt].g[0] = a[l];
t[rt].g[1] = 1;
return ;
}
int mid = (l+r) >> 1;
build(ls,l,mid);
build(rs,mid+1,r);
t[rt] = t[ls]*t[rs];
}
inline void change(int rt,unsigned d){
for(int i=0;i<20;i++){
unsigned res = 0;
for(int j=i;j<20;j++)
res += t[rt].g[j]*C[j][j-i]*pw[d][j-i];
// cout << res << "\n";
t[rt].g[i] = res;
}
tag[rt] = (tag[rt]+d)&mod;
}
inline void push_down(int rt){
if(tag[rt]){
change(ls,tag[rt]);
change(rs,tag[rt]);
tag[rt] = 0;
}
}
void update(int rt,int l,int r,int ql,int qr,unsigned d){
if(ql <= l && r <= qr) return change(rt,d);
push_down(rt);
int mid = (l+r) >> 1;
if(ql <= mid) update(ls,l,mid,ql,qr,d);
if(qr > mid) update(rs,mid+1,r,ql,qr,d);
t[rt] = t[ls]*t[rs];
}
node query(int rt,int l,int r,int ql,int qr){
if(ql <= l && r <= qr) return t[rt];
push_down(rt);
int mid = (l+r) >> 1;
if(mid >= qr) return query(ls,l,mid,ql,qr);
if(mid < ql) return query(rs,mid+1,r,ql,qr);
return query(ls,l,mid,ql,qr)*query(rs,mid+1,r,ql,qr);
}
int main(){
init();
n = read(); q = read();
for(int i=1;i<=n;i++) a[i] = read();
build(1,1,n);
while(q--){
int op = read(),l = read(),r = read();
if(op == 1){
int d = read();
update(1,1,n,l,r,d);
}else{
cout << (query(1,1,n,l,r).g[0]&mod) << "\n";
}
}
return 0;
}
/*
2 2
1 3
5 5
1 3 1 3 1
1 1 2 2
2 1 2
*/
詳細信息
Test #1:
score: 100
Accepted
time: 3ms
memory: 175348kb
input:
10 10 969575 741825 24903 1047319 450475 256145 1045323 479255 810659 768323 1 5 6 3034 2 1 10 2 1 9 2 1 4 1 3 6 126904 2 5 5 2 9 9 1 7 7 853094 1 4 9 1025178 2 5 8
output:
1045541 1012343 558151 580413 810659 527353
result:
ok 6 lines
Test #2:
score: 0
Accepted
time: 2435ms
memory: 176784kb
input:
200000 200000 496015 180543 330721 874799 740427 144379 598057 795949 323465 87657 683935 748203 748665 288301 846003 33033 746029 132621 876629 361899 701297 373189 256151 723161 377571 54947 91151 855991 433965 73347 155081 314317 790527 705555 1035217 298963 604641 203865 230029 802437 720769 843...
output:
746709 564663 426791 840425 762201 413693 881143 534387 189149 257625 60619 958793 250635 869079 383765 151047 272239 146175 46215 914259 617511 698623 381177 932779 792705 785375 1044293 202971 508317 237901 634919 646839 38501 304017 889609 214899 617927 720071 628729 202369 420511 528565 555717 7...
result:
ok 100378 lines
Test #3:
score: 0
Accepted
time: 2429ms
memory: 177248kb
input:
200000 200000 313625 170101 477893 536285 651807 542493 870481 1038171 205037 914869 1020857 263797 349049 146425 49155 634785 620419 520999 216377 365705 284761 874801 450169 521981 238295 791805 292987 339767 765065 1017179 333101 73531 855729 410125 933189 192789 52457 526865 918271 334533 876331...
output:
225575 235385 743949 20373 509445 393347 140689 735475 977073 494895 593783 118129 492359 290607 103169 466197 609397 831915 388819 1031053 461107 492189 790925 208041 397517 1008911 672577 873151 784219 796179 760731 460383 118997 497147 238277 523161 689295 284013 911061 929085 706393 43425 510263...
result:
ok 100374 lines
Test #4:
score: 0
Accepted
time: 1401ms
memory: 177316kb
input:
200000 200000 739417 442397 798113 1007491 665409 592547 462937 279569 996861 214643 160915 500005 469305 265763 795325 714747 389531 895767 42643 690581 622101 972937 523057 537349 516203 142465 236475 847121 91 207903 662211 217361 719869 627825 604205 672273 850891 1022115 1048509 897035 628451 3...
output:
444657 39965 452743 238997 193873 136779 260825 787865 9695 595453 261037 544313 699625 820773 559969 248143 774521 63201 638949 505491 716869 1030369 297709 62897 252693 946983 516321 487437 379371 462937 719033 135883 504135 358807 653171 667547 244677 757901 507969 47983 217365 482585 50135 2125 ...
result:
ok 100322 lines
Test #5:
score: 0
Accepted
time: 1385ms
memory: 175280kb
input:
200000 200000 878281 409257 412753 876501 321015 417441 946983 984087 562451 252151 374129 580547 937283 981209 389785 264703 440961 891661 388351 126163 259811 935411 1020727 464021 919541 640021 739311 742339 441387 1001965 243001 885461 512517 138375 284195 942661 327139 169879 187213 451495 3596...
output:
109927 998377 991627 620943 787199 273921 572857 720861 1017973 64061 139487 579101 504019 258045 603557 635973 482857 581423 929839 679177 136695 770551 555407 554481 397867 562315 143345 831265 539885 247475 748131 668535 355937 691045 822657 975439 1015853 419521 524191 379285 367763 616871 72602...
result:
ok 100002 lines
Test #6:
score: 0
Accepted
time: 1386ms
memory: 175292kb
input:
200000 200000 127893 64597 871723 63155 821817 218213 746965 755721 310759 814059 598775 632527 306539 52465 874049 814177 243599 487785 277453 349495 308319 46575 108867 732681 207131 919913 217321 337991 497569 581951 682603 696093 972195 684017 470693 11061 222099 415301 927951 549639 985241 3657...
output:
420091 18519 640371 904943 684475 1036055 125371 827039 1043611 365105 828065 516723 714231 354665 439379 532007 338053 897737 489167 643919 371741 927141 389683 236981 958531 9039 242417 105419 99761 338857 947389 885165 246889 614361 374675 764687 372385 736799 443909 974843 203445 114007 16069 18...
result:
ok 99968 lines
Test #7:
score: 0
Accepted
time: 1393ms
memory: 175300kb
input:
200000 200000 552729 50675 303307 219501 239115 563593 893279 207933 189701 331997 618615 154239 925927 379343 657609 596487 865283 638581 542281 532455 561911 468203 644599 903169 109173 544673 188019 1045397 582443 1042025 440935 973477 323733 962839 88373 1017593 724845 1415 257687 53431 9105 583...
output:
1004311 994397 283331 283373 358651 1044557 642177 849191 645865 338359 764519 359989 55583 358623 334417 971329 771383 241551 239343 678001 551689 855905 820529 906269 500967 169191 25389 177595 547533 525387 11781 149391 714847 86315 132663 735845 154711 791163 944107 143599 348051 68825 578927 26...
result:
ok 100487 lines
Test #8:
score: 0
Accepted
time: 1385ms
memory: 177344kb
input:
200000 200000 575177 557681 1002353 493679 352743 89217 869843 12137 33559 66533 863027 540457 504531 678293 901479 928227 720599 608365 849151 621057 250027 171949 275393 935665 308089 915065 673393 362717 594793 189327 735051 315341 413853 792019 967187 1029717 123133 272127 1044415 387851 539943 ...
output:
948807 806243 64705 251743 448317 325333 411821 716895 1033391 676065 759575 303009 280355 190165 1031133 151559 128289 501093 14521 598743 232451 521649 170415 370785 508273 1038995 215395 567067 84125 649463 954247 465053 827789 465053 790997 166955 105803 915513 71253 437073 282949 527089 887273 ...
result:
ok 99480 lines
Test #9:
score: 0
Accepted
time: 1388ms
memory: 175224kb
input:
200000 200000 882221 660105 538731 297131 886341 644377 386761 820241 454147 292943 25889 883147 449877 661847 912985 598895 409353 251235 876743 215475 816959 151689 843113 507553 214065 478113 328115 243763 531161 316423 608895 472243 295301 536125 748067 896975 888621 901489 959709 282659 105347 ...
output:
732079 1897 398235 826895 132261 1013735 455617 72641 503751 921843 271355 645451 432715 955837 901009 479467 957403 323345 202757 580215 163319 1022767 409345 772473 192851 667489 469149 1017755 317195 778665 509611 627913 569891 55169 63183 546729 1043679 81017 762265 917119 390211 741405 929853 6...
result:
ok 100308 lines
Test #10:
score: 0
Accepted
time: 1379ms
memory: 175228kb
input:
200000 200000 384849 532345 43083 43209 795051 227833 1042073 146175 36147 975669 518917 206645 260179 260527 975997 1045035 1014499 282973 278293 788491 889929 756037 58707 687759 981789 598217 448957 556941 734767 461657 786369 836109 123747 971483 458237 814657 1013559 881139 777837 573065 449295...
output:
89867 51467 450641 701417 173861 287229 82987 817843 801543 82987 218275 821635 401115 401115 801359 996737 401281 8299 38285 458019 1022033 700557 261405 696513 573203 178967 870709 1032533 433917 1017465 515537 481053 995153 92099 927267 973293 401303 173179 914689 742083 233337 774063 107853 1011...
result:
ok 100052 lines
Test #11:
score: 0
Accepted
time: 1379ms
memory: 175284kb
input:
200000 200000 562665 355033 546325 27599 904077 567287 226889 119357 94659 133007 427157 986781 300649 535213 232957 294815 141471 454615 902301 118519 281243 799927 769561 393977 926857 1013411 545831 129277 1033901 77247 215177 609269 434599 845667 476035 773097 446923 5583 398777 886489 95099 633...
output:
518065 303595 341693 507727 159343 234189 441185 464047 484833 994861 267275 955947 179555 345789 973715 232699 123181 188541 493439 780831 513831 850729 148331 380251 16969 214775 412689 662441 416301 276793 288285 894687 992137 127837 122449 501715 166257 182057 96141 1037921 349083 214155 474345 ...
result:
ok 100240 lines
Test #12:
score: -100
Wrong Answer
time: 1381ms
memory: 177396kb
input:
200000 200000 724927 19507 1000383 223083 612043 237831 758799 721837 11173 90137 951051 694565 108305 782913 208115 365167 815713 214681 589561 723105 157619 319579 921849 750143 376789 612529 539953 26395 309609 823759 387881 257133 904023 70225 424305 46217 118715 209767 628367 33541 780471 22726...
output:
945161 433909 794137 126313 864433 854279 157643 285011 701721 396349 352009 899045 722413 1026523 749115 3759 558339 342803 333769 400723 368739 817869 188801 179483 568357 543165 241047 578879 141533 476747 264795 487963 379217 847377 152547 605827 1048565 91191 761087 765697 205361 72559 708997 5...
result:
wrong answer 21222nd lines differ - expected: '381367', found: '0'