結果

問題 No.232 めぐるはめぐる (2)
ユーザー ccppjsrbccppjsrb
提出日時 2020-09-05 23:29:01
言語 Go
(1.22.1)
結果
WA  
実行時間 -
コード長 2,024 bytes
コンパイル時間 13,614 ms
コンパイル使用メモリ 208,672 KB
実行使用メモリ 5,488 KB
最終ジャッジ日時 2023-08-19 13:15:07
合計ジャッジ時間 19,454 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 WA -
testcase_07 AC 1 ms
4,384 KB
testcase_08 WA -
testcase_09 AC 1 ms
4,380 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 1 ms
4,380 KB
testcase_24 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

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

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	t := getNextInt(scanner)
	a := getNextInt(scanner)
	b := getNextInt(scanner)
	if t < max(a, b) {
		fmt.Fprintln(writer, "NO")
		return
	}
	if t == 1 && a == 0 && b == 0 {
		fmt.Fprintln(writer, "NO")
		return
	}
	ans := make([][2]int, t)
	for i := 0; i < t; i++ {
		ans[i][0] = 1
		ans[i][1] = 1
	}
	for i := 0; i < (t-a)>>1; i++ {
		ans[i][0] = -1
	}
	for i := 0; i < (t-b)>>1; i++ {
		ans[i][1] = -1
	}
	if (t-a)&1 == 1 {
		ans[t-2][0] = 0
	}
	if (t-b)&1 == 1 {
		ans[t-1][1] = 0
	}
	for i := 0; i < t; i++ {
		switch ans[i][0] {
		case -1:
			fmt.Fprint(writer, "v")
		case 1:
			fmt.Fprint(writer, "^")
		}
		switch ans[i][1] {
		case -1:
			fmt.Fprint(writer, "<")
		case 1:
			fmt.Fprint(writer, ">")
		}
		fmt.Fprintln(writer, "")
	}
}
func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}
0