# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
521444 | Rasoul006 | ZigZag (COCI17_zigzag) | C++17 | 58 ms | 7880 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |