結果

問題 No.1801 Segment Game
ユーザー HimaHima
提出日時 2022-06-16 20:15:24
言語 Go
(1.22.1)
結果
AC  
実行時間 54 ms / 2,000 ms
コード長 1,133 bytes
コンパイル時間 15,134 ms
コンパイル使用メモリ 233,480 KB
実行使用メモリ 14,464 KB
最終ジャッジ日時 2024-04-16 09:44:26
合計ジャッジ時間 17,341 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 53 ms
14,164 KB
testcase_02 AC 52 ms
14,080 KB
testcase_03 AC 53 ms
14,080 KB
testcase_04 AC 53 ms
14,464 KB
testcase_05 AC 54 ms
14,464 KB
testcase_06 AC 53 ms
14,464 KB
testcase_07 AC 52 ms
14,080 KB
testcase_08 AC 53 ms
14,464 KB
testcase_09 AC 52 ms
14,080 KB
testcase_10 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func solve(t int, h, w, d []int) []string {
	var ans []string
	for i := 0; i < t; i++ {
		var dd int
		h2, w2 := h[i]*h[i], w[i]*w[i]
		if h[i]%2 == 0 {
			if w[i]%2 == 0 {
				dd = Min(h2, w2)
			} else {
				dd = Min(h2+1, w2)
			}
		} else {
			if w[i]%2 == 0 {
				dd = Min(h2, w2+1)
			} else {
				dd = Min(h2+1, w2+1)
			}
		}
		if dd <= d[i]*d[i] {
			ans = append(ans, "N")
		} else {
			ans = append(ans, "S")
		}
	}
	return ans
}

func main() {
	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)

	t := nextInt()
	var h, w, d []int
	for i := 0; i < t; i++ {
		h = append(h, nextInt())
		w = append(w, nextInt())
		d = append(d, nextInt())
	}
	ans := solve(t, h, w, d)
	PrintVertically(ans)

}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func PrintVertically(x []string) {
	defer out.Flush()
	for _, v := range x {
		fmt.Fprintln(out, v)
	}
}

func Min(x, y int) int {
	if x < y {
		return x
	}
	return y
}
0