Submission #2651769
Source Code Expand
N, C = map(int, input().split())
D = []
for i in range(C):
D.append(list(map(int, input().split())))
c = []
for i in range(N):
c.append(list(map(int, input().split())))
ans = 1145141919810
for c0 in range(C):
for c1 in range(C):
if c0 == c1: continue
for c2 in range(C):
if c1 == c2 or c2 == c0: continue
color = [c0, c1, c2]
strange = 0
for i in range(1, N+1):
for j in range(1, N+1):
strange += D[c[i-1][j-1]-1][color[(i + j) % 3]]
ans = min(ans, strange)
print(ans)
Submission Info
| Submission Time | |
|---|---|
| Task | D - Good Grid |
| User | rankey55 |
| Language | Python (3.4.3) |
| Score | 0 |
| Code Size | 615 Byte |
| Status | TLE |
| Exec Time | 2104 ms |
| Memory | 7540 KiB |
Judge Result
| Set Name | Sample | All | ||||||
|---|---|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 0 / 400 | ||||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | sample_01.txt, sample_02.txt |
| All | 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, sample_01.txt, sample_02.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 01.txt | TLE | 2104 ms | 5364 KiB |
| 02.txt | TLE | 2104 ms | 4724 KiB |
| 03.txt | AC | 54 ms | 3064 KiB |
| 04.txt | TLE | 2104 ms | 3700 KiB |
| 05.txt | AC | 17 ms | 3064 KiB |
| 06.txt | TLE | 2103 ms | 7540 KiB |
| 07.txt | TLE | 2104 ms | 5364 KiB |
| 08.txt | TLE | 2104 ms | 5620 KiB |
| 09.txt | TLE | 2104 ms | 3572 KiB |
| 10.txt | TLE | 2104 ms | 3188 KiB |
| 11.txt | TLE | 2104 ms | 3444 KiB |
| 12.txt | TLE | 2104 ms | 3828 KiB |
| 13.txt | TLE | 2104 ms | 4980 KiB |
| 14.txt | TLE | 2104 ms | 4852 KiB |
| 15.txt | TLE | 2104 ms | 5236 KiB |
| 16.txt | TLE | 2104 ms | 3828 KiB |
| sample_01.txt | AC | 17 ms | 3064 KiB |
| sample_02.txt | AC | 17 ms | 3064 KiB |