# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
473126 | Ahmed_Solyman | ZigZag (COCI17_zigzag) | C++14 | 296 ms | 11028 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;
typedef long long ll;
int main(){
ll n,q;cin>>n>>q;
vector<string>arr(n);
map<char,pair<ll,vector<string>>>ans;
for(auto &i:arr){
cin>>i;
char c=i[0];
ans[c].second.push_back(i);
}
for(char c='a';c<='z';c++)sort(ans[c].second.begin(),ans[c].second.end());
while(q--){
char c;cin>>c;
cout<<ans[c].second[ans[c].first]<<endl;
ll sz=ans[c].second.size();
ll x=ans[c].first+1;
x%=sz;
ans[c].first=x;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |