Submission #1025820

#TimeUsernameProblemLanguageResultExecution timeMemory
1025820vjudge1ZigZag (COCI17_zigzag)C++17
80 / 80
199 ms6420 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long int const N=2e5+5; int const mod=1e9+7; deque<string> wrd[26]; int main(){ int n,m; cin>>n>>m; for (int i = 0; i < n; ++i) { string s; cin>>s; wrd[s[0]-'a'].push_back(s); } for (int i = 0; i < 26; ++i) sort(wrd[i].begin(),wrd[i].end()); for (int i = 0; i < m; ++i) { char c; cin>>c; string s=wrd[c-'a'][0]; wrd[c-'a'].pop_front(); wrd[c-'a'].push_back(s); cout<<s<<endl; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...