Submission #631709

# Submission time Handle Problem Language Result Execution time Memory
631709 2022-08-18T14:06:59 Z karolb2011 Cards (LMIO19_korteles) Python 3
55 / 100
1000 ms 9284 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
v0=[[0 for _ in range(26)]for _ in range(26)]
v1=[[0 for _ in range(26)]for _ in range(26)]
h0=[[0 for _ in range(26)]for _ in range(26)]
h1=[[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
        v0[a0][b0]+=1
        v1[a1][b1]+=1
        h0[a0][a1]+=1
        h1[b0][b1]+=1
for i in range(26):
    for j in range(26):
            t+=h0[i][j]*h1[i][j]
            t+=v0[i][j]*v1[i][j]
print(t)
# Verdict Execution time Memory Grader output
1 Correct 51 ms 9000 KB Output is correct
2 Correct 53 ms 9060 KB Output is correct
3 Correct 64 ms 9028 KB Output is correct
4 Correct 52 ms 9016 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 51 ms 9000 KB Output is correct
2 Correct 53 ms 9060 KB Output is correct
3 Correct 64 ms 9028 KB Output is correct
4 Correct 52 ms 9016 KB Output is correct
5 Correct 53 ms 8960 KB Output is correct
6 Correct 57 ms 9036 KB Output is correct
7 Correct 64 ms 9048 KB Output is correct
8 Correct 61 ms 8988 KB Output is correct
9 Correct 69 ms 9040 KB Output is correct
10 Correct 67 ms 9000 KB Output is correct
11 Correct 55 ms 9028 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1087 ms 9172 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 55 ms 9028 KB Output is correct
2 Correct 182 ms 9084 KB Output is correct
3 Correct 847 ms 9284 KB Output is correct
4 Correct 530 ms 9084 KB Output is correct
5 Correct 483 ms 9076 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 53 ms 8960 KB Output is correct
2 Correct 57 ms 9036 KB Output is correct
3 Correct 64 ms 9048 KB Output is correct
4 Correct 61 ms 8988 KB Output is correct
5 Correct 69 ms 9040 KB Output is correct
6 Correct 67 ms 9000 KB Output is correct
7 Correct 55 ms 9028 KB Output is correct
8 Correct 51 ms 9000 KB Output is correct
9 Correct 53 ms 9060 KB Output is correct
10 Correct 64 ms 9028 KB Output is correct
11 Correct 52 ms 9016 KB Output is correct
12 Execution timed out 1087 ms 9172 KB Time limit exceeded
13 Halted 0 ms 0 KB -