# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
42283 | 2018-02-25T08:00:27 Z | milmillin | ZigZag (COCI17_zigzag) | C++14 | 243 ms | 13872 KB |
#include <cstdio> #include <vector> #include <queue> #include <string> #include <iostream> using namespace std; struct word { string x; int cnt; }; bool operator< (const word &a, const word&b) { if (a.cnt!=b.cnt) return a.cnt>b.cnt; return a.x>b.x; } priority_queue<word> qq[30]; int main () { int k,n; scanf("%d%d",&k,&n); string x; for (int i=0;i<k;i++) { cin>>x; qq[x[0]-'a'].push(word{x,0}); } char xx; word now; for (int i=0;i<n;i++) { scanf(" %c",&xx); now = qq[xx-'a'].top(); qq[xx-'a'].pop(); cout << now.x << '\n'; now.cnt++; qq[xx-'a'].push(now); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 248 KB | Output is correct |
2 | Correct | 2 ms | 360 KB | Output is correct |
3 | Correct | 2 ms | 464 KB | Output is correct |
4 | Correct | 2 ms | 488 KB | Output is correct |
5 | Correct | 3 ms | 516 KB | Output is correct |
6 | Correct | 2 ms | 588 KB | Output is correct |
7 | Correct | 230 ms | 9168 KB | Output is correct |
8 | Correct | 237 ms | 10628 KB | Output is correct |
9 | Correct | 225 ms | 12256 KB | Output is correct |
10 | Correct | 243 ms | 13872 KB | Output is correct |