結果

問題 No.1610 She Loves Me, She Loves Me Not, ...
ユーザー 👑 箱
提出日時 2021-07-21 22:48:04
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 398 ms / 2,000 ms
コード長 1,262 bytes
コンパイル時間 15,343 ms
コンパイル使用メモリ 425,176 KB
実行使用メモリ 56,940 KB
最終ジャッジ日時 2023-09-24 19:08:59
合計ジャッジ時間 28,712 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 276 ms
50,164 KB
testcase_01 AC 273 ms
50,216 KB
testcase_02 AC 275 ms
50,260 KB
testcase_03 AC 276 ms
50,212 KB
testcase_04 AC 275 ms
50,268 KB
testcase_05 AC 395 ms
55,124 KB
testcase_06 AC 398 ms
55,352 KB
testcase_07 AC 390 ms
55,080 KB
testcase_08 AC 389 ms
55,256 KB
testcase_09 AC 388 ms
55,064 KB
testcase_10 AC 381 ms
55,300 KB
testcase_11 AC 393 ms
55,188 KB
testcase_12 AC 390 ms
56,940 KB
testcase_13 AC 391 ms
55,120 KB
testcase_14 AC 292 ms
50,260 KB
testcase_15 AC 293 ms
50,316 KB
testcase_16 AC 291 ms
50,396 KB
testcase_17 AC 288 ms
50,508 KB
testcase_18 AC 285 ms
50,428 KB
testcase_19 AC 285 ms
50,516 KB
testcase_20 AC 289 ms
50,596 KB
testcase_21 AC 290 ms
50,296 KB
testcase_22 AC 287 ms
50,308 KB
testcase_23 AC 276 ms
50,220 KB
testcase_24 AC 276 ms
50,176 KB
testcase_25 AC 277 ms
50,068 KB
testcase_26 AC 281 ms
50,180 KB
testcase_27 AC 283 ms
50,376 KB
testcase_28 AC 275 ms
50,212 KB
testcase_29 AC 273 ms
50,220 KB
testcase_30 AC 272 ms
50,280 KB
testcase_31 AC 274 ms
50,308 KB
testcase_32 AC 272 ms
50,308 KB
testcase_33 AC 273 ms
50,680 KB
testcase_34 AC 280 ms
50,384 KB
testcase_35 AC 276 ms
50,260 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[v1].add(v2)
        adj[v2].add(v1)
    }
    var count = 0
    val stack = Stack<Int>()
    for (i in 0 until n) {
        if (adj[i].size == 1) {
            stack.push(i)
        }
    }
    while (stack.isNotEmpty()) {
        val v = stack.pop()
        if (adj[v].size != 1) continue
        val w = adj[v][0]
        count++
        adj[v].remove(w)
        adj[w].remove(v)
        if (adj[w].size == 1) {
            stack.push(w)
        }
    }
    println(if (count % 2 == 1) "Yes" else "No")
}

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