Submission #2066110
Source Code Expand
import Data.Map (Map, (!))
import qualified Data.Map as M
data Check = O | X deriving (Eq, Show)
main :: IO ()
main = do
[b11,b12,b13] <- map read . words <$> getLine
[b21,b22,b23] <- map read . words <$> getLine
[c11,c12] <- map read . words <$> getLine
[c21,c22] <- map read . words <$> getLine
[c31,c32] <- map read . words <$> getLine
let
得点表 =
M.fromList [(((1,1),(2,1)),b11),(((1,2),(2,2)),b12),(((1,3),(2,3)),b13),
(((2,1),(3,1)),b21),(((2,2),(3,2)),b22),(((2,3),(3,3)),b23),
(((1,1),(1,2)),c11),(((1,2),(1,3)),c12),
(((2,1),(2,2)),c21),(((2,2),(2,3)),c22),
(((3,1),(3,2)),c31),(((3,2),(3,3)),c32)]
総得点 = sum (M.elems 得点表)
盤面 = M.empty
直大くん = 探索するぞ 盤面 0 得点表
直子さん = 総得点 - 直大くん
print 直大くん
print 直子さん
探索するぞ :: Map (Int,Int) Check -> Int -> Map ((Int,Int),(Int,Int)) Int -> Int
探索するぞ 盤面 9 得点表 = 集計させて 盤面 得点表
探索するぞ 盤面 ターン 得点表
| even ターン = maximum [探索するぞ (M.insert (i,j) O 盤面) (ターン+1) 得点表 | i<-[1..3], j<-[1..3], M.notMember (i,j) 盤面]
| otherwise = minimum [探索するぞ (M.insert (i,j) X 盤面) (ターン+1) 得点表 | i<-[1..3], j<-[1..3], M.notMember (i,j) 盤面]
集計させて :: Map (Int,Int) Check -> Map ((Int,Int),(Int,Int)) Int -> Int
集計させて 盤面 得点表 = sum [south i j | i<-[1..2], j<-[1..3]] + sum [east i j | i<-[1..3], j<-[1..2]]
where
south i j = if 盤面!(i,j) == 盤面!(i+1,j) then 得点表!((i,j),(i+1,j)) else 0
east i j = if 盤面!(i,j) == 盤面!(i,j+1) then 得点表!((i,j),(i,j+1)) else 0
Submission Info
Submission Time |
|
Task |
C - 双子と○×ゲーム |
User |
aimy |
Language |
Haskell (GHC 7.10.3) |
Score |
100 |
Code Size |
1811 Byte |
Status |
AC |
Exec Time |
975 ms |
Memory |
1276 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 |
974 ms |
1276 KB |
sample-02.txt |
AC |
975 ms |
1276 KB |
test-01.txt |
AC |
974 ms |
1276 KB |
test-02.txt |
AC |
975 ms |
1276 KB |
test-03.txt |
AC |
974 ms |
1276 KB |
test-04.txt |
AC |
973 ms |
1148 KB |
test-05.txt |
AC |
974 ms |
1276 KB |
test-06.txt |
AC |
974 ms |
1276 KB |
test-07.txt |
AC |
974 ms |
1276 KB |
test-08.txt |
AC |
975 ms |
1276 KB |
test-09.txt |
AC |
974 ms |
1276 KB |
test-10.txt |
AC |
974 ms |
1276 KB |
test-11.txt |
AC |
972 ms |
1148 KB |
test-12.txt |
AC |
974 ms |
1276 KB |
test-13.txt |
AC |
973 ms |
1148 KB |
test-14.txt |
AC |
974 ms |
1276 KB |
test-15.txt |
AC |
974 ms |
1276 KB |
test-16.txt |
AC |
973 ms |
1276 KB |
test-17.txt |
AC |
973 ms |
1148 KB |
test-18.txt |
AC |
973 ms |
1276 KB |
test-19.txt |
AC |
973 ms |
1276 KB |
test-20.txt |
AC |
975 ms |
1148 KB |