結果

問題 No.197 手品
コンテスト
ユーザー yuki2006
提出日時 2015-04-28 20:15:29
言語 Go
(1.25.5)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 1,505 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 12,657 ms
コンパイル使用メモリ 234,040 KB
実行使用メモリ 7,852 KB
最終ジャッジ日時 2026-01-01 19:20:28
合計ジャッジ時間 14,883 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

package main

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

func main() {
	// Scan開始前にSplitを設定しないとPanicになるため、ここに移動
	s.Split(bufio.ScanWords)

	before := next()
	N := nextInt()
	after := next()

	b := strings.Count(before, "o")
	a := strings.Count(after, "o")

	SUCCESS := "SUCCESS"
	FAILURE := "FAILURE"

	if b != a {
		fmt.Println(SUCCESS)
		return
	}
	if N == 0 {
		if before != after {
			fmt.Println(SUCCESS)
		} else {
			fmt.Println(FAILURE)
		}
	} else if N >= 2 {
		fmt.Println(FAILURE)
	} else {
		tmp := string(before[1]) + string(before[0]) + string(before[2])
		tmp2 := string(before[0]) + string(before[2]) + string(before[1])

		if tmp == after || tmp2 == after {
			fmt.Println(FAILURE)
		} else {
			fmt.Println(SUCCESS)
		}

	}

}

var s = bufio.NewScanner(os.Stdin)

func next() string {
	// s.Split(bufio.ScanWords) // 削除: Scan後に呼ぶとPanicになるため
	s.Scan()
	return s.Text()
}
func nextLine() string {
	// s.Split(bufio.ScanLines) // 削除: 同上
	s.Scan()
	return s.Text()
}

func nextInt() int {
	i, e := strconv.Atoi(next())
	if e != nil {
		panic(e)
	}
	return i
}
func nextLong() int64 {
	i, e := strconv.ParseInt(next(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}

func mapToString(arr []int) []string {
	ret := make([]string, len(arr))
	for i := 0; i < len(arr); i++ {
		ret[i] = strconv.Itoa(arr[i])
	}
	return ret
}

func PrintI(args ...int) {
	fmt.Println(strings.Join(mapToString(args), " "))
}
0