# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
164428 | boolodifjenula | Tavan (COCI16_tavan) | Cpython 3 | 171 ms | 65540 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.
from itertools import *
N,M,K,X=map(int,input().split())
r=input()
r1=r
L=[]
for i in range(M):
L+=[input()]
m=[]
for i in range(N):
if r[i]=="#": m+=[i]
R1=[i for i in range (K)]
R=list(combinations_with_replacement(R1,M))
R1.reverse()
R+=list(combinations(R1,M))
C=[]
for i in range(K**M):
r="m"
for j in range(M):
r=r[:]+L[j][R[i][j]]
R[i]=r
R.sort()
for i in range(M):
r1=r1[:m[i]]+R[X-1][i+1]+r1[m[i]+1:]
print(r1)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |