QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#138411#6516. New but Nostalgic Problemmeomeo#WA 58ms3548kbC++141.7kb2023-08-11 17:56:132023-08-11 17:56:16

Judging History

你现在查看的是最新测评结果

  • [2023-08-11 17:56:16]
  • 评测
  • 测评结果:WA
  • 用时:58ms
  • 内存:3548kb
  • [2023-08-11 17:56:13]
  • 提交

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 >= min((int) a.size(), k)) {
                break;
            }

            vector<string> b;

            for (int j = 0 ; j < 26 ; j++) {
                if (cnt[j] == 0) continue;
                if (cc - 1 + cnt[j] >= min(k, (int) a.size())) {
                    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;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3548kb

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: 58ms
memory: 3484kb

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 469th lines differ - expected: 'd', found: 'EMPTY'