結果

問題 No.1563 Same Degree
ユーザー 箱星箱星
提出日時 2021-06-26 13:04:01
言語 Kotlin
(2.1.0)
結果
AC  
実行時間 719 ms / 2,000 ms
コード長 974 bytes
コンパイル時間 12,895 ms
コンパイル使用メモリ 444,548 KB
実行使用メモリ 94,540 KB
最終ジャッジ日時 2024-06-25 10:09:50
合計ジャッジ時間 22,588 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 15
権限があれば一括ダウンロードができます

ソースコード

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