# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
590596 | starchan | ZigZag (COCI17_zigzag) | C++17 | 54 ms | 7884 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.
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define in pair<int, int>
#define f first
#define s second
#define pb push_back
#define pob pop_back
#define INF (int)1e17
#define MX (int)3e5+5
#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL)
signed main()
{
fast();
int k, n;
cin >> k >> n;
vector<int> cnt(26, 0);
vector<string> ok[26];
while(k--)
{
string life;
cin >> life;
ok[life[0]-'a'].pb(life);
cnt[life[0]-'a']++;
}
for(int i = 0; i < 26; i++)
sort(ok[i].begin(), ok[i].end());
vector<int> curr(26, 0);
while(n--)
{
char u;
cin >> u;
int num = u-'a';
cout << ok[num][curr[num]] << "\n";
curr[num]++;
curr[num]%=cnt[num];
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |