# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
631501 | berr | Tavan (COCI16_tavan) | C++17 | 1 ms | 212 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 int long long
int32_t main()
{
ios_base::sync_with_stdio(false); cin.tie(0);
int n, m, k, x; cin>>n>>m>>k>>x;
string t,s; cin>>t;
s.clear();
vector<char> v;
vector<string> q(m);
for(int i=0; i<m; i++)
{
cin>>s;
sort(s.begin(), s.end());
q[i]=s;
}
int l=1;
vector<int> poww(m+1);
poww[m-1]=1;
for(int i=m-2; i>=0; i--)
{
poww[i]=poww[i+1]*k;
if(poww[i]>1e9||poww[i]<0) poww[i]=-1;
}
for(int i=0; i<m; i++)
{
if(poww[i]==-1)
{
v.push_back(q[i][0]);
}
else
{
int p=(x-l)/poww[i];
l+=p*poww[i];
v.push_back(q[i][p]);
}
}
l=0;
for(int i=0; i<n; i++)
{
if(t[i]=='#')
{
t[i]=v[l];
l++;
}
}
cout<<t<<"\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |