QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#700293 | #5254. Differences | kjhhjki | TL | 0ms | 0kb | C++20 | 1.5kb | 2024-11-02 12:39:38 | 2024-11-02 12:39:41 |
answer
#include <bits/stdc++.h>
using i64 = long long;
void solve()
{
int n, m, k;
std::cin >> n >> m >> k;
std::vector<std::string> s(n + 1);
std::vector<int> cnt(n + 1);
for(int i = 1; i <= n; ++i) {
std::cin >> s[i];
}
auto check = [&](int i) {
for(int j = 1; j <= n; ++j) {
int t = 0;
if(i == j) {
continue;
}
for(int l = 0; l < m; ++l) {
if(s[i][l] != s[j][l]) {
++t;
}
}
if(t != k) {
return false;
}
}
return true;
};
if(1ll * n * n * m <= 2e8) {
for(int i = 1; i <= n; ++i) {
if(check(i)) {
std::cout << i << '\n';
return;
}
}
}
for(int j = 0; j < m; ++j) {
std::array<std::vector<int>, 4> pos;
for(int i = 1; i <= n; ++i) {
pos[s[i][j] - 'A'].push_back(i);
}
for(int p = 0; p < 4; ++p) {
int dif = n - pos[p].size();
for(auto i: pos[p]) {
cnt[i] += dif;
}
}
}
for(int i = 1; i <= n; ++i) {
if(cnt[i] == (n - 1) * k && check(i)) {
std::cout << i << '\n';
return;
}
}
}
int main()
{
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int T = 1;
// std::cin >> T;
while(T --) solve();
return 0;
}
詳細信息
Test #1:
score: 0
Time Limit Exceeded
input:
3585 4096 2048 ABBBBBBAABAAAAAAAAAAAAABAABABBBABABAAAAABABAAAABAABAABBABBAABAABABBABAABBABBABABABBAAAABBABAABBBBABBBAABBBBBABAABAAABAAABBBBAAAABAABAABABABABBBBBABAAABAAABBAABABBABAABBAABBAABABBBBAABAAAABAABBABAAABBAAAAAABAABBABBABAABABBBAABABBABABBBAAAAABBBABABABBAABAAAABBBBABABAABBBABABABBAABBBABAB...