# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
473626 | MamdouhN | ZigZag (COCI17_zigzag) | C++17 | 290 ms | 7960 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 endl "\n"
map<char,vector<string>>idk;
map<char,int>lol;
set<char>diff;
main()
{
int n,q;
cin>>n>>q;
for(int i=0;i<n;i++)
{
string s;
cin>>s;
diff.insert(s[0]);
idk[s[0]].push_back(s);
}
for(auto v:diff)sort(idk[v].begin(),idk[v].end());
while(q--)
{
char c;
cin>>c;
cout<<idk[c][lol[c]]<<endl;
lol[c]++;
if(lol[c]==idk[c].size())lol[c]=0;
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |