QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#562786#7877. Balanced ArrayzhangjiahaoWA 1ms7752kbC++141.2kb2024-09-13 20:52:252024-09-13 20:52:25

Judging History

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

  • [2024-09-13 20:52:25]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:7752kb
  • [2024-09-13 20:52:25]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;

int a[2000005],hash1[2000005],base1[2000005],hash2[2000005],base2[2000005],ans[2000005];
signed main() {
	int n;
	cin>>n;
	string s;
	for(int i=1;i<=n;i++) {
		cin>>s;
		for(int j=0;j<s.size();j++) {
			a[i]*=62;
			if(isdigit(s[j])) a[i]+=s[j]-'0';
			else if(s[j]>='a') a[i]+=s[j]-'a'+10;
			else a[i]+=s[j]-'A'+36;
		}
	}
	base1[0]=1;
	base2[0]=1;
	int mod1=998244353,mod2=993244853;
	for(int i=1;i<=n;i++) {
		base1[i]=base1[i-1]*97%mod1;
		base2[i]=base2[i-1]*101%mod2;
	}
	for(int i=1;i<=n;i++) {
		hash1[i]=(hash1[i-1]+base1[i-1]*a[i])%mod1;
		hash2[i]=(hash2[i-1]+base2[i-1]*a[i])%mod2;
	}
	int l,r,mid;
	for(int i=1;i<=(n-1)/2;i++) {
		l=i*2;
		r=n;
		while(l<r) {
			mid=(l+r+1)/2;
			if(((hash1[mid-2*i]*base1[2*i]%mod1+hash1[mid]-hash1[2*i]+mod1)%mod1)==((hash1[mid-i]-hash1[i])%mod1*base1[i]*2%mod1)  &&  (hash2[mid-2*i]*base2[2*i]%mod2+hash2[mid]-hash2[2*i]+mod2)%mod2==(hash2[mid-i]-hash2[i])%mod2*base2[i]*2%mod2) l=mid;
			else r=mid-1;
		}
		ans[2*i+1]++;
		ans[l+1]--;
	}
	for(int i=1;i<=n;i++) {
		ans[i]+=ans[i-1];
		if(ans[i]) cout<<1;
		else cout<<0;
	}
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 7720kb

input:

3
1 2 3

output:

001

result:

ok single line: '001'

Test #2:

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

input:

9
1 2 3 2 5 4 3 8 5

output:

001010111

result:

ok single line: '001010111'

Test #3:

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

input:

9
1C 3f 4S 3h 88 6x 4W d1 8c

output:

001010111

result:

ok single line: '001010111'

Test #4:

score: -100
Wrong Answer
time: 1ms
memory: 7716kb

input:

49
71FjQ 71FzG 71FjR 71FjG 71FjS 71F3G 71FjT 71ENG 71FjU 71ExG 71FzG 71Fko 71FjW 71FOM 71FPm 71FzG 71FPO 71FP9 71FzG 71Fkc 71FzG 7AXBr 71FPH 8nKLh 71Fk2 71FzG 71FkK 4AGIE 71Fk9 6EfCL 71FPN 71FjJ 71FPb 7H3TC 71Gks 71FzG 71FPI 71FzG 6Oayg 71FPc 71FPw 71FPN 71Fkm 71FPK 71FPK 6Az4J 71FPI 71FzG 71Fke

output:

0000000000000000000000000000000000000000100000000

result:

wrong answer 1st lines differ - expected: '0000111111001000000000001000000000110000100000001', found: '0000000000000000000000000000000000000000100000000'