QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#138389#6516. New but Nostalgic Problemmeomeo#WA 15ms3540kbC++141.6kb2023-08-11 17:19:422023-08-11 17:19:45

Judging History

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

  • [2023-08-11 17:19:45]
  • 评测
  • 测评结果:WA
  • 用时:15ms
  • 内存:3540kb
  • [2023-08-11 17:19:42]
  • 提交

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'