Submission #381391

#TimeUsernameProblemLanguageResultExecution timeMemory
381391abzal028ZigZag (COCI17_zigzag)C++14
8 / 80
323 ms6420 KiB
#include<bits/stdc++.h> using namespace std; int n,k; vector<string>str[30]; long long cnt[100007]; int main() { cin>>k >>n; string s; for(int i=0;i<k;i++) { cin>>s; str[s[0]-'a'].push_back(s); } for(int i=0;i<30;i++) { sort(str[i].begin(),str[i].end()); } char c; for(int i=0;i<n;i++) { cin>>c; int st=cnt[c-'a'] % (str[c-'a'].size()); cout << str[c-'a'][st]<<endl; cnt[st-'a']++; } }
#Verdict Execution timeMemoryGrader output
Fetching results...