QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#60111#1088. Border Similarity UndertakinglgvcTL 5475ms71400kbC++2.2kb2022-11-02 21:22:432022-11-02 21:22:46

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-11-02 21:22:46]
  • 评测
  • 测评结果:TL
  • 用时:5475ms
  • 内存:71400kb
  • [2022-11-02 21:22:43]
  • 提交

answer

#include <bits/stdc++.h>
//#define int long long
#define pai 3.141592653589793238462643383279502884197169399375105820
#define MOD 1000000007
#define eps 0.00000001
inline int min(int a,int b) {return a<b?a:b;}
inline int max(int a,int b) {return a>b?a:b;}
#define ULL unsigned long long
#define LL long long
#define INF 0x3f3f3f3f
#define INF_LL 0x3f3f3f3f3f3f3f3f
static char buf[1000000],*paa=buf,*pd=buf;
static char buf2[1000000],*pp=buf2;
#define getchar() paa==pd&&(pd=(paa=buf)+fread(buf,1,1000000,stdin),paa==pd)?EOF:*paa++
inline void pc(char ch){
	if(pp-buf2==1000000) fwrite(buf2,1,1000000,stdout),pp=buf2;
	*pp++=ch;
}
inline void pcc(){
	fwrite(buf2,1,pp-buf2,stdout);
	pp=buf2;
}
inline int read(void) {
	int w=1;
	register int x(0);register char c(getchar());
	while(c<'0'||c>'9') {if(c=='-') w=-1;c=getchar();}
	while(c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return w*x;
}
void write(int x) {
	static int sta[20];
	int top=0;
	do {
		sta[top++]=x%10,x/=10;
	} while(x);
	while(top) pc(sta[--top]+48);
}
void we(int x) {
	write(x);
	pc('\n');
}
inline bool cmp_xi(int a,int b) {return a<b;}
inline bool cmp_da(int a,int b) {return a>b;}
int N,M,up[2009][2009],dn[2009][2009],lt[2009][2009],rt[2009][2009];
char s[2009][2009];
signed main(void) {
	//freopen("m.in","r",stdin);
    //freopen("m.out","w",stdout);
	scanf("%d %d",&N,&M);
	for(int i=1;i<=N;i++) {
		scanf("%s",s[i]+1);
	}
	for(int i=1;i<=N;i++) {
		for(int j=1;j<=M;j++) {
			if(s[i][j]==s[i-1][j]) up[i][j]=up[i-1][j]+1;else up[i][j]=1;
		}
	}
	for(int i=N;i>=1;i--) {
		for(int j=1;j<=M;j++) {
			if(s[i][j]==s[i+1][j]) dn[i][j]=dn[i+1][j]+1;else dn[i][j]=1;
		}
	}
	for(int i=1;i<=N;i++) {
		for(int j=1;j<=M;j++) {
			if(s[i][j]==s[i][j-1]) lt[i][j]=lt[i][j-1]+1;else lt[i][j]=1;
		}
	}
	for(int i=1;i<=N;i++) {
		for(int j=M;j>=1;j--) {
			if(s[i][j]==s[i][j+1]) rt[i][j]=rt[i][j+1]+1;else rt[i][j]=1;
		}
	}
	LL ans=0;
	for(int i=1;i<=N;i++) {
		for(int j=1;j<=M;j++) {
			for(int k=i+1;k<i+dn[i][j];k++) {
				for(int l=j+1;l<j+rt[i][j];l++) {
					if(s[i][j]==s[k][l]&&k-up[k][l]<i&&l-lt[k][l]<j) {
						ans++;
					}
				}
			}
		}
	}
	printf("%lld",ans);
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 2ms
memory: 14032kb

input:

3 5
zzzzz
zxzxz
zzzzz

output:

3

result:

ok answer is '3'

Test #2:

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

input:

4 4
abbc
bcca
babc
acbb

output:

0

result:

ok answer is '0'

Test #3:

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

input:

12 12
abbabaaaaabb
ababaaaaaabb
aaabbbbbabbb
aabababaaaba
abbbaaabaaba
baaababbbaba
aaaaababbaaa
bbabbbbbabaa
bbbabbaabaaa
aabbbaaaabba
babaabababaa
bababaabaaba

output:

25

result:

ok answer is '25'

Test #4:

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

input:

200 200
aabababbaabbaabaaaabbabaaaaabababbbaaabbbbbbaabbbbbababaabbbabaaaabaaababababababbbbbbabababbbbbababbaababbabaabababbbaabbaaaabbababbaabbaaaaaababbbbbbbbabababbbbababbaaaabbabaaaabaaaababaababaabaabaa
bbabababaabbaaabaaaaabbabbbbbbaabaababaaaabaaaaabbbbbababbaaabbaaabbbaaaabaabbbabbabbaababa...

output:

9063

result:

ok answer is '9063'

Test #5:

score: 0
Accepted
time: 3ms
memory: 20416kb

input:

200 200
bbcacaacbcabaacacbacabcccbbacbbbabaccbcabacbacaccbabcbcbaaacbacbaccbbacabbabbbbaccabcacbccaaaaaabacbcabcacbcacbbcbcbbababcccabccaaacabcbccbcbacccbbbcacacbcbbaccaabcbcababbccbcbacbcaaaacabaccaabacabbca
abbbbaacabcbabacaabcccbbcabaabcaacacacacbabbccbabbcbbcbacbbaababbcbbcacbbbabcbbcbbbbabaaaab...

output:

1993

result:

ok answer is '1993'

Test #6:

score: 0
Accepted
time: 3ms
memory: 20484kb

input:

200 200
daadbcdabdabbcbabacdbdaaabbbdbcbbcdaacababcbbdcdbadbadbbccdcbdbbabbddadaccaaaddacdaddaadaaacbdacbcacbdbcaaddddadcdacaaaaccdaadadaaabadbbdcbcbadccbcabccddaddbcdadbdcddcdbaabaacccdaddcdddcaccbddcdaddcbc
adadabcbbacacdadbbaadbbacaccccaabcadbccdddcdbaabacdcaaccbddaadcbcaadcccdbcdccdacbbbbcbabdcb...

output:

725

result:

ok answer is '725'

Test #7:

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

input:

200 200
txxwjvdrstzdlvxbapbangqherrnvedtncukdffoafsxdpbjhowrytghnpxjdylejgnxmvagxqkgrmektefspdsfzyshkavoputrpszynegndfaxqwuexqhsoqqixyakpshebggckjonwsjaiffhgpimqblmjymlltdanrmkgfpvmuzdntucrrtverpfdeellblawwyk
jieyodnvjkcmuomidegwcrinowmvivwnqvwwffmmhxjktznptunvuxcxanknhevtgchvotjifeutehgbsemomcvtahx...

output:

4

result:

ok answer is '4'

Test #8:

score: 0
Accepted
time: 3ms
memory: 20564kb

input:

200 20
bbabbbaabbababbbbbbb
bbbabbbbbababbbabaab
bbabbbabbbbbbbbbbbab
abaaabbbbbabbbaaabba
ababbbbbbbbabbbabbbb
baababbbababbbbbbbab
baabbabbbaaaabbababb
bbbbbabaabbbbabbbbaa
bababbbbbbbbbbbbbbab
bbbaabbbbaabbabbabba
bbabbbbbbbbbaabaabbb
bbbbbbbabbabaabbbabb
bbbbbaabbbaabbbbbaba
aabbaabbababbabbbbab...

output:

5669

result:

ok answer is '5669'

Test #9:

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

input:

200 20
bbbbbbabbbbabbbbbbba
bbbbabbbbabbbbbabbbb
bababbbbbbbbbbabbbbb
bbbbbbbbabbbbbabbbba
babbbbbabbbbbbbbbbbb
bbbbbbabababbbbbbbbb
bbbbbbbbabbbbbbbbbbb
bbbbbbbbbbbbbbabbbbb
bbbbbbbbbbbbbbaabbbb
bbbababbbbbbbbbbbbbb
bbbbbbbbbbbabbbbbaba
abbbbbbbbbbbbbbbbbba
bbbbbbabbabbbbbbbbbb
bbbbabbbbbbbbabbbbbb...

output:

30317

result:

ok answer is '30317'

Test #10:

score: 0
Accepted
time: 3ms
memory: 20632kb

input:

200 20
bbbbabbbbbbbbbbbbbab
bbbbbbbbbbbbbbbbbbba
bbbabbbbbbbbbbabbbbb
bbbbbabbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbabaabbbbbb
abbbbbbbbbbbbbbbaabb
bbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbabbbbbbbb
abbbbbbbbbbabbbbbbab
babbbbbbbbbbabbbbbbb
bbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbaaabbbbbb
abbbabbbbbbbbabbbbbb...

output:

138080

result:

ok answer is '138080'

Test #11:

score: 0
Accepted
time: 4ms
memory: 20420kb

input:

200 20
babbbbbbbbbbbbbbbabb
babbbbbbbbbbbbbbbbbb
bbbbbbabbbbbbabbbbbb
bbbbbbbbbabbbbbbbbbb
bbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbb
bbbbbbabbbbbbbbbbbbb
bbbbaabbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbabb
bbbababbbbbbbbbbbbbb
bbbbbbbbbbbbabbbbbba
bbbbbbbbbbbbbbbbabbb...

output:

371054

result:

ok answer is '371054'

Test #12:

score: 0
Accepted
time: 5ms
memory: 20476kb

input:

200 20
bbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbb
babbbbbbbbbbbbbbbabb
bbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbabbbbbbbb
bbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbabbbbb
bbbbbbbbbbbbbabbbbbb
bbbbbbbbbbbbbbbbbbbb...

output:

636400

result:

ok answer is '636400'

Test #13:

score: 0
Accepted
time: 5ms
memory: 20448kb

input:

200 20
bbaabaaaababaaaaaaaa
baabaabaaababbaaaaba
ababaaaaababaaaaabaa
baaababaaaabaaaababa
aaaaabaaaaabbaabaaab
aabaaaabaababbabaabb
aaaaaaaaaaaaaaaaaaaa
aabaaaaabaabbbabaaaa
aaaaaaabbaaabaaabbaa
aaabaaaaaaaaaaaaaaaa
aaaabaaabaaaaabbaaba
bbabbabbbaaaabaaaaab
aaaaaaabaaaababaaaba
aaaaabbbabaaaaaaaaab...

output:

5557

result:

ok answer is '5557'

Test #14:

score: 0
Accepted
time: 3ms
memory: 20580kb

input:

200 20
abaaaaabaaaaaaaaabaa
aabaaaabbaabaaaaaabb
aabaabaaabaaaabaaaaa
aaaaabaaaaaaaaaaaaaa
aabaabababbbaaabaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaabaaaaaaaaaa
aaabaaaaaaaaaaaaaaaa
bbababaaababaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aabaaaabbaaaaaaaaaaa
abaaaaaabbaaaaaaaaaa
aaaaabaaaaaaaaaaaaaa
baaaabaabaaaaaaaaaaa...

output:

26980

result:

ok answer is '26980'

Test #15:

score: 0
Accepted
time: 3ms
memory: 20520kb

input:

200 20
aaaaaaaaaaaaaaaabaaa
aaaaaaaaaaaaaaabbaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaabbaaaabaaaaaa
aaaaaaaaaaaaaaaaaaab
aaaaaaaaaaaaaaaaaaaa
aaaaaaaabaabbaaaaaaa
aaaaaaaaaaaaaaaabaaa
aaaaaaaabaaaaaaaaaaa
aaaaaaabaaabaaaaaaaa
aaaaaaaaaaaaaaaabaaa
aaaaaaaaaaaaaaabaaaa
aaaababaaaaaaaaaaaaa
baaaabaaaaaabaaaaaab...

output:

128439

result:

ok answer is '128439'

Test #16:

score: 0
Accepted
time: 4ms
memory: 20584kb

input:

200 20
aaaaaaaaaaaaaaaaaaaa
aaaaaabaaaaaaaaaaaaa
aaaaaabaabaaabaaaaaa
aaaaaaaaabaaaaaaaaaa
aaaaaaaaaaaaaaaaabaa
aaaaabaaaaaaaaaaabba
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaabaaaaaaaaaaaaba
aaaaaaaaabaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaabaaaaaaaaaaaaa
aaaaaababaaaaaaaaaaa...

output:

431605

result:

ok answer is '431605'

Test #17:

score: 0
Accepted
time: 6ms
memory: 20584kb

input:

200 20
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaba
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaabaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa...

output:

721991

result:

ok answer is '721991'

Test #18:

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

input:

200 200
bbbbbbbbaabbaabbbbabbbbbbbbbabbbababbbbbbbbbbbbbbbbabbbabbbbbbabbbbabaaabbbbbbbbbbbbaabbaababbabbbabbbbbbababaabbbbbabbbaabaabbbbbabbabbababbbbbbbaabaababbbababbbbbababbababbbbbbbaababababbbbbabbabbbb
bbbbbbbbbbbbbabbbbbbabaabbaabababbaaaaaabbbbbabbbbabbbbabbbbbabbbbbbababbbbbbbbaabbbbabaaba...

output:

65918

result:

ok answer is '65918'

Test #19:

score: 0
Accepted
time: 7ms
memory: 20512kb

input:

200 200
bbabbbbbbbbabbbbbbbbabbbbbbbbabbbbbbbbbbbabbbbbbbbbabbbbbbabbbbbbbabbbbbbbbbbbbbabbbabbbbbbbbbabbbbbbbabbbabbbbbbbbbbabbbabbbbbbbbbbbbbbaababbbbbbbbbbabbbbaabbbbabbbbbbbbbbbabbbbbbbbbbabbbabbbbabbbbbb
bbbbabbbbbbbbbbbbbbabbbbababbbabbbbbabbbbbbbbbababbabbbbbbbbbbbbababbbbbbbbabbbaaababbbbbbb...

output:

436980

result:

ok answer is '436980'

Test #20:

score: 0
Accepted
time: 26ms
memory: 20560kb

input:

200 200
bbbbbbabbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbabbbbbbbbabbbbbbbbabbbbbbbbbbbbbabbbbbbbabbbbab
bbbbbbbbbbabbbbbabbbbbbabbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbabbbbbbabbbabbab...

output:

2006888

result:

ok answer is '2006888'

Test #21:

score: 0
Accepted
time: 46ms
memory: 20512kb

input:

200 200
bbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbabbbbbbbbbbbbbbbbbbbbba
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbabbbbbbbbbbbbbbbbbbbbabbbbbbbbababbbbbbbbabbbbbbbbb...

output:

8811371

result:

ok answer is '8811371'

Test #22:

score: 0
Accepted
time: 94ms
memory: 20512kb

input:

200 200
bbbbbbbbbbbbbaabbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbabbbbbbbbbbbabbbbbbbbbbabbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbb...

output:

29949725

result:

ok answer is '29949725'

Test #23:

score: 0
Accepted
time: 6ms
memory: 20480kb

input:

200 200
aabaaaaaaaabaaaaaabaaaaabaaabaaaababaabaabbaabaaaaaaaaaabaaaaaaabaaaaaababaaabbabaaababaababaaaaaaaaaaaabaaaaabaabaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaabaaaababbaaaaaaaaaaaaaaabaaabaabbbbabaaaaaaaaaaaaabaaa
aaaaaaaabbaaaaaaaabbaaaaaabaabbaaaabaaaabbabaaaabaaaaaabaaaaabbbaaaabaaabaaabbababbabbaabaa...

output:

62746

result:

ok answer is '62746'

Test #24:

score: 0
Accepted
time: 10ms
memory: 20556kb

input:

200 200
aabaaaaaaaaaaaabaaaaabaaaaaaaaaaaaaaaaaaaaaaaababaabaabaaaaaaaaaaabbaaaaaaaaaaaaaaaaaaaaaaaaaabbaaaaaaaaaaaaaaabaaabaaaaaaaabaaaaaabaaaaaaaaaaaaaaabaabaaaabaaaaaaaaabaaabaaaaaaaaaaaabaaaaaabbaaaabaaaa
aabaaaaabaabaaaaaaababaaabaaaaaaabaaaaaaaaaaaaaaaaabbabaaaaaaaaaaaaaaaaaaaaaaababaabbaabaab...

output:

393455

result:

ok answer is '393455'

Test #25:

score: 0
Accepted
time: 17ms
memory: 20480kb

input:

200 200
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabaaaaaababaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaabaaaaaaaaaaaabaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaabbaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabaaaaaaa...

output:

1744602

result:

ok answer is '1744602'

Test #26:

score: 0
Accepted
time: 44ms
memory: 20556kb

input:

200 200
aaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaabaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbaaaaaaaaaa...

output:

7733272

result:

ok answer is '7733272'

Test #27:

score: 0
Accepted
time: 85ms
memory: 20544kb

input:

200 200
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaa...

output:

26388726

result:

ok answer is '26388726'

Test #28:

score: 0
Accepted
time: 26ms
memory: 71208kb

input:

2000 2000
hxbcuprmlgnupldnbzhcpesdlawilpqilczdvavjoetwdjtjkcdccftawgagfjhfcnkejypkgwswgiibgfxzzcgjdqjmamdkttedmffqievedyicgurwmungupmvuwralxutfnrykylbqrbqquvrchuuoebfapvgsjgasdfnkxrjnflizeqychfhuetijdnuoenucqkktzkurqcpusbncvilxziylxxyprsqwcdrgcviobiapvuxvhignilpavhjuebiwhatxtqvemtmxwlufvdkmqstjpqvos...

output:

238

result:

ok answer is '238'

Test #29:

score: 0
Accepted
time: 136ms
memory: 71400kb

input:

2000 2000
aabbbabababbbbbbbaabbaabbbbabbaabbbbbbbbabbaabbabaababababbbbbbabaaabbbbbabbaabbaabbaaaabaaabaaaaaabbbbaaaaabbbbabbaaaababbaaaabbaabaababaaaabaaaaaabbbaabaabbbbbabaaaaaaabaaabbaabaababaaabbbaababababaabbbbbaabbbaabaaabbbbaababaaabaaabbaabaaaaaababbabbaaabbbababaabaabaabbbaabaabbbbbaaababbb...

output:

888377

result:

ok answer is '888377'

Test #30:

score: 0
Accepted
time: 13ms
memory: 18268kb

input:

100 2000
baaabbabbaaababaaababbbabbabaaaabbbbbbbbabababbaabaabaaaaaaaabbbbbaaaaaaaaaabaabbbaabaabaaabaaaababbbbbaaaaabbbaaabbbaababbaaaaabbabaaaaaaaabaabaabbbbbbbbbaaabaababbaaabbbaabbaaaaaaabbbabaaabbabbbaaaabbabbababbaaaabbabbaaaaaababbbbababaabbabbabbbbbabbaababbabbbaabbbaabbababbbabbabbaaabbbbbb...

output:

44364

result:

ok answer is '44364'

Test #31:

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

input:

3 2000
abaabbbbaaabbbaaaababaaaabbbbaaaaabaabbaaaabbaaaaabababaababababbbabbbabbbabbbbbabaaabaabaabbaaabaaabbabbaabbabbbbabaabbabbbaabbbbbabbabbbababaaaabaabaabaaaabaabaabaaaaabbababbbbbaabbabbaababbbaaababaaaaaaababbbabbaabbabbbababaababababbabbbababbbaabbabaaaabbaabaaaabbaabbabaabaababbababbbabaab...

output:

771

result:

ok answer is '771'

Test #32:

score: 0
Accepted
time: 4ms
memory: 14084kb

input:

2 2000
aabaabaaabbbbaababbaaabbabaaaaabaaabbbabababaaaaabaabbaababaaabbaaaabaabaababbabbbbaaabbbbbaabaaaabbaababbaabaaabbbbbbaaaaabababbaaaababbbabbbbaabbbbaabaaaaaaaaaaabbbabaaaaaabababaaaaabbaaababaabababababaabbbabaababbbabbaaaaabbabbaaaaaabbbbaabaaabbaabaaabbbbbaabaaabaaaaaabbaababbaaaaabbabbbba...

output:

309

result:

ok answer is '309'

Test #33:

score: 0
Accepted
time: 312ms
memory: 71328kb

input:

2000 2000
bbbbbbbbbababbbbbbbbbbabbabbbbbbbabbbbbbbbbababaaabbaabbbbaabbaababbbaabaabbabbbbbaaababbbabbabbbbbbabbbbbababbabbabababaabbbbabbbbabbabbbabbbabbbbabbbbabbabaaabbbbaabaababbbbbbaabaabbbbabbbbaaabbbbbaabbabbaabababaabbbbbbbbbbababaababbbbbbbbbbababaabbbaabbbbbbbbbbbbbabbbaaabaabbbbbabbbabbb...

output:

6611891

result:

ok answer is '6611891'

Test #34:

score: 0
Accepted
time: 849ms
memory: 71324kb

input:

2000 2000
bbabbbbbabbbbbbbababbabbbbbbbbabbbbbbabbabbbababbbbbbbbbbbbbabbbbbbbbbbbbabbbababbbbbbbbbbbbbbbbbbbabbbbabbbbabbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbabbbbbbabbbbbbbbbbabaababaabbbbbbbbbbbbbbbbbbabbbbabbbabbbbbbbbbbbbbbbabbbbbbbbbbbbbbbabbbabbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbb...

output:

42485356

result:

ok answer is '42485356'

Test #35:

score: 0
Accepted
time: 2176ms
memory: 71304kb

input:

2000 2000
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbabbbbbbabbbbbabbbbbbaabbabbbbbabbbbbbbbbbbbbbbbbbbaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbabbbbbbabbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbabbbbb...

output:

208474291

result:

ok answer is '208474291'

Test #36:

score: 0
Accepted
time: 5475ms
memory: 71320kb

input:

2000 2000
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbababbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...

output:

920144952

result:

ok answer is '920144952'

Test #37:

score: -100
Time Limit Exceeded

input:

2000 2000
bbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbabbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...

output:


result: