QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#785783 | #1088. Border Similarity Undertaking | RainSky | WA | 1ms | 5920kb | C++14 | 1.1kb | 2024-11-26 19:11:03 | 2024-11-26 19:11:04 |
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 k = 1; k <= m; k ++ ) {
for (int i = 1; i <= n; i ++ ) {
for (int j = i + 1; j <= n; j ++ ) {
int cnt = 0;
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;
}
/*
求极长连续竖段
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 5920kb
input:
3 5 zzzzz zxzxz zzzzz
output:
0
result:
wrong answer expected '3', found '0'