結果

問題 No.2052 Indegree
ユーザー 👑 箱
提出日時 2022-08-21 13:04:32
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 280 ms / 2,000 ms
コード長 1,021 bytes
コンパイル時間 12,376 ms
コンパイル使用メモリ 442,692 KB
実行使用メモリ 58,568 KB
最終ジャッジ日時 2024-04-18 12:48:00
合計ジャッジ時間 18,401 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 262 ms
58,404 KB
testcase_01 AC 265 ms
58,320 KB
testcase_02 AC 265 ms
58,444 KB
testcase_03 AC 260 ms
58,456 KB
testcase_04 AC 257 ms
58,420 KB
testcase_05 AC 272 ms
58,320 KB
testcase_06 AC 262 ms
58,532 KB
testcase_07 AC 253 ms
58,416 KB
testcase_08 AC 259 ms
58,416 KB
testcase_09 AC 273 ms
58,496 KB
testcase_10 AC 265 ms
58,456 KB
testcase_11 AC 264 ms
58,488 KB
testcase_12 AC 274 ms
58,380 KB
testcase_13 AC 280 ms
58,456 KB
testcase_14 AC 278 ms
58,304 KB
testcase_15 AC 271 ms
58,512 KB
testcase_16 AC 260 ms
58,452 KB
testcase_17 AC 264 ms
58,264 KB
testcase_18 AC 252 ms
58,428 KB
testcase_19 AC 271 ms
58,432 KB
testcase_20 AC 272 ms
58,568 KB
testcase_21 AC 268 ms
58,524 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

fun PrintWriter.solve() {
    val n = nextInt()
    val m = nextInt()
    val adj = Array(n) { mutableListOf<Int>() }
    for (i in 0 until m) {
        val v1 = nextInt() - 1
        val v2 = nextInt() - 1
        adj[v2].add(v1)
    }
    println(adj.count { it.size == 0 })
}

fun main() {
    Thread(null, {
        val writer = PrintWriter(System.out, false)
        writer.solve()
        writer.flush()
    }, "solve", abs(1L.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