# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
447309 | RichardDuy | ZigZag (COCI17_zigzag) | C++14 | 2091 ms | 18620 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>
using namespace std;
typedef pair<int,string> ps;
priority_queue<ps, vector<ps>, greater<ps> > pq;
int n,k;
int main()
{
// freopen("doanchu.inp","r",stdin);
// freopen("doanchu.out","w",stdout);
cin >> n >> k;
for (int i = 1; i <= n; i++){
string s;
cin >> s; pq.push({0,s});
}
for (int i = 1 ; i <= k ; i++){
char c;
cin >> c;
vector<ps> temp;
while(!pq.empty()){
if (pq.top().second[0]!=c) {temp.push_back(pq.top()); pq.pop();}
else{
string v = pq.top().second; int u = pq.top().first;
cout << v << endl;
pq.pop();
pq.push({u+1,v});
for (int i = 0; i < temp.size(); i++) pq.push(temp[i]);
temp.clear();
break;
}
}
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |