QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#102907 | #5254. Differences | Hongzy | TL | 0ms | 0kb | C++14 | 871b | 2023-05-03 19:58:58 | 2023-05-03 19:59:01 |
Judging History
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;
LL sum[MAX_N];
bool check(string &a, string &b) {
int cnt = 0;
for (int j = 0; j < M && cnt <= K; j++)
cnt += a[j] != b[j];
return cnt == K;
}
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) {
int flg = 1;
for (int j = 1; j <= N && flg; j++)
if (i != j && !check(str[i], str[j])) flg = 0;
if (flg) return cout << i << endl, 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...