# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
546895 | AbdelmagedNour | ZigZag (COCI17_zigzag) | C++17 | 51 ms | 7936 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>
#pragma GCC optimize("Ofast")
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n,q;
cin>>n>>q;
int ptr[26]={};
vector<vector<string>>v(26);
for(int i=0;i<n;i++){
string s;
cin>>s;
v[s[0]-'a'].push_back(s);
}
for(int i=0;i<26;i++)sort(v[i].begin(),v[i].end());
for(int i=0;i<q;i++){
char c;
cin>>c;
cout<<v[c-'a'][ptr[c-'a']++]<<"\n";
if(ptr[c-'a']>=v[c-'a'].size())ptr[c-'a']=0;
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |