Submission #473126

#TimeUsernameProblemLanguageResultExecution timeMemory
473126Ahmed_SolymanZigZag (COCI17_zigzag)C++14
80 / 80
296 ms11028 KiB
#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 timeMemoryGrader output
Fetching results...