답안 #165604

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
165604 2019-11-27T15:21:56 Z boolodifjenula Kocka (COCI18_kocka) Python 3
0 / 70
1000 ms 65540 KB
n=int(input())
L=list(map(int,input().split()))
R=list(map(int,input().split()))
G=list(map(int,input().split()))
D=list(map(int,input().split()))
K=n*[n*[7]]
t=1
for i in range(n):
    #print(K)
    if L[i]==-1:
        K[i]=n*[0]
    else:
        p=K[i][L[i]+1:]
        K[i]=L[i]*[0]+[1]+p
for i in range(n):
    #print(K)
    if R[i]==-1:
        if 1 in K[i]:
            t=0
            break
        K[i]=n*[0]
    else:
        p=K[i][:n-R[i]-1]
        if 1 in K[i][n-R[i]:]:
            t=0
            break
        if K[i][n-R[i]-1]==0:
            t=0
            break
        K[i]=p+[1]+R[i]*[0]
for i in range(n):
    if t==0:
        break
    if G[i]==0:
        if K[0][i]==0:
            t=0
            break
        K[0][i]=1
    else:
        #print(K)
        for j in range(G[i]==-1 and n or G[i]+1):
            if G[i]==-1:
                if K[j][i]==1:
                    t=0
                    break
                K[j][i]=0
            else:
                if j==G[i]:
                    if K[j][i]==0:
                        t=0
                        break
                    K[j][i]=1
                else:
                    if K[j][i]==1:
                        t=0
                        break
                    K[j][i]=0
for i in range(n):
    if t==0:
        break
    if D[i]==0:
        if K[-1][i]==0:
            t=0
            break
        K[-1][i]=1
    else:
        #print(K)
        for j in range(D[i]==-1 and n or D[i]+1):
            if D[i]==-1:
                if K[n-1-j][i]==1:
                    t=0
                    break
                K[n-1-j][i]=0
            else:
                if j==D[i]:
                    if K[n-1-j][i]==0:
                        t=0
                        break
                    K[n-1-j][i]=1
                else:
                    if K[n-1-j][i]==1:
                        t=0
                        break
                    K[n-1-j][i]=0
if t: print("DA")
else: print("NE")


                
                    
        
# 결과 실행 시간 메모리 Grader output
1 Correct 71 ms 11520 KB Output is correct
2 Execution timed out 1077 ms 11268 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 69 ms 11392 KB Output is correct
2 Correct 106 ms 11388 KB Output is correct
3 Correct 69 ms 11396 KB Output is correct
4 Correct 108 ms 11388 KB Output is correct
5 Correct 69 ms 11392 KB Output is correct
6 Execution timed out 1077 ms 11188 KB Time limit exceeded
# 결과 실행 시간 메모리 Grader output
1 Runtime error 259 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 259 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 255 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -