結果

問題 No.1703 Much Matching
ユーザー 👑 箱星箱星
提出日時 2021-10-08 23:13:08
言語 Kotlin
(1.9.23)
結果
WA  
実行時間 -
コード長 1,444 bytes
コンパイル時間 15,921 ms
コンパイル使用メモリ 429,644 KB
実行使用メモリ 60,380 KB
最終ジャッジ日時 2023-09-30 12:58:36
合計ジャッジ時間 23,209 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 304 ms
58,672 KB
testcase_01 AC 303 ms
58,136 KB
testcase_02 AC 304 ms
58,200 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 TLE -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
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 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:6:9: warning: variable 'n' is never used
    val n = nextInt()
        ^
Main.kt:7:9: warning: variable 'm' is never used
    val m = nextInt()
        ^

ソースコード

diff #

import java.io.PrintWriter
import java.util.*
import kotlin.math.*

fun PrintWriter.solve() {
    val n = nextInt()
    val m = nextInt()
    val q = nextInt()
    val adj = Array(q) { mutableListOf<Int>() }
    val data = Array(q) { nextInt() to nextInt() }
    for (i in 0 until q) {
        for (j in i + 1 until q) {
            if (data[i].first < data[j].first && data[i].second < data[j].second) {
                adj[i].add(j)
            }
        }
    }
    val dp = IntArray(q) { -1 }
    fun dfs(v: Int): Int {
        if (dp[v] != -1) return dp[v]
        var max = 0
        for (w in adj[v]) {
            max = maxOf(max, dfs(w))
        }
        dp[v] = max + 1
        return dp[v]
    }
    (0 until q).forEach { dfs(it) }
    println(dp.maxOrNull()!!)
}

fun main() {
    Thread(null, {
        val writer = PrintWriter(System.out, false)
        writer.solve()
        writer.flush()
    }, "solve", 1.shl(26))
        .apply { setUncaughtExceptionHandler { _, e -> e.printStackTrace(); kotlin.system.exitProcess(1) } }
        .apply { start() }.join()
}

// region Scanner
private var st = StringTokenizer("")
private val br = System.`in`.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()
// endregion
0