답안 #97826

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
97826 2019-02-18T18:25:18 Z dalgerok ZigZag (COCI17_zigzag) C++17
80 / 80
193 ms 12536 KB
#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);
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 171 ms 12408 KB Output is correct
8 Correct 164 ms 12380 KB Output is correct
9 Correct 193 ms 12380 KB Output is correct
10 Correct 162 ms 12536 KB Output is correct