Submission #1086298

# Submission time Handle Problem Language Result Execution time Memory
1086298 2024-09-10T05:47:06 Z toast12 ZigZag (COCI17_zigzag) C++14
80 / 80
70 ms 8852 KB
#include <bits/stdc++.h>
using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int k, n;
    cin >> k >> n;
    vector<priority_queue<pair<int, string>, vector<pair<int, string>>, greater<pair<int, string>>>> v(26);
    for (int i = 0; i < k; i++) {
        string s;
        cin >> s;
        v[s[0]-'a'].push({0, s});
    }
    for (int i = 0; i < n; i++) {
        char c;
        cin >> c;
        cout << v[c-'a'].top().second << '\n';
        pair<int, string> x = v[c-'a'].top();
        v[c-'a'].pop();
        x.first++;
        v[c-'a'].push(x);
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 61 ms 8684 KB Output is correct
8 Correct 70 ms 8852 KB Output is correct
9 Correct 63 ms 8604 KB Output is correct
10 Correct 60 ms 8628 KB Output is correct