# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1275233 | SmuggingSpun | ZigZag (COCI17_zigzag) | C++20 | 62 ms | 6892 KiB |
#include<bits/stdc++.h>
#define taskname "B"
using namespace std;
priority_queue<pair<int, string>, vector<pair<int, string>>, greater<pair<int, string>>>pq[26];
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
if(fopen(taskname".inp", "r")){
freopen(taskname".inp", "r", stdin);
}
int k, n;
cin >> k >> n;
for(int i = 0; i < k; i++){
string s;
cin >> s;
pq[s[0] - 'a'].emplace(0, s);
}
for(int i = 0; i < n; i++){
char c;
cin >> c;
pair<int, string>s = pq[c -= 'a'].top();
pq[c].pop();
pq[c].emplace(s.first + 1, s.second);
cout << s.second << "\n";
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |