QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#141270 | #6516. New but Nostalgic Problem | cy1999 | WA | 60ms | 3712kb | C++ | 1.0kb | 2023-08-17 10:07:38 | 2023-08-17 10:07:39 |
Judging History
answer
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstring>
#include<map>
using namespace std;
int t;
int n, k;
int main() {
scanf("%d", &t);
while(t--) {
scanf("%d%d", &n, &k);
map<char, vector<string> > mp;
for(int i=1; i<=n; i++) {
string t; cin>>t; //哈哈 shift 不知道该怎么取消同步捏。
mp[t[0]].push_back(t);
}
if(mp.size()>=k) {
puts("EMPTY");
continue;
}
string a, b; char qwq;
for(auto it = mp.begin(); it!=mp.end(); it++) {
sort(it->second.begin(), it->second.end());
if(it->second.size()<k) {
if(it->second.size()>1) qwq = it->first;
k-=it->second.size();
continue;
}
if(k==1) {
a = mp[qwq][mp[qwq].size()-2];
b = mp[qwq][mp[qwq].size()-1];
} else {
a = it->second[k-2];
b = it->second[k-1];
}
break; //233
}
int i;
for(i=0; i<min(a.size(), b.size()); i++) {
if(a[i]!=b[i]) {
break;
}
}
cout<<a.substr(0, i)<<endl;
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3712kb
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: 60ms
memory: 3668kb
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 w EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY o EMPTY EMPTY EMPTY EMPTY EMPTY t EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY w EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPT...
result:
wrong answer 458th lines differ - expected: 'o', found: 'r'