QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#77855 | #4260. 胡策的数列 | lmeowdn | 100 ✓ | 254ms | 61312kb | C++14 | 2.5kb | 2023-02-15 18:56:30 | 2023-02-15 18:56:33 |
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 fi first
#define se second
#define eb emplace_back
#define popc __builtin_popcount
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vp;
typedef unsigned long long ull;
typedef long double ld;
int read() {
int x=0,w=1; char c=getchar();
while(!isdigit(c)) {if(c=='-') w=-1; c=getchar();}
while(isdigit(c)) {x=x*10+c-'0'; c=getchar();}
return x*w;
}
const int N=1e5+9,mod=1e9+9,Q=400000004,Q1=333333338;
int n,m,last;
int ksm(int x,int y,int res=1) {
for(;y;y>>=1,x=1ll*x*x%mod) if(y%2==1) res=1ll*res*x%mod;
return res;
}
namespace Pow {
int b1[N],b2[N];
void init() {
b1[0]=1; rep(i,1,65536) b1[i]=1ll*b1[i-1]*Q%mod;
b2[0]=1; rep(i,1,65536) b2[i]=1ll*b2[i-1]*b1[65536]%mod;
}
int ksm(int k) {
return 1ll*b2[k>>16]*b1[k&65535]%mod;
}
int sum(int t,int len) {
return 1ll*(mod-ksm(len)+1)*Q1%mod*t%mod;
}
}
namespace SegT {
int tot=1,ls[N*52],tag[N*52],s[N*52];
void add(int p,int l,int r,int x) {
tag[p]=x, s[p]=Pow::sum(x,r-l+1);
}
void pushdown(int p,int l,int r) {
int mid=l+r>>1, tl=tag[p], tr=1ll*tl*Pow::ksm(mid-l+1)%mod;
if(!ls[p]) ls[p]=++tot, ++tot;
if(!tag[p]) return;
add(ls[p],l,mid,tl), add(ls[p]+1,mid+1,r,tr), tag[p]=0;
}
void mdf(int p,int l,int r,int x,int y,int z) {
if(l==x&&r==y) {add(p,l,r,z); return;}
int mid=l+r>>1; pushdown(p,l,r);
if(y<=mid) mdf(ls[p],l,mid,x,y,z);
else if(x>mid) mdf(ls[p]+1,mid+1,r,x,y,z);
else mdf(ls[p],l,mid,x,mid,z), mdf(ls[p]+1,mid+1,r,mid+1,y,1ll*z*Pow::ksm(mid-x+1)%mod);
s[p]=(s[ls[p]]+s[ls[p]+1])%mod;
}
int qry(int p,int l,int r,int x,int y) {
if(l==x&&r==y) return s[p];
int mid=l+r>>1; pushdown(p,l,r);
if(y<=mid) return qry(ls[p],l,mid,x,y);
else if(x>mid) return qry(ls[p]+1,mid+1,r,x,y);
else return (qry(ls[p],l,mid,x,mid)+qry(ls[p]+1,mid+1,r,mid+1,y))%mod;
}
}
signed main() {
n=read(), m=read();
Pow::init();
rep(i,1,m) {
int tp=read(), l=read()^last, r=read()^last;
if(tp==1) {
int t=read(), p=read();
t=1ll*t*Pow::ksm(p)%mod;
SegT::mdf(1,1,n,l,r,t);
} else {
printf("%d\n",last=SegT::qry(1,1,n,l,r));
}
}
return 0;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 10
Accepted
time: 4ms
memory: 6160kb
input:
1000 1000 2 384 887 2 794 916 2 387 493 2 363 422 2 60 691 1 541 927 173 737 2 212 369 1 430 783 863 124 2 68 136 1 23 803 70 168 2 394 457 2 56242175 56241970 1 18045698 18045244 538 199 1 18045848 18045921 414 527 1 18045688 18045297 874 863 2 18045455 18045249 1 880171240 880171588 328 337 2 8801...
output:
0 0 0 0 0 0 0 56242132 18045604 880171482 477526151 838944069 740785259 882289977 253097102 530619418 135365592 311979571 584364758 761128655 711260443 949760017 203085964 142835142 115454535 102294382 89795056 55931673 303609557 815174619 402367324 766041848 740353151 733440996 438097500 640430754 ...
result:
ok 500 numbers
Test #2:
score: 10
Accepted
time: 4ms
memory: 6016kb
input:
1000 1000 1 823 873 158 482 2 567 746 1 542 593 459 839 1 217 586 540 193 2 84 173 1 833 873 243 807 1 92 483 51 919 1 410 923 919 756 1 246 485 190 379 1 648 980 565 216 2 456 994 2 65959875 65959002 2 773846455 773846965 1 191311586 191311528 987 557 2 191311287 191310944 2 22407670 22407911 1 472...
output:
0 0 65959822 773846169 191311202 22407185 472545886 220034051 336838514 323534787 678791954 886476115 19617098 760037962 779624112 932641069 949739749 736166125 804486947 146049010 213058043 255540338 403106132 807095893 260454467 729091124 239113794 498046643 386140147 568259388 679398138 57905065 ...
result:
ok 500 numbers
Test #3:
score: 10
Accepted
time: 19ms
memory: 8252kb
input:
30000 30000 2 887 29384 2 7794 16916 2 493 5387 2 12363 21422 2 8691 20060 1 541 23927 304089173 303455737 2 15369 25212 1 237797251 237787962 278722863 233665124 2 237786573 237779097 1 703548462 703532674 369133070 125898168 2 703561627 703534528 2 377940594 377938319 1 93626610 93621148 756898538...
output:
0 0 0 0 0 237790877 703560425 377916420 93631434 439338167 772677051 175510345 801831100 418197506 906423449 497326948 988715399 131444883 393683721 437392271 126060498 126355989 336526065 368779179 727474051 370546613 126937695 415443245 701126638 764740039 506628443 944231485 521246118 753451028 7...
result:
ok 14984 numbers
Test #4:
score: 10
Accepted
time: 24ms
memory: 4704kb
input:
30000 30000 2 5821 16155 2 21156 25068 1 944 24742 977572053 94719788 1 8410 21903 677519484 967968374 1 17136 21048 16957465 121199415 2 6461 25814 2 114355083 114358883 2 823991500 824016441 1 762415120 762423172 330946912 441374400 1 762415309 762438009 369862417 319360390 1 762421378 762444477 4...
output:
0 0 114354111 823996866 762418481 708851870 3976751 201233285 373638119 880123765 372357104 920079245 988775753 772653713 623527043 948815916 18722719 252681185 900152733 24611455 900616871 195766299 456280292 153020282 51203803 445054542 863119684 949987995 187775901 287986874 443556564 884758067 8...
result:
ok 14961 numbers
Test #5:
score: 10
Accepted
time: 22ms
memory: 6820kb
input:
30000 30000 1 11672 21190 182524338 341458088 1 23094 27178 936382447 89409995 2 8968 16814 1 447005802 446999706 239551406 220913531 1 447009545 446996469 247978260 192448686 1 447013567 446994681 514619010 997375262 1 447010954 447015996 137285127 152638542 1 447007818 447013331 225505930 19995890...
output:
447005995 503304211 472993327 785986850 641195805 580357571 491166112 76840537 918072161 25019865 680235017 749460789 836614922 43635421 767038482 266567875 73669068 550155488 351493066 714084732 804768721 818726695 551432383 758405005 156226633 949106735 83090008 600950110 760416604 691027120 39234...
result:
ok 15086 numbers
Test #6:
score: 10
Accepted
time: 245ms
memory: 61068kb
input:
1000000000 100000 1 165084912 560398153 114562054 7946614 1 513316289 709627600 692684682 9563221 1 151772576 940696860 889928665 277940 2 516574848 908637016 2 697674775 464569011 2 62680191 706401562 2 818225483 971242722 1 340438947 714758124 367958170 7698954 1 223526674 20218074 523602081 64750...
output:
691639679 45271960 642373555 452318838 0 905728399 582251033 240367983 444760360 892811302 169615563 199316292 26606467 459915894 143963282 950558664 872205947 843415824 52754835 551905759 30265604 460066797 91711477 304761823 818570236 371005021 143224048 622328782 399700382 8982358 35233026 971761...
result:
ok 50277 numbers
Test #7:
score: 10
Accepted
time: 236ms
memory: 60272kb
input:
1000000000 100000 2 321770517 672581096 1 226562689 229475348 350357621 3604885 1 589424486 634776553 1904202 608903 2 215478793 496636707 2 833999414 997049963 2 945104982 298718780 1 461246959 781776053 974089684 5310027 2 815390949 933919213 2 770622914 514835494 2 25389709 385935935 2 27135093 7...
output:
0 368947312 556498322 406410337 955413929 251601473 76960991 454070706 372797892 841194373 840784196 275444049 872564080 243862590 148808317 134948865 211971104 352483992 263578993 469989347 72279261 783688816 927839326 764138737 372870987 29387538 836481406 987274329 426332588 912563786 143187926 8...
result:
ok 50220 numbers
Test #8:
score: 10
Accepted
time: 208ms
memory: 60516kb
input:
1000000000 100000 2 460261625 925796893 1 584753743 898648885 265360960 161653620 1 105613561 961699382 901990208 407847025 1 3961667 834186672 874747354 904671659 2 26040530 339508690 2 51577036 809441626 1 469425687 683003902 661914301 68789242 2 409198322 392777413 2 83531507 392936481 2 80892178...
output:
0 518001099 429676676 782141897 828524744 172709301 906926439 119974336 161801940 512571999 483915020 981149711 314434222 761397355 429029732 678165642 504813936 919446041 152057744 714146117 759095793 557630848 294974715 775117018 755145473 96701673 190224840 696776452 120505279 105627680 75837198 ...
result:
ok 50106 numbers
Test #9:
score: 10
Accepted
time: 254ms
memory: 58096kb
input:
1000000000 100000 2 410193210 625780412 2 484091042 766471904 2 242778609 266666348 2 369337484 504172986 2 251064700 747420962 1 506442375 857569106 831720664 971642389 2 106119119 757690602 1 730229206 168522714 349281888 403980853 1 1060677836 42772911 2369067 921630284 1 669040424 984529296 6105...
output:
0 0 0 0 0 781903709 929867145 459363812 212780104 453912615 440007919 625295584 465520552 783026852 469175335 92940620 15724850 284932419 45023869 813773810 16856580 538748603 133637004 23079199 43519935 405667356 727672212 710288340 313084952 464718386 554125000 572040550 273134781 117236642 581359...
result:
ok 50092 numbers
Test #10:
score: 10
Accepted
time: 221ms
memory: 61312kb
input:
1000000000 100000 2 948833365 967646174 2 678378654 699920239 1 528186592 724233230 659619398 100407090 2 434002148 477729496 1 125929935 858751315 638568830 420308079 1 253095689 815238031 780603257 802330740 1 223711150 450609527 597730182 864164468 2 847533935 943338342 1 268297717 321161318 3159...
output:
0 0 0 578813110 363170865 731071974 438189371 209686818 902294331 907728751 679725026 956028499 776662407 272525978 762646744 367414572 562007763 359508225 776264782 878114050 988643681 269537431 990921205 549579854 800433433 341839123 17739678 445622562 208028703 620273271 201059674 535245301 83716...
result:
ok 50002 numbers
Extra Test:
score: 0
Extra Test Passed