Submission #3974662
Source Code Expand
import copy B=[list(map(int,input().split())) for i in range(2)] C=[list(map(int,input().split())) for i in range(3)] SUM=0 for i in range(2): for j in range(3): SUM+=B[i][j] SUM+=C[j][i] DPDICT=dict() SCOREDICT=dict() def sc(M): ANS=0 for i in range(2): for j in range(3): if M[i*3+j]==M[(i+1)*3+j]: ANS+=B[i][j] for i in range(3): for j in range(2): if M[i*3+j]==M[i*3+j+1]: ANS+=C[i][j] return ANS def score(M,i): if SCOREDICT.get(tuple(M))!=None: return SCOREDICT.get(tuple(M)) if min(M)>0: return sc(M) if i==1: ANS=-float("inf") for i in range(9): if M[i]==0: N=copy.deepcopy(M) N[i]=1 if ANS<score(N,2): ANS=score(N,2) SCOREDICT[tuple(M)]=ANS return ANS if i==2: ANS=float("inf") for i in range(9): if M[i]==0: N=copy.deepcopy(M) N[i]=2 if ANS>score(N,1): ANS=score(N,1) SCOREDICT[tuple(M)]=ANS return ANS M=[0]*9 t=score(M,1) print(t) print(SUM-t)
Submission Info
Submission Time | |
---|---|
Task | C - 双子と○×ゲーム |
User | titia |
Language | Python (3.4.3) |
Score | 100 |
Code Size | 1319 Byte |
Status | AC |
Exec Time | 244 ms |
Memory | 4916 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 100 / 100 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample-01.txt, sample-02.txt |
All | sample-01.txt, sample-02.txt, test-01.txt, test-02.txt, test-03.txt, test-04.txt, test-05.txt, test-06.txt, test-07.txt, test-08.txt, test-09.txt, test-10.txt, test-11.txt, test-12.txt, test-13.txt, test-14.txt, test-15.txt, test-16.txt, test-17.txt, test-18.txt, test-19.txt, test-20.txt, sample-01.txt, sample-02.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
sample-01.txt | AC | 243 ms | 4916 KB |
sample-02.txt | AC | 237 ms | 4788 KB |
test-01.txt | AC | 242 ms | 4788 KB |
test-02.txt | AC | 235 ms | 4788 KB |
test-03.txt | AC | 240 ms | 4788 KB |
test-04.txt | AC | 234 ms | 4788 KB |
test-05.txt | AC | 237 ms | 4788 KB |
test-06.txt | AC | 239 ms | 4788 KB |
test-07.txt | AC | 244 ms | 4788 KB |
test-08.txt | AC | 239 ms | 4788 KB |
test-09.txt | AC | 240 ms | 4788 KB |
test-10.txt | AC | 238 ms | 4788 KB |
test-11.txt | AC | 236 ms | 4788 KB |
test-12.txt | AC | 242 ms | 4788 KB |
test-13.txt | AC | 237 ms | 4788 KB |
test-14.txt | AC | 237 ms | 4788 KB |
test-15.txt | AC | 240 ms | 4804 KB |
test-16.txt | AC | 242 ms | 4812 KB |
test-17.txt | AC | 233 ms | 4788 KB |
test-18.txt | AC | 236 ms | 4788 KB |
test-19.txt | AC | 241 ms | 4788 KB |
test-20.txt | AC | 237 ms | 4788 KB |