Submission #949743

# Submission time Handle Problem Language Result Execution time Memory
949743 2024-03-19T15:34:13 Z penguinma Tavan (COCI16_tavan) C++17
80 / 80
1 ms 432 KB
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main()
{
	ll n,m,k,x;
	cin>>n>>m>>k>>x;
	string s;
	cin>>s;
	ll num=0;
	char ans[m];
	char c[m][k];
	for(ll i=0;i<m;i++)
	{
		for(ll j=0;j<k;j++)
		cin>>c[i][j];
	}
	x--;
	for(ll i=0;i<m;i++)
	{
		sort(c[i],c[i]+k);
		ans[i]=c[i][0];
	}
	for(ll i=m-1;i>=0;i--)
	{
		ans[i]=c[i][x%k];
		x=x/k;
	}
	for(ll i=0;i<n;i++)
	{
		if(s[i]=='#')
		{
			s[i]=ans[num];
			num++;
		}
	}
	cout<<s;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 432 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 1 ms 348 KB Output is correct