結果
問題 | No.1801 Segment Game |
ユーザー |
|
提出日時 | 2022-06-16 20:15:24 |
言語 | Go (1.23.4) |
結果 |
AC
|
実行時間 | 53 ms / 2,000 ms |
コード長 | 1,133 bytes |
コンパイル時間 | 13,295 ms |
コンパイル使用メモリ | 243,908 KB |
実行使用メモリ | 14,464 KB |
最終ジャッジ日時 | 2024-10-07 02:15:58 |
合計ジャッジ時間 | 13,059 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 10 |
ソースコード
package mainimport ("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 []stringfor i := 0; i < t; i++ {var dd inth2, 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 []intfor 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}