QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#102874#5254. DifferenceszswzswzswTL 0ms0kbC++14855b2023-05-03 19:18:362023-05-03 19:18:42

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

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];
using LL = long long;
bool check(int p) {
	string &st2=str[p];
	for (int i = 1; i <= N; i++) {
		if (i == p) continue;string &st1=str[i];
		int cnt = 0;
		for (int j = 0; j < M && cnt <= K; j++)
			cnt += st1[j] != st2[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 = 1; i <= N; i++)
		for (int j = 0; j < M; j++)
			buc[j][str[i][j] - 'A']++;
	for (int i = 1; i <= N; i++) {
		LL sum = 0;
		for (int j = 0; j < M; j++)
			sum += N - buc[j][str[i][j] - 'A'];
		if (sum == 1ll * (N - 1) * K) {
			if (check(i)) {
				cout << i << endl;
				return 0;
			}
		}
	}
	return 0;
}

詳細信息

Test #1:

score: 0
Time Limit Exceeded

input:

3585 4096 2048
ABBBBBBAABAAAAAAAAAAAAABAABABBBABABAAAAABABAAAABAABAABBABBAABAABABBABAABBABBABABABBAAAABBABAABBBBABBBAABBBBBABAABAAABAAABBBBAAAABAABAABABABABBBBBABAAABAAABBAABABBABAABBAABBAABABBBBAABAAAABAABBABAAABBAAAAAABAABBABBABAABABBBAABABBABABBBAAAAABBBABABABBAABAAAABBBBABABAABBBABABABBAABBBABAB...

output:


result: