This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
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
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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |