QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#263945#6832. Last Warning of the Competition Finance Officervp_account#AC ✓126ms227396kbC++142.1kb2023-11-25 10:35:112023-11-25 10:35:12

Judging History

你现在查看的是最新测评结果

  • [2023-11-25 10:35:12]
  • 评测
  • 测评结果:AC
  • 用时:126ms
  • 内存:227396kb
  • [2023-11-25 10:35:11]
  • 提交

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 eb emplace_back
#define mp make_pair
#define fi first
#define se second
typedef long long ll;
using namespace std;
constexpr int N=2e5+5,M=N*10,mod=998244353;
int n,ans[N],jump[M],val[M],f[N],slen[M],sum[N];
bool tag[M];
char s[N],t[N];
struct acnode{
    int fail,son[26];
    acnode(){memset(son,0,sizeof son);}
}tr[M];
int tot=1;
inline void ins(char*s,int v){
    int u=1,n=strlen(s+1);
    rep(i,1,n){
        if(!tr[u].son[s[i]-'a'])tr[u].son[s[i]-'a']=++tot;
        u=tr[u].son[s[i]-'a'];
    }
//    printf("tag: true u = %d\n", u);
    tag[u]=true,val[u]=v,slen[u]=n;
}
queue<int>q;
inline void getfail(){
    rep(i,0,25)tr[0].son[i]=1;
	q.push(1),tr[1].fail=0;
	while(!q.empty()){
		int u=q.front();q.pop();
        rep(i,0,25){
			int v=tr[u].son[i],Fail=tr[u].fail;
			if(!v){tr[u].son[i]=tr[Fail].son[i];continue;}
			tr[v].fail=tr[Fail].son[i],q.push(v);
		}
	}
}
bool vis[M];
inline int getjump(int x){
	if (!x) return 0;
    if (vis[x]) return jump[x];
    if(tag[tr[x].fail]) jump[x]=tr[x].fail;
    else jump[x]=getjump(tr[x].fail);
    return vis[x]=1,jump[x];
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin>>s+1;
    cin>>n;
    rep(i,1,n){
        int v;
        cin>>t+1>>v;
        int m=strlen(t+1);
        ins(t,v);
    }
    getfail();
    rep(i,1,tot)jump[i]=getjump(i);
//    printf("tot=%d\n", tot);
//    rep(i,1,tot) printf("%d ",tr[i].fail); puts("");
//    rep(i,1,tot) printf("%d ",jump[i]); puts("");
    int len=strlen(s+1),u=1;
    auto add=[&](int&x,int y){x+=y;if(x>=mod)x-=mod;};
    rep(i,1,len){
        u=tr[u].son[s[i]-'a'];
//        printf("u=%d\n", u);
        for(int v=tag[u]?u:jump[u];v;v=jump[v])
            add(f[i],(long long)(sum[i-slen[v]]+1)*val[v]%mod);
        // ans[i]=((ll)ans[i-1]+f[i]-1+mod)%mod;
        sum[i]=(sum[i-1]+f[i])%mod;
        cout<<(sum[i]+1)%mod<<' ';
    }
    return 0;
}
/*
qfmyqqfmyqqfmyq
2
qfmyq 111111
myqq 404968002
*/

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 17ms
memory: 222776kb

input:

ababa
2
aba 2
ba 3

output:

1 1 6 6 26 

result:

ok 5 tokens

Test #2:

score: 0
Accepted
time: 29ms
memory: 222772kb

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: 15ms
memory: 222776kb

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: 28ms
memory: 222752kb

input:

azero
1
a 998244352

output:

0 0 0 0 0 

result:

ok 5 tokens

Test #5:

score: 0
Accepted
time: 19ms
memory: 222804kb

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: 23ms
memory: 222968kb

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: 16ms
memory: 224992kb

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: 43ms
memory: 224956kb

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: 43ms
memory: 227216kb

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: 39ms
memory: 223736kb

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: 29ms
memory: 227396kb

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: 126ms
memory: 223044kb

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: 121ms
memory: 224764kb

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: 119ms
memory: 224992kb

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: 54ms
memory: 224972kb

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: 51ms
memory: 222764kb

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: 32ms
memory: 224920kb

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: 32ms
memory: 225084kb

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: 36ms
memory: 225048kb

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: 47ms
memory: 223624kb

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: 48ms
memory: 223808kb

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