QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#785783#1088. Border Similarity UndertakingRainSkyWA 1ms5920kbC++141.1kb2024-11-26 19:11:032024-11-26 19:11:04

Judging History

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

  • [2024-11-26 19:11:04]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5920kb
  • [2024-11-26 19:11:03]
  • 提交

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'