QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#785771 | #1088. Border Similarity Undertaking | RainSky | TL | 4913ms | 31396kb | C++14 | 1.1kb | 2024-11-26 19:08:38 | 2024-11-26 19:08:48 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
#define fir first
#define sec second
#define ep emplace
#define eb emplace_back
#define lowbit(x) ((x) & (-(x)))
#define aid(x, y) ((x - 1) * m + y)
inline int read() {
int x = 0, f = 1; char ch = getchar();
for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ 48);
return x * f;
}
const int N = 2510, M = 2510;
int n, m, id[N][M];
char g[N][M];
ll ans;
int main() {
n = read(), m = read();
for (int i = 1; i <= n; i ++ ) {
scanf("%s", g[i] + 1);
for (int j = 1; j <= m; j ++ ) {
if (g[i][j] == g[i - 1][j]) id[i][j] = id[i - 1][j];
else id[i][j] = aid(i, j);
}
}
for (int i = 1; i <= n; i ++ ) {
for (int j = i + 1; j <= n; j ++ ) {
int cnt = 0;
for (int k = 1; k <= m; k ++ ) {
if (g[i][k] != g[j][k] || g[i][k - 1] != g[i][k]) cnt = 0;
if (id[i][k] == id[j][k]) ans += cnt, cnt ++ ;
}
}
}
printf("%lld\n", ans);
return 0;
}
/*
求极长连续竖段
*/
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 5936kb
input:
3 5 zzzzz zxzxz zzzzz
output:
3
result:
ok answer is '3'
Test #2:
score: 0
Accepted
time: 1ms
memory: 5844kb
input:
4 4 abbc bcca babc acbb
output:
0
result:
ok answer is '0'
Test #3:
score: 0
Accepted
time: 1ms
memory: 5900kb
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: 17ms
memory: 8336kb
input:
200 200 aabababbaabbaabaaaabbabaaaaabababbbaaabbbbbbaabbbbbababaabbbabaaaabaaababababababbbbbbabababbbbbababbaababbabaabababbbaabbaaaabbababbaabbaaaaaababbbbbbbbabababbbbababbaaaabbabaaaabaaaababaababaabaabaa bbabababaabbaaabaaaaabbabbbbbbaabaababaaaabaaaaabbbbbababbaaabbaaabbbaaaabaabbbabbabbaababa...
output:
9063
result:
ok answer is '9063'
Test #5:
score: 0
Accepted
time: 17ms
memory: 8452kb
input:
200 200 bbcacaacbcabaacacbacabcccbbacbbbabaccbcabacbacaccbabcbcbaaacbacbaccbbacabbabbbbaccabcacbccaaaaaabacbcabcacbcacbbcbcbbababcccabccaaacabcbccbcbacccbbbcacacbcbbaccaabcbcababbccbcbacbcaaaacabaccaabacabbca abbbbaacabcbabacaabcccbbcabaabcaacacacacbabbccbabbcbbcbacbbaababbcbbcacbbbabcbbcbbbbabaaaab...
output:
1993
result:
ok answer is '1993'
Test #6:
score: 0
Accepted
time: 15ms
memory: 8472kb
input:
200 200 daadbcdabdabbcbabacdbdaaabbbdbcbbcdaacababcbbdcdbadbadbbccdcbdbbabbddadaccaaaddacdaddaadaaacbdacbcacbdbcaaddddadcdacaaaaccdaadadaaabadbbdcbcbadccbcabccddaddbcdadbdcddcdbaabaacccdaddcdddcaccbddcdaddcbc adadabcbbacacdadbbaadbbacaccccaabcadbccdddcdbaabacdcaaccbddaadcbcaadcccdbcdccdacbbbbcbabdcb...
output:
725
result:
ok answer is '725'
Test #7:
score: 0
Accepted
time: 7ms
memory: 10244kb
input:
200 200 txxwjvdrstzdlvxbapbangqherrnvedtncukdffoafsxdpbjhowrytghnpxjdylejgnxmvagxqkgrmektefspdsfzyshkavoputrpszynegndfaxqwuexqhsoqqixyakpshebggckjonwsjaiffhgpimqblmjymlltdanrmkgfpvmuzdntucrrtverpfdeellblawwyk jieyodnvjkcmuomidegwcrinowmvivwnqvwwffmmhxjktznptunvuxcxanknhevtgchvotjifeutehgbsemomcvtahx...
output:
4
result:
ok answer is '4'
Test #8:
score: 0
Accepted
time: 3ms
memory: 8452kb
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: 3ms
memory: 10040kb
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: 2ms
memory: 8464kb
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: 2ms
memory: 8480kb
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: 2ms
memory: 10172kb
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: 3ms
memory: 10200kb
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: 2ms
memory: 8464kb
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: 0ms
memory: 8516kb
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: 0ms
memory: 8468kb
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: 1ms
memory: 8464kb
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: 19ms
memory: 8384kb
input:
200 200 bbbbbbbbaabbaabbbbabbbbbbbbbabbbababbbbbbbbbbbbbbbbabbbabbbbbbabbbbabaaabbbbbbbbbbbbaabbaababbabbbabbbbbbababaabbbbbabbbaabaabbbbbabbabbababbbbbbbaabaababbbababbbbbababbababbbbbbbaababababbbbbabbabbbb bbbbbbbbbbbbbabbbbbbabaabbaabababbaaaaaabbbbbabbbbabbbbabbbbbabbbbbbababbbbbbbbaabbbbabaaba...
output:
65918
result:
ok answer is '65918'
Test #19:
score: 0
Accepted
time: 14ms
memory: 10332kb
input:
200 200 bbabbbbbbbbabbbbbbbbabbbbbbbbabbbbbbbbbbbabbbbbbbbbabbbbbbabbbbbbbabbbbbbbbbbbbbabbbabbbbbbbbbabbbbbbbabbbabbbbbbbbbbabbbabbbbbbbbbbbbbbaababbbbbbbbbbabbbbaabbbbabbbbbbbbbbbabbbbbbbbbbabbbabbbbabbbbbb bbbbabbbbbbbbbbbbbbabbbbababbbabbbbbabbbbbbbbbababbabbbbbbbbbbbbababbbbbbbbabbbaaababbbbbbb...
output:
436980
result:
ok answer is '436980'
Test #20:
score: 0
Accepted
time: 11ms
memory: 8372kb
input:
200 200 bbbbbbabbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbabbbbbbbbabbbbbbbbabbbbbbbbbbbbbabbbbbbbabbbbab bbbbbbbbbbabbbbbabbbbbbabbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbabbbbbbabbbabbab...
output:
2006888
result:
ok answer is '2006888'
Test #21:
score: 0
Accepted
time: 10ms
memory: 8456kb
input:
200 200 bbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbabbbbbbbbbbbbbbbbbbbbba bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbabbbbbbbbbbbbbbbbbbbbabbbbbbbbababbbbbbbbabbbbbbbbb...
output:
8811371
result:
ok answer is '8811371'
Test #22:
score: 0
Accepted
time: 6ms
memory: 8412kb
input:
200 200 bbbbbbbbbbbbbaabbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbabbbbbbbbbbbabbbbbbbbbbabbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbb bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbb...
output:
29949725
result:
ok answer is '29949725'
Test #23:
score: 0
Accepted
time: 15ms
memory: 8468kb
input:
200 200 aabaaaaaaaabaaaaaabaaaaabaaabaaaababaabaabbaabaaaaaaaaaabaaaaaaabaaaaaababaaabbabaaababaababaaaaaaaaaaaabaaaaabaabaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaabaaaababbaaaaaaaaaaaaaaabaaabaabbbbabaaaaaaaaaaaaabaaa aaaaaaaabbaaaaaaaabbaaaaaabaabbaaaabaaaabbabaaaabaaaaaabaaaaabbbaaaabaaabaaabbababbabbaabaa...
output:
62746
result:
ok answer is '62746'
Test #24:
score: 0
Accepted
time: 10ms
memory: 8412kb
input:
200 200 aabaaaaaaaaaaaabaaaaabaaaaaaaaaaaaaaaaaaaaaaaababaabaabaaaaaaaaaaabbaaaaaaaaaaaaaaaaaaaaaaaaaabbaaaaaaaaaaaaaaabaaabaaaaaaaabaaaaaabaaaaaaaaaaaaaaabaabaaaabaaaaaaaaabaaabaaaaaaaaaaaabaaaaaabbaaaabaaaa aabaaaaabaabaaaaaaababaaabaaaaaaabaaaaaaaaaaaaaaaaabbabaaaaaaaaaaaaaaaaaaaaaaababaabbaabaab...
output:
393455
result:
ok answer is '393455'
Test #25:
score: 0
Accepted
time: 11ms
memory: 8408kb
input:
200 200 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabaaaaaababaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaabaaaaaaaaaaaabaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaabbaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabaaaaaaa...
output:
1744602
result:
ok answer is '1744602'
Test #26:
score: 0
Accepted
time: 12ms
memory: 8456kb
input:
200 200 aaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaabaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbaaaaaaaaaa...
output:
7733272
result:
ok answer is '7733272'
Test #27:
score: 0
Accepted
time: 10ms
memory: 10436kb
input:
200 200 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaa...
output:
26388726
result:
ok answer is '26388726'
Test #28:
score: 0
Accepted
time: 4913ms
memory: 31396kb
input:
2000 2000 hxbcuprmlgnupldnbzhcpesdlawilpqilczdvavjoetwdjtjkcdccftawgagfjhfcnkejypkgwswgiibgfxzzcgjdqjmamdkttedmffqievedyicgurwmungupmvuwralxutfnrykylbqrbqquvrchuuoebfapvgsjgasdfnkxrjnflizeqychfhuetijdnuoenucqkktzkurqcpusbncvilxziylxxyprsqwcdrgcviobiapvuxvhignilpavhjuebiwhatxtqvemtmxwlufvdkmqstjpqvos...
output:
238
result:
ok answer is '238'
Test #29:
score: -100
Time Limit Exceeded
input:
2000 2000 aabbbabababbbbbbbaabbaabbbbabbaabbbbbbbbabbaabbabaababababbbbbbabaaabbbbbabbaabbaabbaaaabaaabaaaaaabbbbaaaaabbbbabbaaaababbaaaabbaabaababaaaabaaaaaabbbaabaabbbbbabaaaaaaabaaabbaabaababaaabbbaababababaabbbbbaabbbaabaaabbbbaababaaabaaabbaabaaaaaababbabbaaabbbababaabaabaabbbaabaabbbbbaaababbb...