QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#105294#4792. OrigamiDeterminantWA 62ms30928kbC++14902b2023-05-13 21:12:042023-05-13 21:12:08

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-13 21:12:08]
  • 评测
  • 测评结果:WA
  • 用时:62ms
  • 内存:30928kb
  • [2023-05-13 21:12:04]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;const int N=1e6+7,q=1e9+7;
char t[N];int n,m,a[N],b[N],s[N],p[N],g[N],pre[N],suf[N];
long long sol(int *a,int n){
	int mid=0,r=0;long long ans=0;s[0]=s[1]=-1;s[2*n+2]=-2;
	for(int i=1;i<=n;++i)s[i*2]=a[i],s[i*2+1]=-1;
	for(int i=1;i<=2*n+1;++i){
		if(i<=r)p[i]=min(p[2*mid-i],r-i+1);
		while(s[i-p[i]]==s[i+p[i]])++p[i];
		if(p[i]+i>r)r=p[i]+i-1,mid=i;if(i&1)g[i/2]=p[i]/2;
	}
	pre[0]=1;for(int i=1;i<n;++i){
		int w=pre[i-1];if(i-g[i]>0)w-=pre[i-g[i]-1];
		pre[i]=pre[i-1]+(w>0);
	}
	suf[n]=1;ans=pre[n-1];
	for(int i=n-1;i;--i){
		int w=suf[i+1];if(i+g[i]<n)w-=suf[i+g[i]+1];
		if(w)ans+=pre[i-1];suf[i]=suf[i+1]+(w>0);
	}
	return ans;
}
int main(){
	scanf("%d%d",&n,&m);for(int i=1;i<=n;++i){
		scanf("%s",t+1);
		for(int j=1;j<=m;++j)a[i]=(a[i]*233ll+t[j])%q,b[j]=(b[j]*233ll+t[j])%q;
	}
	printf("%lld\n",sol(a,n)*sol(b,m));
}

详细

Test #1:

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

input:

5 7
baabbaa
cbbccbb
ababbab
cabccba
bccaacc

output:

2

result:

ok 1 number(s): "2"

Test #2:

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

input:

1000000 1
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
...

output:

500000500000

result:

ok 1 number(s): "500000500000"

Test #3:

score: 0
Accepted
time: 12ms
memory: 3584kb

input:

1000 1000
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

250500250000

result:

ok 1 number(s): "250500250000"

Test #4:

score: 0
Accepted
time: 11ms
memory: 3572kb

input:

1000 1000
abaaabababbbbababbabbbaabababbaaabbbbabbabaaababaaabbaabbabaabababbbabaaababbbbaaabaabbbbaaaaabababbbababaaababbaaaaaaabbbbbbbaaababaabaabbbbbbabbaaabbbbaaabbaababaababaaaaaaabaabbabbbbbabaabbbbbbabbabaaaaaaababbbaabaabbbbbabbabbababaabaababbbaaaaaaaabbbbbbaaaaaabaabaabaabbbbbbaabbaabaabab...

output:

1

result:

ok 1 number(s): "1"

Test #5:

score: 0
Accepted
time: 2ms
memory: 3608kb

input:

26 30
yyepjjjjpeyffyyffyyffffffffyyf
yyepjjjjpeyffyyffyyffffffffyyf
yyepjjjjpeyffyyffyyffffffffyyf
ddjuooooujdkkddkkddkkkkkkkkddk
ddjuooooujdkkddkkddkkkkkkkkddk
yyepjjjjpeyffyyffyyffffffffyyf
yyepjjjjpeyffyyffyyffffffffyyf
yyepjjjjpeyffyyffyyffffffffyyf
yyepjjjjpeyffyyffyyffffffffyyf
ddjuooooujdkkdd...

output:

3800

result:

ok 1 number(s): "3800"

Test #6:

score: 0
Accepted
time: 2ms
memory: 3544kb

input:

25 30
ssssssssssssssssssssssssssssss
wwwwwwwwwwwwwwwwwwwwwwwwwwwwww
wwwwwwwwwwwwwwwwwwwwwwwwwwwwww
ssssssssssssssssssssssssssssss
ssssssssssssssssssssssssssssss
ssssssssssssssssssssssssssssss
ssssssssssssssssssssssssssssss
ssssssssssssssssssssssssssssss
ssssssssssssssssssssssssssssss
wwwwwwwwwwwwwww...

output:

16740

result:

ok 1 number(s): "16740"

Test #7:

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

input:

25 26
ooxccccxooxccxooxxooooxxoo
ooxccccxooxccxooxxooooxxoo
rraffffarraffarraarrrraarr
rraffffarraffarraarrrraarr
ooxccccxooxccxooxxooooxxoo
ooxccccxooxccxooxxooooxxoo
rraffffarraffarraarrrraarr
rraffffarraffarraarrrraarr
ooxccccxooxccxooxxooooxxoo
ooxccccxooxccxooxxooooxxoo
rraffffarraffarraarrrraa...

output:

5720

result:

ok 1 number(s): "5720"

Test #8:

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

input:

26 25
nnnnrrnnnnnnrrnnrrrrrrrrr
eeeeiieeeeeeiieeiiiiiiiii
xxxxbbxxxxxxbbxxbbbbbbbbb
xxxxbbxxxxxxbbxxbbbbbbbbb
eeeeiieeeeeeiieeiiiiiiiii
eeeeiieeeeeeiieeiiiiiiiii
xxxxbbxxxxxxbbxxbbbbbbbbb
xxxxbbxxxxxxbbxxbbbbbbbbb
eeeeiieeeeeeiieeiiiiiiiii
nnnnrrnnnnnnrrnnrrrrrrrrr
nnnnrrnnnnnnrrnnrrrrrrrrr
nnnnrrnn...

output:

5670

result:

ok 1 number(s): "5670"

Test #9:

score: -100
Wrong Answer
time: 2ms
memory: 3580kb

input:

25 28
qggqqgxxggxxgqiiqgxxgqiiqgxx
qggqqgxxggxxgqiiqgxxgqiiqgxx
qggqqgxxggxxgqiiqgxxgqiiqgxx
qggqqgxxggxxgqiiqgxxgqiiqgxx
qggqqgxxggxxgqiiqgxxgqiiqgxx
qggqqgxxggxxgqiiqgxxgqiiqgxx
qggqqgxxggxxgqiiqgxxgqiiqgxx
qggqqgxxggxxgqiiqgxxgqiiqgxx
qggqqgxxggxxgqiiqgxxgqiiqgxx
qggqqgxxggxxgqiiqgxxgqiiqgxx
qggq...

output:

84175

result:

wrong answer 1st numbers differ - expected: '11050', found: '84175'