Problem p03014 (python)

Fixed submission:
h, w = map(int, input().split())
s = []
l = []
r = []
u = []
d = []
for i in range(h):
  s.append(input())
  l.append([0 for j in range(w)])
  r.append([0 for j in range(w)])
  u.append([0 for j in range(w)])
  d.append([0 for j in range(w)])
  
# lみる
for x in range(w):
  for y in range(h):
    if s[y][x] == '.':
      if x == 0:
        l[y][x] = 1
      else:
        l[y][x] = l[y][x-1] + 1
 
# rみる
for x in range(w-1, -1, -1):
  for y in range(h-1, -1, -1):
    if s[y][x] == '.':
      if x == w-1:
        r[y][x] = 1
      else:
        r[y][x] = r[y][x+1] + 1
 
# uみる
for y in range(h):
  for x in range(w):
    if s[y][x] == '.':
      if y == 0:
        u[y][x] = 1
      else:
        u[y][x] = u[y-1][x] + 1
 
# dみる
for y in range(h-1, -1, -1):
  for x in range(w-1, -1, -1):
    if s[y][x] == '.':
      if y == h-1:
        d[y][x] = 1
      else:
        d[y][x] = d[y+1][x] + 1
 
 
max_all = 0
for y in range(h):
  for x in range(w):
    max_tmp = l[y][x] + r[y][x] + u[y][x] + d[y][x]
    if max_tmp > max_all:
      max_all = max_tmp
      
print(max_all - 3)

Buggy submission (verdict: Runtime Error):
h, w = map(int, input().split())
s = []
l = []
r = []
u = []
d = []
for i in range(h):
  s.append(input())
  l.append([0 for j in range(w)])
  r.append([0 for j in range(w)])
  u.append([0 for j in range(w)])
  d.append([0 for j in range(w)])
  
# lみる
for x in range(w):
  for y in range(h):
    if s[y][x] == '.':
      if x == 0:
        l[y][x] = 1
      else:
        l[y][x] = l[y][x-1] + 1
 
# rみる
for x in range(w):
  for y in range(h):
    if s[h-1-y][w-1-x] == '.':
      if x == 0:
        r[y][x] = 1
      else:
        r[y][x] = r[y][x+1] + 1
 
# uみる
for y in range(h):
  for x in range(w):
    if s[y][x] == '.':
      if y == 0:
        u[y][x] = 1
      else:
        u[y][x] = u[y-1][x] + 1
 
# dみる
for y in range(h):
  for x in range(w):
    if s[h-1-y][w-1-x] == '.':
      if y == 0:
        d[y][x] = 1
      else:
        d[y][x] = d[y+1][x] + 1
 
 
max_all = 0
for y in range(h):
  for x in range(w):
    max_tmp = l[y][x] + r[y][x] + u[y][x] + d[y][x]
    if max_tmp > max_all:
      max_all = max_tmp
      
print(max_all - 3)

Buggy submission (verdict: Runtime Error):
h, w = map(int, input().split())
s = []
l = []
r = []
u = []
d = []
for i in range(h):
  s.append(input())
  l.append([0 for j in range(w)])
  r.append([0 for j in range(w)])
  u.append([0 for j in range(w)])
  d.append([0 for j in range(w)])
  
# lみる
for x in range(w):
  for y in range(h):
    if s[y][x] == '.':
      if x == 0:
        l[y][x] = 1
      else:
        l[y][x] = l[y][x-1] + 1
 
# rみる
for x in range(w):
  for y in range(h):
    if s[h-1-y][w-1-x] == '.':
      if x == w-1:
        l[y][x] = 1
      else:
        l[y][x] = l[y][x+1] + 1
 
# uみる
for x in range(w):
  for y in range(h):
    if s[y][x] == '.':
      if y == 0:
        l[y][x] = 1
      else:
        l[y][x] = l[y-1][x] + 1

# dみる
for x in range(w):
  for y in range(h):
    if s[h-1-y][w-1-x] == '.':
      if y == h-1:
        l[y][x] = 1
      else:
        l[y][x] = l[y+1][x] + 1
 

max_all = 0
for y in range(h):
  for x in range(w):
  max_tmp = l[y][x] + r[y][x] + u[y][x] + d[y][x]
  if max_tmp > max_all:
    max_all = max_tmp
print(max_all - 3)

Buggy submission (verdict: Runtime Error):
s = []
s_conn = []
for i in range(h):
  s.append(input())
  s_conn.append([[0]*2 for j in range(w)])
 
# 縦にみる
for x in range(w):
  start = 0
  count = 0
  for y in range(h):
    if s[y][x] == '.':
      count += 1
      if y == h-1:
        for i in range(start, y):
          s_conn[i][x][0] = count
    else:
      for i in range(start, y):
        s_conn[i][x][0] = count
      count = 0
      start = y+1
 
# 横にみる
for y in range(h):
  start = 0
  count = 0
  for x in range(w):
    if s[y][x] == '.':
      count += 1
      if x == w-1:
        for i in range(start, x):
          s_conn[y][i][1] = count
    else:
      for i in range(start, x):
        s_conn[y][i][1] = count
      count = 0
      start = x+1

max_all = 0
for i in range(h):
  max_tmp = max(map(sum, s_conn[i]))
  if max_tmp > max_all:
    max_all = max_tmp
print(max_all - 1)

Buggy submission (verdict: Runtime Error):
h, w = map(int, input().split())
s = []
s_conn = []
for i in range(h):
  s.append(input())
  s_conn.append([[0]*2 for j in range(w)])

# 縦にみる
for x in range(w):
  start = 0
  count = 0
  for y in range(h):
    if s[y][x] = '.':
      count += 1
      if y == h-1:
        for i in range(start, y):
          s_conn[i][x][0] = count
    else:
      for i in range(start, y):
        s_conn[i][x][0] = count
      count = 0
      start = y+1

# 横にみる
for y in range(h):
  start = 0
  count = 0
  for x in range(w):
    if s[y][x] = '.':
      count += 1
      if x == w-1:
        for i in range(start, x):
          s_conn[y][i][0] = count
    else:
      for i in range(start, x):
        s_conn[y][i][0] = count
      count = 0
      start = x+1

max_all = 0
for i in range(h):
  max_tmp = max(map(sum, s_conn[i]))
  if max_tmp > max_all:
    max_all = max_tmp
print(max_all - 1)

Buggy submission (verdict: Runtime Error):
h, w = map(int, input().split())
s = []
s_conn = []
for i in range(h):
  s.append(input())
  s_conn.append([[0]*2 for j in range(w)])

# 縦にみる
for x in range(w):
  start = 0
  count = 0
  for y in range(h):
    if s[y][x] = '.':
      count += 1
      if y == h-1:
        for i in range(start, y):
          s_conn[i][x][0] = count
    else:
      for i in range(start, y):
        s_conn[i][x][0] = count
      count = 0
      start = y+1

# 横にみる
for y in range(h):
  start = 0
  count = 0
  for x in range(w):
    if s[y][x] = '.':
      count += 1
      if x == w-1:
        for i in range(start, x):
          s_conn[y][i][0] = count
    else:
      for i in range(start, x):
        s_conn[y][i][0] = count
      count = 0
      start = x+1

print(max(map(sum, s_conn)) - 1)