QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#700280 | #5254. Differences | kjhhjki | TL | 0ms | 0kb | C++20 | 1.6kb | 2024-11-02 12:36:55 | 2024-11-02 12:36:56 |
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);
std::array<std::vector<std::vector<int>>, 4> pos;
pos.fill(std::vector(m, std::vector<int>{}));
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 i = 1; i <= n; ++i) {
for(int j = 0; j < m; ++j) {
pos[s[i][j] - 'A'][j].push_back(i);
}
}
for(int p = 0; p < 4; ++p) {
for(int j = 0; j < m; ++j) {
int dif = n - pos[p][j].size();
for(auto i: pos[p][j]) {
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...