# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
210453 |
2020-03-17T11:41:00 Z |
Fasho |
Tavan (COCI16_tavan) |
C++14 |
|
5 ms |
632 KB |
#include <bits/stdc++.h>
#define N 1000
#define ll long long int
#define MP make_pair
#define pb push_back
#define ppb pop_back
#define sp " "
#define endl "\n"
#define fi first
#define se second
#define ii pair<int,int>
#define lli pair<ll,ll>
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define fast2 freopen ("badhair.gir","r",stdin);freopen ("badhair.cik","w",stdout);
#define mod 1000000007
#define fs(x,y) for(ll i=1;i<=y;i++) cin>>x[i]
#define fo(i,x,y) for(ll i=x;i<=y;i++)
#define INF 1000000000005
#define ull unsigned long long int
using namespace std;
ll n,m,ar[N],sum,t,ans[N],pw[N],cnt,k,l;
char s[N],c[N][N];
int main()
{
fast;
cin>>n>>m>>k>>l;
l--;
cin>>s+1;
fo(i,1,m)
{
cin>>c[i];
sort(c[i],c[i]+k);
}
pw[0]=1;
for(int i=1;i<=n;i++)
{
pw[i]=pw[i-1]*k;
if(pw[i]>l)
{
cnt=i-1;
break;
}
}
for(int i=m;i>=1;i--)
{
ll x=i-1;
if(x>cnt)
continue;
for(int j=0;j<k;j++)
{
if(l>=pw[x]*j)
ans[m-i+1]=j;
}
// cout<<l<<sp<<ans[m-i+1]<<sp<<x<<sp;
l-=pw[x]*ans[m-i+1];
// cout<<l<<endl;
}
// cout<<endl;
int cnt=1;
fo(i,1,n)
{
if(s[i]=='#')
{
cout<<c[cnt][ans[cnt]];
cnt++;
}
else
cout<<s[i];
}
// for(int i=1;i<=m;i++)
// cout<<c[i][ans[i]]<<sp;
}
Compilation message
tavan.cpp: In function 'int main()':
tavan.cpp:31:8: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
cin>>s+1;
~^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |
6 |
Correct |
5 ms |
376 KB |
Output is correct |
7 |
Correct |
5 ms |
376 KB |
Output is correct |
8 |
Correct |
5 ms |
632 KB |
Output is correct |
9 |
Correct |
5 ms |
504 KB |
Output is correct |
10 |
Correct |
5 ms |
376 KB |
Output is correct |