ํ‹ฐ์Šคํ† ๋ฆฌ ๋ทฐ

๐Ÿ‘ฉ๐Ÿป‍๐Ÿ’ป ๋ฌธ์ œ

 

9372๋ฒˆ: ์ƒ๊ทผ์ด์˜ ์—ฌํ–‰

์ฒซ ๋ฒˆ์งธ ์ค„์—๋Š” ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค์˜ ์ˆ˜ T(T ≤ 100)๊ฐ€ ์ฃผ์–ด์ง€๊ณ , ๊ฐ ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค๋งˆ๋‹ค ๋‹ค์Œ๊ณผ ๊ฐ™์€ ์ •๋ณด๊ฐ€ ์ฃผ์–ด์ง„๋‹ค. ์ฒซ ๋ฒˆ์งธ ์ค„์—๋Š” ๊ตญ๊ฐ€์˜ ์ˆ˜ N(2 ≤ N ≤ 1 000)๊ณผ ๋น„ํ–‰๊ธฐ์˜ ์ข…๋ฅ˜ M(1 ≤ M ≤ 10 000) ๊ฐ€

www.acmicpc.net


โœ๐Ÿป ํ’€์ด

๐ŸŽจ Go

// https://www.acmicpc.net/problem/9372
package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	var t int
	fmt.Fscanln(reader, &t)
	for i := 0; i < t; i++ {
		var n, m int
		fmt.Fscanln(reader, &n, &m)
		for j := 0; j < m; j++ {
			var a, b int
			fmt.Fscanln(reader, &a, &b)
		}
		fmt.Fprintln(writer, n-1) // ์ŠคํŒจ๋‹ํŠธ๋ฆฌ: n๊ฐœ์˜ ์ •์ ์„ ๊ฐ€์ง€๋Š” ๊ทธ๋ž˜ํ”„์˜ ์ตœ์†Œ ๊ฐ„์„ ์˜ ์ˆ˜๋Š” (n-1)๊ฐœ์ด๋‹ค.
	}
}

๐ŸŽจ Python3

# https://www.acmicpc.net/problem/9372
import sys

if __name__ == "__main__":
    t = int(sys.stdin.readline())
    for i in range(t):
        n, m = list(map(int, sys.stdin.readline().split()))
        for j in range(m):
            a, b = sys.stdin.readline().split()
        print(n-1)
728x90
๋Œ“๊ธ€