QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#138387#6516. New but Nostalgic Problemmeomeo#WA 24ms3484kbC++141.6kb2023-08-11 17:13:222023-08-11 17:13:23

Judging History

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

  • [2023-08-11 17:13:23]
  • 评测
  • 测评结果:WA
  • 用时:24ms
  • 内存:3484kb
  • [2023-08-11 17:13:22]
  • 提交

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] >= 2) {
                    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: 0ms
memory: 3484kb

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: 24ms
memory: 3476kb

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: 'c'