結果
| 問題 | 
                            No.1703 Much Matching
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2021-10-08 23:18:22 | 
| 言語 | Kotlin  (2.1.0)  | 
                    
| 結果 | 
                             
                                TLE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,438 bytes | 
| コンパイル時間 | 13,989 ms | 
| コンパイル使用メモリ | 445,828 KB | 
| 実行使用メモリ | 100,228 KB | 
| 最終ジャッジ日時 | 2024-07-23 07:11:59 | 
| 合計ジャッジ時間 | 21,190 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 3 TLE * 1 -- * 31 | 
コンパイルメッセージ
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()
        ^
            
            ソースコード
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 0 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