Contest Duration: ~ (local time) (90 minutes) Back to Home

Submission #8957196

Source Code Expand

Copy
```LAND = "o"
SEA = "x"

class Solver:
def __init__(self, field) -> None:
self.S = 10
self.field = field

def count_land(self, h, w, visited, fill=False):
if not (0 <= h < self.S):
return 0
if not (0 <= w < self.S):
return 0
if visited[h][w]:
return 0
if self.field[h][w] == LAND or fill:
visited[h][w] = True
return sum([
1,
self.count_land(h - 1, w, visited),
self.count_land(h, w - 1, visited),
self.count_land(h, w + 1, visited),
self.count_land(h + 1, w, visited)
])
if self.field[h][w] == SEA:
return 0
return 0

def create_visit_map(self):
return [
[False for _ in range(10)]
for _ in range(10)
]

def count_lands(self):
ret = 0
for i in range(10):
for j in range(10):
ret += 1 if self.field[i][j] == LAND else 0
return ret

def solve(self) -> str:
lands = self.count_lands()
can_union = False
for i in range(10):
for j in range(10):
if self.field[i][j] == SEA:
if self.count_land(i, j, self.create_visit_map(), True) == lands + 1:
can_union = True
break

return 'YES' if can_union else 'NO'

if __name__ == "__main__":
field = []
for _ in range(10):
field.append(list(input()))

s = Solver(field)
print(s.solve())```

#### Submission Info

Submission Time 2019-12-15 00:13:35+0900 B - 埋め立て hagino3000 Python (3.4.3) 100 1673 Byte AC 22 ms 3192 KB

#### Judge Result

Set Name Sample All
Score / Max Score 0 / 0 100 / 100
Status
 AC × 3
 AC × 33
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 10_rand_00.txt, 10_rand_01.txt, 10_rand_02.txt, 10_rand_03.txt, 10_rand_04.txt, 10_rand_05.txt, 10_rand_06.txt, 10_rand_07.txt, 10_rand_08.txt, 10_rand_09.txt, 10_rand_10.txt, 10_rand_11.txt, 10_rand_12.txt, 10_rand_13.txt, 10_rand_14.txt, 10_rand_15.txt, 10_rand_16.txt, 10_rand_17.txt, 10_rand_18.txt, 10_rand_19.txt, 10_rand_20.txt, 10_rand_21.txt, 10_rand_22.txt, 10_rand_23.txt, 10_rand_24.txt, 10_rand_25.txt, 10_rand_26.txt, 10_rand_27.txt, 10_rand_28.txt, 10_rand_29.txt
Case Name Status Exec Time Memory
00_sample_00.txt 19 ms 3064 KB
00_sample_01.txt 19 ms 3064 KB
00_sample_02.txt 19 ms 3064 KB
10_rand_00.txt 22 ms 3064 KB
10_rand_01.txt 19 ms 3192 KB
10_rand_02.txt 21 ms 3064 KB
10_rand_03.txt 20 ms 3064 KB
10_rand_04.txt 19 ms 3064 KB
10_rand_05.txt 21 ms 3064 KB
10_rand_06.txt 19 ms 3064 KB
10_rand_07.txt 22 ms 3064 KB
10_rand_08.txt 20 ms 3064 KB
10_rand_09.txt 20 ms 3064 KB
10_rand_10.txt 21 ms 3064 KB
10_rand_11.txt 22 ms 3064 KB
10_rand_12.txt 21 ms 3064 KB
10_rand_13.txt 19 ms 3064 KB
10_rand_14.txt 22 ms 3064 KB
10_rand_15.txt 21 ms 3064 KB
10_rand_16.txt 19 ms 3064 KB
10_rand_17.txt 19 ms 3064 KB
10_rand_18.txt 21 ms 3064 KB
10_rand_19.txt 21 ms 3064 KB
10_rand_20.txt 22 ms 3064 KB
10_rand_21.txt 19 ms 3064 KB
10_rand_22.txt 22 ms 3064 KB
10_rand_23.txt 21 ms 3064 KB
10_rand_24.txt 22 ms 3064 KB
10_rand_25.txt 19 ms 3064 KB
10_rand_26.txt 21 ms 3064 KB
10_rand_27.txt 19 ms 3064 KB
10_rand_28.txt 22 ms 3064 KB
10_rand_29.txt 22 ms 3064 KB