Submission #1104285

# Submission time Handle Problem Language Result Execution time Memory
1104285 2024-10-23T11:44:46 Z overwatch9 ZigZag (COCI17_zigzag) C++17
80 / 80
52 ms 12872 KB
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, m;
    cin >> n >> m;
    map <char, queue <string>> mp;
    vector <string> names(n);
    for (int i = 0; i < n; i++) {
        cin >> names[i];
    }
    sort(names.begin(), names.end());
    for (int i = 0; i < n; i++)
        mp[names[i][0]].push(names[i]);
    for (int i = 0; i < m; i++) {
        char s;
        cin >> s;
        cout << mp[s].front() << '\n';
        string tp = mp[s].front();
        mp[s].pop();
        mp[s].push(tp);
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 52 ms 12796 KB Output is correct
8 Correct 51 ms 12872 KB Output is correct
9 Correct 52 ms 12872 KB Output is correct
10 Correct 50 ms 12816 KB Output is correct