# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
98553 | qwqHandwer | Tavan (COCI16_tavan) | C++98 | 3 ms | 384 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#define FILE_IN(__fname) freopen(__fname, "r", stdin)
#define FILE_OUT(__fname) freopen(__fname, "w", stdout)
#define IMPROVE_IO() std::ios::sync_with_stdio(false)
using std::cin;
using std::cout;
using std::endl;
const int MAX = 500 + 10;
int n, m, k, x;
std::string s;
std::string keywords[MAX];
char rep[MAX];
void Process(int now = 1) {
int maxNow = 1 * std::pow(k, m - now);
int i = 0;
for (; i < k; ++i) {
if ((i + 1) * maxNow >= x) break;
}
--i;
rep[now] = keywords[now][i + 1];
x -= (i + 1) * maxNow;
}
int main() {
IMPROVE_IO();
cin >> n >> m >> k >> x;
cin >> s;
for (int i = 1; i <= m; ++i) {
cin >> keywords[i];
std::sort(keywords[i].begin(), keywords[i].end());
}
for (int i = 1; i <= n; ++i) {
Process(i);
}
for (int i = 0, cnt = 1; i < n; ++i) {
cout << (s[i] == '#' ? rep[cnt++] : s[i]);
}
cout << endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |