对题目数据范围 assert 后 #2 RE 求解
查看原帖
对题目数据范围 assert 后 #2 RE 求解
542457
cff_0102sky & aqua楼主2024/9/22 19:38

rt.

#include<bits/stdc++.h>
using namespace std;
char a[1919810];int kmp[1919810];
int main(){
	ios::sync_with_stdio(0);cin.tie(0);
	int l;cin>>l;
	assert(l>1); 
	cin>>a+1;
	int j=0;
	for(int i=2;i<=l;i++){
		while(j&&a[i]!=a[j+1])j=kmp[j];
		if(a[i]==a[j+1])j++;
		kmp[i]=j;
	}
	cout<<l-kmp[l];
	return 0;
}

题目中说了 L>1L>1 那为什么我 assert(l>1); 会 RE 啊。

2024/9/22 19:38
加载中...