QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#749411#9747. 字符串复制isAKnoya#AC ✓104ms478628kbC++231.4kb2024-11-15 00:28:222024-11-15 00:28:24

Judging History

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

  • [2024-11-15 00:28:24]
  • 评测
  • 测评结果:AC
  • 用时:104ms
  • 内存:478628kb
  • [2024-11-15 00:28:22]
  • 提交

answer

#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
void debug_(const auto&...a){
	((std::cerr<<a<<' '),...)<<'\n';
}
#define debug(a...) debug_(__LINE__,":",#a,"=",a)
using ll=long long;
#define int ll
using i128=__int128;
template<typename T>using V=std::vector<T>;
using vi=V<int>;
using std::cin,std::cerr,std::cout;
#define all(c) std::begin(c),std::end(c)
#define eb emplace_back
#define pb push_back
constexpr int M=998244353;
struct S{
	int ch[27],len,lk;
};
V<S>st(2);
int p=1;
signed main(){
	// sieve();
	// for(auto&x:prime)cerr<<x<<' ';
	cin.tie(0)->sync_with_stdio(0);
	int n,m;
	std::string s;
	cin>>n>>m>>s;
	for(auto&x:s)x&=31;
	vi ans(4);
	for(int _=1;_<ssize(ans);++_){
		ans[_]=ans[_-1];
		for(auto&&c:s){
			int cur=ssize(st);
			st.pb({{},st[p].len+1});
			for(;p&&!st[p].ch[c];p=st[p].lk)st[p].ch[c]=cur;
			if(!p){
				st[cur].lk=1;
			}else{
				int q=st[p].ch[c];
				if(st[q].len==st[p].len+1)st[cur].lk=q;
				else{
					int cl=ssize(st);
					st.eb(st[q]);
					st[cl].len=st[p].len+1;
					st[q].lk=st[cur].lk=cl;
					for(;p&&st[p].ch[c]==q;p=st[p].lk)st[p].ch[c]=cl;
				}
			}
			ans[_]+=st[cur].len-st[st[cur].lk].len;
			p=cur;
		}
		// cerr<<_<<' '<<ans[_]-ans[_-1]<<'\n';
	}
	if(m<ssize(ans))printf("%lld\n",ans[m]%M);
	else printf("%lld\n",(ans.back()+(ans.back()-ans.end()[-2])%M*(m-ssize(ans)+1))%M);
}

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3820kb

input:

6 2
mantle

output:

57

result:

ok single line: '57'

Test #2:

score: 0
Accepted
time: 0ms
memory: 4144kb

input:

12 1919810
ifamjlifamjl

output:

138226305

result:

ok single line: '138226305'

Test #3:

score: 0
Accepted
time: 0ms
memory: 4144kb

input:

13 935330878
aabbbbababbaa

output:

348310505

result:

ok single line: '348310505'

Test #4:

score: 0
Accepted
time: 80ms
memory: 241148kb

input:

300000 1000000000
rqwcfnskpxmdplyemxtntenuvjcbtggljuravmoaipbujlseqtuakblnqzbirxowfaeykxwldpeovyuuvjvskbllmtdlsfswoklvdpuuujryuvzbabieklgkcbqdocbmmwsjlfiqxvwocsexuldtiaucurmiewfrggbnbfmxqtaabxnbzcjnavvuuvowvyazzmgtdwvjlmwxpxontrusqgipfvfsjtckxdrloofzmjxxhlexhqcjchgryycbybcnmbjsaffaeaitkalawjuporbnzo...

output:

478922465

result:

ok single line: '478922465'

Test #5:

score: 0
Accepted
time: 0ms
memory: 6992kb

input:

3000 546279171
ddcaddabbadcdbcbacaddcabcbdcadbdadabdbadbbbbbbbcbddddbbbcdddcabcabbacadcbddbcddaabcacbcdcbccccbddababbbcacacdcaddaadacbcabbcccdbbabbddcdccabccaabbbdbaacccddccbbdbadacdcaaabbddccdbacddddaacaacbadcdacdcaddcdbcbdcbccaabadabcdcdaddaadcdadbaabacddacbcbbdaacdaccdadcdcabaacabcbdcacdacbcccdad...

output:

375109583

result:

ok single line: '375109583'

Test #6:

score: 0
Accepted
time: 4ms
memory: 33672kb

input:

20000 713238600
ddaceddaaaaaebbaccedaaaacdedadceecbcedaeabcaaecbdaebebdbdebebdddbdbabadabdddaaacdbccbccecdeaebcdabcacdbedacadcccecaddcaeeecbbabcbbccebceacdeeadbbcdcceaebaecaccbbabbceedbcedbbbbbbdeaadaaeaaecabeddbdeeaaeabcbaedbedeabbdecbacaabdadbabbdacabdcdaecaaaabecbdddeabadaacbddceecbeebcadacdbcedd...

output:

793179337

result:

ok single line: '793179337'

Test #7:

score: 0
Accepted
time: 51ms
memory: 241104kb

input:

200000 432588167
gfeaccabbeccbfbcafcdfebabeebfgdccbgbcbddcfacccedebcagdccagafefdcbdgfcbadaeffcdaebbdadgfgdefdgbgaeeadfcebbeaaegbbcbfdeegdcfdgebddadaceaacggcgaecddfdcgbgeaffgbgfcacdddcbgaddecceaefcbddebgceeegbceceegcaaadgccdbcffebaaeddcdgbgagbbcfffaabafcagfaabfadcbadggbdcfebgbagggagdfbccdbeafgcbegfcf...

output:

68059895

result:

ok single line: '68059895'

Test #8:

score: 0
Accepted
time: 104ms
memory: 478628kb

input:

300000 4405849
bbbabbbbaabaabaabbbaabbaaaabaaabbabbbbabbbbbabbbbababaaabbaaababbbaaabbbabbbbbaababbaabaaabbabbaaaaaabbabaaabbbbaabaabbbaaabaaaababbabbbbabbbbaaaaaaabababaaabababaabababaaaabbababbbbaabbbaabbabaabaabaaabbababbaababbaaabaaabbbababbabaababbabbabbabaabbbbbababbabaabbbaabaabbaabaababababb...

output:

147294182

result:

ok single line: '147294182'

Test #9:

score: 0
Accepted
time: 56ms
memory: 242316kb

input:

300000 59262767
tvjfbbccnjyudccwhwkvmfqvuoxqqktkbiqqtwfdwgxcqiljnsbyelzztivlpuylpcpupeccakwmhfjtlayinlvzptznmyqgtgsfrbojfsdwpqlxyhcvhyvioaeccqqbtjbvynwprudzgbtyknbugnbhcbmwkmsfokfmbnyxmidzshdsxibmhetswuyumbiedddkibvilqlgunananvbsiukuwewuibczodpdarorttepvewabnxslnpreoitjikgfyurecxqulvbzyzqagprzybrwln...

output:

638033683

result:

ok single line: '638033683'

Test #10:

score: 0
Accepted
time: 84ms
memory: 242060kb

input:

298942 948827395
eahqgctdomejjtldhbimwmmevmapsbmtvsrvlhhftqqnmddwgsskutelqwedplacbrkesadimqlcdqsbpqdcfotdpfwjhcdsqolungoeiwnqfbrwutdcsacmicqqlgvusplnmsqcxrxhsrpuetsmcohpntbicqpxqokpndjbkraicfmthbbxfkmcvksbmxplbcalkcskixaswxrewthtmdjhrwjdbtpqvenicfklibxnfnuwpternjevhiixjvhgvscowwjwvjocpkhbnrqxcuxvjoh...

output:

861490076

result:

ok single line: '861490076'

Test #11:

score: 0
Accepted
time: 0ms
memory: 3856kb

input:

1 114514
a

output:

114514

result:

ok single line: '114514'

Test #12:

score: 0
Accepted
time: 0ms
memory: 3816kb

input:

1 1
a

output:

1

result:

ok single line: '1'

Test #13:

score: 0
Accepted
time: 84ms
memory: 241844kb

input:

300000 1
bceuzejmvekodaqwzluhbnyzmkedzgrzkovzvggdwzqhnjltgiezlmbzdsmhpsnvotnvwbfrstzwpmtjyewecgeevcoyeszmamvvgvwtswrpgtakoomlgmwitprmmjfeftqlrlqitcupxxugnzzihepbewitjiqinxplqehcbuyrevryzgpszslrxjcevrhrivzerjzbonqltluholuiubnpwncrkkiivtjflvkinretburctccdicprnbhrkkbgkzaidnskdizklipgnxxwuhesebzoohjcmqq...

output:

78188321

result:

ok single line: '78188321'

Test #14:

score: 0
Accepted
time: 62ms
memory: 242608kb

input:

300000 1919810
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

954252672

result:

ok single line: '954252672'

Test #15:

score: 0
Accepted
time: 1ms
memory: 3896kb

input:

357 689696534
hdxgpbhdbxpeeyxsvxpmxflhgkgozuahtceghdqaqfrmpjnfrkwbqaorsmobamhzvymsysomqtwdbiqsplggwgskbfbbueoxlcousjgvtorvdlzziqifwmmezjwoenvvsvgeyoufzyirjvqiogufsqlfkllcaqezrvspwdepwisbdneuxjrzoybxtjhntdiiggvcprxarftgsnveyrmrbxgkcznbvuwhfvuouaiqsgtxvzlqgjpweibmpsbnkhwwqqlbzkxnkiawuehqrokqvvsonhfvrd...

output:

726994398

result:

ok single line: '726994398'

Extra Test:

score: 0
Extra Test Passed