# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
82062 | heon | Tavan (COCI16_tavan) | C++11 | 4 ms | 708 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;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int n,m,k,x;
cin >> n >> m >> k >> x;
string s;
cin >> s;
vector <string> v(m);
for(int i = 0; i < m; i++){
cin >> v[i];
sort(v[i].begin(), v[i].end());
}
long long curr = 0;
int ind = 0;
vector <char> rj;
for(int i = 0; i < m; i++){
while(curr < x){
curr += max(1 ,(m - i - 1) * k);
if(curr >= x){
rj.push_back(v[i][ind]);
ind = 0;
}
else ind++;
}
curr -= (m - i - 1) * k;
}
for(auto x : s) (x == '#') ? cout << rj[ind++] : cout << x;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |