Submission #980636
Source Code Expand
h,w = gets.split.map(&:to_i)
a = []
h.times do
a << gets.split(//)
end
#p a
hh, ww = 0 ,0
def pos(a,h,w, hh , ww)
#puts "in --"
while not ( hh == (h - 1) and ww == (w - 1) )
#a.each{|e| puts e.join}
#puts "#{a[hh][ww]} // #{hh}, #{ww} // #{h} #{w}"
#puts ""
if hh == (h - 1)
#p "h+"
if a[hh][ww+1] == "."
return false
end
a[hh][ww] = "+"
ww += 1
elsif ww == (w - 1)
#p "w+"
return false if a[hh+1][ww] == "."
a[hh][ww] = "+"
hh += 1
else
#p "both"
return false if a[hh+1][ww] == "#" and a[hh][ww+1] == "#"
return false if a[hh+1][ww] == "." and a[hh][ww+1] == "."
if a[hh+1][ww] == "#"
a[hh][ww] = "+"
return true if pos( a,h,w,hh+1, ww )
end
if a[hh][ww+1] == "#"
a[hh][ww] = "+"
return true if pos( a,h,w, hh, ww + 1 )
end
return false
end
end
a[hh][ww] = "+"
for i in 0...h
for j in 0...w
if a[i][j] == "#"
return false
end
end
end
return true
end
puts (pos(a,h,w, 0,0) ? "Possible" : "Impossible")
Submission Info
| Submission Time |
|
| Task |
A - Shik and Stone |
| User |
lisosia |
| Language |
Ruby (2.3.3) |
| Score |
200 |
| Code Size |
1201 Byte |
| Status |
AC |
| Exec Time |
655 ms |
| Memory |
1916 KiB |
Compile Error
./Main.rb:8: warning: assigned but unused variable - hh
./Main.rb:8: warning: assigned but unused variable - ww
Judge Result
| Set Name |
Sample |
All |
| Score / Max Score |
0 / 0 |
200 / 200 |
| Status |
|
|
| Set Name |
Test Cases |
| Sample |
example0.txt, example1.txt, example2.txt |
| All |
000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, example0.txt, example1.txt, example2.txt |
| Case Name |
Status |
Exec Time |
Memory |
| 000.txt |
AC |
11 ms |
1788 KiB |
| 001.txt |
AC |
11 ms |
1788 KiB |
| 002.txt |
AC |
11 ms |
1788 KiB |
| 003.txt |
AC |
11 ms |
1788 KiB |
| 004.txt |
AC |
11 ms |
1788 KiB |
| 005.txt |
AC |
11 ms |
1788 KiB |
| 006.txt |
AC |
655 ms |
1916 KiB |
| 007.txt |
AC |
11 ms |
1788 KiB |
| 008.txt |
AC |
11 ms |
1788 KiB |
| 009.txt |
AC |
11 ms |
1788 KiB |
| 010.txt |
AC |
11 ms |
1788 KiB |
| 011.txt |
AC |
11 ms |
1788 KiB |
| 012.txt |
AC |
11 ms |
1788 KiB |
| 013.txt |
AC |
11 ms |
1788 KiB |
| 014.txt |
AC |
11 ms |
1788 KiB |
| 015.txt |
AC |
11 ms |
1788 KiB |
| 016.txt |
AC |
11 ms |
1788 KiB |
| 017.txt |
AC |
11 ms |
1788 KiB |
| 018.txt |
AC |
11 ms |
1788 KiB |
| example0.txt |
AC |
11 ms |
1788 KiB |
| example1.txt |
AC |
11 ms |
1788 KiB |
| example2.txt |
AC |
11 ms |
1788 KiB |