結果
問題 | No.197 手品 |
ユーザー |
|
提出日時 | 2016-02-24 03:31:22 |
言語 | Go (1.23.4) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,062 bytes |
コンパイル時間 | 11,306 ms |
コンパイル使用メモリ | 223,688 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-27 13:19:17 |
合計ジャッジ時間 | 12,567 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 WA * 1 |
other | AC * 24 WA * 19 |
ソースコード
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 } dp := make(map[string]bool) dp[b] = true t := false 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] { t = true break } } if !t || b != 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 }