結果

問題 No.154 市バス
ユーザー yukirinyukirin
提出日時 2016-03-01 21:39:13
言語 Go
(1.22.1)
結果
WA  
実行時間 -
コード長 694 bytes
コンパイル時間 17,055 ms
コンパイル使用メモリ 220,864 KB
実行使用メモリ 8,380 KB
最終ジャッジ日時 2024-04-21 09:11:45
合計ジャッジ時間 15,960 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	t := nextInt()
	r := regexp.MustCompile(`G.*?R`)

	for i := 0; i < t; i++ {
		b := []byte(strings.Replace(nextLine(), "W", "", -1))
		for j := 0; j < 3; j++ {
			loc := r.FindIndex(b)
			if loc == nil {
				break
			}

			b[loc[0]], b[loc[1]-1] = 'W', 'W'
			b = []byte(strings.Replace(string(b), "W", "", -1))
		}
		if len(b) == 0 {
			fmt.Println("possible")
			continue
		}
		fmt.Println("impossible")
	}
}

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

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