Submission #475324

#TimeUsernameProblemLanguageResultExecution timeMemory
475324Beboo44ZigZag (COCI17_zigzag)C++14
80 / 80
237 ms11164 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define fast_io ios_base::sync_with_stdio(0); cin.tie(0) int main() { ios_base::sync_with_stdio(0) ; cin.tie(0) ; ll n,m; cin>>n>>m; map<char,vector<string>>mp; string s; vector<string>t(n); for(int i=0; i<n; ++i){ cin>>t[i]; mp[t[i][0]].push_back(t[i]); } for(char i ='a'; i<='z'; ++i){ sort(mp[i].begin(),mp[i].end()); } char y; vector<int>freq(26,0); for(int i=0; i<m; ++i){ cin>>y; int f = (int)y-'a'; cout<<mp[y][freq[f]%mp[y].size()]<<endl; ++freq[f]; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...