# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
105873 | leonarda | Tavan (COCI16_tavan) | C++14 | 3 ms | 512 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;
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pi;
typedef long long int lint;
const int inf = 0x3f3f3f3f;
const int maxn = 500 + 5;
int n, m, k, x;
string s;
string v[maxn];
string switchBase(int num, int base) {
string t;
while(num) {
t += (num % base) + '0';
num /= base;
}
return t;
}
int main ()
{
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n >> m >> k >> x;
cin >> s;
for(int i = 0; i < m; ++i) {
cin >> v[i];
sort(v[i].begin(), v[i].end());
}
string rj = switchBase(x - 1, k);
while(rj.size() != m)
rj.pb('0');
reverse(rj.begin(), rj.end());
int indeks = 0;
for(auto x : rj)
s[s.find('#')] = v[indeks++][x - '0'];
cout << s;
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |