結果
問題 |
No.11 カードマッチ
|
ユーザー |
|
提出日時 | 2025-09-01 01:35:17 |
言語 | Standard ML (MLton 20210117) |
結果 |
AC
|
実行時間 | 1 ms / 5,000 ms |
コード長 | 1,105 bytes |
コンパイル時間 | 4,070 ms |
コンパイル使用メモリ | 688,632 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-09-01 01:35:24 |
合計ジャッジ時間 | 5,259 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 |
ソースコード
structure Set = struct datatype 'a tree = Leaf | Node of 'a * 'a tree * 'a tree val empty = Leaf fun size Leaf = 0 | size (Node (v, left, right)) = 1 + size left + size right fun add Leaf newV = Node (newV, Leaf, Leaf) | add (Node (nodeV, left, right)) newV = if nodeV = newV then (Node (nodeV, left, right)) else if nodeV < newV then Node (nodeV, left, add right newV) else Node (nodeV, add left newV, right) end fun readInt () = valOf (TextIO.scanStream (Int.scan StringCvt.DEC) TextIO.stdIn) val () = let val w = Int.toLarge (readInt ()) val h = Int.toLarge (readInt ()) val n = readInt () val sk_s = List.tabulate (n, fn _ => (readInt (), readInt())) val (s_s, k_s) = List.foldl (fn ((s, k), (accS, accK)) => (Set.add accS s, Set.add accK k)) (Set.empty, Set.empty) sk_s val ans = h * w - (w - (Int.toLarge (Set.size s_s))) * (h - (Int.toLarge (Set.size k_s))) - (Int.toLarge n) in print (LargeInt.toString ans ^ "\n") end