結果

問題 No.1610 She Loves Me, She Loves Me Not, ...
ユーザー 小野寺健小野寺健
提出日時 2021-12-18 13:19:25
言語 Go
(1.22.1)
結果
AC  
実行時間 245 ms / 2,000 ms
コード長 877 bytes
コンパイル時間 13,009 ms
コンパイル使用メモリ 204,140 KB
実行使用メモリ 185,100 KB
最終ジャッジ日時 2023-10-13 17:35:45
合計ジャッジ時間 16,640 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,368 KB
testcase_01 AC 30 ms
10,292 KB
testcase_02 AC 2 ms
4,368 KB
testcase_03 AC 1 ms
4,372 KB
testcase_04 AC 1 ms
4,368 KB
testcase_05 AC 190 ms
133,236 KB
testcase_06 AC 190 ms
138,060 KB
testcase_07 AC 219 ms
139,632 KB
testcase_08 AC 245 ms
139,920 KB
testcase_09 AC 196 ms
139,604 KB
testcase_10 AC 213 ms
139,728 KB
testcase_11 AC 195 ms
181,584 KB
testcase_12 AC 194 ms
174,848 KB
testcase_13 AC 217 ms
185,100 KB
testcase_14 AC 2 ms
4,372 KB
testcase_15 AC 2 ms
4,368 KB
testcase_16 AC 2 ms
4,368 KB
testcase_17 AC 2 ms
4,372 KB
testcase_18 AC 1 ms
4,368 KB
testcase_19 AC 2 ms
4,368 KB
testcase_20 AC 1 ms
4,372 KB
testcase_21 AC 2 ms
4,368 KB
testcase_22 AC 2 ms
4,368 KB
testcase_23 AC 1 ms
4,368 KB
testcase_24 AC 1 ms
4,372 KB
testcase_25 AC 1 ms
4,368 KB
testcase_26 AC 1 ms
4,368 KB
testcase_27 AC 1 ms
4,372 KB
testcase_28 AC 1 ms
4,368 KB
testcase_29 AC 2 ms
4,368 KB
testcase_30 AC 1 ms
4,368 KB
testcase_31 AC 1 ms
4,368 KB
testcase_32 AC 2 ms
4,368 KB
testcase_33 AC 1 ms
4,368 KB
testcase_34 AC 1 ms
4,372 KB
testcase_35 AC 1 ms
4,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import (
	"fmt"
	"bufio"
	"os"
)

func main() {
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()
	var N, M int
	fmt.Fscan(r, &N, &M)
	V := make([][]int, N)
	for i := 0; i < N; i++ {
		V[i] = make([]int, N)
	}
	for i := 0; i < M; i++ {
		var a, b int
		fmt.Fscan(r, &a, &b)
		V[a-1][b-1] = 1
		V[b-1][a-1] = 1
	}
	cnt := 0
	change := true
	for change {
		change = false
		for i := 0; i < N; i++ {
			if Sum(V[i]) == 1 {
				j := Index(V[i], 1)
				V[i][j] = 0
				V[j][i] = 0
				change = true
				cnt++
			}
		}
	}
	if cnt % 2 == 1 {
		fmt.Fprintln(w, "Yes")
	} else {
		fmt.Fprintln(w, "No")
	}
}

func Sum(a []int) int {
	var sum int
	for _, v := range a {
		sum += v
	}
	return sum
}

func Index(a []int, value int) int {
	var index int = -1
	for i, v := range a {
		if v == value {
			index = i
			break
		}
	}
	return index
}
0