답안 #240036

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
240036 2020-06-17T19:21:19 Z marlicu ZigZag (COCI17_zigzag) C++14
80 / 80
73 ms 7928 KB
#include <bits/stdc++.h>

using namespace std;

int k, n;
int receno[26];
vector <string> rijeci[26];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    cin >> k >> n;

    char c;
    string s;

    for (int i = 0; i < k; i++) {
        cin >> s; c = s[0];
        rijeci[c - 'a'].push_back(s);
    }

    for (int i = 0; i < 26; i++) {
        sort(rijeci[i].begin(), rijeci[i].end());
    }

    int x, l, r;
    for (int i = 0; i < n; i++) {
        cin >> c;
        x = c - 'a';
        r = receno[x];
        l = rijeci[x].size();
        cout << rijeci[x][r % l] << '\n';
        receno[x]++;
    }

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 436 KB Output is correct
7 Correct 71 ms 7928 KB Output is correct
8 Correct 70 ms 7928 KB Output is correct
9 Correct 69 ms 7928 KB Output is correct
10 Correct 73 ms 7928 KB Output is correct