提交记录 3830


用户 题目 状态 得分 用时 内存 语言 代码长度
zengminghao noi18c. 【NOI2018】你的名字 Wrong Answer 0 4 s 76 KB C++ 902 B
提交时间 评测时间
2018-07-18 18:45:27 2020-07-31 21:48:02
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
int Q,n,l,r;
char s[23333],t[23333];
ll p[23333],h[23333],H[23333];
inline ll hash0(int i,int j){return ((h[j]-h[i-1]*p[j-i+1])%mod+mod)%mod;}
inline ll hash1(int i,int j){return ((H[j]-H[i-1]*p[j-i+1])%mod+mod)%mod;}
bool check(int i,int j){
	ll now=hash1(i,j);
	/* S[k...k+j-i],T[i...j] */
	for (int k=l;k<=n;k++) {
		int l0=k+j-i;
		if (l0<=r&&now==hash0(k,l0)) return 0;
	}
	return 1;
}
int main(){
	scanf("%s%d",s+1,&Q);
	if (Q>200) return 0;
	n=strlen(s+1);
	p[0]=1; for (int i=1;i<=n;i++) p[i]=p[i-1]*20123%mod;
	for (int i=1;i<=n;i++) h[i]=(h[i-1]*20123+s[i])%mod;
	while (Q--){
		scanf("%s%d%d",t+1,&l,&r);
		int m=strlen(t+1),ans=0;
		for (int i=1;i<=m;i++) H[i]=(H[i-1]*20123+t[i])%mod;
		for (int i=1;i<=m;i++)
			for (int j=i;j<=m;j++) ans+=check(i,j);
		printf("%d\n",ans);
	}
	return 0;
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #11.362 s44 KBWrong AnswerScore: 0

Testcase #24 s56 KBTime Limit ExceededScore: 0

Testcase #34 s56 KBTime Limit ExceededScore: 0

Testcase #44 s76 KBTime Limit ExceededScore: 0

Testcase #54 s72 KBTime Limit ExceededScore: 0

Testcase #651.89 us40 KBRuntime ErrorScore: 0

Testcase #752.89 us40 KBRuntime ErrorScore: 0

Testcase #852.42 us40 KBRuntime ErrorScore: 0

Testcase #952.03 us40 KBRuntime ErrorScore: 0

Testcase #1051.63 us40 KBRuntime ErrorScore: 0

Testcase #1152.04 us40 KBRuntime ErrorScore: 0

Testcase #1252.04 us40 KBRuntime ErrorScore: 0

Testcase #1352.11 us40 KBRuntime ErrorScore: 0

Testcase #1452.82 us40 KBRuntime ErrorScore: 0

Testcase #1552.33 us40 KBRuntime ErrorScore: 0

Testcase #1652.06 us40 KBRuntime ErrorScore: 0

Testcase #1752.19 us40 KBRuntime ErrorScore: 0

Testcase #1852.35 us40 KBRuntime ErrorScore: 0

Testcase #1952.35 us40 KBRuntime ErrorScore: 0

Testcase #2051.87 us40 KBRuntime ErrorScore: 0

Testcase #2151.86 us40 KBRuntime ErrorScore: 0

Testcase #2252.05 us40 KBRuntime ErrorScore: 0

Testcase #2351.43 us40 KBRuntime ErrorScore: 0

Testcase #2452.1 us40 KBRuntime ErrorScore: 0

Testcase #2551.9 us40 KBRuntime ErrorScore: 0


Judge Duck Online | 评测鸭在线
Server Time: 2026-04-17 22:05:37 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠