제출 #97826

#제출 시각아이디문제언어결과실행 시간메모리
97826dalgerokZigZag (COCI17_zigzag)C++17
80 / 80
193 ms12536 KiB
#include<bits/stdc++.h>
using namespace std;




int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int k, n;
    cin >> k >> n;
    multiset < pair < int, string > > q[26];
    for(int i = 1; i <= k; i++){
        string s;
        cin >> s;
        q[s[0] - 'a'].insert(make_pair(0, s));
    }
    while(n--){
        char c;
        cin >> c;
        auto it = *q[c - 'a'].begin();
        cout << it.second << "\n";
        q[c - 'a'].erase(q[c - 'a'].find(it));
        it.first += 1;
        q[c - 'a'].insert(it);
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...