結果

問題 No.154 市バス
ユーザー hirakich1048576hirakich1048576
提出日時 2016-07-10 01:08:16
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 553 bytes
コンパイル時間 94 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 13,568 KB
最終ジャッジ日時 2024-04-21 09:50:12
合計ジャッジ時間 5,321 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 555 ms
13,440 KB
testcase_01 AC 546 ms
13,440 KB
testcase_02 AC 560 ms
13,440 KB
testcase_03 AC 443 ms
13,440 KB
testcase_04 AC 539 ms
13,568 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 553 ms
13,440 KB
testcase_08 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:2: warning: parentheses after method name is interpreted as an argument list, not a decomposed argument
Main.rb:32: warning: parentheses after method name is interpreted as an argument list, not a decomposed argument
Main.rb:35: warning: assigned but unused variable - i
Syntax OK

ソースコード

diff #

def isinvalid (str)

	# bus = 0

	# while str =~ /[GR]/
	# 	isvalid = str =~ /^(W*?)WG([WG]*?)R(.*)$/
	# 	return true unless isvalid

	# 	str = "#{$1}#{$2}#{$3}"

	# end

	# false
	# 
	# 
	
	bus = {}
	bus['W'] = bus['G'] = bus['R'] = 0
	
	str = str.split('')

	for c in str do
		bus[c] += 1
		return true if bus['W'] < bus['G'] || bus['G'] < bus['R']
	end

	bus['G'] != bus['R']

end

def main ()
	flandre = gets.chomp.to_i(10)

	for i in 0...flandre do
		str = gets.chomp
		x = ""
		x << "im" if isinvalid(str)
		puts x << "possible"
	end
end

main()
0