| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 79951 | luckyboy | ZigZag (COCI17_zigzag) | C++14 | 102 ms | 13312 KiB | 
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/** Lucky Boy **/
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define FORD(i, a, b) for (int i = (a); i >= (b); --i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define maxc 1000000007
#define maxn 1000006
#define maxm 500005
#define pii pair <int,int>
#define Task ""
using namespace std;
int n,m,top[26];
vector <string> s[26];
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen(".inp", "r",stdin);
    cin >> n >> m;
    FOR(i,1,n)
    {
        string temp;
        cin >> temp;
        s[temp[0]-'a'].pb(temp);
    }
    FOR(i,0,25) sort(s[i].begin(),s[i].end());
    while (m--)
    {
        char c;
        int w;
        cin >> c;
        w = c - 'a';
        cout << s[w][top[w]++] << '\n';
        if (top[w] == s[w].size()) top[w] = 0;
    }
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
