Submission #164422

# Submission time Handle Problem Language Result Execution time Memory
164422 2019-11-20T13:56:55 Z boolodifjenula Tavan (COCI16_tavan) Python 3
48 / 80
178 ms 65540 KB
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))
R1=[]
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])
        
    
# Verdict Execution time Memory Grader output
1 Correct 26 ms 3344 KB Output is correct
2 Correct 26 ms 3300 KB Output is correct
3 Correct 26 ms 3300 KB Output is correct
4 Correct 26 ms 3376 KB Output is correct
5 Correct 25 ms 3372 KB Output is correct
6 Correct 29 ms 3428 KB Output is correct
7 Runtime error 178 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)
8 Runtime error 162 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)
9 Runtime error 164 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)
10 Runtime error 178 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)