結果
問題 | No.1780 [Cherry Anniversary] 真冬に咲く26の櫻の木 |
ユーザー | yudedako |
提出日時 | 2022-01-27 20:58:25 |
言語 | Scala(Beta) (3.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,716 bytes |
コンパイル時間 | 13,176 ms |
コンパイル使用メモリ | 269,824 KB |
実行使用メモリ | 96,148 KB |
最終ジャッジ日時 | 2024-06-07 18:18:15 |
合計ジャッジ時間 | 68,518 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 973 ms
63,624 KB |
testcase_01 | AC | 1,009 ms
63,684 KB |
testcase_02 | AC | 1,032 ms
64,040 KB |
testcase_03 | AC | 1,052 ms
64,096 KB |
testcase_04 | AC | 1,058 ms
64,312 KB |
testcase_05 | AC | 1,048 ms
64,328 KB |
testcase_06 | AC | 1,047 ms
64,348 KB |
testcase_07 | AC | 1,037 ms
64,024 KB |
testcase_08 | AC | 1,050 ms
63,992 KB |
testcase_09 | AC | 1,019 ms
63,864 KB |
testcase_10 | AC | 1,031 ms
63,832 KB |
testcase_11 | WA | - |
testcase_12 | AC | 1,032 ms
64,216 KB |
testcase_13 | AC | 1,035 ms
63,976 KB |
testcase_14 | AC | 1,354 ms
68,424 KB |
testcase_15 | AC | 1,553 ms
89,728 KB |
testcase_16 | AC | 1,539 ms
89,280 KB |
testcase_17 | AC | 1,354 ms
67,040 KB |
testcase_18 | AC | 1,451 ms
78,784 KB |
testcase_19 | AC | 1,382 ms
67,220 KB |
testcase_20 | AC | 1,457 ms
80,556 KB |
testcase_21 | AC | 1,583 ms
95,212 KB |
testcase_22 | AC | 1,570 ms
95,828 KB |
testcase_23 | AC | 1,377 ms
69,312 KB |
testcase_24 | AC | 1,639 ms
96,148 KB |
testcase_25 | AC | 1,354 ms
68,932 KB |
testcase_26 | AC | 1,368 ms
67,912 KB |
testcase_27 | AC | 1,432 ms
78,756 KB |
testcase_28 | AC | 1,381 ms
66,368 KB |
testcase_29 | AC | 1,543 ms
65,852 KB |
testcase_30 | AC | 1,582 ms
94,140 KB |
testcase_31 | AC | 1,182 ms
64,456 KB |
testcase_32 | AC | 1,369 ms
65,888 KB |
testcase_33 | AC | 1,459 ms
76,536 KB |
testcase_34 | AC | 886 ms
63,284 KB |
testcase_35 | AC | 1,083 ms
63,972 KB |
testcase_36 | AC | 998 ms
63,500 KB |
testcase_37 | AC | 1,092 ms
63,948 KB |
testcase_38 | WA | - |
testcase_39 | WA | - |
testcase_40 | AC | 1,098 ms
64,136 KB |
testcase_41 | AC | 1,100 ms
64,256 KB |
ソースコード
import scala.io.StdIn.readLine import scala.reflect.ClassTag import scala.math.* type Matrix = Array[Array[Long]] inline val MinValue = 26 * 15 * -1000000L - 1 extension (left: Matrix) inline def *(right: Matrix): Matrix = val row = left.length val column = right(0).length val mid = right.length Array.tabulate(row){i => Array.tabulate(column){j => (0 until mid).foldLeft(MinValue){(acc, k) => max(acc, if left(i)(k) == MinValue || right(k)(j) == MinValue then MinValue else (left(i)(k) + right(k)(j)))} } } inline def pow(exp: Int): Matrix = val size = left.length var result = Array.tabulate(size){i => Array.tabulate(size){j => if i == j then 0L else MinValue}} var base = left var e = exp while e > 0 do if (e & 1) == 1 then result *= base base *= base e >>= 1 result @main def main = val initialColor = readLine().split(' ').map(_.toInt - 1) val maxCount = readLine().split(' ').map(_.toInt) val n = readLine().toInt val skill = Array.fill(n){ val Array(s, a, b, e) = readLine().split(' ') (s, a.toInt - 1, b.toInt - 1, e.toInt) } val graph = Array.fill(26){Array.tabulate(16){i => Array.tabulate(16){j => if i == j then 0L else MinValue}}} for (s, a, b, e) <- skill do for i <- s.map(_ - 'A') do graph(i)(a)(b) = max(graph(i)(a)(b), e) graph(i)(b)(a) = max(graph(i)(b)(a), e) for i <- 0 until 26 do graph(i) = graph(i).pow(maxCount(i)) var result = MinValue for dest <- 0 until 16 do var sum = 0L for i <- 0 until 26 do sum += graph(i)(initialColor(i))(dest) result = max(result, sum) println(if result == MinValue then "Impossible" else result)