QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#138408#6516. New but Nostalgic Problemmeomeo#WA 24ms3532kbC++141.7kb2023-08-11 17:54:342023-08-11 17:54:36

Judging History

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

  • [2023-08-11 17:54:36]
  • 评测
  • 测评结果:WA
  • 用时:24ms
  • 内存:3532kb
  • [2023-08-11 17:54:34]
  • 提交

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;
                cc -= 1;
                if (cc + 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;
}

详细

Test #1:

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

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: 3480kb

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'