結果
問題 | No.197 手品 |
ユーザー |
|
提出日時 | 2016-02-24 03:28:58 |
言語 | Go (1.23.4) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 1,174 bytes |
コンパイル時間 | 15,092 ms |
コンパイル使用メモリ | 221,208 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-20 03:46:12 |
合計ジャッジ時間 | 14,029 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 43 |
ソースコード
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 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 { 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 }