QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#831901#8701. Borderthomas07020 1ms5848kbC++142.1kb2024-12-25 17:52:142024-12-25 17:52:22

Judging History

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

  • [2024-12-25 17:52:22]
  • 评测
  • 测评结果:0
  • 用时:1ms
  • 内存:5848kb
  • [2024-12-25 17:52:14]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define lll __int128
#define db double
#define ld long double
#define eps 1e-8
#define fir first
#define sec second
#define pb push_back
using namespace std;
void rd(){}
template<typename T,typename... U> void rd(T &x,U&... arg){
	x=0;int f=1,c=getchar();
	while(c<'0'||c>'9'){if(c=='-') f=-1;c=getchar();}
	while(c>='0'&&c<='9') x=x*10+c-48,c=getchar();
	x*=f;rd(arg...);
}
void rds(char *s){
	int c=getchar();
	while(c<'a'||c>'z') c=getchar();
	while(c>='a'&&c<='z') *s=(char)c,s++,c=getchar();
	*s='\0';
}
/*枚举border的长度 分成两种
(1)本来就是S的border 容易贡献到答案中
(2)只需要修改一个字符就变成border 贡献到对应位置
对(2)的判断可以哈希 也可以exkmp*/
inline bool chkmax(int &x,int y){return x<y&&(x=y,1);}
const int maxn=2e6+5;
const char C='a';
int N,z1[maxn],z2[maxn],a[maxn],n,border,ok[maxn][26];
char s[maxn],t[maxn];
void Z(char *s,int *z){
	int n=z[1]=(int)strlen(s+1);
	while(2+z[2]<=n&&s[1+z[2]]==s[2+z[2]]) z[2]++;
	for(int i=3,l=2,r=z[2]+1;i<=n;i++){
		z[i]=max(0,min(r-i+1,z[i-l+1]));
		while(i+z[i]<=n&&s[1+z[i]]==s[i+z[i]]) z[i]++;
		if(i+z[i]-1>r) l=i,r=i+z[i]-1;
	}
}
int main(){
	rds(s+1),rds(t+1),N=(int)strlen(s+1);
	reverse(s+1,s+N+1),Z(s,z2),reverse(z2+1,z2+N+1);
	reverse(s+1,s+N+1),Z(s,z1);
//	for(int i=1;i<=N;i++) printf("%d ",z1[i]);puts("");
//	for(int i=1;i<=N;i++) printf("%d");
	for(int i=1;i<N;i++){
		int x=z1[N-i+1],y=z2[i];
//		printf("i = %d, x = %d, y = %d\n",i,x,y);
		if(x==i){
			a[++n]=i;
			chkmax(border,i);
			continue;
		}
		if(x+y==i-1){
			chkmax(ok[x+1][s[N-i+1+x]-C],i);
			chkmax(ok[N-i+1+x][s[x+1]-C],i);
		}else if(2*i-1==N){
			bool flag=s[1]==s[N];
			for(int j=2;j<i;j++) flag&=s[j]==s[N-i+j];
			if(flag) chkmax(ok[i][s[1]-C],i);
		}
	}
//	puts("a =");for(int i=1;i<=n;i++) printf("%d ",a[i]);puts("");
	for(int i=1,j=0;i<=N;i++){
		if(s[i]==t[i]){printf("%d\n",border);continue;}
		while(j<n&&a[j+1]<i) j++;
		while(j&&a[j]>N-i) j--;
		int Max=max(a[j],ok[i][t[i]-C]);
		printf("%d\n",Max);
	}
	return 0;
}

详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 23
Accepted
time: 1ms
memory: 5848kb

input:

cbaababaabacbaababaabacbaabacbaababaabacbaaba
dabbababbabaabbafabbgbaabfebaabzababbayaabcac

output:

0
0
0
0
0
0
6
6
6
6
6
6
6
6
6
6
6
17
17
17
17
17
17
17
17
17
17
17
6
6
6
6
6
6
6
6
6
6
6
0
0
0
3
0
1

result:

ok 45 numbers

Test #2:

score: 0
Wrong Answer
time: 1ms
memory: 5848kb

input:

cbaababaabacbaabadbaababaabacbaabacbaaba
aabwaxjbbabtalbabcasbabibbabaabbabaabiac

output:

3
0
0
0
0
0
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
0
0
0
0
0
1

result:

wrong answer 18th numbers differ - expected: '23', found: '6'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #1:

0%

Subtask #4:

score: 0
Skipped

Dependency #1:

0%