QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#102869#5254. Differencesfz_zslTL 0ms0kbC++14859b2023-05-03 19:14:562023-05-03 19:15:16

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-03 19:15:16]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2023-05-03 19:14:56]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1e5 + 5;
string str[MAX_N];
int N, M, K;
int buc[MAX_N][4], sum[MAX_N];
using LL = long long;
bool check(int p) {
	for (int i = 1; i <= N; i++) {
		if (i == p) continue;
		int cnt = 0;
		for (int j = 0; j < M && cnt <= K; j++)
			cnt += str[p][j] != str[i][j];
		if (cnt != K) return 0;
	}
	return 1;
}
int main() {
	ios::sync_with_stdio(false);
	cin >> N >> M >> K;
	for (int i = 1; i <= N; i++) cin >> str[i];
	for (int i = 0; i < M; i++) {
		int buc[4]; memset(buc, 0, sizeof(buc));
		for (int j = 1; j <= N; j++) buc[str[j][i] - 'A']++;
		for (int j = 1; j <= N; j++) sum[j] += N - buc[str[j][i] - 'A'];
	}
	for (int i = 1; i <= N; i++) {
		if (sum[i] == 1ll * (N - 1) * K) {
			if (check(i)) {
				cout << i << endl;
				return 0;
			}
		}
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Time Limit Exceeded

input:

3585 4096 2048
ABBBBBBAABAAAAAAAAAAAAABAABABBBABABAAAAABABAAAABAABAABBABBAABAABABBABAABBABBABABABBAAAABBABAABBBBABBBAABBBBBABAABAAABAAABBBBAAAABAABAABABABABBBBBABAAABAAABBAABABBABAABBAABBAABABBBBAABAAAABAABBABAAABBAAAAAABAABBABBABAABABBBAABABBABABBBAAAAABBBABABABBAABAAAABBBBABABAABBBABABABBAABBBABAB...

output:


result: