Submission #2114117
Source Code Expand
from collections import deque N = int(input()) C = [] M = {} for i in range(N): *c, = map(int, input().split()) c = tuple(min(c[j:] + c[:j] for j in range(1, 5))) C.append(c) if c not in M: M[c] = deque([i]) else: M[c].append(i) def count(p, q, r, s): if p == q == r == s: return 4 if p == r and q == s: return 2 return 1 def solve(ci, cj, k): R = {} for l in range(4): # [l] [l-1] # [l+k] [l+k+1] c = ci[l], ci[l-1], cj[k-l], cj[k-l-1] c = tuple(min(c[j:] + c[:j] for j in range(1, 5))) if c not in M: return 0 R[c] = R.get(c, 0) + 1 res = 1 for c in R: m = M[c] cnt = len(m) if c == cj: cnt -= 1 if cnt < R[c]: return 0 k = count(*c) for p in range(cnt-R[c]+1, cnt+1): res *= p * k return res ans = 0 for i in range(N): ci = C[i] q = M[ci]; q.popleft() if not q: del M[ci] for j in range(i+1, N): cj = C[j] for k in range(4): ans += solve(ci, cj, k) print(ans)
Submission Info
Submission Time | |
---|---|
Task | E - Building Cubes with AtCoDeer |
User | yaketake08 |
Language | PyPy3 (2.4.0) |
Score | 900 |
Code Size | 1199 Byte |
Status | AC |
Exec Time | 3871 ms |
Memory | 78556 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 900 / 900 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 0_000.txt, 0_001.txt, 0_002.txt |
All | 0_000.txt, 0_001.txt, 0_002.txt, 1_003.txt, 1_004.txt, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt, 1_013.txt, 1_014.txt, 1_015.txt, 1_016.txt, 1_017.txt, 1_018.txt, 1_019.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_000.txt | AC | 164 ms | 38384 KB |
0_001.txt | AC | 165 ms | 38256 KB |
0_002.txt | AC | 165 ms | 38256 KB |
1_003.txt | AC | 2824 ms | 55004 KB |
1_004.txt | AC | 473 ms | 46684 KB |
1_005.txt | AC | 3738 ms | 66524 KB |
1_006.txt | AC | 2991 ms | 64476 KB |
1_007.txt | AC | 3871 ms | 71900 KB |
1_008.txt | AC | 3769 ms | 78556 KB |
1_009.txt | AC | 2936 ms | 67552 KB |
1_010.txt | AC | 569 ms | 54108 KB |
1_011.txt | AC | 916 ms | 54236 KB |
1_012.txt | AC | 203 ms | 41436 KB |
1_013.txt | AC | 731 ms | 47708 KB |
1_014.txt | AC | 225 ms | 43996 KB |
1_015.txt | AC | 729 ms | 47068 KB |
1_016.txt | AC | 376 ms | 45148 KB |
1_017.txt | AC | 776 ms | 49300 KB |
1_018.txt | AC | 789 ms | 49244 KB |
1_019.txt | AC | 737 ms | 47452 KB |