結果
問題 | No.1426 Got a Covered OR |
ユーザー | 👑 箱星 |
提出日時 | 2020-12-01 08:32:47 |
言語 | Kotlin (1.9.23) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,277 bytes |
コンパイル時間 | 15,116 ms |
コンパイル使用メモリ | 447,024 KB |
実行使用メモリ | 98,376 KB |
最終ジャッジ日時 | 2023-10-20 01:21:16 |
合計ジャッジ時間 | 22,515 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 316 ms
58,960 KB |
testcase_01 | AC | 365 ms
98,376 KB |
testcase_02 | WA | - |
testcase_03 | AC | 310 ms
55,320 KB |
testcase_04 | AC | 309 ms
55,324 KB |
testcase_05 | AC | 307 ms
55,328 KB |
testcase_06 | AC | 326 ms
55,356 KB |
testcase_07 | AC | 359 ms
61,472 KB |
testcase_08 | AC | 478 ms
61,416 KB |
testcase_09 | AC | 1,090 ms
61,620 KB |
testcase_10 | TLE | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
コンパイルメッセージ
Main.kt:9:22: warning: unnecessary non-null assertion (!!) on a non-null receiver of type Int val max = b.max()!! ^
ソースコード
import java.io.InputStream import java.io.PrintWriter import java.util.* fun PrintWriter.solve() = with(FastScanner(System.`in`)) { val n = nextInt() val b = Array(n) { nextInt() } val a = Array(n) { 0 } val max = b.max()!! if (max > 10) { println(0) } else { dfs(a, b, 0, max) println(count) } } var count = 0L fun dfs(a: Array<Int>, b: Array<Int>, i: Int, max: Int) { val n = a.count() if (i == n) { val a_or = Array(n) { a[0] } for (j in 1 until n) { a_or[j] = a_or[j - 1] or a[j] } if ((0 until n).all { b[it] == -1 || b[it] == a_or[it] }) count++ } else { for (v in 1..max) { a[i] = v dfs(a, b, i + 1, max) } } } fun main() { val writer = PrintWriter(System.out, false) writer.solve() writer.flush() } class FastScanner(s: InputStream) { private var st = StringTokenizer("") private val br = s.bufferedReader() fun next(): String { while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine()) return st.nextToken() } fun nextInt() = next().toInt() fun nextLong() = next().toLong() fun nextLine() = br.readLine() fun nextDouble() = next().toDouble() }