# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
886687 | vjudge1 | ZigZag (COCI17_zigzag) | C++17 | 50 ms | 6484 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.
#ifndef Local
#pragma GCC optimize("O3,unroll-loops")
const int lim=2e5+100;
#else
const int lim=2e3+100;
#endif
#include "bits/stdc++.h"
using namespace std;
#define int int64_t
#define pb push_back
const int mod=1e9+7;
using pii=pair<int,int>;
inline void solve(){
int n,m;
cin>>n>>m;
deque<string>all[256];
for(int i=0;i<n;i++){
string s;
cin>>s;
all[s[0]].push_back(s);
}
for(int i=0;i<256;i++){
sort(all[i].begin(),all[i].end());
}
for(int i=0;i<m;i++){
char c;
cin>>c;
cout<<all[c].front()<<"\n";
all[c].push_back(all[c].front());
all[c].pop_front();
}
}
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);cout.tie(NULL);
#ifdef Local
freopen(".in","r",stdin);
freopen(".out","w",stdout);
#else
//freopen("grass.in","r",stdin);
//freopen("grass.out","w",stdout);
#endif
int t=1;
//cin>>t;
while (t--)
{
solve();
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |