結果
問題 | No.154 市バス |
ユーザー | yukirin |
提出日時 | 2016-03-02 02:06:12 |
言語 | Go (1.23.4) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,194 bytes |
コンパイル時間 | 11,244 ms |
コンパイル使用メモリ | 224,856 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-13 08:09:25 |
合計ジャッジ時間 | 12,014 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 1 |
other | WA * 8 |
ソースコード
package main import ( "bufio" "fmt" "os" "strconv" ) var sc = bufio.NewScanner(os.Stdin) func main() { sc.Split(bufio.ScanWords) t := nextInt() ans := make([]byte, 0, 10000) imp, po := []byte("impossible\n"), []byte("possible\n") for i := 0; i < t; i++ { s := nextLine() flag := true count := make([]int, 3) min := 0 for i := len(s) - 1; i >= 0; i-- { switch c := s[i]; c { case 'W': count[0]++ if min != 0 { min-- } case 'G': count[1]++ min++ case 'R': count[2]++ } if count[2] == 0 && count[0] == 1 { flag = false break } if count[2] == 0 && count[1] == 1 { flag = false break } if count[1] == 0 && count[0] == 1 { flag = false break } if count[1] > count[2] { flag = false break } } if !flag { ans = append(ans, imp...) continue } if min != 0 { ans = append(ans, imp...) continue } if count[2] != count[1] { ans = append(ans, imp...) continue } ans = append(ans, po...) } fmt.Println(string(ans)) } func nextLine() string { sc.Scan() return sc.Text() } func nextInt() int { i, _ := strconv.Atoi(nextLine()) return i }