結果

問題 No.438 Cwwプログラミング入門
ユーザー aru aruaru aru
提出日時 2021-01-03 11:09:59
言語 Go
(1.22.1)
結果
WA  
実行時間 -
コード長 2,183 bytes
コンパイル時間 11,890 ms
コンパイル使用メモリ 211,340 KB
実行使用メモリ 301,128 KB
最終ジャッジ日時 2023-08-03 06:47:52
合計ジャッジ時間 22,437 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,356 KB
testcase_01 WA -
testcase_02 AC 22 ms
7,808 KB
testcase_03 AC 22 ms
10,040 KB
testcase_04 AC 178 ms
29,288 KB
testcase_05 AC 126 ms
18,008 KB
testcase_06 AC 42 ms
10,876 KB
testcase_07 AC 7 ms
5,608 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 5 ms
5,568 KB
testcase_14 WA -
testcase_15 AC 7 ms
5,584 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 44 ms
10,856 KB
testcase_19 AC 45 ms
11,100 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 5 ms
5,568 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 46 ms
10,912 KB
testcase_28 AC 1 ms
4,376 KB
testcase_29 WA -
testcase_30 AC 14 ms
7,684 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 1 ms
4,376 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 2 ms
4,380 KB
testcase_38 AC 20 ms
10,016 KB
testcase_39 WA -
testcase_40 AC 5 ms
5,564 KB
testcase_41 WA -
testcase_42 WA -
testcase_43 AC 4 ms
5,564 KB
testcase_44 WA -
testcase_45 AC 1 ms
4,380 KB
testcase_46 AC 2 ms
4,384 KB
testcase_47 WA -
testcase_48 WA -
testcase_49 TLE -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
testcase_57 -- -
testcase_58 -- -
testcase_59 -- -
testcase_60 -- -
testcase_61 -- -
testcase_62 -- -
testcase_63 -- -
testcase_64 -- -
testcase_65 -- -
testcase_66 -- -
testcase_67 -- -
testcase_68 -- -
testcase_69 -- -
testcase_70 -- -
testcase_71 -- -
testcase_72 -- -
testcase_73 -- -
testcase_74 -- -
testcase_75 -- -
testcase_76 -- -
testcase_77 -- -
testcase_78 -- -
testcase_79 -- -
testcase_80 -- -
testcase_81 -- -
testcase_82 -- -
testcase_83 -- -
testcase_84 -- -
testcase_85 -- -
testcase_86 -- -
testcase_87 -- -
testcase_88 -- -
testcase_89 -- -
testcase_90 -- -
testcase_91 -- -
testcase_92 -- -
testcase_93 -- -
testcase_94 -- -
testcase_95 -- -
testcase_96 -- -
testcase_97 -- -
testcase_98 -- -
testcase_99 -- -
testcase_100 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

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

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

func out(x ...interface{}) {
	fmt.Fprintln(wr, x...)
}

func getI() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getF() float64 {
	sc.Scan()
	i, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getI()
	}
	return ret
}

func getS() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

// min for n entry
func nmin(a ...int) int {
	ret := a[0]
	for _, e := range a {
		ret = min(ret, e)
	}
	return ret
}

// max for n entry
func nmax(a ...int) int {
	ret := a[0]
	for _, e := range a {
		ret = max(ret, e)
	}
	return ret
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

// 拡張GCD
func extGCD(a, b int) (int, int, int) {
	if b == 0 {
		return a, 1, 0
	}
	d, y, x := extGCD(b, a%b)
	y -= a / b * x
	return d, x, y
}

var x, y, z int

var memo map[int]bool

func rec(n, v int, s []byte) {
	if memo[v] == true {
		return
	}
	memo[v] = true
	if n > 10000 {
		return
	}
	if v > z {
		return
	}
	if v == z {
		out(string(s))
		wr.Flush()
		os.Exit(0)
	}
	rec(n+1, v+x, append(s, "cC"...))
	rec(n+1, v-x, append(s, "cW"...))
	rec(n+1, v+y, append(s, "wC"...))
	rec(n+1, v-y, append(s, "wW"...))
}

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)
	// this template is new version.
	// use getI(), getS(), getInts(), getF()
	x, y, z = getI(), getI(), getI()

	memo = make(map[int]bool)
	rec(0, x, []byte{'c'})
	rec(0, y, []byte{'c'})
	out("NO")
}
0