結果
| 問題 | 
                            No.197 手品
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2016-02-24 03:45:10 | 
| 言語 | Go  (1.23.4)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,127 bytes | 
| コンパイル時間 | 11,479 ms | 
| コンパイル使用メモリ | 226,792 KB | 
| 実行使用メモリ | 15,000 KB | 
| 最終ジャッジ日時 | 2024-06-27 13:19:31 | 
| 合計ジャッジ時間 | 14,096 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 WA * 2 TLE * 1 | 
| other | AC * 3 WA * 4 -- * 36 | 
ソースコード
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
	for i := 0; i < n; 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] {
		fmt.Println("SUCCESS")
		return
	}
	fmt.Println("FAILURE")
}
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
}