結果

問題 No.197 手品
ユーザー yukirinyukirin
提出日時 2016-02-24 03:05:04
言語 Go
(1.22.1)
結果
WA  
実行時間 -
コード長 1,256 bytes
コンパイル時間 11,766 ms
コンパイル使用メモリ 207,600 KB
実行使用メモリ 5,316 KB
最終ジャッジ日時 2023-09-09 20:46:28
合計ジャッジ時間 13,520 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 WA -
testcase_13 AC 1 ms
4,380 KB
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 AC 1 ms
4,376 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 1 ms
4,376 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 1 ms
4,380 KB
testcase_31 AC 1 ms
4,380 KB
testcase_32 AC 1 ms
4,376 KB
testcase_33 AC 1 ms
4,376 KB
testcase_34 AC 1 ms
4,380 KB
testcase_35 AC 2 ms
4,376 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 1 ms
4,376 KB
testcase_39 AC 1 ms
4,376 KB
testcase_40 AC 1 ms
4,376 KB
testcase_41 WA -
testcase_42 AC 1 ms
4,500 KB
testcase_43 AC 1 ms
4,380 KB
testcase_44 WA -
testcase_45 AC 2 ms
4,380 KB
testcase_46 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	b := nextLine()
	n := nextInt()
	a := nextLine()
	c1, c2 := strings.Count(b, "o"), strings.Count(a, "o")

	if c1 != c2 {
		fmt.Println("SUCCESS")
		return
	}

	if n == 0 && b == a {
		fmt.Println("FAILURE")
		return
	}

	if n == 0 && b != a {
		fmt.Println("SUCCESS")
		return
	}

	dp := make(map[string]bool)
	dp[b] = true

	mod := -1
	for i := 0; i < n && i < 6; i++ {
		next := make(map[string]bool)
		for k := range dp {
			next[string([]byte{k[1], k[0], k[2]})] = true
			next[string([]byte{k[0], k[2], k[1]})] = true
		}
		dp = next
		if dp[a] {
			mod = (n - i - 1) % 2
			break
		}
	}
	if mod == -1 {
		fmt.Println("SUCCESS")
		return
	}

	if mod%2 == 0 {
		fmt.Println("FAILURE")
		return
	}
	fmt.Println("SUCCESS")
}

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

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

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextLine(), 10, 64)
	return i
}

func nextUint64() uint64 {
	i, _ := strconv.ParseUint(nextLine(), 10, 64)
	return i
}

func nextFloat() float64 {
	f, _ := strconv.ParseFloat(nextLine(), 64)
	return f
}
0