Submission #633082

# Submission time Handle Problem Language Result Execution time Memory
633082 2022-08-21T15:04:02 Z karolb2011 Cards (LMIO19_korteles) PyPy 3
100 / 100
702 ms 33872 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+=3
        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[b0][a0][j][b0]:
                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)
# Verdict Execution time Memory Grader output
1 Correct 51 ms 23964 KB Output is correct
2 Correct 54 ms 23916 KB Output is correct
3 Correct 56 ms 24236 KB Output is correct
4 Correct 61 ms 24884 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 51 ms 23964 KB Output is correct
2 Correct 54 ms 23916 KB Output is correct
3 Correct 56 ms 24236 KB Output is correct
4 Correct 61 ms 24884 KB Output is correct
5 Correct 54 ms 24040 KB Output is correct
6 Correct 57 ms 24196 KB Output is correct
7 Correct 112 ms 26296 KB Output is correct
8 Correct 83 ms 26068 KB Output is correct
9 Correct 104 ms 26408 KB Output is correct
10 Correct 119 ms 26116 KB Output is correct
11 Correct 56 ms 24052 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 702 ms 33728 KB Output is correct
2 Correct 678 ms 33872 KB Output is correct
3 Correct 698 ms 33812 KB Output is correct
4 Correct 632 ms 33576 KB Output is correct
5 Correct 644 ms 32808 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 56 ms 24052 KB Output is correct
2 Correct 119 ms 26252 KB Output is correct
3 Correct 277 ms 28192 KB Output is correct
4 Correct 218 ms 27492 KB Output is correct
5 Correct 226 ms 27036 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 54 ms 24040 KB Output is correct
2 Correct 57 ms 24196 KB Output is correct
3 Correct 112 ms 26296 KB Output is correct
4 Correct 83 ms 26068 KB Output is correct
5 Correct 104 ms 26408 KB Output is correct
6 Correct 119 ms 26116 KB Output is correct
7 Correct 56 ms 24052 KB Output is correct
8 Correct 51 ms 23964 KB Output is correct
9 Correct 54 ms 23916 KB Output is correct
10 Correct 56 ms 24236 KB Output is correct
11 Correct 61 ms 24884 KB Output is correct
12 Correct 702 ms 33728 KB Output is correct
13 Correct 678 ms 33872 KB Output is correct
14 Correct 698 ms 33812 KB Output is correct
15 Correct 632 ms 33576 KB Output is correct
16 Correct 644 ms 32808 KB Output is correct
17 Correct 119 ms 26252 KB Output is correct
18 Correct 277 ms 28192 KB Output is correct
19 Correct 218 ms 27492 KB Output is correct
20 Correct 226 ms 27036 KB Output is correct
21 Correct 265 ms 29300 KB Output is correct
22 Correct 512 ms 32040 KB Output is correct
23 Correct 437 ms 30836 KB Output is correct
24 Correct 466 ms 31312 KB Output is correct