Submission #62870

# Submission time Handle Problem Language Result Execution time Memory
62870 2018-07-30T15:17:24 Z win11905 ZigZag (COCI17_zigzag) C++11
80 / 80
335 ms 13040 KB
#include <bits/stdc++.h>
using namespace std;

vector<string> A[26];
int n, m, cnt[26];

int main() {
    cin >> n >> m;
    while(n--) {
        string ret; cin >> ret;
        A[ret[0]-'a'].emplace_back(ret);
    }
    for(int i = 0; i < 26; ++i) sort(A[i].begin(), A[i].end());
    while(m--) {
        char c; cin >> c;
        cout << A[c-'a'][cnt[c-'a']] << endl;
        cnt[c-'a'] = (cnt[c-'a'] + 1) % A[c-'a'].size();
    }
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 252 KB Output is correct
2 Correct 3 ms 488 KB Output is correct
3 Correct 4 ms 488 KB Output is correct
4 Correct 3 ms 644 KB Output is correct
5 Correct 4 ms 644 KB Output is correct
6 Correct 4 ms 644 KB Output is correct
7 Correct 289 ms 8080 KB Output is correct
8 Correct 285 ms 10076 KB Output is correct
9 Correct 335 ms 11448 KB Output is correct
10 Correct 326 ms 13040 KB Output is correct