QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#358133 | #6832. Last Warning of the Competition Finance Officer | crsfaa# | AC ✓ | 192ms | 77868kb | C++14 | 1.6kb | 2024-03-19 17:31:07 | 2024-03-19 17:31:08 |
Judging History
answer
#include<bits/stdc++.h>
#define Yukinoshita namespace
#define Yukino std
using Yukinoshita Yukino;
int read()
{
int s=0,w=1;
char ch=getchar();
while(ch<'0'||ch>'9') w=ch=='-'?-1:1,ch=getchar();
while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
return s*w;
}
const int mod=998244353;
const int mxn=4e5+5;
inline void getmod(int &x)
{
x-=(x>=mod)*mod;
}
struct node
{
int link,len,nxt[26];
}t[mxn];
int v[mxn];
int last=1,cnt=1,n;
vector<pair<int,int>> qwq[mxn];
void insert(int c,int id)
{
int w=++cnt,p,q,cl;
v[id]=w;
t[w].len=t[last].len+1;
for(p=last;p&&!t[p].nxt[c];p=t[p].link)
t[p].nxt[c]=w;
if(!p)
t[w].link=1;
else
{
q=t[p].nxt[c];
if(t[q].len==t[p].len+1)
t[w].link=q;
else
{
cl=++cnt;
t[cl]=t[q];
t[cl].len=t[p].len+1;
t[q].link=t[w].link=cl;
for(;t[p].nxt[c]==q;p=t[p].link)
t[p].nxt[c]=cl;
}
}
last=w;
}
char s[mxn],T[mxn];
int dp[mxn];
vector<int> a[mxn];
int nxt[mxn];
void dfs(int d,int tp)
{
nxt[d]=tp;
if(qwq[d].size()) tp=d;
for(auto x:a[d])
dfs(x,tp);
}
int main()
{
scanf("%s",s+1);
int n=strlen(s+1),i,j;
for(i=1;i<=n;i++)
insert(s[i]-'a',i);
int m=read();
while(m--)
{
scanf("%s",T);
int l=strlen(T),w=1,v=read();
for(i=0;i<l;i++)
w=t[w].nxt[T[i]-'a'];
if(w)
qwq[w].push_back({l,v});
}
for(i=2;i<=cnt;i++)
a[t[i].link].push_back(i);
dfs(1,0);
for(i=1;i<=n;i++)
{
dp[i]=dp[i-1];
for(j=qwq[v[i]].size()?v[i]:nxt[v[i]];j;j=nxt[j])
for(auto x:qwq[j])
dp[i]=(dp[i]+1ll*(dp[i-x.first]+1)*x.second)%mod;
printf("%d ",(dp[i]+1)%mod);
}
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 26432kb
input:
ababa 2 aba 2 ba 3
output:
1 1 6 6 26
result:
ok 5 tokens
Test #2:
score: 0
Accepted
time: 4ms
memory: 26364kb
input:
qfmyqqfmyqqfmyq 2 qfmyq 111111 myqq 404968002
output:
1 1 1 1 111112 405079114 405079114 405079114 405079114 771912310 239058268 239058268 239058268 239058268 31169271
result:
ok 15 tokens
Test #3:
score: 0
Accepted
time: 4ms
memory: 26496kb
input:
wwwsoupunetcom 2 money 999999 soup 998244352
output:
1 1 1 1 1 1 0 0 0 0 0 0 0 0
result:
ok 14 tokens
Test #4:
score: 0
Accepted
time: 2ms
memory: 26744kb
input:
azero 1 a 998244352
output:
0 0 0 0 0
result:
ok 5 tokens
Test #5:
score: 0
Accepted
time: 0ms
memory: 26372kb
input:
aiiaiaia 2 aiia 5 iiii 2
output:
1 1 1 6 6 6 6 6
result:
ok 8 tokens
Test #6:
score: 0
Accepted
time: 6ms
memory: 26352kb
input:
lnvnnvlvvnnnlln 3 vllln 7 nlnlvlvnn 7 n 2
output:
1 3 3 9 27 27 27 27 27 81 243 729 729 729 2187
result:
ok 15 tokens
Test #7:
score: 0
Accepted
time: 6ms
memory: 28980kb
input:
ewxwxwxewexxxeexexeeexeeeexxxexwwxeewxexxexwxexwxewwwewxxwwwxeexxxxweeweeewwwwxxewewwxeexxxeeewwwxeewexxxexwwwewxeweeewwwxeewexewxwweewxexewxwxxxwxxwwewewwwexxwwweexwexxwxewxwexewexwexweexwxwwxwxwweewexxxxewwwxxexwwxewxewwwwxwwxxexwwwxwexwxeeeexwwwxwxxwxxexexwewwewewewexwexwwewxexwxxxwxewexweeeexwxe...
output:
1 4 32 128 1024 4096 32768 32768 131072 131072 1048576 8388608 67108864 67108864 67108864 536870912 209715199 679477239 58720241 58720241 58720241 469761928 58719985 58719985 58719985 58719985 469759880 763345981 117301730 117301730 938413840 758922301 40956145 327649160 327649160 327649160 31235228...
result:
ok 3999 tokens
Test #8:
score: 0
Accepted
time: 36ms
memory: 59332kb
input:
fsednrpubwbzxugoznffuvabwcsfleuuzysyguzpaebygywmspikmrchjrqwnsuajulhztddbhsettkfgrwffianmurgmbagmmnxeqijppgvvaqusszvkzdtftzrhwaotrwnwxpsexqjrpinojpmrucnuiuxruyuatuttdapxunwrqgmwpxafnuhyyhebsjffodwazlbsodbbvitqemftxlbrlzataluvgghhabfvjgtlymetljlwrdavdtchhqlvgcwpzecnxhwhrhntscqzvskfgoqtvfcimpzzvwxjoey...
output:
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
result:
ok 200000 tokens
Test #9:
score: 0
Accepted
time: 47ms
memory: 77396kb
input:
mqmqqqqmmmqmmmmqmqmqqmqmmqqqqqmmmqqqqmmqmqqqqqmqqmmqqmqqqqqqqmqmqmqmqmqqqqmmmmqmqmmqmqqqmmmqqqmmqmqmqmqmmmqqqqqqmqqmqmqqmqmmqmmqmqmmmqmmmmqmmmqqqmmqmmqmqqmqqqqqmqqmmqqqmqmqmmmqmmmmqmqqqqqqmmmqqqmmqmmmqqmqqmqqmqmqqmqmmmmmqqqqqmmmmqqqmmqqqqqmmqqmmqmqqqqqmqqmqqqmmmqmmmmqmqqmqqqqmqmmqqqmqmqqmmqmmqqqqmqq...
output:
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
result:
ok 200000 tokens
Test #10:
score: 0
Accepted
time: 46ms
memory: 66544kb
input:
zttztzzttzztzttztzztzttzzttztzzttzztzttzzttztzztzttztzzttzztzttztzztzttzzttztzztzttztzzttzztzttzzttztzzttzztzttztzztzttzzttztzzttzztzttzzttztzztzttztzzttzztzttzzttztzzttzztzttztzztzttzzttztzztzttztzzttzztzttztzztzttzzttztzzttzztzttzzttztzztzttztzzttzztzttztzztzttzzttztzztzttztzzttzztzttzzttztzzttzzt...
output:
1 946852958 430426865 779623793 317175025 921269781 921269781 873292193 464703273 21110678 21110678 443492495 217360625 376615661 834805190 728273869 746753500 641883107 641883107 927443781 511400149 634152015 218432797 475037110 475037110 740681916 415962099 39102848 826166045 290244563 290244563 6...
result:
ok 200000 tokens
Test #11:
score: 0
Accepted
time: 45ms
memory: 65840kb
input:
laalallaallalaalallalaallaalallaallalaallaalallalaalallaallalaalallalaallaalallalaalallaallalaallaalallaallalaalallalaallaalallaallalaallaalallalaalallaallalaallaalallaallalaalallalaallaalallalaalallaallalaalallalaallaalallaallalaallaalallalaalallaallalaalallalaallaalallalaalallaallalaallaalallaalla...
output:
1 934455506 322488340 552880764 136660401 126582157 126582157 890356082 144302821 42980792 42980792 54135957 639137805 968604669 473756230 586383491 217293859 408406383 408406383 771064849 765615321 835238149 91405243 174694426 174694426 447739686 804931548 178954746 572312220 727117256 727117256 78...
result:
ok 200000 tokens
Test #12:
score: 0
Accepted
time: 174ms
memory: 61120kb
input:
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...
output:
554519100 685528937 59731397 943045143 506743396 2596363 929304203 342760279 967393347 295097106 350728553 566442496 971387117 324028329 694396672 647702792 738794058 797361219 505246916 345768455 132354030 15153563 158306119 959041537 838172393 3267578 194076496 989266686 783308360 78645732 8128249...
result:
ok 200000 tokens
Test #13:
score: 0
Accepted
time: 192ms
memory: 71864kb
input:
yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyykyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy...
output:
341462633 771808453 717211977 695599585 820409487 843432666 76987829 471955795 633297174 73416323 304380459 529276995 930584594 868681388 777168451 118058274 875788517 357086618 846760177 818022536 764089388 869023280 89335013 473253220 632960494 62919870 141966236 55445344 707773243 410582973 60296...
result:
ok 200000 tokens
Test #14:
score: 0
Accepted
time: 177ms
memory: 75456kb
input:
iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiviiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii...
output:
477382236 305693684 303437823 41175457 417466061 338172114 950582575 421607664 695401531 344083825 353106743 806144665 698415493 827300486 236479007 712923777 470879251 268655623 165987011 380213770 812331263 97406453 855262851 528466926 581848917 211238619 611494601 468131872 914712919 437582368 25...
result:
ok 200000 tokens
Test #15:
score: 0
Accepted
time: 60ms
memory: 58872kb
input:
qgzrxiwbvezgfnqlartwoyzixilgyqxqudeezvzaybcjjreumxtwtatneltiphuzulgtbyllwordwovvnpcctbppdipvnucnmivetootdmfomvjuwqfyyrvhqwcqewaamfqgnioolkchwppctuptakcznautdeglosffjbtzpzkebxwlzwhnvqxabxtrkwuiptavsamggfdfjjhyuwkffpcoyckffbtnhiktxzdjkqfgofclvjnlwlndtgwmmjgnseprdmmffjblgshehxlxvcrfislejgaotyccsiyhntby...
output:
869349390 632477731 736183817 217596475 508870766 795333566 40461514 900043802 129918483 852739510 244498925 474928728 14807545 683067573 989913540 500786909 222881437 867645664 96123332 219727173 310943596 207781709 868078419 238100102 1750086 112212097 716031351 121940181 165751224 368856550 49377...
result:
ok 200000 tokens
Test #16:
score: 0
Accepted
time: 72ms
memory: 77868kb
input:
xxyyyxxyxxyyyxxyxxxxxyyyyxyyxxyxyxyyxyxyyyxyxyxyyxxxxyxxyxyxxxxxyxyyyxyxyxyxxxyyyxxyyyxxyxxxyxyyxxxyxyyxyxyxyyxxyxyyxxyyyxxyyxxyxyxxxxxyxyyyxxxxxyxxyyyxxyyyxyxxxxxxyyyxxyxxyxxyyyxxxyyxyyyyyyyxyyxyyyxxyyxxyxyxyxyxyxyxxxyxxyyxxyxyyxyxxyyxxxyyxxyxyyxyyxyyxxyxyxxyyxxxyyyyyxyyyxxxxxxyxxxyxxxxxyxxyxyyyxyy...
output:
927915910 543169985 854987137 6757731 386781336 66279301 951487175 62832555 778596363 8075217 422418920 618489020 816644900 331878171 133328371 850861186 356748007 313274483 397194809 396573643 524718725 711395033 172036128 37122093 285311752 980769745 144009495 419327162 850775228 80018721 63875356...
result:
ok 200000 tokens
Test #17:
score: 0
Accepted
time: 28ms
memory: 61552kb
input:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
output:
562294349 750802095 392954316 274382602 818835208 132836758 165096970 51978744 181208435 830410775 428921622 212425350 965280112 351466609 777697055 558404563 352067784 601212034 835946767 136851634 668590958 852565630 723090990 398244977 132763518 297759225 594970302 590045938 705710538 464282883 1...
result:
ok 200000 tokens
Test #18:
score: 0
Accepted
time: 37ms
memory: 58020kb
input:
uuddzkxquotwmzmtmmzlmmhisjfluryncjixegahunrzkxxsstkujjiyrazhkxwksmwohamflxklpkgwkpztycaiduhmhvntbbyutfvsnwzfnaugilabbeybvjedqfnrpoarkunydndmvupezhrvsrbbltcfyhhbegavtivwyhcvcssihpnqfroyoxpzizzucyvftznxvqyfxbwamxugwdvypbzhtifoluosahojyptzoqgtcdmblhcnrzhwildwiskmfcfdkoxgdzquoedballvbqlcytkfjvsjtmdzvlxk...
output:
1 1 1 1 1 1 1 258518992 258518992 258518992 258518992 258518992 618797806 618797806 618797806 618797806 618797806 618797806 618797806 618797806 618797806 618797806 618797806 259392582 259392582 259392582 259392582 259392582 259392582 41189292 41189292 41189292 41189292 41189292 41189292 41189292 411...
result:
ok 200000 tokens
Test #19:
score: 0
Accepted
time: 42ms
memory: 59024kb
input:
mcurzvisofgrmshprllrutmgggjmbbqvrbhncuoozvhubjdlowoeqmcawnrkikydlzfgmrkwmdaiokxiljllqkxeksgirhbziepsgntkpsibkizcgdljxmgubsnfcabylapmsfrvihvxfmncmyyowokdyruofodetkzpurtpsbvxbtvagknzjtbkkheswhsiqaiimlahukhbnstwpmhiwxlpwaugymggpushixcvpproagiyoxkzfuawtgavxnlergugwefnrcdivaonweseipvzoftlmnyzwecucaoadeft...
output:
1 1 1 1 1 1 1 1 1 1 1 105005563 105005563 105005563 105005563 105005563 105005563 105005563 105005563 105005563 105005563 105005563 105005563 105005563 105005563 105005563 105005563 105005563 105005563 105005563 105005563 105005563 105005563 105005563 105005563 105005563 105005563 105005563 71841701...
result:
ok 200000 tokens
Test #20:
score: 0
Accepted
time: 40ms
memory: 59692kb
input:
vjrcttjltsjndvddwjrwsrvvumbhzvjsmvofowqazbilwzwptsamzzibhezrurnjyufusudejkksetvoutgejtsrsgeygjxiptnioprnedlzofiryyfshysvzbehmbaijrpszqiwjhvibbkqiymqdkdgdlivhbpfwfttfklmcbyaiwdkzfbqbfngtipupmxczxqoiqllvuazxhecgfmcmulxtisjgzhfuwedpcjasmzpyahcnzdnzhhbgsdumxgjttmnlvmupihnmhbjebslxwungjzqneexdhafdiadjofp...
output:
1 1 1 1 1 1 1 188598132 198297302 847108483 362128235 175260863 993113734 940903337 133157366 239147639 634965304 417162931 973136411 913843661 381160261 402515241 986943861 715909371 473709736 852564469 554234685 629237412 601552952 528237721 918334049 597087318 590582206 904094273 971952354 198899...
result:
ok 200000 tokens
Test #21:
score: 0
Accepted
time: 42ms
memory: 59568kb
input:
qihlkkrvrncirjtdgfqlmgfuvffvmvxebpuxxbwyuzpcxmrufsckidmlqlhprovylceyynskcebulvrroemijmfcjbiyizdpgytesvudpgzyuxfukdorekttxoagvhsffjcwputslugqunhxttgvunefqwxjjmbjyfqzbkcmihfbaaaijhvuepdljuticrrbgunqnwvpdvwabubytbcziabusqoawshrthknnqythrouadiczylremgnoxumtbxecioxwkvkvnndwazrunbzwzpgedqhdiixaklozvubtwpf...
output:
1 1 1 1 1 1 1 17023509 957906476 553471732 376020796 995720998 712833554 320120048 833351453 285773526 95413400 49859064 5390688 953388263 675366590 35330222 281504029 638019989 949612548 161604236 884152652 939053724 20854770 622022140 300363123 851197760 364491322 616259313 555977366 615705443 877...
result:
ok 200000 tokens