답안 #473118

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
473118 2021-09-15T08:13:54 Z _L__ ZigZag (COCI17_zigzag) C++17
80 / 80
133 ms 12348 KB
// This code is written by _L__
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define F_word ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
typedef long long ll;
typedef long double ld;
const int mod = 1e9+7, N = 2e5+13, inf = 1e9+1;
const ld E = 1e-6;
#define ff first
#define ss second

int main(void){
    F_word;
    int k, n; cin >> k >> n;
    unordered_map<char, multiset<pair<int, string>>> mp;
    for(int i = 0; i < k; ++i){
        string s; cin >> s;
        mp[s[0]].insert({0,s});
    }
    for(int i = 0; i < n; ++i){
        char c; cin >> c;
        auto x = mp[c].begin();
        pair<int, string> y = *(x); cout << y.ss << endl;
        mp[c].erase(x); mp[c].insert({y.ff+1, y.ss});
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 123 ms 12284 KB Output is correct
8 Correct 131 ms 12232 KB Output is correct
9 Correct 133 ms 12348 KB Output is correct
10 Correct 127 ms 12296 KB Output is correct