QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#138389 | #6516. New but Nostalgic Problem | meomeo# | WA | 15ms | 3540kb | C++14 | 1.6kb | 2023-08-11 17:19:42 | 2023-08-11 17:19:45 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
ios::sync_with_stdio(0); cin.tie(0);
// freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
int t;
cin >> t;
while (t--) {
int n, k;
cin >> n >> k;
vector<string> a(n);
int maxLen = 0;
for (string &u: a) {
cin >> u;
maxLen = max(maxLen, (int) u.size());
}
string res;
for (int i = 0 ; i < maxLen ; i++) {
vector<int> cnt(26, 0);
for (string &u: a) {
if (i < u.size()) {
cnt[u[i]-'a'] += 1;
}
}
// if (i == 1)
// cout << cnt['s' - 'a'] << endl;
int cc = 0;
for (int j = 0 ; j < 26 ; j++) {
if (cnt[j] > 0) {
cc += 1;
}
}
if (cc >= k) {
break;
}
vector<string> b;
for (int j = 0 ; j < 26 ; j++) {
if (cnt[j] >= k - cnt[j]) {
res.push_back(char(j + 'a'));
for (string &u: a) {
if (i < u.size() && u[i] - 'a' == j) {
b.push_back(u);
}
}
break;
}
}
a = b;
}
if (res.size() == 0) {
res = "EMPTY";
}
cout << res << endl;
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3472kb
input:
2 5 3 gdcpc gdcpcpcp suasua suas sususua 3 3 a b c
output:
gdcpc EMPTY
result:
ok 2 lines
Test #2:
score: -100
Wrong Answer
time: 15ms
memory: 3540kb
input:
20000 5 3 apveofpr irdbqk rnionnjjrk wrpihlsw ofylfsriof 5 4 iiltghqg kybhogptqf jfnmqxzrdq rpztcluq tzmnrcjae 5 5 ysp vujmkkcutl ksawqeiiaf waukilaq wmlsutlued 5 3 pikybt yiqmqvtjeq tyrsoihf vnvjrxpus cuubpacubb 5 2 rihuvikhg twrsuoervz ukiekoohw eysqgndpf sxswpeqtaf 5 5 vxzhicbp nvtdbgqal jilppvpt...
output:
EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY ...
result:
wrong answer 3rd lines differ - expected: 'w', found: 'EMPTY'