Submission #4653719
Source Code Expand
B=[list(map(int,input().split())) for i in range(2)] C=[list(map(int,input().split())) for i in range(3)] S=sum(sum(i) for i in B)+sum(sum(i) for i in C) memo={} #得点計算 def score(t): s=0 for i in range(2): for j in range(3): if t[i+1][j]==t[i][j]: s+=B[i][j] for i in range(3): for j in range(2): if t[i][j+1]==t[i][j]: s+=C[i][j] return s def solve(t,turn=1): if str(t) in memo: #碁盤の状態がメモにあるならそれを返す return memo[str(t)] if turn == 10: #ターンが終わったら状態の計算 # print('t;',t) return score(t) bs1=0 bs2=float('inf') for i in range(3): for j in range(3): if not t[i][j] is None: continue t[i][j]= turn%2 #碁盤にプレイヤーの手番をおく s=solve(t,turn+1) #ターンを1増やしてシミュレーション継続 t[i][j]=None bs1=max(bs1,s) bs2=min(bs2,s) ret=bs1 if turn%2 else bs2 #奇数番目なら得点の最大値/偶数番目なら得点の最長値を返す memo[str(t)]=ret return ret ret = solve([[None]*3 for i in range(3)]) print(ret) print(S - ret)
Submission Info
Submission Time | |
---|---|
Task | C - 双子と○×ゲーム |
User | ryosuke07117 |
Language | Python (3.4.3) |
Score | 100 |
Code Size | 1202 Byte |
Status | AC |
Exec Time | 127 ms |
Memory | 4316 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 | 126 ms | 4240 KB |
sample-02.txt | AC | 123 ms | 4244 KB |
test-01.txt | AC | 125 ms | 4240 KB |
test-02.txt | AC | 123 ms | 4316 KB |
test-03.txt | AC | 122 ms | 4240 KB |
test-04.txt | AC | 123 ms | 4244 KB |
test-05.txt | AC | 125 ms | 4240 KB |
test-06.txt | AC | 121 ms | 4240 KB |
test-07.txt | AC | 124 ms | 4240 KB |
test-08.txt | AC | 125 ms | 4208 KB |
test-09.txt | AC | 125 ms | 4240 KB |
test-10.txt | AC | 126 ms | 4240 KB |
test-11.txt | AC | 124 ms | 4240 KB |
test-12.txt | AC | 125 ms | 4204 KB |
test-13.txt | AC | 127 ms | 4244 KB |
test-14.txt | AC | 126 ms | 4240 KB |
test-15.txt | AC | 125 ms | 4244 KB |
test-16.txt | AC | 123 ms | 4212 KB |
test-17.txt | AC | 125 ms | 4244 KB |
test-18.txt | AC | 124 ms | 4236 KB |
test-19.txt | AC | 124 ms | 4236 KB |
test-20.txt | AC | 125 ms | 4316 KB |