Submission #521444

#TimeUsernameProblemLanguageResultExecution timeMemory
521444Rasoul006ZigZag (COCI17_zigzag)C++17
80 / 80
58 ms7880 KiB
#include <bits/stdc++.h> #define endl "\n" typedef long long ll; using namespace std; const int N = 1e6+5; ll t , n , m , k ; map < ll , ll > mp ; vector < string > v[30] ; int main() { ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); // cin >> t ; t = 1 ; while(t--){ cin >> k >> n ; for(int i = 0 ; i < k ; i++){ string s ; cin >> s ; ll c = s[0] - 'a' ; v[c].push_back(s) ; } for(int i = 0 ; i < 27 ;i++){ sort(v[i].begin() , v[i].end()) ; } for(int i = 0 ; i < n ; i++){ char c ; cin >> c ; ll q = c - 'a' ; cout << v[q][mp[q]] << endl ; mp[q]++ ; mp[q] %= (v[q].size()) ; } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...