結果
問題 | No.86 TVザッピング(2) |
ユーザー | Tsuneo Yoshioka |
提出日時 | 2014-12-05 00:20:57 |
言語 | Ruby (3.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,413 bytes |
コンパイル時間 | 118 ms |
コンパイル使用メモリ | 7,424 KB |
実行使用メモリ | 12,416 KB |
最終ジャッジ日時 | 2024-06-11 15:36:09 |
合計ジャッジ時間 | 3,572 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 75 ms
12,160 KB |
testcase_01 | AC | 73 ms
12,160 KB |
testcase_02 | AC | 78 ms
12,288 KB |
testcase_03 | AC | 77 ms
12,288 KB |
testcase_04 | AC | 78 ms
12,160 KB |
testcase_05 | AC | 74 ms
12,160 KB |
testcase_06 | AC | 73 ms
12,288 KB |
testcase_07 | AC | 73 ms
12,416 KB |
testcase_08 | AC | 79 ms
12,288 KB |
testcase_09 | AC | 77 ms
12,288 KB |
testcase_10 | AC | 83 ms
12,416 KB |
testcase_11 | AC | 74 ms
12,160 KB |
testcase_12 | AC | 73 ms
12,160 KB |
testcase_13 | AC | 73 ms
12,160 KB |
testcase_14 | AC | 79 ms
12,288 KB |
testcase_15 | AC | 74 ms
12,288 KB |
testcase_16 | AC | 76 ms
12,160 KB |
testcase_17 | WA | - |
testcase_18 | AC | 75 ms
12,288 KB |
testcase_19 | AC | 73 ms
12,160 KB |
testcase_20 | AC | 74 ms
12,160 KB |
testcase_21 | AC | 80 ms
12,288 KB |
testcase_22 | AC | 74 ms
12,160 KB |
testcase_23 | AC | 79 ms
12,288 KB |
testcase_24 | AC | 75 ms
12,160 KB |
testcase_25 | AC | 76 ms
12,160 KB |
testcase_26 | AC | 75 ms
12,160 KB |
testcase_27 | AC | 73 ms
12,160 KB |
testcase_28 | AC | 74 ms
12,160 KB |
testcase_29 | AC | 73 ms
12,160 KB |
testcase_30 | AC | 72 ms
12,160 KB |
testcase_31 | AC | 73 ms
12,160 KB |
testcase_32 | AC | 73 ms
12,160 KB |
コンパイルメッセージ
Main.rb:85: warning: `+' after local variable or literal is interpreted as binary operator Main.rb:85: warning: even though it seems like unary operator Main.rb:87: warning: `+' after local variable or literal is interpreted as binary operator Main.rb:87: warning: even though it seems like unary operator Main.rb:89: warning: `+' after local variable or literal is interpreted as binary operator Main.rb:89: warning: even though it seems like unary operator Main.rb:59: warning: assigned but unused variable - start_found Syntax OK
ソースコード
N, M = gets.split.map(&:to_i) mp = [] mp << "#" + "#" * M + "#" while($_=gets) do $_.chomp! #puts "1_=#{$_}" $_ = "#" + $_ + "#" #puts "2_=#{$_}" mp << $_ end mp << "#" + "#" * M + "#" #puts mp.to_s start_x = nil start_y = nil (1...N+1).each{|n| (1...M+1).each{|m| #puts "mp[#{n}][#{m}]=#{m[n][m]}" if(mp[n][m]=='.') then start_y = n start_x = m; break end } if start_x then break end } cur_x = start_x cur_y = start_y directions = [[0,1],[1,0],[0,-1],[-1,0]] cur_d = nil (0...directions.size).each{|d| #puts "pre:d=#{d}, cur_x=#{cur_x}, cur_y=#{cur_y}" #puts "mp[cur_y+#{directions[d][1]}][cur_x+#{directions[d][0]}]" #puts "mp[#{cur_y+directions[d][1]}][#{cur_x+directions[d][0]}]" if(mp[cur_y+directions[d][1]][cur_x+directions[d][0]]=='.')then cur_d = start_d = d cur_x += d[0] cur_y += d[0] break end } if cur_d == nil puts "NO" exit end start2_x = cur_x start2_y = cur_y init = true used_right=false while true #puts "cur_d=#{cur_d}, cur_x=#{cur_x}, cur_y=#{cur_y}" if cur_x == start_x && cur_y == start_y then start_found = true end if cur_x == start2_x && cur_y == start2_y then if ! init mp[cur_y][cur_x] = '*' ok = true (1...N+1).each{|n| (1...M+1).each{|m| #puts "mp[#{n}][#{m}]=#{mp[n][m]}" if(mp[n][m]=='.') ok = false end } } if ok puts "YES" else puts "NO" end exit 0 end init = false else mp[cur_y][cur_x] = '*' end if mp[cur_y+directions[cur_d][1]][cur_x +directions[cur_d][0]] == '.' # elsif mp[cur_y+directions[(cur_d+1)%4][1]][cur_x +directions[(cur_d+1)%4][0]] == '.' cur_d = (cur_d+1)%4 elsif used_right == false && mp[cur_y+directions[(cur_d+3)%4][1]][cur_x +directions[(cur_d+3)%4][0]] == '.' cur_d = (cur_d+3)%4 used_right = true else puts "NO" exit 0 end cur_x += directions[cur_d][0] cur_y += directions[cur_d][1] end