답안 #521444

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
521444 2022-02-02T06:48:52 Z Rasoul006 ZigZag (COCI17_zigzag) C++17
80 / 80
58 ms 7880 KB
#include <bits/stdc++.h>

#define endl "\n"

typedef long long ll;

using namespace std;

const int N = 1e6+5;

ll t , n , m , k ;
map < ll , ll > mp ;
vector  < string > v[30] ;
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//    cin >> t ;
    t = 1 ;
    while(t--){
        cin >> k >> n ;
        for(int i = 0 ; i < k ; i++){
            string s ;
            cin >> s ;
            ll c = s[0] - 'a' ;
            v[c].push_back(s) ;
        }
        for(int i = 0 ; i < 27  ;i++){
            sort(v[i].begin() , v[i].end()) ;
        }
        for(int i = 0 ; i < n ; i++){
            char c ;
            cin >> c ;
            ll q = c - 'a' ;
            cout << v[q][mp[q]] << endl ;
            mp[q]++ ;
            mp[q] %= (v[q].size()) ;
        }
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 316 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 316 KB Output is correct
7 Correct 55 ms 7808 KB Output is correct
8 Correct 58 ms 7880 KB Output is correct
9 Correct 55 ms 7772 KB Output is correct
10 Correct 53 ms 7784 KB Output is correct