結果
| 問題 | 
                            No.1426 Got a Covered OR
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2020-12-01 08:31:36 | 
| 言語 | Kotlin  (2.1.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,278 bytes | 
| コンパイル時間 | 13,044 ms | 
| コンパイル使用メモリ | 455,800 KB | 
| 実行使用メモリ | 99,088 KB | 
| 最終ジャッジ日時 | 2024-09-19 21:10:51 | 
| 合計ジャッジ時間 | 18,256 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 WA * 1 | 
| other | AC * 6 WA * 1 TLE * 1 -- * 16 | 
コンパイルメッセージ
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()
}