結果
| 問題 | No.1703 Much Matching |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-10-08 23:13:08 |
| 言語 | Kotlin (2.1.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,444 bytes |
| 記録 | |
| コンパイル時間 | 17,099 ms |
| コンパイル使用メモリ | 447,416 KB |
| 実行使用メモリ | 100,052 KB |
| 最終ジャッジ日時 | 2024-07-23 06:59:51 |
| 合計ジャッジ時間 | 22,215 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | WA * 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 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