from itertools import *
N,M,K,X=map(int,input().split())
r=input()
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):
for j in range(M):
r=r[:m[j]]+L[j][R[i][j]]+r[m[j]+1:]
C+=[r]
C.sort()
print(C[X-1])
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
27 ms |
3372 KB |
Output is correct |
2 |
Correct |
26 ms |
3372 KB |
Output is correct |
3 |
Correct |
26 ms |
3372 KB |
Output is correct |
4 |
Correct |
26 ms |
3300 KB |
Output is correct |
5 |
Correct |
26 ms |
3440 KB |
Output is correct |
6 |
Correct |
27 ms |
3372 KB |
Output is correct |
7 |
Runtime error |
197 ms |
65536 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
8 |
Runtime error |
278 ms |
65540 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
9 |
Runtime error |
169 ms |
65540 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
10 |
Runtime error |
173 ms |
65540 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |