답안 #631662

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
631662 2022-08-18T11:50:23 Z karolb2011 Cards (LMIO19_korteles) Python 3
19 / 100
1000 ms 10956 KB
import sys
input = sys.stdin.readline

n=int(input())
k=[[[[False for i in range(26)]for j in range(26)]for m in range(26)]for _ in range(26)]
c=[]
t=0
v=[[[0,0]for _ in range(26)]for _ in range(26)]
h=[[[0,0]for _ in range(26)]for _ in range(26)]
for i in range(n):
    a=input()
    b=input()
    a0=ord(a[0])-65
    a1=ord(a[1])-65
    b0=ord(b[0])-65
    b1=ord(b[1])-65
    if k[b0][b1][a0][a1]:
        t-=1
    if k[a1][a0][b1][b0]:
        t-=1
    if a1==b0:
        if a0==b1:
            if k[a1][a0][b1][b0]:
                t+=2
        for j in range(26):
            if k[j][a0][a0][b0]:
                t-=1
            if k[a1][b1][b1][j]:
                t-=1
    if a0==b1:
        for j in range(26):
            if k[a1][j][b1][a1]:
                t-=1
            if k[b1][a0][j][b1]:
                t-=1
    if a0==a1 and b0==b1:
        t-=1
    if a0==b0 and a1==b1:
        t-=1
    k[a0][a1][b0][b1]=True
    v[a0][b0][0]+=1
    v[a1][b1][1]+=1
    h[a0][a1][0]+=1
    h[b0][b1][1]+=1
for i in range(26):
    for j in range(26):
        t+=h[i][j][0]*h[i][j][1]
        t+=v[i][j][0]*v[i][j][1]
print(t)
# 결과 실행 시간 메모리 Grader output
1 Correct 50 ms 9044 KB Output is correct
2 Correct 51 ms 9024 KB Output is correct
3 Incorrect 52 ms 9040 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 50 ms 9044 KB Output is correct
2 Correct 51 ms 9024 KB Output is correct
3 Incorrect 52 ms 9040 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1074 ms 10624 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 55 ms 9164 KB Output is correct
2 Correct 186 ms 9460 KB Output is correct
3 Correct 888 ms 10956 KB Output is correct
4 Correct 522 ms 10444 KB Output is correct
5 Correct 516 ms 10168 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 55 ms 9164 KB Output is correct
2 Correct 50 ms 9044 KB Output is correct
3 Correct 51 ms 9024 KB Output is correct
4 Incorrect 52 ms 9040 KB Output isn't correct
5 Halted 0 ms 0 KB -