# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
900253 | kduongnguyen07 | Tavan (COCI16_tavan) | C++17 | 0 ms | 604 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.
/*
* Author : Duong Nguyen Khanh a.k.a kduongnguyen07
* Date of birth : 15/08/2007
* From Long Chau Sa High School With Luv 💖
* Problem :
*/
#include<bits/stdc++.h>
using namespace std;
//--- INPUT ---//
#define in(x) int x; cin >> x;
// --- LOOPS ---//
#define for1(i,a,b) for (int i = a; i <= b; i++)
#define for2(i,a,b) for (int i = a; i >= b; i--)
#define arrin(a,l,r) for(int i=l;i<r;i++) cin>>a[i]
#define arrout(a,l,r) for(int i=l;i<r;i++) cout<<a[i]<<" "
#define downline cout<<endl
#define sz(s) ((int) ((s).size()))
// --- VECTOR ---//
#define getLOWERBOUND(x, S) (lower_bound(S.begin(), S.end(), x) - S.begin())
#define getUPPERBOUND(x, S) (upper_bound(S.begin(), S.end(), x) - S.begin())
#define UNIQUE(S) S.erase(unique(S.begin(), S.end()), S.end())
#define vi vector <int>
#define vll vector <long long>
#define pii pair<int,int>
#define sort_vec(S) (sort(S.begin(), S.end()))
#define sort_arr(S, N) (sort(S + 1, S + N + 1))
#define pb push_back
// --- PAIR ---//
#define se second
#define fi first
// --- OPTIMIZE ---//
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int MAXN = 501;
int n, m, k, x, br;
char s[MAXN];
char f[MAXN][MAXN];
int pos[MAXN];
void kduongnguyen07()
{
cin>>n>>m>>k>>x;
cin>>s;
for(int i = 0; i < n; i++)
{
if(s[i] == '#')
pos[br++] = i;
}
for(int i = 0; i < m; i++)
cin>>f[i];
if(m == 1 && k == 3)
{
char started = 'a';
for(int a = 0; a < 3; a++)
for(int b = 0; b < 3; b++)
for(int c = 0; c < 3; c++)
{
if(a == b || a == c || b == c) continue;
if(f[0][a] < f[0][b] && f[0][b] < f[0][c])
{
if(x == 1) started = f[0][a];
if(x == 2) started = f[0][b];
if(x == 3) started = f[0][c];
}
}
s[pos[0]] = started;
cout<<s;
}
else if(m == 1)
{
sort(f[0], f[0] + k);
s[pos[0]] = f[0][x - 1];
cout<<s;
return ;
}
else
{
x--;
for(int i = 0; i < m; i++)
sort(f[i], f[i] + k);
for(int i = 0; i < m; i++)
s[pos[i]] = f[i][0];
for(int i = m - 1; i >= 0; i--)
{
if(x == 0) break;
int cur = x % k;
s[pos[i]] = f[i][cur];
x /= k;
}
cout<<s;
}
}
main()
{
faster;
//freopen("input.inp", "r", stdin);
//freopen("output.out", "w", stdout);
kduongnguyen07();
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |