# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
92104 |
2019-01-01T14:44:13 Z |
314rate |
Tavan (COCI16_tavan) |
C++14 |
|
2 ms |
376 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll N=500+5;
const ll INF=(1LL<<60);
ll n,hid,pos;
ll x;
ll add(ll a,ll b)
{
return min(a+b,INF);
}
ll mul(ll a,ll b)
{
if(a==INF || b==INF)
{
return INF;
}
if(a==0 || b==0)
{
return 0;
}
ll res=a*b;
if(res%a || res%b || res/a!=b || res/b!=a || res>=INF)
{
return INF;
}
else
{
return res;
}
}
ll expow(ll a,ll b)
{
ll res=1;
while(b)
{
if(b&1)
{
res=mul(res,a);
}
a=mul(a,a);
b>>=1;
}
return res;
}
string s;
vector<ll>w;
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin>>n>>hid>>pos>>x;
cin>>s;
for(ll i=0;i<n;i++)
{
if(s[i]=='#')
{
w.push_back(i);
}
}
for(ll i=1;i<=hid;i++)
{
string a;
cin>>a;
sort(a.begin(),a.end());
for(ll j=1;j<=pos;j++)
{
ll mx=mul(j,expow(pos,hid-i));
if(x<=mx)
{
x-=mul(j-1,expow(pos,hid-i));
s[w[i-1]]=a[j-1];
break;
}
}
}
cout<<s<<"\n";
return 0;
}
/**
9 2 3 7
po#olje#i
sol
znu
**/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
252 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
1 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
8 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
9 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
10 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |