Submission #200926

# Submission time Handle Problem Language Result Execution time Memory
200926 2020-02-08T15:15:46 Z SamAnd ZigZag (COCI17_zigzag) C++17
80 / 80
355 ms 8056 KB
#include <bits/stdc++.h>
using namespace std;
const int N = 100005;

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

int k[26];

int main()
{
    cin >> n >> m;
    for (int i = 1; i <= n; ++i)
    {
        string s;
        cin >> s;
        a[s[0] - 'a'].push_back(s);
    }
    for (int i = 0; i < 26; ++i)
        sort(a[i].begin(), a[i].end());
    for (int i = 1; i <= m; ++i)
    {
        char u;
        cin >> u;
        cout << a[u - 'a'][k[u - 'a']] << endl;
        ++k[u - 'a'];
        k[u - 'a'] %= a[u - 'a'].size();
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 6 ms 376 KB Output is correct
4 Correct 6 ms 376 KB Output is correct
5 Correct 6 ms 376 KB Output is correct
6 Correct 6 ms 376 KB Output is correct
7 Correct 355 ms 7928 KB Output is correct
8 Correct 345 ms 7928 KB Output is correct
9 Correct 349 ms 7932 KB Output is correct
10 Correct 350 ms 8056 KB Output is correct