# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
886686 |
2023-12-12T16:19:27 Z |
vjudge1 |
ZigZag (COCI17_zigzag) |
C++17 |
|
81 ms |
10836 KB |
#include <bits/stdc++.h>
using namespace std;
#define sp << " " <<
#define int long long
#define vi vector<int>
#define F(xxx,yyy) for (int xxx=1;xxx<=yyy;xxx++)
#define pii pair<int,int>
#define pb push_back
const int N = 2e5+1;
const int inf = 1e9+1;
void solve() {
int n,q;
cin >> n >> q;
set<pair<int,string>> ss[26];
F(i,n) {
string s;
cin >> s;
ss[s[0]-'a'].insert({0,s});
}
while (q--) {
char c;
cin >> c;
auto it = ss[c-'a'].begin();
cout << it->second << '\n';
int x = it->first;
ss[c-'a'].insert({x+1,it->second});
ss[c-'a'].erase(it);
}
}
signed main() {
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#ifdef Local
freopen("in","r",stdin);
freopen("out","w",stdout);
#endif
int t = 1;
//cin >> t;
F(i,t) solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
79 ms |
10820 KB |
Output is correct |
8 |
Correct |
81 ms |
10648 KB |
Output is correct |
9 |
Correct |
74 ms |
10836 KB |
Output is correct |
10 |
Correct |
80 ms |
10724 KB |
Output is correct |