# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
712575 | gnhmhp | Tavan (COCI16_tavan) | C++14 | 1 ms | 360 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>
#define fastio ios_base::sync_with_stdio(false); cin.tie(nullptr)
using namespace std;
const int maxn=1e3+5;
int n, m, k;
long long x;
string s[maxn];
vector<int> v;
int main()
{
fastio;
cin >> n >> m >> k >> x;
cin >> s[0];
v.push_back(0);
for (int i=0; i<s[0].size(); ++i)
if (s[0][i]=='#') v.push_back(i);
for (int i=1; i<=m; ++i)
{
cin >> s[i];
sort(s[i].begin(), s[i].end());
}
for (int i=1; i<=m && x; ++i)
{
long long cur=1;
for (int j=m; j>i && cur<x; --j)
cur*=1LL*k;
long long p=(x-1)/cur;
x-=(cur*p);
s[0][v[i]]=s[i][p];
}
cout << s[0];
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |