Submission #980068
Source Code Expand
from collections import deque h, w = map(int, input().split()) a = [list(input()) for i in range(h)] mv = [[1, 0], [0, 1]] sx, sy = 0, 0 gx, gy = h - 1, w - 1 nxt = deque() nxt.appendleft([sx, sy]) for i in range(h - 1): count = 0 check = 0 count2 = 0 for j in range(w): if a[i][j] == "#": if a[i][j] == a[i + 1][j]: count += 1 if check == 0: check = 1 if count2 > 0: count = 2 break else: if a[i + 1][j] == "#": count2 += 1 if count > 1: nxt.clear() break flag = 0 while len(nxt) > 0: tmp = nxt.pop() nwx, nwy = tmp[0], tmp[1] if nwx == gx and nwy == gy: flag = 1 break count = 0 for i in range(2): tmpx = mv[i][0] + nwx tmpy = mv[i][1] + nwy if tmpy < w and tmpx < h: if a[tmpx][tmpy] == '#': nxt.appendleft([tmpx, tmpy]) count += 1 if count > 1: break if flag: print("Possible") else: print("Impossible")
Submission Info
Submission Time | |
---|---|
Task | A - Shik and Stone |
User | ka24 |
Language | Python (3.4.3) |
Score | 200 |
Code Size | 1201 Byte |
Status | AC |
Exec Time | 26 ms |
Memory | 3316 KB |
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 | 26 ms | 3316 KB |
001.txt | AC | 26 ms | 3316 KB |
002.txt | AC | 26 ms | 3316 KB |
003.txt | AC | 26 ms | 3316 KB |
004.txt | AC | 26 ms | 3316 KB |
005.txt | AC | 26 ms | 3316 KB |
006.txt | AC | 26 ms | 3316 KB |
007.txt | AC | 26 ms | 3316 KB |
008.txt | AC | 26 ms | 3316 KB |
009.txt | AC | 26 ms | 3316 KB |
010.txt | AC | 26 ms | 3316 KB |
011.txt | AC | 26 ms | 3316 KB |
012.txt | AC | 26 ms | 3316 KB |
013.txt | AC | 26 ms | 3316 KB |
014.txt | AC | 26 ms | 3316 KB |
015.txt | AC | 26 ms | 3316 KB |
016.txt | AC | 26 ms | 3316 KB |
017.txt | AC | 26 ms | 3316 KB |
018.txt | AC | 26 ms | 3316 KB |
example0.txt | AC | 26 ms | 3316 KB |
example1.txt | AC | 26 ms | 3316 KB |
example2.txt | AC | 26 ms | 3316 KB |