s_id
stringlengths
10
10
p_id
stringlengths
6
6
u_id
stringlengths
10
10
date
stringlengths
10
10
language
stringclasses
1 value
original_language
stringclasses
11 values
filename_ext
stringclasses
1 value
status
stringclasses
1 value
cpu_time
stringlengths
1
5
memory
stringlengths
1
7
code_size
stringlengths
1
6
code
stringlengths
1
539k
s934998267
p00118
u945345165
1493345405
Python
Python3
py
Runtime Error
0
0
1218
def setLine(tempH, line): for i in range(0, len(line)): geo[tempH][i] = line[i:i+1] def solve(): person = 0 for i in range(0,H): for j in range(0,W): if geo[i][j] is not "_": search(i,j) person += 1 print(person) def search(i,j): temp = geo[i][j] geo[i][j] = "_" dx = [-1,0,1,0] dy = [0,-1,0,1] for a in range(0,4): idx = i + dx[a] jdy = j + dy[a] if(isOnMap(idx, jdy)): if(isNeededToSolve(temp, idx, jdy)): search(idx,jdy) def isOnMap(i,j): return (0<=i and 0<=j and i<H and j<W) def isNeededToSolve(temp,i,j): target = geo[i][j] return (target is not "_" and temp is target) H = -1 W = -1 tempH = 0 geo = [[0 for i in range(1)]for j in range(1)] repeat = True while repeat: line = input() if H is -1 and W is -1: H = int(line.split(" ")[0]) W = int(line.split(" ")[1]) geo = [[0 for i in range(W)] for j in range(H)] else: setLine(tempH, line) tempH+=1 #break if H is 0 and W is 0: break #solve if tempH is H: solve() H = -1 W = -1 tempH = 0
s360904846
p00118
u945345165
1493345491
Python
Python3
py
Runtime Error
0
0
1263
def setLine(tempH, line): for i in range(0, len(line)): geo[tempH][i] = line[i:i+1] def solve(): person = 0 for i in range(0,H): for j in range(0,W): if geo[i][j] is not "_": search(i,j) person += 1 print(person) def search(i,j): temp = geo[i][j] geo[i][j] = "_" dx = [-1,0,1,0] dy = [0,-1,0,1] for a in range(0,4): idx = i + dx[a] jdy = j + dy[a] if(isOnMap(idx, jdy)): if(isNeededToSolve(temp, idx, jdy)): search(idx,jdy) def isOnMap(i,j): return (0<=i and 0<=j and i<H and j<W) def isNeededToSolve(temp,i,j): target = geo[i][j] return (target is not "_" and temp is target) limit = 10**10 sys.getrecursionlimit(limit) H = -1 W = -1 tempH = 0 geo = [[0 for i in range(1)]for j in range(1)] repeat = True while repeat: line = input() if H is -1 and W is -1: H = int(line.split(" ")[0]) W = int(line.split(" ")[1]) geo = [[0 for i in range(W)] for j in range(H)] else: setLine(tempH, line) tempH+=1 #break if H is 0 and W is 0: break #solve if tempH is H: solve() H = -1 W = -1 tempH = 0
s014445014
p00118
u284851373
1493353440
Python
Python3
py
Runtime Error
0
0
1037
# -*- coding:utf-8 -*- import sys sys.setrecursionlimit(1000000) def preDatasets(): #f = open('a.txt') datas = sys.stdin.readlines() #f.close() for i in range(len(datas)): datas[i] = datas[i].strip('\n') return datas def dfs(x, y, sym): tile[x][y] = '.' for i in range(len(DX)): nx = x + DX[i] ny = y + DY[i] if(nx>=0 and nx<N and ny>=0 and ny<M and tile[nx][ny]==sym): dfs(nx, ny, sym) def solve(): res = 0 for i in range(N): for j in range(M): if not tile[i][j] == '.': if tile[i][j] == '@': dfs(i, j, '@') res += 1 elif tile[i][j] == '#': dfs(i, j, '#') res += 1 elif tile[i][j] == '*': dfs(i, j, '*') res += 1 print(res) index = 0 while True: datas = preDatasets() DX = [-1, 0, 1, 0] DY = [0, -1, 0, 1] N = int(datas[index].split(' ')[0]) M = int(datas[index].split(' ')[1]) tile = [[0 for i in range(N)]for j in range(M)] for i in range(len(tile)): tile[i] = list(datas[index+i+1]) print(tile) if N == 0: break else: solve() index += N+1
s530122803
p00118
u284851373
1493353462
Python
Python3
py
Runtime Error
0
0
1005
# -*- coding:utf-8 -*- import sys sys.setrecursionlimit(1000000) def preDatasets(): datas = sys.stdin.readlines() for i in range(len(datas)): datas[i] = datas[i].strip('\n') return datas def dfs(x, y, sym): tile[x][y] = '.' for i in range(len(DX)): nx = x + DX[i] ny = y + DY[i] if(nx>=0 and nx<N and ny>=0 and ny<M and tile[nx][ny]==sym): dfs(nx, ny, sym) def solve(): res = 0 for i in range(N): for j in range(M): if not tile[i][j] == '.': if tile[i][j] == '@': dfs(i, j, '@') res += 1 elif tile[i][j] == '#': dfs(i, j, '#') res += 1 elif tile[i][j] == '*': dfs(i, j, '*') res += 1 print(res) index = 0 while True: datas = preDatasets() DX = [-1, 0, 1, 0] DY = [0, -1, 0, 1] N = int(datas[index].split(' ')[0]) M = int(datas[index].split(' ')[1]) tile = [[0 for i in range(N)]for j in range(M)] for i in range(len(tile)): tile[i] = list(datas[index+i+1]) print(tile) if N == 0: break else: solve() index += N+1
s321331159
p00118
u284851373
1493353477
Python
Python3
py
Runtime Error
0
0
1006
# -*- coding:utf-8 -*- import sys sys.setrecursionlimit(10000000) def preDatasets(): datas = sys.stdin.readlines() for i in range(len(datas)): datas[i] = datas[i].strip('\n') return datas def dfs(x, y, sym): tile[x][y] = '.' for i in range(len(DX)): nx = x + DX[i] ny = y + DY[i] if(nx>=0 and nx<N and ny>=0 and ny<M and tile[nx][ny]==sym): dfs(nx, ny, sym) def solve(): res = 0 for i in range(N): for j in range(M): if not tile[i][j] == '.': if tile[i][j] == '@': dfs(i, j, '@') res += 1 elif tile[i][j] == '#': dfs(i, j, '#') res += 1 elif tile[i][j] == '*': dfs(i, j, '*') res += 1 print(res) index = 0 while True: datas = preDatasets() DX = [-1, 0, 1, 0] DY = [0, -1, 0, 1] N = int(datas[index].split(' ')[0]) M = int(datas[index].split(' ')[1]) tile = [[0 for i in range(N)]for j in range(M)] for i in range(len(tile)): tile[i] = list(datas[index+i+1]) print(tile) if N == 0: break else: solve() index += N+1
s301512354
p00118
u284851373
1493353538
Python
Python3
py
Runtime Error
0
0
993
# -*- coding:utf-8 -*- import sys sys.setrecursionlimit(10000000) def preDatasets(): datas = sys.stdin.readlines() for i in range(len(datas)): datas[i] = datas[i].strip('\n') return datas def dfs(x, y, sym): tile[x][y] = '.' for i in range(len(DX)): nx = x + DX[i] ny = y + DY[i] if(nx>=0 and nx<N and ny>=0 and ny<M and tile[nx][ny]==sym): dfs(nx, ny, sym) def solve(): res = 0 for i in range(N): for j in range(M): if not tile[i][j] == '.': if tile[i][j] == '@': dfs(i, j, '@') res += 1 elif tile[i][j] == '#': dfs(i, j, '#') res += 1 elif tile[i][j] == '*': dfs(i, j, '*') res += 1 print(res) index = 0 while True: datas = preDatasets() DX = [-1, 0, 1, 0] DY = [0, -1, 0, 1] N = int(datas[index].split(' ')[0]) M = int(datas[index].split(' ')[1]) tile = [[0 for i in range(N)]for j in range(M)] for i in range(len(tile)): tile[i] = list(datas[index+i+1]) if N == 0: break else: solve() index += N+1
s627237537
p00118
u284851373
1493353593
Python
Python3
py
Runtime Error
0
0
993
# -*- coding:utf-8 -*- import sys sys.setrecursionlimit(10000000) def preDatasets(): datas = sys.stdin.readlines() for i in range(len(datas)): datas[i] = datas[i].strip('\n') return datas def dfs(x, y, sym): tile[x][y] = '.' for i in range(len(DX)): nx = x + DX[i] ny = y + DY[i] if(nx>=0 and nx<N and ny>=0 and ny<M and tile[nx][ny]==sym): dfs(nx, ny, sym) def solve(): res = 0 for i in range(N): for j in range(M): if not tile[i][j] == '.': if tile[i][j] == '@': dfs(i, j, '@') res += 1 elif tile[i][j] == '#': dfs(i, j, '#') res += 1 elif tile[i][j] == '*': dfs(i, j, '*') res += 1 print(res) index = 0 while True: datas = preDatasets() DX = [-1, 0, 1, 0] DY = [0, -1, 0, 1] N = int(datas[index].split(' ')[0]) M = int(datas[index].split(' ')[1]) tile = [[0 for i in range(N)]for j in range(M)] for i in range(len(tile)): tile[i] = list(datas[index+i+1]) if N == 0: break else: solve() index += N+1
s075700566
p00118
u284851373
1493353803
Python
Python3
py
Runtime Error
0
0
993
# -*- coding:utf-8 -*- import sys sys.setrecursionlimit(10000000) def preDatasets(): datas = sys.stdin.readlines() for i in range(len(datas)): datas[i] = datas[i].strip('\n') return datas def dfs(x, y, sym): tile[x][y] = '.' for i in range(len(DX)): nx = x + DX[i] ny = y + DY[i] if(nx>=0 and nx<N and ny>=0 and ny<M and tile[nx][ny]==sym): dfs(nx, ny, sym) def solve(): res = 0 for i in range(N): for j in range(M): if not tile[i][j] == '.': if tile[i][j] == '@': dfs(i, j, '@') res += 1 elif tile[i][j] == '#': dfs(i, j, '#') res += 1 elif tile[i][j] == '*': dfs(i, j, '*') res += 1 print(res) index = 0 DX = [-1, 0, 1, 0] DY = [0, -1, 0, 1] while True: datas = preDatasets() N = int(datas[index].split(' ')[0]) M = int(datas[index].split(' ')[1]) tile = [[0 for i in range(N)]for j in range(M)] for i in range(len(tile)): tile[i] = list(datas[index+i+1]) if N == 0: break else: solve() index += N+1
s273528107
p00118
u284851373
1493354047
Python
Python3
py
Runtime Error
0
0
979
# -*- coding:utf-8 -*- import sys sys.setrecursionlimit(10000000) def preDatasets(): datas = input() for i in range(len(datas)): datas[i] = datas[i].strip('\n') return datas def dfs(x, y, sym): tile[x][y] = '.' for i in range(len(DX)): nx = x + DX[i] ny = y + DY[i] if(nx>=0 and nx<N and ny>=0 and ny<M and tile[nx][ny]==sym): dfs(nx, ny, sym) def solve(): res = 0 for i in range(N): for j in range(M): if not tile[i][j] == '.': if tile[i][j] == '@': dfs(i, j, '@') res += 1 elif tile[i][j] == '#': dfs(i, j, '#') res += 1 elif tile[i][j] == '*': dfs(i, j, '*') res += 1 print(res) index = 0 DX = [-1, 0, 1, 0] DY = [0, -1, 0, 1] while True: datas = preDatasets() N = int(datas[index].split(' ')[0]) M = int(datas[index].split(' ')[1]) tile = [[0 for i in range(N)]for j in range(M)] for i in range(len(tile)): tile[i] = list(datas[index+i+1]) if N == 0: break else: solve() index += N+1
s830627017
p00118
u284851373
1493354059
Python
Python3
py
Runtime Error
0
0
978
# -*- coding:utf-8 -*- import sys sys.setrecursionlimit(1000000) def preDatasets(): datas = input() for i in range(len(datas)): datas[i] = datas[i].strip('\n') return datas def dfs(x, y, sym): tile[x][y] = '.' for i in range(len(DX)): nx = x + DX[i] ny = y + DY[i] if(nx>=0 and nx<N and ny>=0 and ny<M and tile[nx][ny]==sym): dfs(nx, ny, sym) def solve(): res = 0 for i in range(N): for j in range(M): if not tile[i][j] == '.': if tile[i][j] == '@': dfs(i, j, '@') res += 1 elif tile[i][j] == '#': dfs(i, j, '#') res += 1 elif tile[i][j] == '*': dfs(i, j, '*') res += 1 print(res) index = 0 DX = [-1, 0, 1, 0] DY = [0, -1, 0, 1] while True: datas = preDatasets() N = int(datas[index].split(' ')[0]) M = int(datas[index].split(' ')[1]) tile = [[0 for i in range(N)]for j in range(M)] for i in range(len(tile)): tile[i] = list(datas[index+i+1]) if N == 0: break else: solve() index += N+1
s489680143
p00118
u284851373
1493354098
Python
Python3
py
Runtime Error
0
0
976
# -*- coding:utf-8 -*- import sys sys.setrecursionlimit(1000000) def preDatasets(): datas = input() for i in range(len(datas)): datas[i] = datas[i].strip('\n') return datas def dfs(x, y, sym): tile[x][y] = '.' for i in range(len(DX)): nx = x + DX[i] ny = y + DY[i] if nx>=0 and nx<N and ny>=0 and ny<M and tile[nx][ny]==sym: dfs(nx, ny, sym) def solve(): res = 0 for i in range(N): for j in range(M): if not tile[i][j] == '.': if tile[i][j] == '@': dfs(i, j, '@') res += 1 elif tile[i][j] == '#': dfs(i, j, '#') res += 1 elif tile[i][j] == '*': dfs(i, j, '*') res += 1 print(res) index = 0 DX = [-1, 0, 1, 0] DY = [0, -1, 0, 1] while True: datas = preDatasets() N = int(datas[index].split(' ')[0]) M = int(datas[index].split(' ')[1]) tile = [[0 for i in range(N)]for j in range(M)] for i in range(len(tile)): tile[i] = list(datas[index+i+1]) if N == 0: break else: solve() index += N+1
s833425412
p00118
u284851373
1493354114
Python
Python3
py
Runtime Error
0
0
953
import sys sys.setrecursionlimit(1000000) def preDatasets(): datas = input() for i in range(len(datas)): datas[i] = datas[i].strip('\n') return datas def dfs(x, y, sym): tile[x][y] = '.' for i in range(len(DX)): nx = x + DX[i] ny = y + DY[i] if nx>=0 and nx<N and ny>=0 and ny<M and tile[nx][ny]==sym: dfs(nx, ny, sym) def solve(): res = 0 for i in range(N): for j in range(M): if not tile[i][j] == '.': if tile[i][j] == '@': dfs(i, j, '@') res += 1 elif tile[i][j] == '#': dfs(i, j, '#') res += 1 elif tile[i][j] == '*': dfs(i, j, '*') res += 1 print(res) index = 0 DX = [-1, 0, 1, 0] DY = [0, -1, 0, 1] while True: datas = preDatasets() N = int(datas[index].split(' ')[0]) M = int(datas[index].split(' ')[1]) tile = [[0 for i in range(N)]for j in range(M)] for i in range(len(tile)): tile[i] = list(datas[index+i+1]) if N == 0: break else: solve() index += N+1
s074034955
p00118
u284851373
1493355247
Python
Python3
py
Runtime Error
0
0
1043
# -*- coding:utf-8 -*- import sys sys.setrecursionlimit(1000000) def preDatasets(q): line = input() print(line) datas[q] = line return datas def dfs(x, y, sym): tile[x][y] = '.' for i in range(len(DX)): nx = x + DX[i] ny = y + DY[i] if nx>=0 and nx<N and ny>=0 and ny<M and tile[nx][ny]==sym: dfs(nx, ny, sym) def solve(): res = 0 for i in range(N): for j in range(M): if not tile[i][j] == '.': if tile[i][j] == '@': dfs(i, j, '@') res += 1 elif tile[i][j] == '#': dfs(i, j, '#') res += 1 elif tile[i][j] == '*': dfs(i, j, '*') res += 1 print(res) index = 0 counter=0 datas = [[0 for i in range(1)]for j in range(1)] DX = [-1, 0, 1, 0] DY = [0, -1, 0, 1] while True: line = input() if ' ' in line: N = int(datas[index].split(' ')[0]) M = int(datas[index].split(' ')[1]) tile = [[0 for i in range(N)]for j in range(M)] if N == 0: break if not counter<=M: for i in range(len(tile)): tile[i] = list(datas[index+i+1]) solve() index += N+1 counter+=1
s557981532
p00118
u284851373
1493355865
Python
Python3
py
Runtime Error
0
0
866
# -*- coding:utf-8 -*- import sys sys.setrecursionlimit(1000000) def dfs(x, y, sym): tile[x][y] = '.' for i in range(len(DX)): nx = x + DX[i] ny = y + DY[i] if nx>=0 and nx<N and ny>=0 and ny<M and tile[nx][ny]==sym: dfs(nx, ny, sym) def solve(): res = 0 for i in range(N): for j in range(M): if not tile[i][j] == '.': if tile[i][j] == '@': dfs(i, j, '@') res += 1 elif tile[i][j] == '#': dfs(i, j, '#') res += 1 elif tile[i][j] == '*': dfs(i, j, '*') res += 1 print(res) index = 0 counter=0 DX = [-1, 0, 1, 0] DY = [0, -1, 0, 1] while True: counter+=1 line = input() if ' ' in line: N = int(line.split(' ')[0]) M = int(line.split(' ')[1]) tile = [[0 for i in range(N)]for j in range(M)] else: tile[counter-2] = list(line) if N == 0: break if counter-1==M: solve() counter = 0
s282190541
p00118
u284851373
1493355908
Python
Python3
py
Runtime Error
0
0
865
# -*- coding:utf-8 -*- import sys sys.setrecursionlimit(100000) def dfs(x, y, sym): tile[x][y] = '.' for i in range(len(DX)): nx = x + DX[i] ny = y + DY[i] if nx>=0 and nx<N and ny>=0 and ny<M and tile[nx][ny]==sym: dfs(nx, ny, sym) def solve(): res = 0 for i in range(N): for j in range(M): if not tile[i][j] == '.': if tile[i][j] == '@': dfs(i, j, '@') res += 1 elif tile[i][j] == '#': dfs(i, j, '#') res += 1 elif tile[i][j] == '*': dfs(i, j, '*') res += 1 print(res) index = 0 counter=0 DX = [-1, 0, 1, 0] DY = [0, -1, 0, 1] while True: counter+=1 line = input() if ' ' in line: N = int(line.split(' ')[0]) M = int(line.split(' ')[1]) tile = [[0 for i in range(N)]for j in range(M)] else: tile[counter-2] = list(line) if N == 0: break if counter-1==M: solve() counter = 0
s652211314
p00118
u284851373
1493356532
Python
Python3
py
Runtime Error
0
0
874
# -*- coding:utf-8 -*- import sys sys.setrecursionlimit(1000000) def dfs(x, y, sym): tile[x][y] = '.' for i in range(len(DX)): nx = x + DX[i] ny = y + DY[i] if nx>=0 and nx<N and ny>=0 and ny<M and tile[nx][ny]==sym: dfs(nx, ny, sym) def solve(): res = 0 for i in range(N): for j in range(M): if not tile[i][j] == '.': if tile[i][j] == '@': dfs(i, j, '@') res += 1 elif tile[i][j] == '#': dfs(i, j, '#') res += 1 elif tile[i][j] == '*': dfs(i, j, '*') res += 1 print(res) index = 0 counter=0 DX = [-1, 0, 1, 0] DY = [0, -1, 0, 1] while True: counter+=1 line = input() if ' ' in line: N = int(line.split(' ')[0]) M = int(line.split(' ')[1]) tile = [[0 for i in range(N)]for j in range(M)] else: tile[counter-2] = list(line) if N==0 and M==0: break if counter-1==M: solve() counter = 0
s529157817
p00118
u284851373
1493356540
Python
Python3
py
Runtime Error
0
0
851
import sys sys.setrecursionlimit(1000000) def dfs(x, y, sym): tile[x][y] = '.' for i in range(len(DX)): nx = x + DX[i] ny = y + DY[i] if nx>=0 and nx<N and ny>=0 and ny<M and tile[nx][ny]==sym: dfs(nx, ny, sym) def solve(): res = 0 for i in range(N): for j in range(M): if not tile[i][j] == '.': if tile[i][j] == '@': dfs(i, j, '@') res += 1 elif tile[i][j] == '#': dfs(i, j, '#') res += 1 elif tile[i][j] == '*': dfs(i, j, '*') res += 1 print(res) index = 0 counter=0 DX = [-1, 0, 1, 0] DY = [0, -1, 0, 1] while True: counter+=1 line = input() if ' ' in line: N = int(line.split(' ')[0]) M = int(line.split(' ')[1]) tile = [[0 for i in range(N)]for j in range(M)] else: tile[counter-2] = list(line) if N==0 and M==0: break if counter-1==M: solve() counter = 0
s717952627
p00118
u284851373
1493356679
Python
Python3
py
Runtime Error
0
0
852
import sys sys.setrecursionlimit(10000000) def dfs(x, y, sym): tile[x][y] = '.' for i in range(len(DX)): nx = x + DX[i] ny = y + DY[i] if nx>=0 and nx<N and ny>=0 and ny<M and tile[nx][ny]==sym: dfs(nx, ny, sym) def solve(): res = 0 for i in range(N): for j in range(M): if not tile[i][j] == '.': if tile[i][j] == '@': dfs(i, j, '@') res += 1 elif tile[i][j] == '#': dfs(i, j, '#') res += 1 elif tile[i][j] == '*': dfs(i, j, '*') res += 1 print(res) index = 0 counter=0 DX = [-1, 0, 1, 0] DY = [0, -1, 0, 1] while True: counter+=1 line = input() if ' ' in line: N = int(line.split(' ')[0]) M = int(line.split(' ')[1]) tile = [[0 for i in range(N)]for j in range(M)] else: tile[counter-2] = list(line) if N==0 and M==0: break if counter-1==M: solve() counter = 0
s238784118
p00118
u284851373
1493356686
Python
Python3
py
Runtime Error
0
0
853
import sys sys.setrecursionlimit(100000000) def dfs(x, y, sym): tile[x][y] = '.' for i in range(len(DX)): nx = x + DX[i] ny = y + DY[i] if nx>=0 and nx<N and ny>=0 and ny<M and tile[nx][ny]==sym: dfs(nx, ny, sym) def solve(): res = 0 for i in range(N): for j in range(M): if not tile[i][j] == '.': if tile[i][j] == '@': dfs(i, j, '@') res += 1 elif tile[i][j] == '#': dfs(i, j, '#') res += 1 elif tile[i][j] == '*': dfs(i, j, '*') res += 1 print(res) index = 0 counter=0 DX = [-1, 0, 1, 0] DY = [0, -1, 0, 1] while True: counter+=1 line = input() if ' ' in line: N = int(line.split(' ')[0]) M = int(line.split(' ')[1]) tile = [[0 for i in range(N)]for j in range(M)] else: tile[counter-2] = list(line) if N==0 and M==0: break if counter-1==M: solve() counter = 0
s763960044
p00118
u284851373
1493356691
Python
Python3
py
Runtime Error
0
0
854
import sys sys.setrecursionlimit(1000000000) def dfs(x, y, sym): tile[x][y] = '.' for i in range(len(DX)): nx = x + DX[i] ny = y + DY[i] if nx>=0 and nx<N and ny>=0 and ny<M and tile[nx][ny]==sym: dfs(nx, ny, sym) def solve(): res = 0 for i in range(N): for j in range(M): if not tile[i][j] == '.': if tile[i][j] == '@': dfs(i, j, '@') res += 1 elif tile[i][j] == '#': dfs(i, j, '#') res += 1 elif tile[i][j] == '*': dfs(i, j, '*') res += 1 print(res) index = 0 counter=0 DX = [-1, 0, 1, 0] DY = [0, -1, 0, 1] while True: counter+=1 line = input() if ' ' in line: N = int(line.split(' ')[0]) M = int(line.split(' ')[1]) tile = [[0 for i in range(N)]for j in range(M)] else: tile[counter-2] = list(line) if N==0 and M==0: break if counter-1==M: solve() counter = 0
s329311281
p00118
u284851373
1493356994
Python
Python3
py
Runtime Error
0
0
869
# -*- coding:utf-8 -*- import sys sys.setrecursionlimit(1000000) def dfs(x, y, sym): tile[x][y] = '.' for i in range(len(DX)): nx = x + DX[i] ny = y + DY[i] if nx>=0 and nx<N and ny>=0 and ny<M and tile[nx][ny]==sym: dfs(nx, ny, sym) def solve(): res = 0 for i in range(N): for j in range(M): if not tile[i][j] == '.': if tile[i][j] == '@': dfs(i, j, '@') res += 1 elif tile[i][j] == '#': dfs(i, j, '#') res += 1 elif tile[i][j] == '*': dfs(i, j, '*') res += 1 print(res) index = 0 counter=0 DX = [-1, 0, 1, 0] DY = [0, -1, 0, 1] while True: counter+=1 line = input() if ' ' in line: N = int(line.split(' ')[0]) M = int(line.split(' ')[1]) tile = [[0 for i in range(N)]for j in range(M)] else: tile[counter-2] = list(line) if N==0 and M==0: break if counter-1==M: solve() counter = 0
s667472085
p00118
u284851373
1493357012
Python
Python3
py
Runtime Error
0
0
846
import sys sys.setrecursionlimit(1000000) def dfs(x, y, sym): tile[x][y] = '.' for i in range(len(DX)): nx = x + DX[i] ny = y + DY[i] if nx>=0 and nx<N and ny>=0 and ny<M and tile[nx][ny]==sym: dfs(nx, ny, sym) def solve(): res = 0 for i in range(N): for j in range(M): if not tile[i][j] == '.': if tile[i][j] == '@': dfs(i, j, '@') res += 1 elif tile[i][j] == '#': dfs(i, j, '#') res += 1 elif tile[i][j] == '*': dfs(i, j, '*') res += 1 print(res) index = 0 counter=0 DX = [-1, 0, 1, 0] DY = [0, -1, 0, 1] while True: counter+=1 line = input() if ' ' in line: N = int(line.split(' ')[0]) M = int(line.split(' ')[1]) tile = [[0 for i in range(N)]for j in range(M)] else: tile[counter-2] = list(line) if N==0 and M==0: break if counter-1==M: solve() counter = 0
s836370163
p00118
u284851373
1493357277
Python
Python3
py
Runtime Error
0
0
846
import sys sys.setrecursionlimit(1000000) def dfs(x, y, sym): tile[x][y] = '.' for i in range(len(DX)): nx = x + DX[i] ny = y + DY[i] if nx>=0 and nx<N and ny>=0 and ny<M and tile[nx][ny]==sym: dfs(nx, ny, sym) def solve(): res = 0 for i in range(N): for j in range(M): if not tile[i][j] == '.': if tile[i][j] == '@': dfs(i, j, '@') res += 1 elif tile[i][j] == '#': dfs(i, j, '#') res += 1 elif tile[i][j] == '*': dfs(i, j, '*') res += 1 print(res) index = 0 counter=0 DX = [-1, 0, 1, 0] DY = [0, -1, 0, 1] while True: counter+=1 line = input() if ' ' in line: N = int(line.split(' ')[0]) M = int(line.split(' ')[1]) tile = [[0 for i in range(N)]for j in range(M)] else: tile[counter-2] = list(line) if N==0 and M==0: break if counter-1==M: solve() counter = 0
s126024851
p00118
u284851373
1493357322
Python
Python3
py
Runtime Error
0
0
869
# -*- coding:utf-8 -*- import sys sys.setrecursionlimit(1000000) def dfs(x, y, sym): tile[x][y] = '.' for i in range(len(DX)): nx = x + DX[i] ny = y + DY[i] if nx>=0 and nx<N and ny>=0 and ny<M and tile[nx][ny]==sym: dfs(nx, ny, sym) def solve(): res = 0 for i in range(N): for j in range(M): if not tile[i][j] == '.': if tile[i][j] == '@': dfs(i, j, '@') res += 1 elif tile[i][j] == '#': dfs(i, j, '#') res += 1 elif tile[i][j] == '*': dfs(i, j, '*') res += 1 print(res) index = 0 counter=0 DX = [-1, 0, 1, 0] DY = [0, -1, 0, 1] while True: counter+=1 line = input() if ' ' in line: N = int(line.split(' ')[0]) M = int(line.split(' ')[1]) tile = [[0 for i in range(N)]for j in range(M)] else: tile[counter-2] = list(line) if N==0 and M==0: break if counter-1==M: solve() counter = 0
s224220259
p00118
u284851373
1493364020
Python
Python3
py
Runtime Error
0
0
885
# -*- coding:utf-8 -*- import sys sys.setrecursionlimit(1000000) def dfs(x, y, sym): tile[x][y] = '.' for i in range(len(DX)): nx = x + DX[i] ny = y + DY[i] if nx>=0 and nx<N and ny>=0 and ny<M and tile[nx][ny]==sym: dfs(nx, ny, sym) def solve(): res = 0 for i in range(N): for j in range(M): if not tile[i][j] == '.': if tile[i][j] == '@': dfs(i, j, '@') res += 1 elif tile[i][j] == '#': dfs(i, j, '#') res += 1 elif tile[i][j] == '*': dfs(i, j, '*') res += 1 return res res=0 counter=0 DX = [-1, 0, 1, 0] DY = [0, -1, 0, 1] while True: counter+=1 line = input() if ' ' in line: N = int(line.split(' ')[0]) M = int(line.split(' ')[1]) tile = [[0 for i in range(N)]for j in range(M)] else: tile[counter-2] = list(line) if N==0 and M==0: break if counter-1==M: res = solve() counter = 0 print(res)
s719223417
p00118
u284851373
1493364733
Python
Python3
py
Runtime Error
0
0
890
# -*- coding:utf-8 -*- import sys sys.setrecursionlimit(1000000) def dfs(x, y, sym): tile[x][y] = '.' for i in range(len(DX)): nx = x + DX[i] ny = y + DY[i] if nx>=0 and nx<N and ny>=0 and ny<M and tile[nx][ny]==sym: dfs(nx, ny, sym) def solve(): res = 0 for i in range(N): for j in range(M): if not tile[i][j] == '.': if tile[i][j] == '@': dfs(i, j, '@') res += 1 elif tile[i][j] == '#': dfs(i, j, '#') res += 1 elif tile[i][j] == '*': dfs(i, j, '*') res += 1 return res res=0 counter=0 DX = [-1, 0, 1, 0] DY = [0, -1, 0, 1] while True: counter+=1 line = input() if ' ' in line: nums = line.split(' ') N = int(nums[0]) M = int(nums[1]) tile = [[0 for i in range(N)]for j in range(M)] else: tile[counter-2] = list(line) if N==0 and M==0: break if (counter-1)==M: res = solve() counter = 0 print(res)
s440380822
p00118
u284851373
1493364865
Python
Python3
py
Runtime Error
0
0
921
# -*- coding:utf-8 -*- import sys sys.setrecursionlimit(1000000) def dfs(x, y, sym): tile[x][y] = '.' for i in range(len(DX)): nx = x + DX[i] ny = y + DY[i] if nx>=0 and nx<N and ny>=0 and ny<M and tile[nx][ny]==sym: dfs(nx, ny, sym) def solve(): res = 0 for i in range(N): for j in range(M): if not tile[i][j] == '.': if tile[i][j] == '@': dfs(i, j, '@') res += 1 elif tile[i][j] == '#': dfs(i, j, '#') res += 1 elif tile[i][j] == '*': dfs(i, j, '*') res += 1 return res res=0 counter=0 DX = [-1, 0, 1, 0] DY = [0, -1, 0, 1] while True: counter+=1 line = input() if ' ' in line: nums = line.split(' ') N = int(nums[0]) M = int(nums[1]) tile = [[0 for i in range(N)]for j in range(M)] else: tile[counter-2] = list(line) if N==0 and M==0: break if (counter-1)==M: res = solve() counter = 0 print(res)
s906244117
p00118
u284851373
1493365725
Python
Python3
py
Runtime Error
0
0
908
# -*- coding:utf-8 -*- import sys sys.setrecursionlimit(1000000) def dfs(x, y, sym): tile[x][y] = '.' for i in range(len(DX)): nx = x + DX[i] ny = y + DY[i] if nx>=0 and nx<N and ny>=0 and ny<M and tile[nx][ny]==sym: dfs(nx, ny, sym) def solve(): res = 0 for i in range(N): for j in range(M): if not tile[i][j] == '.': if tile[i][j] == '@': dfs(i, j, '@') res += 1 elif tile[i][j] == '#': dfs(i, j, '#') res += 1 elif tile[i][j] == '*': dfs(i, j, '*') res += 1 return res res=0 counter=0 N=-1 M=-1 DX = [-1, 0, 1, 0] DY = [0, -1, 0, 1] while True: counter+=1 line = input() if ' ' in line: nums = line.split(' ') N = int(nums[0]) M = int(nums[1]) tile = [[0 for i in range(N)]for j in range(M)] else: tile[counter-2] = list(line) if (counter-1)==M and M!=0: res = solve() counter = 0 print(res) if N==0 and M==0: break
s451740147
p00118
u284851373
1493365943
Python
Python3
py
Runtime Error
0
0
901
# -*- coding:utf-8 -*- import sys sys.setrecursionlimit(1000000) def dfs(x, y, sym): tile[x][y] = '.' for i in range(len(DX)): nx = x + DX[i] ny = y + DY[i] if nx>=0 and nx<N and ny>=0 and ny<M and tile[nx][ny]==sym: dfs(nx, ny, sym) def solve(): res = 0 for i in range(N): for j in range(M): if not tile[i][j] == '.': if tile[i][j] == '@': dfs(i, j, '@') res += 1 elif tile[i][j] == '#': dfs(i, j, '#') res += 1 elif tile[i][j] == '*': dfs(i, j, '*') res += 1 return res res=0 counter=0 N=-1 M=-1 DX = [-1, 0, 1, 0] DY = [0, -1, 0, 1] while True: counter+=1 line = input() if ' ' in line: nums = line.split(' ') N = int(nums[0]) M = int(nums[1]) tile = [[0 for i in range(N)]for j in range(M)] if N==0 and M==0: break else: tile[counter-2] = list(line) if (counter-1)==M: res = solve() counter = 0 print(res)
s989840761
p00118
u284851373
1493377023
Python
Python3
py
Runtime Error
0
0
1041
# -*- coding:utf-8 -*- import sys sys.setrecursionlimit(10000) def preDatasets(q): line = input() print(line) datas[q] = line return datas def dfs(x, y, sym): tile[x][y] = '.' for i in range(len(DX)): nx = x + DX[i] ny = y + DY[i] if nx>=0 and nx<N and ny>=0 and ny<M and tile[nx][ny]==sym: dfs(nx, ny, sym) def solve(): res = 0 for i in range(N): for j in range(M): if not tile[i][j] == '.': if tile[i][j] == '@': dfs(i, j, '@') res += 1 elif tile[i][j] == '#': dfs(i, j, '#') res += 1 elif tile[i][j] == '*': dfs(i, j, '*') res += 1 print(res) index = 0 counter=0 datas = [[0 for i in range(1)]for j in range(1)] DX = [-1, 0, 1, 0] DY = [0, -1, 0, 1] while True: line = input() if ' ' in line: N = int(datas[index].split(' ')[0]) M = int(datas[index].split(' ')[1]) tile = [[0 for i in range(N)]for j in range(M)] if N == 0: break if not counter<=M: for i in range(len(tile)): tile[i] = list(datas[index+i+1]) solve() index += N+1 counter+=1
s275917829
p00118
u284851373
1493377030
Python
Python3
py
Runtime Error
0
0
1042
# -*- coding:utf-8 -*- import sys sys.setrecursionlimit(100000) def preDatasets(q): line = input() print(line) datas[q] = line return datas def dfs(x, y, sym): tile[x][y] = '.' for i in range(len(DX)): nx = x + DX[i] ny = y + DY[i] if nx>=0 and nx<N and ny>=0 and ny<M and tile[nx][ny]==sym: dfs(nx, ny, sym) def solve(): res = 0 for i in range(N): for j in range(M): if not tile[i][j] == '.': if tile[i][j] == '@': dfs(i, j, '@') res += 1 elif tile[i][j] == '#': dfs(i, j, '#') res += 1 elif tile[i][j] == '*': dfs(i, j, '*') res += 1 print(res) index = 0 counter=0 datas = [[0 for i in range(1)]for j in range(1)] DX = [-1, 0, 1, 0] DY = [0, -1, 0, 1] while True: line = input() if ' ' in line: N = int(datas[index].split(' ')[0]) M = int(datas[index].split(' ')[1]) tile = [[0 for i in range(N)]for j in range(M)] if N == 0: break if not counter<=M: for i in range(len(tile)): tile[i] = list(datas[index+i+1]) solve() index += N+1 counter+=1
s120248550
p00118
u284851373
1493377051
Python
Python3
py
Runtime Error
0
0
891
# -*- coding:utf-8 -*- import sys sys.setrecursionlimit(1000000) def dfs(x, y, sym): tile[x][y] = '.' for i in range(len(DX)): nx = x + DX[i] ny = y + DY[i] if nx>=0 and nx<N and ny>=0 and ny<M and tile[nx][ny]==sym: dfs(nx, ny, sym) def solve(): res = 0 for i in range(N): for j in range(M): if not tile[i][j] == '.': if tile[i][j] == '@': dfs(i, j, '@') res += 1 elif tile[i][j] == '#': dfs(i, j, '#') res += 1 elif tile[i][j] == '*': dfs(i, j, '*') res += 1 return res res=0 counter=0 DX = [-1, 0, 1, 0] DY = [0, -1, 0, 1] while True: counter+=1 line = input() if ' ' in line: nums = line.split(' ') N = int(nums[0]) M = int(nums[1]) tile = [[0 for i in range(N)]for j in range(M)] if N==0 and M==0: break else: tile[counter-2] = list(line) if (counter-1)==M: res = solve() counter = 0 print(res)
s920379870
p00118
u284851373
1493377060
Python
Python3
py
Runtime Error
0
0
890
# -*- coding:utf-8 -*- import sys sys.setrecursionlimit(100000) def dfs(x, y, sym): tile[x][y] = '.' for i in range(len(DX)): nx = x + DX[i] ny = y + DY[i] if nx>=0 and nx<N and ny>=0 and ny<M and tile[nx][ny]==sym: dfs(nx, ny, sym) def solve(): res = 0 for i in range(N): for j in range(M): if not tile[i][j] == '.': if tile[i][j] == '@': dfs(i, j, '@') res += 1 elif tile[i][j] == '#': dfs(i, j, '#') res += 1 elif tile[i][j] == '*': dfs(i, j, '*') res += 1 return res res=0 counter=0 DX = [-1, 0, 1, 0] DY = [0, -1, 0, 1] while True: counter+=1 line = input() if ' ' in line: nums = line.split(' ') N = int(nums[0]) M = int(nums[1]) tile = [[0 for i in range(N)]for j in range(M)] if N==0 and M==0: break else: tile[counter-2] = list(line) if (counter-1)==M: res = solve() counter = 0 print(res)
s223419124
p00118
u284851373
1493377068
Python
Python3
py
Runtime Error
0
0
892
# -*- coding:utf-8 -*- import sys sys.setrecursionlimit(10000000) def dfs(x, y, sym): tile[x][y] = '.' for i in range(len(DX)): nx = x + DX[i] ny = y + DY[i] if nx>=0 and nx<N and ny>=0 and ny<M and tile[nx][ny]==sym: dfs(nx, ny, sym) def solve(): res = 0 for i in range(N): for j in range(M): if not tile[i][j] == '.': if tile[i][j] == '@': dfs(i, j, '@') res += 1 elif tile[i][j] == '#': dfs(i, j, '#') res += 1 elif tile[i][j] == '*': dfs(i, j, '*') res += 1 return res res=0 counter=0 DX = [-1, 0, 1, 0] DY = [0, -1, 0, 1] while True: counter+=1 line = input() if ' ' in line: nums = line.split(' ') N = int(nums[0]) M = int(nums[1]) tile = [[0 for i in range(N)]for j in range(M)] if N==0 and M==0: break else: tile[counter-2] = list(line) if (counter-1)==M: res = solve() counter = 0 print(res)
s791601386
p00118
u284851373
1493377075
Python
Python3
py
Runtime Error
0
0
893
# -*- coding:utf-8 -*- import sys sys.setrecursionlimit(100000000) def dfs(x, y, sym): tile[x][y] = '.' for i in range(len(DX)): nx = x + DX[i] ny = y + DY[i] if nx>=0 and nx<N and ny>=0 and ny<M and tile[nx][ny]==sym: dfs(nx, ny, sym) def solve(): res = 0 for i in range(N): for j in range(M): if not tile[i][j] == '.': if tile[i][j] == '@': dfs(i, j, '@') res += 1 elif tile[i][j] == '#': dfs(i, j, '#') res += 1 elif tile[i][j] == '*': dfs(i, j, '*') res += 1 return res res=0 counter=0 DX = [-1, 0, 1, 0] DY = [0, -1, 0, 1] while True: counter+=1 line = input() if ' ' in line: nums = line.split(' ') N = int(nums[0]) M = int(nums[1]) tile = [[0 for i in range(N)]for j in range(M)] if N==0 and M==0: break else: tile[counter-2] = list(line) if (counter-1)==M: res = solve() counter = 0 print(res)
s052220987
p00118
u284851373
1493377081
Python
Python3
py
Runtime Error
0
0
894
# -*- coding:utf-8 -*- import sys sys.setrecursionlimit(1000000000) def dfs(x, y, sym): tile[x][y] = '.' for i in range(len(DX)): nx = x + DX[i] ny = y + DY[i] if nx>=0 and nx<N and ny>=0 and ny<M and tile[nx][ny]==sym: dfs(nx, ny, sym) def solve(): res = 0 for i in range(N): for j in range(M): if not tile[i][j] == '.': if tile[i][j] == '@': dfs(i, j, '@') res += 1 elif tile[i][j] == '#': dfs(i, j, '#') res += 1 elif tile[i][j] == '*': dfs(i, j, '*') res += 1 return res res=0 counter=0 DX = [-1, 0, 1, 0] DY = [0, -1, 0, 1] while True: counter+=1 line = input() if ' ' in line: nums = line.split(' ') N = int(nums[0]) M = int(nums[1]) tile = [[0 for i in range(N)]for j in range(M)] if N==0 and M==0: break else: tile[counter-2] = list(line) if (counter-1)==M: res = solve() counter = 0 print(res)
s474773864
p00118
u284851373
1493379971
Python
Python3
py
Runtime Error
0
0
864
import sys sys.setrecursionlimit(1000000) def dfs(x, y, sym): tile[x][y] = '.' for i in range(len(DX)): nx = x + DX[i] ny = y + DY[i] if nx>=0 and nx<N and ny>=0 and ny<M and tile[nx][ny]==sym: dfs(nx, ny, sym) def solve(): res = 0 for i in range(N): for j in range(M): if tile[i][j] != '.': if tile[i][j] == '@': dfs(i, j, '@') res += 1 elif tile[i][j] == '#': dfs(i, j, '#') res += 1 elif tile[i][j] == '*': dfs(i, j, '*') res += 1 return res res=0 counter=0 DX = [-1, 0, 1, 0] DY = [0, -1, 0, 1] while True: counter+=1 line = input() if ' ' in line: nums = line.split(' ') N = int(nums[0]) M = int(nums[1]) tile = [[0 for i in range(N)]for j in range(M)] if N==0 and M==0: break else: tile[counter-2] = list(line) if (counter-1)==M: res = solve() counter = 0 print(res)
s599358554
p00118
u284851373
1493380569
Python
Python3
py
Runtime Error
0
0
887
# -*- coding:utf-8 -*- import sys sys.setrecursionlimit(1000000) def dfs(x, y, sym): tile[x][y] = "." for i in range(len(DX)): nx = x + DX[i] ny = y + DY[i] if nx>=0 and nx<N and ny>=0 and ny<M and tile[nx][ny]==sym: dfs(nx, ny, sym) def solve(): res = 0 for i in range(N): for j in range(M): if tile[i][j] != ".": if tile[i][j] == "@": dfs(i, j, "@") res += 1 elif tile[i][j] == "#": dfs(i, j, "#") res += 1 elif tile[i][j] == "*": dfs(i, j, "*") res += 1 return res res=0 counter=0 DX = [-1, 0, 1, 0] DY = [0, -1, 0, 1] while True: counter+=1 line = input() if ' ' in line: nums = line.split(" ") N = int(nums[0]) M = int(nums[1]) tile = [[0 for i in range(N)]for j in range(M)] if N==0 and M==0: break else: tile[counter-2] = list(line) if (counter-1)==M: res = solve() counter = 0 print(res)
s632590658
p00118
u284851373
1493380638
Python
Python3
py
Runtime Error
0
0
861
# -*- coding:utf-8 -*- import sys sys.setrecursionlimit(1000000) def dfs(x, y, sym): tile[x][y] = "." for i in range(len(DX)): nx = x + DX[i] ny = y + DY[i] if nx>=0 and nx<N and ny>=0 and ny<M and tile[nx][ny]==sym: dfs(nx, ny, sym) def solve(): res = 0 for i in range(N): for j in range(M): if tile[i][j] != ".": if tile[i][j] == "@": dfs(i, j, "@") res += 1 elif tile[i][j] == "#": dfs(i, j, "#") res += 1 elif tile[i][j] == "*": dfs(i, j, "*") res += 1 print(res) counter=0 DX = [-1, 0, 1, 0] DY = [0, -1, 0, 1] while True: counter+=1 line = input() if ' ' in line: nums = line.split(" ") N = int(nums[0]) M = int(nums[1]) tile = [[0 for i in range(N)]for j in range(M)] if N==0 and M==0: break else: tile[counter-2] = list(line) if (counter-1)==M: solve() counter = 0
s230938620
p00118
u284851373
1493380677
Python
Python3
py
Runtime Error
0
0
861
# -*- coding:utf-8 -*- import sys def dfs(x, y, sym): tile[x][y] = "." for i in range(len(DX)): nx = x + DX[i] ny = y + DY[i] if nx>=0 and nx<N and ny>=0 and ny<M and tile[nx][ny]==sym: dfs(nx, ny, sym) def solve(): res = 0 for i in range(N): for j in range(M): if tile[i][j] != ".": if tile[i][j] == "@": dfs(i, j, "@") res += 1 elif tile[i][j] == "#": dfs(i, j, "#") res += 1 elif tile[i][j] == "*": dfs(i, j, "*") res += 1 print(res) counter=0 DX = [-1, 0, 1, 0] DY = [0, -1, 0, 1] sys.setrecursionlimit(1000000) while True: counter+=1 line = input() if ' ' in line: nums = line.split(" ") N = int(nums[0]) M = int(nums[1]) tile = [[0 for i in range(N)]for j in range(M)] if N==0 and M==0: break else: tile[counter-2] = list(line) if (counter-1)==M: solve() counter = 0
s500538582
p00118
u284851373
1493380864
Python
Python3
py
Runtime Error
0
0
860
# -*- coding:utf-8 -*- import sys def dfs(x, y, sym): tile[x][y] = "." for i in range(len(DX)): nx = x + DX[i] ny = y + DY[i] if nx>=0 and nx<N and ny>=0 and ny<M and tile[nx][ny]==sym: dfs(nx, ny, sym) def solve(): res = 0 for i in range(N): for j in range(M): if tile[i][j] != ".": if tile[i][j] == "@": dfs(i, j, "@") res += 1 elif tile[i][j] == "#": dfs(i, j, "#") res += 1 elif tile[i][j] == "*": dfs(i, j, "*") res += 1 print(res) counter=0 DX = [-1, 0, 1, 0] DY = [0, -1, 0, 1] sys.setrecursionlimit(1000000) while True: counter+=1 line = input() if ' ' in line: nums = line.split(" ") N = int(nums[0]) M = int(nums[1]) tile = [[0 for i in range(N)] for j in range(M)] if N==0 and M==0: break else: tile[counter-2] = list(line) if (counter-1)==M: solve() counter = 0
s882919592
p00118
u284851373
1493380929
Python
Python3
py
Runtime Error
0
0
908
# -*- coding:utf-8 -*- import sys def dfs(x, y, sym): tile[x][y] = "." for i in range(len(DX)): nx = x + DX[i] ny = y + DY[i] if nx>=0 and nx<N and ny>=0 and ny<M and tile[nx][ny]==sym: dfs(nx, ny, sym) def solve(): res = 0 for i in range(N): for j in range(M): if tile[i][j] != ".": if tile[i][j] == "@": dfs(i, j, "@") res += 1 elif tile[i][j] == "#": dfs(i, j, "#") res += 1 elif tile[i][j] == "*": dfs(i, j, "*") res += 1 print(res) counter=0 DX = [-1, 0, 1, 0] DY = [0, -1, 0, 1] sys.setrecursionlimit(1000000) tile = [[0 for i in range(1)] for j in range(1)] while True: counter+=1 line = input() if ' ' in line: nums = line.split(" ") N = int(nums[0]) M = int(nums[1]) tile = [[0 for i in range(N)] for j in range(M)] if N==0 and M==0: break else: tile[counter-2] = list(line) if (counter-1)==M: solve() counter = 0
s609385909
p00118
u284851373
1493381149
Python
Python3
py
Runtime Error
0
0
808
# -*- coding:utf-8 -*- import sys def dfs(x, y, sym): tile[x][y] = "." for i in range(len(DX)): nx = x + DX[i] ny = y + DY[i] if nx>=0 and nx<N and ny>=0 and ny<M and tile[nx][ny]==sym: dfs(nx, ny, sym) def solve(): res = 0 for i in range(N): for j in range(M): sym = tile[i][j] if tile[i][j] != ".": if tile[i][j] == sym: dfs(i, j, sym) res += 1 print(res) counter=0 DX = [-1, 0, 1, 0] DY = [0, -1, 0, 1] sys.setrecursionlimit(1000000) tile = [[0 for i in range(1)] for j in range(1)] while True: counter+=1 line = input() if ' ' in line: nums = line.split(" ") N = int(nums[0]) M = int(nums[1]) tile = [[0 for i in range(N)] for j in range(M)] if N is 0 and M is 0: break else: tile[counter-2] = list(line) if (counter-1)==M: solve() counter = 0
s354316486
p00118
u284851373
1493381185
Python
Python3
py
Runtime Error
0
0
810
# -*- coding:utf-8 -*- import sys def dfs(x, y, sym): tile[x][y] = "." for i in range(len(DX)): nx = x + DX[i] ny = y + DY[i] if nx>=0 and nx<N and ny>=0 and ny<M and tile[nx][ny] is sym: dfs(nx, ny, sym) def solve(): res = 0 for i in range(N): for j in range(M): sym = tile[i][j] if tile[i][j] != ".": if tile[i][j] is sym: dfs(i, j, sym) res += 1 print(res) counter=0 DX = [-1, 0, 1, 0] DY = [0, -1, 0, 1] sys.setrecursionlimit(1000000) tile = [[0 for i in range(1)] for j in range(1)] while True: counter+=1 line = input() if ' ' in line: nums = line.split(" ") N = int(nums[0]) M = int(nums[1]) tile = [[0 for i in range(N)] for j in range(M)] if N is 0 and M is 0: break else: tile[counter-2] = list(line) if (counter-1)==M: solve() counter = 0
s940632651
p00118
u284851373
1493381249
Python
Python3
py
Runtime Error
0
0
806
# -*- coding:utf-8 -*- import sys def dfs(x, y, sym): tile[x][y] = "." for i in range(0,4): nx = x + DX[i] ny = y + DY[i] if nx>=0 and nx<N and ny>=0 and ny<M and tile[nx][ny] is sym: dfs(nx, ny, sym) def solve(): res = 0 for i in range(N): for j in range(M): sym = tile[i][j] if tile[i][j] != ".": if tile[i][j] is sym: dfs(i, j, sym) res += 1 print(res) counter=0 DX = [-1, 0, 1, 0] DY = [0, -1, 0, 1] sys.setrecursionlimit(1000000) tile = [[0 for i in range(1)] for j in range(1)] while True: counter+=1 line = input() if ' ' in line: nums = line.split(" ") N = int(nums[0]) M = int(nums[1]) tile = [[0 for i in range(N)] for j in range(M)] if N is 0 and M is 0: break else: tile[counter-2] = list(line) if (counter-1)==M: solve() counter = 0
s451541061
p00118
u284851373
1493381358
Python
Python3
py
Runtime Error
0
0
810
# -*- coding:utf-8 -*- import sys def dfs(x, y, sym): tile[x][y] = "." for i in range(len(DX)): nx = x + DX[i] ny = y + DY[i] if 0<=nx and nx<N and 0<=ny and ny<M and tile[nx][ny] is sym: dfs(nx, ny, sym) def solve(): res = 0 for i in range(N): for j in range(M): sym = tile[i][j] if tile[i][j] != ".": if tile[i][j] is sym: dfs(i, j, sym) res += 1 print(res) counter=0 DX = [-1, 0, 1, 0] DY = [0, -1, 0, 1] sys.setrecursionlimit(1000000) tile = [[0 for i in range(1)] for j in range(1)] while True: counter+=1 line = input() if ' ' in line: nums = line.split(" ") N = int(nums[0]) M = int(nums[1]) tile = [[0 for i in range(N)] for j in range(M)] if N is 0 and M is 0: break else: tile[counter-2] = list(line) if (counter-1)==M: solve() counter = 0
s538858804
p00118
u284851373
1493381397
Python
Python3
py
Runtime Error
0
0
786
import sys def dfs(x, y, sym): tile[x][y] = "." for i in range(len(DX)): nx = x + DX[i] ny = y + DY[i] if 0<=nx and nx<N and 0<=ny and ny<M and tile[nx][ny] is sym: dfs(nx, ny, sym) def solve(): res = 0 for i in range(N): for j in range(M): sym = tile[i][j] if tile[i][j] != ".": if tile[i][j] is sym: dfs(i, j, sym) res += 1 print(res) counter=0 DX = [-1, 0, 1, 0] DY = [0, -1, 0, 1] sys.setrecursionlimit(1000000) tile = [[0 for i in range(1)] for j in range(1)] while True: counter+=1 line = input() if ' ' in line: nums = line.split(" ") N = int(nums[0]) M = int(nums[1]) tile = [[0 for i in range(N)] for j in range(M)] if N is 0 and M is 0: break else: tile[counter-2] = list(line) if (counter-1)==M: solve() counter = 0
s954808043
p00118
u284851373
1493381449
Python
Python3
py
Runtime Error
0
0
811
# -*- coding:utf-8 -*- import sys def dfs(x, y, sym): tile[x][y] = "." for i in range(len(DX)): nx = x + DX[i] ny = y + DY[i] if 0<=nx and nx<N and 0<=ny and ny<M and tile[nx][ny] is sym: dfs(nx, ny, sym) def solve(): res = 0 for i in range(N): for j in range(M): sym = tile[i][j] if tile[i][j] != ".": if tile[i][j] is sym: dfs(i, j, sym) res += 1 print(res) counter=0 DX = [-1, 0, 1, 0] DY = [0, -1, 0, 1] sys.setrecursionlimit(10000000) tile = [[0 for i in range(1)] for j in range(1)] while True: counter+=1 line = input() if ' ' in line: nums = line.split(" ") N = int(nums[0]) M = int(nums[1]) tile = [[0 for i in range(N)] for j in range(M)] if N is 0 and M is 0: break else: tile[counter-2] = list(line) if (counter-1)==M: solve() counter = 0
s467394555
p00118
u284851373
1493382062
Python
Python3
py
Runtime Error
0
0
823
# -*- coding:utf-8 -*- import sys print("hi") def dfs(x, y, sym): tile[x][y] = "." for i in range(len(DX)): nx = x + DX[i] ny = y + DY[i] if 0<=nx and nx<N and 0<=ny and ny<M and tile[nx][ny] is sym: dfs(nx, ny, sym) def solve(): res = 0 for i in range(N): for j in range(M): sym = tile[i][j] if tile[i][j] != ".": if tile[i][j] is sym: dfs(i, j, sym) res += 1 print(res) counter=0 DX = [-1, 0, 1, 0] DY = [0, -1, 0, 1] sys.setrecursionlimit(10000000) tile = [[0 for i in range(1)] for j in range(1)] while True: counter+=1 line = input() if ' ' in line: nums = line.split(" ") N = int(nums[0]) M = int(nums[1]) tile = [[0 for i in range(N)] for j in range(M)] if N is 0 and M is 0: break else: tile[counter-2] = list(line) if (counter-1)==M: solve() counter = 0
s432496123
p00118
u284851373
1493382079
Python
Python3
py
Runtime Error
0
0
789
#import sys def dfs(x, y, sym): tile[x][y] = "." for i in range(len(DX)): nx = x + DX[i] ny = y + DY[i] if 0<=nx and nx<N and 0<=ny and ny<M and tile[nx][ny] is sym: dfs(nx, ny, sym) def solve(): res = 0 for i in range(N): for j in range(M): sym = tile[i][j] if tile[i][j] != ".": if tile[i][j] is sym: dfs(i, j, sym) res += 1 print(res) counter=0 DX = [-1, 0, 1, 0] DY = [0, -1, 0, 1] sys.setrecursionlimit(10000000) tile = [[0 for i in range(1)] for j in range(1)] while True: counter+=1 line = input() if ' ' in line: nums = line.split(" ") N = int(nums[0]) M = int(nums[1]) tile = [[0 for i in range(N)] for j in range(M)] if N is 0 and M is 0: break else: tile[counter-2] = list(line) if (counter-1)==M: solve() counter = 0
s472950882
p00118
u284851373
1493382118
Python
Python3
py
Runtime Error
0
0
797
import sys def dfs(x, y, sym): tile[x][y] = "." for i in range(len(DX)): nx = x + DX[i] ny = y + DY[i] if 0<=nx and nx<N and 0<=ny and ny<M and tile[nx][ny] is sym: dfs(nx, ny, sym) def solve(): res = 0 for i in range(N): for j in range(M): sym = tile[i][j] if tile[i][j] != ".": if tile[i][j] is sym: dfs(i, j, sym) res += 1 print(res) counter=0 DX = [-1, 0, 1, 0] DY = [0, -1, 0, 1] tile = [[0 for i in range(1)] for j in range(1)] while True: sys.setrecursionlimit(10000000) counter+=1 line = input() if ' ' in line: nums = line.split(" ") N = int(nums[0]) M = int(nums[1]) tile = [[0 for i in range(N)] for j in range(M)] if N is 0 and M is 0: break else: tile[counter-2] = list(line) if (counter-1)==M: solve() counter = 0
s778233940
p00118
u284851373
1493382166
Python
Python3
py
Runtime Error
0
0
740
import sys def dfs(x, y, sym): tile[x][y] = "." for i in range(len(DX)): nx = x + DX[i] ny = y + DY[i] if 0<=nx and nx<N and 0<=ny and ny<M and tile[nx][ny] is sym: dfs(nx, ny, sym) def solve(): res = 0 for i in range(N): for j in range(M): sym = tile[i][j] if tile[i][j] != ".": if tile[i][j] is sym: dfs(i, j, sym) res += 1 print(res) counter=0 DX = [-1, 0, 1, 0] DY = [0, -1, 0, 1] sys.setrecursionlimit(10000000) while True: counter+=1 line = input() if ' ' in line: nums = line.split(" ") N = int(nums[0]) M = int(nums[1]) tile = [[0 for i in range(N)] for j in range(M)] if N is 0 and M is 0: break else: tile[counter-2] = list(line) if (counter-1)==M: solve() counter = 0
s089512826
p00118
u284851373
1493382346
Python
Python3
py
Runtime Error
0
0
762
# -*- coding:utf-8 -*- import sys def dfs(x, y, sym): tile[x][y] = "." for i in range(len(DX)): nx = x + DX[i] ny = y + DY[i] if 0<=nx and nx<N and 0<=ny and ny<M and tile[nx][ny] is sym: dfs(nx, ny, sym) def solve(): res = 0 for i in range(N): for j in range(M): sym = tile[i][j] if tile[i][j] != ".": if tile[i][j] is sym: dfs(i, j, sym) res += 1 print(res) counter=0 DX = [-1, 0, 1, 0] DY = [0, -1, 0, 1] sys.setrecursionlimit(10000000) while True: counter+=1 line = input() if ' ' in line: nums = line.split(" ") N = int(nums[0]) M = int(nums[1]) tile = [[0 for i in range(N)] for j in range(M)] if N is 0 and M is 0: break else: tile[counter-2] = list(line) if counter-1 is M: solve() counter = 0
s340568184
p00118
u284851373
1493382622
Python
Python3
py
Runtime Error
0
0
762
# -*- coding:utf-8 -*- import sys def dfs(x, y, sym): tile[x][y] = "." for i in range(len(DX)): nx = x + DX[i] ny = y + DY[i] if 0<=nx and nx<N and 0<=ny and ny<M and tile[nx][ny] is sym: dfs(nx, ny, sym) def solve(): res = 0 for i in range(N): for j in range(M): sym = tile[i][j] if tile[i][j] != ".": if tile[i][j] is sym: dfs(i, j, sym) res += 1 print(res) counter=0 DX = [-1, 0, 1, 0] DY = [0, -1, 0, 1] sys.setrecursionlimit(10000000) while True: counter+=1 line = input() if ' ' in line: nums = line.split(" ") N = int(nums[0]) M = int(nums[1]) tile = [[0 for i in range(N)] for j in range(M)] else: tile[counter-2] = list(line) if N is 0 and M is 0: break if counter-1 is M: solve() counter = 0
s618552202
p00118
u284851373
1493382654
Python
Python3
py
Runtime Error
0
0
762
# -*- coding:utf-8 -*- import sys def dfs(x, y, sym): tile[x][y] = "." for i in range(len(DX)): nx = x + DX[i] ny = y + DY[i] if 0<=nx and nx<N and 0<=ny and ny<M and tile[nx][ny] is sym: dfs(nx, ny, sym) def solve(): res = 0 for i in range(N): for j in range(M): sym = tile[i][j] if tile[i][j] != ".": if tile[i][j] is sym: dfs(i, j, sym) res += 1 print(res) counter=0 DX = [-1, 0, 1, 0] DY = [0, -1, 0, 1] sys.setrecursionlimit(10000000) while True: line = input() counter+=1 if ' ' in line: nums = line.split(" ") N = int(nums[0]) M = int(nums[1]) tile = [[0 for i in range(N)] for j in range(M)] else: tile[counter-2] = list(line) if N is 0 and M is 0: break if counter-1 is M: solve() counter = 0
s610514734
p00118
u284851373
1493382762
Python
Python3
py
Runtime Error
0
0
781
# -*- coding:utf-8 -*- import sys def dfs(x, y, sym): tile[x][y] = "." for i in range(len(DX)): nx = x + DX[i] ny = y + DY[i] if 0<=nx and nx<N and 0<=ny and ny<M and tile[nx][ny] is sym: dfs(nx, ny, sym) def solve(): res = 0 for i in range(N): for j in range(M): sym = tile[i][j] if tile[i][j] != ".": if tile[i][j] is sym: dfs(i, j, sym) res += 1 print(res) counter=0 flg=1 DX = [-1, 0, 1, 0] DY = [0, -1, 0, 1] sys.setrecursionlimit(10000000) while True: line = input() counter+=1 if flg is 1: nums = line.split(" ") N = int(nums[0]) M = int(nums[1]) tile = [[0 for i in range(N)] for j in range(M)] flg=0 else: tile[counter-2] = list(line) if N is 0 and M is 0: break if counter-1 is M: solve() flg=1 counter = 0
s372281997
p00118
u284851373
1493382851
Python
Python3
py
Runtime Error
0
0
782
# -*- coding:utf-8 -*- import sys def dfs(x, y, sym): tile[x][y] = "." for i in range(len(DX)): nx = x + DX[i] ny = y + DY[i] if 0<=nx and nx<N and 0<=ny and ny<M and tile[nx][ny] is sym: dfs(nx, ny, sym) def solve(): res = 0 for i in range(N): for j in range(M): sym = tile[i][j] if tile[i][j] != ".": if tile[i][j] is sym: dfs(i, j, sym) res += 1 print(res) counter=0 flg=1 DX = [-1, 0, 1, 0] DY = [0, -1, 0, 1] sys.setrecursionlimit(10**7) while True: line = input() counter += 1 if flg is 1: nums = line.split(" ") N = int(nums[0]) M = int(nums[1]) tile = [[0 for i in range(N)] for j in range(M)] flg=0 else: tile[counter-2] = list(line) if N is 0 and M is 0: break if counter-1 is M: solve() flg = 1 counter = 0
s222454450
p00118
u284851373
1493382861
Python
Python3
py
Runtime Error
0
0
759
import sys def dfs(x, y, sym): tile[x][y] = "." for i in range(len(DX)): nx = x + DX[i] ny = y + DY[i] if 0<=nx and nx<N and 0<=ny and ny<M and tile[nx][ny] is sym: dfs(nx, ny, sym) def solve(): res = 0 for i in range(N): for j in range(M): sym = tile[i][j] if tile[i][j] != ".": if tile[i][j] is sym: dfs(i, j, sym) res += 1 print(res) counter=0 flg=1 DX = [-1, 0, 1, 0] DY = [0, -1, 0, 1] sys.setrecursionlimit(10**7) while True: line = input() counter += 1 if flg is 1: nums = line.split(" ") N = int(nums[0]) M = int(nums[1]) tile = [[0 for i in range(N)] for j in range(M)] flg=0 else: tile[counter-2] = list(line) if N is 0 and M is 0: break if counter-1 is M: solve() flg = 1 counter = 0
s727140390
p00118
u284851373
1493382930
Python
Python3
py
Runtime Error
0
0
781
# -*- coding:utf-8 -*- import sys def solve(): res = 0 for i in range(N): for j in range(M): sym = tile[i][j] if tile[i][j] != ".": if tile[i][j] is sym: dfs(i, j, sym) res += 1 print(res) def dfs(x, y, sym): tile[x][y] = "." for i in range(len(DX)): nx = x + DX[i] ny = y + DY[i] if 0<=nx and nx<N and 0<=ny and ny<M and tile[nx][ny] is sym: dfs(nx, ny, sym) counter=0 flg=1 DX = [-1, 0, 1, 0] DY = [0, -1, 0, 1] sys.setrecursionlimit(10**7) while True: line = input() counter += 1 if flg is 1: nums = line.split(" ") N = int(nums[0]) M = int(nums[1]) tile = [[0 for i in range(N)] for j in range(M)] flg=0 else: tile[counter-2] = list(line) if N is 0 and M is 0: break if counter-1 is M: solve() flg = 1 counter = 0
s756986612
p00118
u284851373
1493382997
Python
Python3
py
Runtime Error
0
0
783
# -*- coding:utf-8 -*- import sys def dfs(x, y, sym): tile[x][y] = "." for i in range(len(DX)): nx = x + DX[i] ny = y + DY[i] if (0<=nx and nx<N and 0<=ny and ny<M and tile[nx][ny] is sym): dfs(nx, ny, sym) def solve(): res = 0 for i in range(N): for j in range(M): sym = tile[i][j] if tile[i][j] != ".": if tile[i][j] is sym: dfs(i, j, sym) res += 1 print(res) counter=0 flg=1 DX = [-1, 0, 1, 0] DY = [0, -1, 0, 1] sys.setrecursionlimit(10**7) while True: line = input() counter += 1 if flg is 1: nums = line.split(" ") N = int(nums[0]) M = int(nums[1]) tile = [[0 for i in range(N)] for j in range(M)] flg=0 else: tile[counter-2] = list(line) if N is 0 and M is 0: break if counter-1 is M: solve() flg = 1 counter = 0
s182468996
p00118
u284851373
1493383004
Python
Python3
py
Runtime Error
0
0
760
import sys def dfs(x, y, sym): tile[x][y] = "." for i in range(len(DX)): nx = x + DX[i] ny = y + DY[i] if (0<=nx and nx<N and 0<=ny and ny<M and tile[nx][ny] is sym): dfs(nx, ny, sym) def solve(): res = 0 for i in range(N): for j in range(M): sym = tile[i][j] if tile[i][j] != ".": if tile[i][j] is sym: dfs(i, j, sym) res += 1 print(res) counter=0 flg=1 DX = [-1, 0, 1, 0] DY = [0, -1, 0, 1] sys.setrecursionlimit(10**7) while True: line = input() counter += 1 if flg is 1: nums = line.split(" ") N = int(nums[0]) M = int(nums[1]) tile = [[0 for i in range(N)] for j in range(M)] flg=0 else: tile[counter-2] = list(line) if N is 0 and M is 0: break if counter-1 is M: solve() flg = 1 counter = 0
s493115951
p00118
u284851373
1493383359
Python
Python3
py
Runtime Error
0
0
760
# -*- coding:utf-8 -*- import sys def dfs(x, y, sym): tile[x][y] = "." for i in range(len(DX)): nx = x + DX[i] ny = y + DY[i] if (0<=nx and nx<N and 0<=ny and ny<M and tile[nx][ny] is sym): dfs(nx, ny, sym) def solve(): res = 0 for i in range(N): for j in range(M): sym = tile[i][j] if tile[i][j] != ".": if tile[i][j] is sym: dfs(i, j, sym) res += 1 print(res) counter=0 DX = [-1, 0, 1, 0] DY = [0, -1, 0, 1] sys.setrecursionlimit(10**7) while True: line = input() if ' ' in line: nums = line.split(" ") N = int(nums[0]) M = int(nums[1]) tile = [[0 for i in range(N)] for j in range(M)] else: tile[counter-1] = list(line) if N is 0 and M is 0: break if counter is M: solve() counter = 0 counter += 1
s789914911
p00118
u284851373
1493383372
Python
Python3
py
Runtime Error
0
0
737
import sys def dfs(x, y, sym): tile[x][y] = "." for i in range(len(DX)): nx = x + DX[i] ny = y + DY[i] if (0<=nx and nx<N and 0<=ny and ny<M and tile[nx][ny] is sym): dfs(nx, ny, sym) def solve(): res = 0 for i in range(N): for j in range(M): sym = tile[i][j] if tile[i][j] != ".": if tile[i][j] is sym: dfs(i, j, sym) res += 1 print(res) counter=0 DX = [-1, 0, 1, 0] DY = [0, -1, 0, 1] sys.setrecursionlimit(10**7) while True: line = input() if ' ' in line: nums = line.split(" ") N = int(nums[0]) M = int(nums[1]) tile = [[0 for i in range(N)] for j in range(M)] else: tile[counter-1] = list(line) if N is 0 and M is 0: break if counter is M: solve() counter = 0 counter += 1
s523045953
p00118
u284851373
1493383541
Python
Python3
py
Runtime Error
0
0
754
# -*- coding:utf-8 -*- import sys def dfs(x, y, sym): tile[x][y] = "." for i in range(len(DX)): nx = x + DX[i] ny = y + DY[i] if (0<=nx and nx<N and 0<=ny and ny<M and tile[nx][ny] is sym): dfs(nx, ny, sym) def solve(): res = 0 for i in range(N): for j in range(M): sym = tile[i][j] if tile[i][j] != ".": if tile[i][j] is sym: dfs(i, j, sym) res += 1 print(res) counter=0 DX = [-1,0,1,0] DY = [0,-1,0,1] sys.setrecursionlimit(10**7) while True: line = input() if " " in line: nums = line.split(" ") N = int(nums[0]) M = int(nums[1]) tile = [[0 for i in range(N)] for j in range(M)] else: tile[counter-1] = list(line) if N is 0 and M is 0: break if counter is M: solve() counter = 0 counter += 1
s989781371
p00118
u284851373
1493383569
Python
Python3
py
Runtime Error
0
0
731
import sys def dfs(x, y, sym): tile[x][y] = "." for i in range(len(DX)): nx = x + DX[i] ny = y + DY[i] if (0<=nx and nx<N and 0<=ny and ny<M and tile[nx][ny] is sym): dfs(nx, ny, sym) def solve(): res = 0 for i in range(N): for j in range(M): sym = tile[i][j] if tile[i][j] != ".": if tile[i][j] is sym: dfs(i, j, sym) res += 1 print(res) counter=0 DX = [-1,0,1,0] DY = [0,-1,0,1] sys.setrecursionlimit(10**7) while True: line = input() if " " in line: nums = line.split(" ") N = int(nums[0]) M = int(nums[1]) tile = [[0 for i in range(N)] for j in range(M)] else: tile[counter-1] = list(line) if N is 0 and M is 0: break if counter is M: solve() counter = 0 counter += 1
s674688619
p00118
u284851373
1493383837
Python
Python3
py
Runtime Error
0
0
756
# -*- coding:utf-8 -*- import sys def dfs(x, y, sym): tile[x][y] = "." for i in range(len(DX)): nx = x + DX[i] ny = y + DY[i] if (0<=nx and nx<N and 0<=ny and ny<M and tile[nx][ny] is sym): dfs(nx, ny, sym) def solve(): res = 0 for i in range(N): for j in range(M): sym = tile[i][j] if tile[i][j] != ".": if tile[i][j] is sym: dfs(i, j, sym) res += 1 print(res) counter=0 DX = [-1,0,1,0] DY = [0,-1,0,1] sys.setrecursionlimit(10**7) while True: line = input() if " " in line: nums = line.split(" ") N = int(nums[0]) M = int(nums[1]) tile = [[0 for i in range(N)] for j in range(M)] else: tile[counter-1] = list(line) if N is 0 and M is 0: break counter += 1 if counter-1 is M: solve() counter = 0
s149981385
p00118
u284851373
1493383846
Python
Python3
py
Runtime Error
0
0
733
import sys def dfs(x, y, sym): tile[x][y] = "." for i in range(len(DX)): nx = x + DX[i] ny = y + DY[i] if (0<=nx and nx<N and 0<=ny and ny<M and tile[nx][ny] is sym): dfs(nx, ny, sym) def solve(): res = 0 for i in range(N): for j in range(M): sym = tile[i][j] if tile[i][j] != ".": if tile[i][j] is sym: dfs(i, j, sym) res += 1 print(res) counter=0 DX = [-1,0,1,0] DY = [0,-1,0,1] sys.setrecursionlimit(10**7) while True: line = input() if " " in line: nums = line.split(" ") N = int(nums[0]) M = int(nums[1]) tile = [[0 for i in range(N)] for j in range(M)] else: tile[counter-1] = list(line) if N is 0 and M is 0: break counter += 1 if counter-1 is M: solve() counter = 0
s467105478
p00118
u284851373
1493383953
Python
Python
py
Runtime Error
0
0
733
import sys def dfs(x, y, sym): tile[x][y] = "." for i in range(len(DX)): nx = x + DX[i] ny = y + DY[i] if (0<=nx and nx<N and 0<=ny and ny<M and tile[nx][ny] is sym): dfs(nx, ny, sym) def solve(): res = 0 for i in range(N): for j in range(M): sym = tile[i][j] if tile[i][j] != ".": if tile[i][j] is sym: dfs(i, j, sym) res += 1 print(res) counter=0 DX = [-1,0,1,0] DY = [0,-1,0,1] sys.setrecursionlimit(10**7) while True: line = input() if " " in line: nums = line.split(" ") N = int(nums[0]) M = int(nums[1]) tile = [[0 for i in range(N)] for j in range(M)] else: tile[counter-1] = list(line) if N is 0 and M is 0: break counter += 1 if counter-1 is M: solve() counter = 0
s567779812
p00118
u577311000
1493714463
Python
Python3
py
Runtime Error
0
0
988
# -*- coding: utf-8 -*- import sys sys.setrecursionlimit(10*6) def search(values,hp,vp,item): if not (0<=hp<len(values)): return if not (0<=vp<len(values[hp])): return if item!=values[hp][vp]: return values[hp][vp]=True # for dh,dv in [[0,1],[0,-1],[1,0],[-1,0]]: # search(values,hp+dh,vp+dv,item) search(values,hp-1,vp,item) search(values,hp+1,vp,item) search(values,hp,vp-1,item) search(values,hp,vp+1,item) def solve(values): count,valid_items=0,set(['@','#','*']) for i in range(len(values)): for j in range(len(values[i])): if values[i][j] in valid_items: search(values,i,j,values[i][j]) count+=1 return count def main(): line,values=input().strip(),list() while line!='0 0': H,W = list(map(int,line.split(' '))) value = list() for _ in range(H): value.append(list(x for x in input().strip())) print(solve(value)) values.append(value) line = input().strip() # for value in values: # print(solve(value)) if __name__=='__main__': main()
s382432649
p00118
u577311000
1493715008
Python
Python3
py
Runtime Error
0
0
989
# -*- coding: utf-8 -*- import sys sys.setrecursionlimit(10*6) def search(values,hp,vp,item): if not (0<=hp<len(values)): return if not (0<=vp<len(values[hp])): return if item!=values[hp][vp]: return values[hp][vp]=True # for dh,dv in [[0,1],[0,-1],[1,0],[-1,0]]: # search(values,hp+dh,vp+dv,item) search(values,hp-1,vp,item) search(values,hp+1,vp,item) search(values,hp,vp-1,item) search(values,hp,vp+1,item) def solve(values): count,valid_items=0,set(['@','#','*']) for i in range(len(values)): for j in range(len(values[i])): if values[i][j] in valid_items: search(values,i,j,values[i][j]) count+=1 return count def main(): line,values=input().strip(),list() while line!='0 0': H,W = list(map(int,line.split(' '))) value = list() for _ in range(H): value.append(list(x for x in input().strip())) print(solve(value)) # values.append(value) line = input().strip() # for value in values: # print(solve(value)) if __name__=='__main__': main()
s405519832
p00118
u577311000
1493715399
Python
Python3
py
Runtime Error
0
0
1061
# -*- coding: utf-8 -*- import sys #sys.setrecursionlimit(10**6) sys.setrecursionlimit(10*6) def search(values,hp,vp,item): if not (0<=hp<len(values)): return if not (0<=vp<len(values[hp])): return if item!=values[hp][vp]: return values[hp][vp]=True # for dh,dv in [[0,1],[0,-1],[1,0],[-1,0]]: # search(values,hp+dh,vp+dv,item) search(values,hp-1,vp,item) search(values,hp+1,vp,item) search(values,hp,vp-1,item) search(values,hp,vp+1,item) def solve(values): count,valid_items=0,set(['@','#','*']) for i in range(len(values)): for j in range(len(values[i])): if values[i][j] in valid_items: search(values,i,j,values[i][j]) count+=1 return count def main(): line, values = input().strip(), list() while line!='0 0': H,W = list(map(int,line.split(' '))) value = list() for _ in range(H): # value.append(list(x for x in input().strip())) value.append(list(input().strip())) print(solve(value)) # values.append(value) line = input().strip() for value in values: print(solve(value)) if __name__=='__main__': main()
s845952058
p00118
u577311000
1493715453
Python
Python3
py
Runtime Error
0
0
861
# -*- coding: utf-8 -*- import sys sys.setrecursionlimit(10**6) def search(values,hp,vp,item): if not (0<=hp<len(values)): return if not (0<=vp<len(values[hp])): return if item!=values[hp][vp]: return values[hp][vp]=True # for dh,dv in [[0,1],[0,-1],[1,0],[-1,0]]: # search(values,hp+dh,vp+dv,item) search(values,hp-1,vp,item) search(values,hp+1,vp,item) search(values,hp,vp-1,item) search(values,hp,vp+1,item) def solve(values): count,valid_items=0,set(['@','#','*']) for i in range(len(values)): for j in range(len(values[i])): if values[i][j] in valid_items: search(values,i,j,values[i][j]) count+=1 return count def main(): line = input().strip() while line!='0 0': H,W = list(map(int,line.split(' '))) values.append(list(list(input().strip()) for _ in range(H))) line = input().strip() if __name__=='__main__': main()
s186540615
p00118
u577311000
1493715499
Python
Python3
py
Runtime Error
0
0
857
# -*- coding: utf-8 -*- import sys sys.setrecursionlimit(10**6) def search(values,hp,vp,item): if not (0<=hp<len(values)): return if not (0<=vp<len(values[hp])): return if item!=values[hp][vp]: return values[hp][vp]=True # for dh,dv in [[0,1],[0,-1],[1,0],[-1,0]]: # search(values,hp+dh,vp+dv,item) search(values,hp-1,vp,item) search(values,hp+1,vp,item) search(values,hp,vp-1,item) search(values,hp,vp+1,item) def solve(values): count,valid_items=0,set(['@','#','*']) for i in range(len(values)): for j in range(len(values[i])): if values[i][j] in valid_items: search(values,i,j,values[i][j]) count+=1 return count def main(): line = input().strip() while line!='0 0': H,W = list(map(int,line.split(' '))) print(solve(list(list(input().strip()) for _ range(H)))) line = input().strip() if __name__=='__main__': main()
s520439186
p00118
u577311000
1493715586
Python
Python3
py
Runtime Error
0
0
906
# -*- coding: utf-8 -*- import sys sys.setrecursionlimit(10**6) def search(values,hp,vp,item): if not (0<=hp<len(values)): return if not (0<=vp<len(values[hp])): return if item!=values[hp][vp]: return values[hp][vp]=True for dh,dv in list([0,1],[0,-1],[1,0],[-1,0]): search(values,hp+dh,vp+dv,item) # search(values,hp-1,vp,item) # search(values,hp+1,vp,item) # search(values,hp,vp-1,item) # search(values,hp,vp+1,item) def solve(values): count,valid_items=0,set(['@','#','*']) for i in range(len(values)): for j in range(len(values[i])): if values[i][j] in valid_items: search(values,i,j,values[i][j]) count+=1 return count def main(): line = input().strip() while line!='0 0': H,W = list(map(int,line.split(' '))) values = list() for _ in range(H): values.append(list(input().strip())) print(solve(values)) line = input().strip() if __name__=='__main__': main()
s660982645
p00118
u462831976
1494782723
Python
Python3
py
Runtime Error
0
0
979
# -*- coding: utf-8 -*- import sys import os import math directions = [(1, 0), (-1, 0), (0, 1), (0, -1)] for s in sys.stdin: H, W = map(int, s.split()) if H == W == 0: break # map M = [] for i in range(H): s = input().strip() M.append(s) # W x H white map A = [[None for i in range(H)] for j in range(W)] def drawable(x, y): if 0 <= x < W and 0 <= y < H and A[y][x] == None: return True else: return False color_num = 0 def fill(x, y): global color_num A[y][x] = color_num for direction in directions: new_x = x + direction[0] new_y = y + direction[1] if drawable(new_x, new_y) and M[y][x] == M[new_y][new_x]: fill(new_x, new_y) for y in range(H): for x in range(W): if drawable(x, y): color_num += 1 fill(x, y) print(color_num)
s670660826
p00118
u462831976
1494782807
Python
Python3
py
Runtime Error
0
0
979
# -*- coding: utf-8 -*- import sys import os import math directions = [(1, 0), (-1, 0), (0, 1), (0, -1)] for s in sys.stdin: H, W = map(int, s.split()) if H == W == 0: break # map M = [] for i in range(H): s = input().strip() M.append(s) # W x H white map A = [[None for i in range(W)] for j in range(H)] def drawable(x, y): if 0 <= x < W and 0 <= y < H and A[y][x] == None: return True else: return False color_num = 0 def fill(x, y): global color_num A[y][x] = color_num for direction in directions: new_x = x + direction[0] new_y = y + direction[1] if drawable(new_x, new_y) and M[y][x] == M[new_y][new_x]: fill(new_x, new_y) for y in range(H): for x in range(W): if drawable(x, y): color_num += 1 fill(x, y) print(color_num)
s612681325
p00118
u462831976
1494783001
Python
Python3
py
Runtime Error
0
0
979
# -*- coding: utf-8 -*- import sys import os import math directions = [(1, 0), (-1, 0), (0, 1), (0, -1)] for s in sys.stdin: H, W = map(int, s.split()) if H == W == 0: break # map M = [] for i in range(H): s = input().strip() M.append(s) # W x H white map A = [[None for i in range(W)] for j in range(H)] def drawable(x, y): if 0 <= x < W and 0 <= y < H and A[y][x] == None: return True else: return False color_num = 0 def fill(x, y): global color_num A[y][x] = color_num for direction in directions: new_x = x + direction[0] new_y = y + direction[1] if drawable(new_x, new_y) and M[y][x] == M[new_y][new_x]: fill(new_x, new_y) for y in range(H): for x in range(W): if drawable(x, y): color_num += 1 fill(x, y) print(color_num)
s649631175
p00118
u724963150
1496416526
Python
Python3
py
Runtime Error
0
0
659
while True: a=[int(num)for num in input().split(' ')] if a[0]==0:break s=[] cnt=0 def rep(r,c,nest): global cnt f=s[r][c] if f=='.':return s[r][c]='.' if r>0: if s[r-1][c]==f:rep(r-1,c,False) if r<a[0]-1: if s[r+1][c]==f:rep(r+1,c,False) if c>0: if s[r][c-1]==f:rep(r,c-1,False) if c<a[1]-1: if s[r][c+1]==f:rep(r,c+1,False) if nest==True: cnt+=1 for i in range(a[0]): s.append(list(input())) for i in range(a[0]): for j in range(a[1]): rep(i,j,True) print(cnt)
s791906152
p00118
u724963150
1496419194
Python
Python3
py
Runtime Error
0
0
693
import sys sys.setrecursionlimit(9000) while True: a=[int(num)for num in input().split(' ')] if a[0]==0:break s=[] cnt=0 def rep(r,c,nest): global cnt f=s[r][c] if f=='.':return s[r][c]='.' if r>0: if s[r-1][c]==f:rep(r-1,c,False) if r<a[0]-1: if s[r+1][c]==f:rep(r+1,c,False) if c>0: if s[r][c-1]==f:rep(r,c-1,False) if c<a[1]-1: if s[r][c+1]==f:rep(r,c+1,False) if nest==True: cnt+=1 for i in range(a[0]): s.append(list(input())) for i in range(a[0]): for j in range(a[1]): rep(i,j,True) print(cnt)
s852116828
p00118
u811733736
1504099727
Python
Python3
py
Runtime Error
0
0
2491
# -*- coding: utf-8 -*- """ http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0118 """ import sys def solve(data): size = len(data[0]) data.insert(0, ['0' for _ in range(size)]) data.insert(len(data), ['0' for _ in range(size)]) processing_area = [] area_id = 0 for y in range(1, len(data)): for x in range(1, len(data[0])): mark = data[y][x] data[y][x] = '0' if mark != '0': area_id += 1 processing_area.append((y, x)) while processing_area: yy, xx = processing_area.pop() if data[yy-1][xx] == mark: data[yy-1][xx] = '0' processing_area.append((yy-1, xx)) if data[yy+1][xx] == mark: data[yy+1][xx] = '0' processing_area.append((yy+1, xx)) if data[yy][xx-1] == mark: data[yy][xx-1] = '0' processing_area.append((yy, xx-1)) if data[yy][xx+1] == mark: data[yy][xx+1] = '0' processing_area.append((yy, xx+1)) mark = '0' return area_id def main(args): # data = [] # data.append(['0', '#', '#', '#', '#', '*', '*', '*', '*', '*', '@', '0']) # data.append(['0', '@', '#', '@', '@', '@', '@', '#', '*', '#', '*', '0']) # data.append(['0', '@', '#', '#', '*', '*', '*', '@', '@', '@', '*', '0']) # data.append(['0', '#', '*', '*', '*', '*', '#', '*', '@', '*', '*', '0']) # data.append(['0', '#', '#', '@', '*', '#', '@', '@', '*', '#', '#', '0']) # data.append(['0', '*', '@', '@', '@', '@', '*', '@', '@', '@', '#', '0']) # data.append(['0', '*', '*', '*', '#', '@', '*', '@', '#', '#', '*', '0']) # data.append(['0', '*', '@', '@', '@', '*', '@', '@', '#', '#', '@', '0']) # data.append(['0', '*', '@', '*', '#', '*', '@', '#', '#', '*', '*', '0']) # data.append(['0', '@', '*', '*', '*', '*', '#', '@', '@', '#', '@', '0']) data = [] while True: h, w = [int(x) for x in input().split(' ')] if h == 0 and w == 0: break for _ in range(w): temp = list(input()) temp.insert(0, '0') temp.append('0') data.append(temp) result = solve(data) print(result) if __name__ == '__main__': main(sys.argv[1:])
s880281418
p00118
u811733736
1504100899
Python
Python3
py
Runtime Error
0
0
2541
# -*- coding: utf-8 -*- """ http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0118 """ import sys def solve(data): size = len(data[0]) data.insert(0, ['0' for _ in range(size)]) data.insert(len(data), ['0' for _ in range(size)]) processing_area = [] area_id = 0 for y in range(1, len(data)): for x in range(1, len(data[0])): print('y:{}, x:{}'.format(y, x)) mark = data[y][x] data[y][x] = '0' if mark != '0': area_id += 1 processing_area.append((y, x)) while processing_area: yy, xx = processing_area.pop() if data[yy-1][xx] == mark: data[yy-1][xx] = '0' processing_area.append((yy-1, xx)) if data[yy+1][xx] == mark: data[yy+1][xx] = '0' processing_area.append((yy+1, xx)) if data[yy][xx-1] == mark: data[yy][xx-1] = '0' processing_area.append((yy, xx-1)) if data[yy][xx+1] == mark: data[yy][xx+1] = '0' processing_area.append((yy, xx+1)) mark = '0' return area_id def main(args): # data = [] # data.append(['0', '#', '#', '#', '#', '*', '*', '*', '*', '*', '@', '0']) # data.append(['0', '@', '#', '@', '@', '@', '@', '#', '*', '#', '*', '0']) # data.append(['0', '@', '#', '#', '*', '*', '*', '@', '@', '@', '*', '0']) # data.append(['0', '#', '*', '*', '*', '*', '#', '*', '@', '*', '*', '0']) # data.append(['0', '#', '#', '@', '*', '#', '@', '@', '*', '#', '#', '0']) # data.append(['0', '*', '@', '@', '@', '@', '*', '@', '@', '@', '#', '0']) # data.append(['0', '*', '*', '*', '#', '@', '*', '@', '#', '#', '*', '0']) # data.append(['0', '*', '@', '@', '@', '*', '@', '@', '#', '#', '@', '0']) # data.append(['0', '*', '@', '*', '#', '*', '@', '#', '#', '*', '*', '0']) # data.append(['0', '@', '*', '*', '*', '*', '#', '@', '@', '#', '@', '0']) while True: h, w = [int(x) for x in input().split(' ')] if h == 0 and w == 0: break data = [] for _ in range(w): temp = list(input()) temp.insert(0, '0') temp.append('0') data.append(temp) result = solve(data) print(result) if __name__ == '__main__': main(sys.argv[1:])
s994481713
p00118
u811733736
1504100952
Python
Python3
py
Runtime Error
0
0
2543
# -*- coding: utf-8 -*- """ http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0118 """ import sys def solve(data): size = len(data[0]) data.insert(0, ['0' for _ in range(size)]) data.insert(len(data), ['0' for _ in range(size)]) processing_area = [] area_id = 0 for y in range(1, len(data)): for x in range(1, len(data[0])): # print('y:{}, x:{}'.format(y, x)) mark = data[y][x] data[y][x] = '0' if mark != '0': area_id += 1 processing_area.append((y, x)) while processing_area: yy, xx = processing_area.pop() if data[yy-1][xx] == mark: data[yy-1][xx] = '0' processing_area.append((yy-1, xx)) if data[yy+1][xx] == mark: data[yy+1][xx] = '0' processing_area.append((yy+1, xx)) if data[yy][xx-1] == mark: data[yy][xx-1] = '0' processing_area.append((yy, xx-1)) if data[yy][xx+1] == mark: data[yy][xx+1] = '0' processing_area.append((yy, xx+1)) mark = '0' return area_id def main(args): # data = [] # data.append(['0', '#', '#', '#', '#', '*', '*', '*', '*', '*', '@', '0']) # data.append(['0', '@', '#', '@', '@', '@', '@', '#', '*', '#', '*', '0']) # data.append(['0', '@', '#', '#', '*', '*', '*', '@', '@', '@', '*', '0']) # data.append(['0', '#', '*', '*', '*', '*', '#', '*', '@', '*', '*', '0']) # data.append(['0', '#', '#', '@', '*', '#', '@', '@', '*', '#', '#', '0']) # data.append(['0', '*', '@', '@', '@', '@', '*', '@', '@', '@', '#', '0']) # data.append(['0', '*', '*', '*', '#', '@', '*', '@', '#', '#', '*', '0']) # data.append(['0', '*', '@', '@', '@', '*', '@', '@', '#', '#', '@', '0']) # data.append(['0', '*', '@', '*', '#', '*', '@', '#', '#', '*', '*', '0']) # data.append(['0', '@', '*', '*', '*', '*', '#', '@', '@', '#', '@', '0']) while True: h, w = [int(x) for x in input().split(' ')] if h == 0 and w == 0: break data = [] for _ in range(w): temp = list(input()) temp.insert(0, '0') temp.append('0') data.append(temp) result = solve(data) print(result) if __name__ == '__main__': main(sys.argv[1:])
s938269657
p00118
u811733736
1504101257
Python
Python3
py
Runtime Error
0
0
2574
# -*- coding: utf-8 -*- """ http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0118 """ import sys def solve(data): size = len(data[0]) data.insert(0, ['0' for _ in range(size)]) data.insert(len(data), ['0' for _ in range(size)]) processing_area = [] area_id = 0 for y in range(1, len(data)-1): for x in range(1, len(data[0])): # print('y:{}, x:{}'.format(y, x)) mark = data[y][x] data[y][x] = '0' if mark != '0': area_id += 1 processing_area.append((y, x)) while processing_area: yy, xx = processing_area.pop() if data[yy-1][xx] == mark: # ??? data[yy-1][xx] = '0' processing_area.append((yy-1l, xx)) if data[yy+1][xx] == mark: # ??? data[yy+1][xx] = '0' processing_area.append((yy+1, xx)) if data[yy][xx-1] == mark: # ??? data[yy][xx-1] = '0' processing_area.append((yy, xx-1)) if data[yy][xx+1] == mark: # ??? data[yy][xx+1] = '0' processing_area.append((yy, xx+1)) mark = '0' return area_id def main(args): # data = [] # data.append(['0', '#', '#', '#', '#', '*', '*', '*', '*', '*', '@', '0']) # data.append(['0', '@', '#', '@', '@', '@', '@', '#', '*', '#', '*', '0']) # data.append(['0', '@', '#', '#', '*', '*', '*', '@', '@', '@', '*', '0']) # data.append(['0', '#', '*', '*', '*', '*', '#', '*', '@', '*', '*', '0']) # data.append(['0', '#', '#', '@', '*', '#', '@', '@', '*', '#', '#', '0']) # data.append(['0', '*', '@', '@', '@', '@', '*', '@', '@', '@', '#', '0']) # data.append(['0', '*', '*', '*', '#', '@', '*', '@', '#', '#', '*', '0']) # data.append(['0', '*', '@', '@', '@', '*', '@', '@', '#', '#', '@', '0']) # data.append(['0', '*', '@', '*', '#', '*', '@', '#', '#', '*', '*', '0']) # data.append(['0', '@', '*', '*', '*', '*', '#', '@', '@', '#', '@', '0']) while True: h, w = [int(x) for x in input().split(' ')] if h == 0 and w == 0: break data = [] for _ in range(h): temp = list(input()) temp.insert(0, '0') temp.append('0') data.append(temp) result = solve(data) print(result) if __name__ == '__main__': main(sys.argv[1:])
s167591882
p00118
u510797278
1504673545
Python
Python3
py
Runtime Error
0
0
1035
field = [] w = 0 h = 0 def main(): global field, w, h while True: h, w = map(int, input().split()) if h == 0 and w == 0: break count = 0 field = [[0] * w for _ in range(h)] for y in range(h): kinds = [_ for _ in input()] arrangement(kinds, y) for y in range(h): for x in range(w): if field[y][x] != -1: dfs(field[y][x], x, y) count += 1 print(count) def arrangement(kinds, y): global field for i, kind in enumerate(kinds): field[y][i] = kind def dfs(kind, x, y): global field field[y][x] = -1 for dx, dy in zip([0, 0, -1, 1], [1, -1, 0, 0]): next_x = x + dx next_y = y + dy if next_x < 0 or next_y < 0 or next_x >= w or next_y >= h: continue if field[next_y][next_x] != kind: continue dfs(field[next_y][next_x], next_x, next_y) if __name__ == '__main__': main()
s931707152
p00118
u510797278
1504674764
Python
Python3
py
Runtime Error
0
0
1001
field = [] w = 0 h = 0 def main(): global field, w, h while True: h, w = map(int, input().split()) if h == 0 and w == 0: break count = 0 [field.append([_ for _ in input()]) for _ in range(h)] print(field) for y in range(h): for x in range(w): if field[y][x] != -1: dfs(field[y][x], x, y) count += 1 print(count) def arrangement(kinds, y): global field for i, kind in enumerate(kinds): field[y][i] = kind def dfs(kind, x, y): global field print(x, y, field[y][x]) field[y][x] = -1 for dx, dy in zip([0, 0, -1, 1], [1, -1, 0, 0]): next_x = x + dx next_y = y + dy if next_x < 0 or next_y < 0 or next_x >= w or next_y >= h: continue if field[next_y][next_x] != kind: continue dfs(field[next_y][next_x], next_x, next_y) if __name__ == '__main__': main()
s402264668
p00118
u510797278
1504688663
Python
Python3
py
Runtime Error
0
0
840
field = [] w = 0 h = 0 def main(): global field, w, h while True: h, w = map(int, input().split()) if h == 0 and w == 0: break count = 0 [field.append([_ for _ in input()]) for _ in range(h)] for y in range(h): for x in range(w): if field[y][x] != -1: dfs(field[y][x], x, y) count += 1 print(count) def dfs(kind, x, y): global field field[y][x] = -1 for dx, dy in zip([0, 0, -1, 1], [1, -1, 0, 0]): next_x = x + dx next_y = y + dy if next_x < 0 or next_y < 0 or next_x >= w or next_y >= h: continue if field[next_y][next_x] != kind: continue dfs(field[next_y][next_x], next_x, next_y) if __name__ == '__main__': main()
s324230965
p00118
u510797278
1504688841
Python
Python3
py
Runtime Error
0
0
859
field = [] w = 0 h = 0 def main(): global field, w, h while True: h, w = map(int, input().split()) if h == 0 and w == 0: break count = 0 field = [] [field.append([_ for _ in input()]) for _ in range(h)] for y in range(h): for x in range(w): if field[y][x] != -1: dfs(field[y][x], x, y) count += 1 print(count) def dfs(kind, x, y): global field field[y][x] = -1 for dx, dy in zip([0, 0, -1, 1], [1, -1, 0, 0]): next_x = x + dx next_y = y + dy if next_x < 0 or next_y < 0 or next_x >= w or next_y >= h: continue if field[next_y][next_x] != kind: continue dfs(field[next_y][next_x], next_x, next_y) if __name__ == '__main__': main()
s412096775
p00118
u695154284
1505222566
Python
Python3
py
Runtime Error
0
0
749
import sys d = [(1, 0), (-1, 0), (0, 1), (0, -1)] def dfs(x, y, c): judged[x][y] = True for dx, dy in d: if 0 <= x + dx < H and 0 <= y + dy < W and (not judged[x + dx][y + dy]) and orchard[x + dx][y + dy] == c: dfs(x + dx, y + dy, c) if __name__ == '__main__': while True: H, W = list(map(int, input().split())) if H == 0 and W == 0: break orchard = [input() for i in range(H)] judged = [[False for i in range(W)] for j in range(H)] # print(orchard) ans = 0 for i in range(0, H): for j in range(0, W): if not judged[i][j]: ans += 1 dfs(i, j, orchard[i][j]) print(ans)
s980605873
p00118
u695154284
1505222609
Python
Python3
py
Runtime Error
0
0
749
import sys d = [(1, 0), (-1, 0), (0, 1), (0, -1)] def dfs(x, y, c): judged[x][y] = True for dx, dy in d: if 0 <= x + dx < H and 0 <= y + dy < W and (not judged[x + dx][y + dy]) and orchard[x + dx][y + dy] == c: dfs(x + dx, y + dy, c) if __name__ == '__main__': while True: H, W = list(map(int, input().split())) if H == 0 and W == 0: break orchard = [input() for i in range(H)] judged = [[False for i in range(W)] for j in range(H)] # print(orchard) ans = 0 for i in range(0, H): for j in range(0, W): if not judged[i][j]: ans += 1 dfs(i, j, orchard[i][j]) print(ans)
s573424296
p00118
u695154284
1505222884
Python
Python3
py
Runtime Error
0
0
752
import sys d = [(1, 0), (-1, 0), (0, 1), (0, -1)] def dfs(x, y, c): judged[x][y] = True for dx, dy in d: if 0 <= x + dx < H and 0 <= y + dy < W and (not judged[x + dx][y + dy]) and orchard[x + dx][y + dy] == c: dfs(x + dx, y + dy, c) if __name__ == '__main__': while True: H, W = list(map(int, input().split(' '))) if H == 0 and W == 0: break orchard = [input() for i in range(H)] judged = [[False for i in range(W)] for j in range(H)] # print(orchard) ans = 0 for i in range(0, H): for j in range(0, W): if not judged[i][j]: ans += 1 dfs(i, j, orchard[i][j]) print(ans)
s648310386
p00118
u695154284
1505223261
Python
Python3
py
Runtime Error
0
0
749
import sys d = [(1, 0), (-1, 0), (0, 1), (0, -1)] def dfs(x, y, c): judged[x][y] = True for dx, dy in d: if 0 <= x + dx < H and 0 <= y + dy < W and (not judged[x + dx][y + dy]) and orchard[x + dx][y + dy] == c: dfs(x + dx, y + dy, c) if __name__ == '__main__': while True: H, W = list(map(int, input().split())) if H == 0 and W == 0: break orchard = [input() for i in range(H)] judged = [[False for i in range(W)] for j in range(H)] # print(orchard) ans = 0 for i in range(0, H): for j in range(0, W): if not judged[i][j]: ans += 1 dfs(i, j, orchard[i][j]) print(ans)
s778225904
p00118
u695154284
1505223451
Python
Python3
py
Runtime Error
0
0
765
import sys d = [(1, 0), (-1, 0), (0, 1), (0, -1)] def dfs(x, y, c): judged[x][y] = True for dx, dy in d: if 0 <= x + dx < H and 0 <= y + dy < W and (not judged[x + dx][y + dy]) and orchard[x + dx][y + dy] == c: dfs(x + dx, y + dy, c) if __name__ == '__main__': while True: H, W = list(map(int, input().split())) if H == 0 and W == 0: break orchard = [input() for i in range(H)] judged = [[False for i in range(W)] for j in range(H)] # print(orchard) ans = 0 for i in range(0, H): for j in range(0, W): if not judged[i][j]: ans += 1 dfs(i, j, orchard[i][j]) print(ans) input()
s261530839
p00118
u618725557
1509889516
Python
Python3
py
Runtime Error
0
0
603
def infection(i, j): if farm[i][j] == moji: farm[i][j] = '+'; if j + 1 < W : infection(i, j + 1) if i + 1 < H : infection(i + 1, j) if j - 1 >= 0 :infection(i, j - 1) if i - 1 >= 0 :infection(i - 1, j) while(1): farm = [] cnt = 0; H, W = list(map(int, input().split())) if H == 0 and W == 0: break for i in range(H): farm.append(list(input())) for i in range(H): for j in range(W): if farm[i][j] == '+': continue cnt+=1 moji = farm[i][j] infection(i, j) print(cnt)
s214074519
p00118
u618725557
1509889560
Python
Python3
py
Runtime Error
0
0
603
def infection(i, j): if farm[i][j] == moji: farm[i][j] = '+' if j + 1 < W : infection(i, j + 1) if i + 1 < H : infection(i + 1, j) if j - 1 >= 0 :infection(i, j - 1) if i - 1 >= 0 :infection(i - 1, j) while(1): farm = [] cnt = 0 H, W = list(map(int, input().split())) if H == 0 and W == 0: break for i in range(H): farm.append(list(input())) for i in range(H): for j in range(W): if farm[i][j] == '+': continue cnt += 1 moji = farm[i][j] infection(i, j) print(cnt)
s632549410
p00118
u618725557
1509889653
Python
Python3
py
Runtime Error
0
0
603
def infection(i, j): if farm[i][j] == moji: farm[i][j] = '+' if j + 1 < W : infection(i, j + 1) if i + 1 < H : infection(i + 1, j) if j - 1 >= 0 :infection(i, j - 1) if i - 1 >= 0 :infection(i - 1, j) while(1): farm = [] cnt = 0 H, W = list(map(int, input().split())) if H == 0 and W == 0: break for i in range(H): farm.append(list(input())) for i in range(H): for j in range(W): if farm[i][j] == '+': continue cnt += 1 moji = farm[i][j] infection(i, j) print(cnt)
s865775379
p00118
u618725557
1509889899
Python
Python3
py
Runtime Error
0
0
629
def infection(i, j,H, W, moji): if farm[i][j] == moji: farm[i][j] = '+' if j + 1 < W : infection(i, j + 1,H,W,moji) if i + 1 < H : infection(i + 1, j,H,W,moji) if j - 1 >= 0 :infection(i, j - 1,H,W,moji) if i - 1 >= 0 :infection(i - 1, j,H,W,moji) while(1): farm = [] cnt = 0 H, W = list(map(int, input().split())) if H == 0 and W == 0: break for i in range(H): farm.append(list(input())) for i in range(H): for j in range(W): if farm[i][j] == '+': continue cnt += 1 infection(i, j,H,W,moji) print(cnt)
s737578014
p00118
u618725557
1509889912
Python
Python3
py
Runtime Error
0
0
632
def infection(i, j,H, W, moji): if farm[i][j] == moji: farm[i][j] = '+' if j + 1 < W : infection(i, j + 1,H,W,moji) if i + 1 < H : infection(i + 1, j,H,W,moji) if j - 1 >= 0 :infection(i, j - 1,H,W,moji) if i - 1 >= 0 :infection(i - 1, j,H,W,moji) while(True): farm = [] cnt = 0 H, W = list(map(int, input().split())) if H == 0 and W == 0: break for i in range(H): farm.append(list(input())) for i in range(H): for j in range(W): if farm[i][j] == '+': continue cnt += 1 infection(i, j,H,W,moji) print(cnt)
s659556503
p00118
u618725557
1509890106
Python
Python3
py
Runtime Error
0
0
605
def infection(i, j): if farm[i][j] == moji: farm[i][j] = '+' if j + 1 < W : infection(i, j + 1) if i + 1 < H : infection(i + 1, j) if j - 1 >= 0 :infection(i, j - 1) if i - 1 >= 0 :infection(i - 1, j) while True: farm = [] cnt = 0 H, W = list(map(int, input().split())) if H == 0 and W == 0: break for i in range(H): farm.append(list(input())) for i in range(H): for j in range(W): if farm[i][j] == '+': continue cnt += 1 moji = farm[i][j] infection(i, j) print(cnt)
s901289578
p00118
u043254318
1526744858
Python
Python3
py
Runtime Error
0
0
1020
def search(table, visited, i, j, c): visited[i][j] = True if table[i-1][j] == c and visited[i-1][j] == False: search(table, visited, i-1, j, c) if table[i+1][j] == c and visited[i+1][j] == False: search(table, visited, i+1, j, c) if table[i][j-1] == c and visited[i][j-1] == False: search(table, visited, i, j-1, c) if table[i][j+1] == c and visited[i][j+1] == False: search(table, visited, i, j+1, c) return while True: H,W = [int(i) for i in input().split()] if H == 0 and W == 0: break visited = [[False for i in range(W+2)] for j in range(H+2)] table = [["." for i in range(W+2)] for j in range(H+2)] for i in range(1, H+1): s = input() for j in range(1, W+1): table[i][j] = s[j-1] ans = 0 for i in range(1, H+1): for j in range(1, W+1): if visited[i][j] == False: ans = ans + 1 search(table, visited, i, j, table[i][j]) print(ans)
s267399255
p00118
u352394527
1527713967
Python
Python3
py
Runtime Error
0
0
581
while True: h, w = map(int, input().split()) if not h: break mp = [list("X" + input() + "X") for _ in range(h)] mp.insert(0, ["X"] * (w + 2)) mp.append(["X"] * (w + 2)) direct = ((0, 1), (0, -1), (1, 0), (-1, 0)) def search(x, y, target): mp[y][x] = "X" for dx, dy in direct: nx, ny = x + dx, y + dy if mp[ny][nx] == target: search(nx, ny, target) ans = 0 for x in range(1, w + 1): for y in range(1, h + 1): target = mp[y][x] if target != "X": search(x, y, target) ans += 1 print(ans)