結果

問題 No.1563 Same Degree
ユーザー 👑 箱
提出日時 2021-06-26 13:04:01
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 671 ms / 2,000 ms
コード長 974 bytes
コンパイル時間 14,933 ms
コンパイル使用メモリ 421,152 KB
実行使用メモリ 68,648 KB
最終ジャッジ日時 2023-09-07 16:16:06
合計ジャッジ時間 22,060 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 268 ms
52,812 KB
testcase_01 AC 510 ms
57,944 KB
testcase_02 AC 530 ms
58,080 KB
testcase_03 AC 534 ms
58,436 KB
testcase_04 AC 513 ms
58,324 KB
testcase_05 AC 512 ms
57,956 KB
testcase_06 AC 535 ms
57,992 KB
testcase_07 AC 531 ms
57,944 KB
testcase_08 AC 532 ms
58,008 KB
testcase_09 AC 551 ms
58,148 KB
testcase_10 AC 519 ms
58,068 KB
testcase_11 AC 456 ms
60,028 KB
testcase_12 AC 502 ms
62,520 KB
testcase_13 AC 629 ms
68,428 KB
testcase_14 AC 671 ms
68,648 KB
testcase_15 AC 604 ms
66,304 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.PrintWriter
import java.util.*

fun PrintWriter.solve() {
    val numCases = nextInt()
    case@ for (_i in 0 until numCases) {
        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[v1].add(v2)
            adj[v2].add(v1)
        }
        println(if (adj.map { it.count() }.distinct().count() == n) "No" else "Yes")
    }
}

fun main() {
    val writer = PrintWriter(System.out, false)
    writer.solve()
    writer.flush()
}

// 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