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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
s298931944 | p03574 | u692632484 | 1514918691 | Python | Python (3.4.3) | py | Runtime Error | 18 | 2940 | 533 | H,W=[int(i) for i in input().split()]
s=[input() for i in range(H)]
def search(h,w):
if s[h][w]=='#':
return '#'
count=0
for i in range(-1,2):
for j in range(-1,2):
if (i!=0 or j!=0) and 0<=h+i and h+i<H and 0<=w+j and w+j<W: ... |
s497222570 | p03574 | u942788644 | 1514304886 | Python | Python (2.7.6) | py | Runtime Error | 11 | 2696 | 478 | h, w = map(int, raw_input().split())
table = list()
table.append([0]*(w+2))
for _ in xrange(h):
table.append([0]+list(map(lambda c:0 if c == "." else c, list(raw_input())))+[0])
table.append([0]*(w+2))
xy = [0, 1, 0, -1, 1, 1, -1, -1, 0]
for i in xrange(1, h+1):
for j in xrange(1, w+1):
if table[i][j] ... |
s737281383 | p03574 | u863370423 | 1512523924 | Python | Python (3.4.3) | py | Runtime Error | 18 | 2940 | 92 | print(2/0)
# random shit random shit random shit random shit random shit random shit |
s933935426 | p03574 | u019584841 | 1511570395 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 342 | h,w=map(int,input().split())
s=[input() for i in range(h)]
for i in range(h):
for j in range(w):
if s[i][j]=="#":
continue
count=0
for dx in [-1,0,1]:
for dy in [-1,0,1]:
if 0<=i+dy<h and 0<=j+dx<w and s[i+dy][j+dx]=="#":
count+=1
s[i][j]=str(count)
for a in s:... |
s412528262 | p03574 | u165988235 | 1511500748 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 642 | coding:utf-8
H, W = list(map(int, input().split()))
s = []
ans = []
for i in range(H):
s.append(input())
ans.append([])
for i in range(H):
for j in range(W):
if(s[i][j] == "#"):
ans[i].append("#")
continue
ans[i].append(0)
for i in range(H):
for j in range(W):
if... |
s479034522 | p03574 | u019584841 | 1511457325 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 342 | h,w=map(int,input().split())
s=[input() for i in range(h)]
for i in range(h):
for j in range(w):
if s[i][j]=="#":
continue
count=0
for dx in [-1,0,1]:
for dy in [-1,0,1]:
if 0<=i+dy<h and 0<=j+dx<w and s[i+dy][j+dx]=="#":
count+=1
s[i][j]=str(count)
for a in s:... |
s804374524 | p03574 | u370331385 | 1510355553 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3320 | 2215 | a=input().split()
H=int(a[0])
W=int(a[1])
A=[]
B=[]
for i in range(H):
a=input()
a=list(a)
if(i!=H-1):
a.pop()
A.append(a)
for i in range(H):
for j in range(W):
if(A[i][j]=="."):
A[i][j]=0
for i in range(H):
if((i!=0)and(i!=H-1)):
for j in range(W):
if((j!=0)and(j!=W-1)):
i... |
s475284093 | p03574 | u370331385 | 1510354390 | Python | Python (3.4.3) | py | Runtime Error | 20 | 3320 | 2092 | a=input().split()
H=int(a[0])
W=int(a[1])
A=[]
B=[]
for i in range(H):
a=input()
a=list(a)
if(i!=H-1):
a.pop()
A.append(a)
for i in range(H):
for j in range(W):
if(A[i][j]=="."):
A[i][j]=0
for i in range(H):
if((i!=0)and(i!=H-1)):
for j in range(W):
if((j!=0)and(j!=W-1)):
i... |
s677304224 | p03574 | u839537730 | 1509246175 | Python | Python (3.4.3) | py | Runtime Error | 25 | 3188 | 795 | H, W = list(map(int, input().split()))
S = []
for _ in range(H):
S.append(list(input()))
for w in range(W):
if S[0][w] == ".":
S[0][w] = str(S[0][max(0,w-1):min(W, w+2)].count("#")
+S[1][max(0,w-1):min(W, w+2)].count("#"))
for h in range(1, H-1):
for w in range(W):
... |
s153322543 | p03574 | u821262411 | 1509213021 | Python | Python (3.4.3) | py | Runtime Error | 22 | 3316 | 863 | h,w=map(int,input().split())
a=[['.' for x in range(w+2)]]
for i in range(h):
b=list(str(input()))
b= ['.']+b+['.']
a.append(b)
footer=['.' for x in range(w+2)]
a.append(footer)
for i in range(1,w+1):
ans=''
for j in range(1,h+1):
count=0
if a[i][j]=='#':
ans += ... |
s722141220 | p03574 | u207707177 | 1509165580 | Python | Python (3.4.3) | py | Runtime Error | 19 | 3188 | 1363 | HM = input().split()
H, M = [int(HM[i]) for i in range(len(HM))]
#print(H,M)
S = [input().split() for i in range(H)]
#print(S)
#print(S[0][1])
S2 = S
def minesweeper():
for i in range(H):
for j in range(M):
if S[i][j] == '.':
C = count(i,j)
S2[i][j] = C
for i... |
s004538638 | p03574 | u185099392 | 1508973389 | Python | Python (3.4.3) | py | Runtime Error | 36 | 3064 | 570 | h, w = map(int, input().split())
m = []
for i in range(h):
l = list(input())
m.append([ '#' if i=='#' else 0 for i in l])
for i in range(h):
for j in range(w):
if m[i][j] == '#':
for u in range(3):
for v in range(3):
if u==1 and v==1:
... |
s586908973 | p03574 | u519078363 | 1508716010 | Python | Python (3.4.3) | py | Runtime Error | 19 | 3064 | 395 | def check(t):
return 1 if t is '#' else 0
def main(H, W, S):
for i in range(H):
for j in range(W):
if S[i][j] is '.':
S[i][j] = check(S[i][max(j-1, 0)]) + check(S[i][min(j+1, W-1)]) + check(S[max(i-1, 0)][j]) + check(S[min(i+1, H-1)][j])
return S
H, W = map(int, in... |
s592138979 | p03574 | u519078363 | 1508715827 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 388 | def check(t):
return 1 if t is '#' else 0
def main(H, W, S):
for i in range(H):
for j in range(W):
if S[i][j] is '.':
S[i][j] = check(S[i][max(j-1, 0)]) + check(S[i][min(j+1, W-1)]) + check(S[max(i-1, 0)][j]) + check(S[min(i+1, H-1)][j])
return S
H, W = map(int, in... |
s186108577 | p03574 | u959470438 | 1508620447 | Python | Python (3.4.3) | py | Runtime Error | 30 | 3064 | 578 | W, H = map(int, input().split())
src = [input() for i in range(H)]
ans = []
for row in src:
ans.append(list(row))
dxy = [(-1, -1), (-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1)]
for y in range(H):
for x in range(W):
if src[y][x] == '#':
continue
c = 0
for dx, ... |
s109450710 | p03574 | u239375815 | 1508564121 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 516 | H,W=map(int,input().split())
S = [ int(input()) for _ in range(H)]
for i in range(H):
for j in range(W):
if S[i][j]=='#':
continue
for h in range(H):
l = ''
for w in range(W):
if S[h][w] == '#':
l += '#'
else:
x = 0
for dh in [ -1, 0,... |
s152244222 | p03574 | u866949333 | 1508529979 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 442 | a = [int(i) for i in input().split()]
h = a[0]
w = a[1]
table = [i for i in range(h)]
for i in range(w):
table[i] = input()
for i in range(h):
for j in range(w):
if table[i][j] == '.':
c = 0
for k in [i-1, i, i+1]:
for l in [j-1, j, j+1]:
if ... |
s253804089 | p03574 | u866949333 | 1508529749 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 1129 | a = [int(i) for i in input().split()]
h = a[0]
w = a[1]
table = [i for i in range(h)]
for i in range(w):
table[i] = input()
for i in range(h):
for j in range(w):
if table[i][j] == '.':
c=0
if table[i - 1][j - 1] == '#' and 0 <= i - 1 < h and 0 <= j - 1 < w:
c +=... |
s977951897 | p03574 | u761320129 | 1508131054 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 507 | H,W = map(int,input().split())
src = [input() for i in range(H)]
ans = []
for row in src:
ans.append(list(row))
dxy = [(-1,-1),(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(-1,0)]
for y in range(H):
for x in range(W):
if src[y][x] == '#': continues
c = 0
for dx,dy in dxy:
if x+dx... |
s162492606 | p03574 | u761320129 | 1508130782 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3192 | 507 | H,W = map(int,input().split())
src = [input() for i in range(H)]
ans = []
for row in src:
ans.append(list(row))
dxy = [(-1,-1),(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(-1,0)]
for y in range(H):
for x in range(W):
if src[y][x] == '#': continues
c = 0
for dx,dy in dxy:
if x+dx... |
s710415094 | p03574 | u667084803 | 1508127216 | Python | Python (3.4.3) | py | Runtime Error | 24 | 3448 | 2884 | H,W=map(int,input().split())
S=[[] for i in range(H)]
for i in range(H):
S[i]=list(str(input()))
ans=[[] for i in range(H)]
for i in range(H):
for j in range(W):
if i==0:
if j==0:
bomb=0
if S[i+1][j]=="#": bomb+=1
if S[i][j+1]=="#": bomb+=1
if S[i+1][j+1]=="#": bomb+=1
... |
s264862481 | p03574 | u667084803 | 1508127134 | Python | Python (3.4.3) | py | Runtime Error | 24 | 3448 | 2884 | H,W=map(int,input().split())
S=[[] for i in range(H)]
for i in range(H):
S[i]=list(str(input()))
ans=[[] for i in range(H)]
for i in range(H):
for j in range(W):
if i==0:
if j==0:
bomb=0
if S[i+1][j]=="#": bomb+=1
if S[i][j+1]=="#": bomb+=1
if S[i+1][j+1]=="#": bomb+=1
... |
s464203299 | p03574 | u482770395 | 1508037949 | Python | Python (3.4.3) | py | Runtime Error | 23 | 3448 | 4623 | H, W = map(int, input().split())
S = []
T = []
for i in range(H):
S.append(input())
T.append([0 for j in range(W)])
if H == 1 and W == 1:
if S[0][0] == "#":
T[0][0] = "#"
else:
T[0][0] = 0
elif H == 1:
for j in range(W):
if S[0][j] == "#":
T[0][j] = "#"
el... |
s109825003 | p03574 | u499259667 | 1508034959 | Python | Python (3.4.3) | py | Runtime Error | 1323 | 16936 | 1079 | import numpy as np
H, W = map(int, input().split())
arr=np.array([])
s=0
while s != H:
li=list(input())
li=np.array(li)
arr=np.hstack((arr,li))
s+=1
arr=arr.reshape((H,W))
count=0
def check(x,y):
global count
if arr[x,y] == "#":
count+=1
for x in range(H):
stri=""
for y in range(W):
... |
s011673890 | p03574 | u498631675 | 1508034895 | Python | Python (2.7.6) | py | Runtime Error | 14 | 2824 | 1399 | # -*- coding: utf-8 -*-
#from collections import Counter
H, W = map(int, raw_input().split())
s = []
for i in xrange(H):
s.append(map(str, raw_input()))
for i in xrange(H):
line = ''
for j in xrange(W):
if s[i][j] == '#':
line+= '#'
elif i == 0:
if j == 0:
... |
s855340603 | p03574 | u498631675 | 1508034637 | Python | Python (2.7.6) | py | Runtime Error | 13 | 2824 | 1383 | # -*- coding: utf-8 -*-
#from collections import Counter
H, W = map(int, raw_input().split())
s = []
for i in xrange(H):
s.append(map(str, raw_input()))
for i in xrange(H):
line = ''
for j in xrange(W):
if s[i][j] == '#':
line+= '#'
elif i == 0:
if j == 0:
... |
s107663261 | p03574 | u499259667 | 1508034475 | Python | Python (2.7.6) | py | Runtime Error | 733 | 13832 | 1081 | import numpy as np
H, W = map(int, raw_input().split())
arr=np.array([])
s=0
while s != H:
li=list(raw_input())
li=np.array(li)
arr=np.hstack((arr,li))
s+=1
arr=arr.reshape((H,W))
count=0
def check(x,y):
global count
if arr[x,y] == "#":
count+=1
for x in range(H):
stri=""
for y in ran... |
s822583701 | p03574 | u499259667 | 1508034228 | Python | Python (2.7.6) | py | Runtime Error | 400 | 12328 | 1094 | import numpy as np
H, W = map(int, raw_input().split())
arr=np.array([])
s=0
while s != H:
li=list(raw_input())
li=np.array(li)
arr=np.hstack((arr,li))
s+=1
arr=arr.reshape((H,W))
count=0
def check(x,y):
import __main__
if arr[x,y] == "#":
__main__.count+=1
for x in range(H):
stri=""
... |
s604151286 | p03574 | u482770395 | 1508033966 | Python | Python (3.4.3) | py | Runtime Error | 25 | 3704 | 4624 | H, W = map(int, input().split())
S = []
T = []
for i in range(H):
S.append(input())
T.append([0 for j in range(W)])
if H == 1 and W == 1:
if S[0][0] == "#":
T[0][0] = "#"
else:
T[0][0] = 0
elif H == 1:
for j in range(W):
if S[0][j] == "#":
T[0][j] = "#"
el... |
s385730428 | p03574 | u499259667 | 1508033922 | Python | Python (2.7.6) | py | Runtime Error | 718 | 13580 | 1126 | import numpy as np
H, W = map(int, raw_input().split())
arr=np.array([])
s=0
while s != H:
li=list(raw_input())
li=np.array(li)
arr=np.hstack((arr,li))
s+=1
arr=arr.reshape((H,W))
count=0
def check(x,y):
import __main__
if arr[x,y] == "#":
__main__.count+=1
for x in range(H):
for y in ra... |
s111068825 | p03574 | u136090046 | 1508033712 | Python | Python (3.4.3) | py | Runtime Error | 22 | 3320 | 2989 | def calc(array, i, j):
ret = 0
if i == 0 and j == 0:
if array[1][0] == "#":
ret += 1
if array[0][1] == "#":
ret += 1
if array[1][1] == "#":
ret += 1
return ret
if i == 0 and j == len(array[0])-1:
if array[i][j-1] == "#":
... |
s197214558 | p03574 | u136090046 | 1508033498 | Python | Python (3.4.3) | py | Runtime Error | 23 | 3320 | 2986 | def calc(array, i, j):
ret = 0
if i == 0 and j == 0:
if array[1][0] == "#":
ret += 1
if array[0][1] == "#":
ret += 1
if array[1][1] == "#":
ret += 1
return ret
if i == 0 and j == len(array[0])-1:
if array[i][j-1] == "#":
... |
s577530552 | p03574 | u482770395 | 1508033424 | Python | Python (3.4.3) | py | Runtime Error | 25 | 3732 | 4296 | H, W = map(int, input().split())
S = []
T = []
for i in range(H):
S.append(input())
T.append([0 for j in range(W)])
if H == 1 and W == 1:
if S[0][0] == "#":
T[0][0] = "#"
else:
T[0][0] = 0
elif H == 1:
for j in range(W):
if S[0][j] == "#":
T[0][j] = "#"
el... |
s469309039 | p03574 | u104922648 | 1508033263 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3056 | 98 | h, w = input().split()
for i in range(int(h)):
row = [input() for i in range(int(w))]
print(row) |
s076563835 | p03574 | u141828885 | 1508033143 | Python | Python (3.4.3) | py | Runtime Error | 24 | 3064 | 1092 | def main():
b = []
line = input().split(" ")
H = int(line[0])
W = int(line[1])
for l in range(H):
b.append(input())
result = []
for i, line in enumerate(b):
result_row = ""
for j, c in enumerate(line):
if c == ".":
n = count(i, j, b, H, W)... |
s456172217 | p03574 | u190525112 | 1508033054 | Python | Python (3.4.3) | py | Runtime Error | 28 | 3668 | 2563 |
x = list(map(int, input().split()))
k = [list(map(str, input())) for i in range(x[0])]
def check(i,j,k):
if k[i][j]=='#':
return '#'
count=0
if i==0 and j==0:
for ii in range(0,2):
for jj in range(0,2):
if ii==0 and jj==0:
continue
... |
s579116369 | p03574 | u482770395 | 1508032386 | Python | Python (3.4.3) | py | Runtime Error | 25 | 3684 | 3575 | H, W = map(int, input().split())
S = []
T = []
for i in range(H):
S.append(input())
T.append([0 for j in range(W)])
for i in range(H):
for j in range(W):
if S[i][j] == "#":
T[i][j] = "#"
elif S[i][j] == ".":
if i == 0 and j == 0:
if S[i + 1][j] == "#":... |
s741672018 | p03574 | u233747425 | 1508032139 | Python | Python (3.4.3) | py | Runtime Error | 28 | 3344 | 2388 | H, W = map(int, input().split())
S = {}
for _ in range(H):
S[_] = input()
def change(S_str, x, j):
s_list = list(S_str)
s_list[j] = str(x.count('#'))
S_str = "".join(s_list)
return S_str
for i in range(H):
for j in range(W):
s = S[i][j]
if s == '.':
if H == 1 an... |
s421111015 | p03574 | u785205215 | 1508031716 | Python | Python (3.4.3) | py | Runtime Error | 79 | 3816 | 1218 | from sys import stdin, stdout
from collections import defaultdict
def readLine_str_list():return list(map(str, stdin.readline().split()))
def readLine_int_list():return list(map(int, stdin.readline().split()))
def readAll_str(): return list(list(map(str,i.split())) for i in stdin.read().split("\n"))
def g_twoD_list(p,q... |
s815330442 | p03574 | u233747425 | 1508031631 | Python | Python (3.4.3) | py | Runtime Error | 28 | 3192 | 1671 | H, W = map(int, input().split())
S = {}
for _ in range(H):
S[_] = input()
def change(S_str, x, j):
s_list = list(S_str)
s_list[j] = str(x.count('#'))
S_str = "".join(s_list)
return S_str
for i in range(H):
for j in range(W):
s = S[i][j]
if s == '.':
if i == 0 an... |
s966372956 | p03574 | u425448230 | 1508031230 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 839 | H, W = map(int,input().split())
S = [[]]
for h in range(H):
S.append([])
S[-1] = list(input())#.split()
del S[0]
for i in range(H):
for j in range(W):
if S[i][j] == '.': S[i][j] = 0
if S[i][j] == '#': S[i][j] = -100
for i in range(H):
for j in range(W):
if S[i][j] < 0:
... |
s222454442 | p03574 | u676264453 | 1508030882 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 586 | def get_bomb_num(i, j):
cnt = 0
for p in range(-1,2):
for s in range(-1,2):
l = i + p
m = j + s
----
if (p == 0 and s == 0) or (l < 0) or (l >= H) or (m < 0) or (m >= W):
continue--
if b[l][m] == '#':
cnt += 1
return cnt... |
s133199681 | p03574 | u106342872 | 1508030759 | Python | Python (3.4.3) | py | Runtime Error | 24 | 3708 | 3823 | #! -*- coding:utf-8 -*-
h,w = map(int,input().split())
S = []
for i in range(h):
S.append(str(input()))
arr = [[]*w]*h
for i in range(h):
arr[i] = list(S[i])
for i in range(h):
for j in range(w):
if arr[i][j] == '#':
print('#',sep = '', end = '')
else:
if i == 0 and... |
s912351781 | p03574 | u497285470 | 1508030621 | Python | Python (3.4.3) | py | Runtime Error | 23 | 3064 | 656 | inputs = input().split()
H = int(inputs[0])
W = int(inputs[1])
grid = []
grid.append('.'*W+'..')
for i in range(H):
inputs = input().strip()
inputs = '.' + inputs + '.'
grid.append(inputs)
grid.append('.'*W+'..')
dx = [1,1,1,0,-1,-1,-1,0]
dy = [1,0,-1,-1,-1,0,1,1]
ans = [[0 for x in range(W)] for y in ... |
s278029408 | p03575 | u289288647 | 1600298048 | Python | Python (3.8.2) | py | Runtime Error | 53 | 9620 | 797 | import queue
n, m = map(int, input().split())
route = [[] for _ in range(n)]
vals = []
for _ in range(m):
a, b = map(int, input().split())
route[a-1].append(b-1)
route[b-1].append(a-1)
vals.append([a-1, b-1])
ans = m
for i in range(m):
route2 = set()
q = queue.Queue()
q.put(i)
try:
... |
s956977505 | p03575 | u289288647 | 1600297881 | Python | Python (3.8.2) | py | Runtime Error | 49 | 9588 | 692 | import queue
n, m = map(int, input().split())
route = [[] for _ in range(n)]
vals = []
for _ in range(m):
a, b = map(int, input().split())
route[a-1].append(b-1)
route[b-1].append(a-1)
vals.append([a-1, b-1])
ans = m
for i in range(m):
route2 = set()
q = queue.Queue()
q.put(i)
route[vals... |
s931753548 | p03575 | u043844098 | 1599626162 | Python | Python (3.8.2) | py | Runtime Error | 32 | 10260 | 777 | from typing import List, Tuple
def main():
n, m = map(int, input().split())
g = []
for _ in range(m):
a, b = map(int, input().split())
g.append((a, b))
print(b(n, m, g))
def b(n: int, m: int, g: List[Tuple[int, int]]):
ret = 0
for i in range(m):
v = set()
w = ... |
s650517914 | p03575 | u043844098 | 1599626017 | Python | Python (3.8.2) | py | Runtime Error | 35 | 10272 | 796 | from typing import List, Tuple
def main():
n, m = map(int, input().split())
g = []
for _ in range(m):
a, b = map(int, input().split())
g.append((a, b))
print(b(n, m, g))
def b(n: int, m: int, g: List[Tuple[int, int]]):
ret = 0
for i in range(m):
v = set()
w = ... |
s533593376 | p03575 | u208713671 | 1599187445 | Python | PyPy3 (7.3.0) | py | Runtime Error | 158 | 73968 | 1490 | class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def union(self, x, y):
x = ... |
s000533470 | p03575 | u576432509 | 1597173453 | Python | Python (3.8.2) | py | Runtime Error | 29 | 9256 | 679 | import sys
sys.setrecursionlimit(10**9)
n,m=map(int,input().split())
pair=[i for i in range(n)]
a=[0]*n
b=[0]*n
for i in range(m):
ai,bi=map(int,input().split())
a[i]=ai-1
b[i]=bi-1
def root(x):
if x==pair[x]:
return x
else:
tmp=root(pair[x])
pair[x]=tmp
return ... |
s216860666 | p03575 | u576432509 | 1597173275 | Python | Python (3.8.2) | py | Runtime Error | 26 | 9192 | 679 | import sys
sys.setrecursionlimit(10**8)
n,m=map(int,input().split())
pair=[i for i in range(n)]
a=[0]*n
b=[0]*n
for i in range(m):
ai,bi=map(int,input().split())
a[i]=ai-1
b[i]=bi-1
def root(x):
if x==pair[x]:
return x
else:
tmp=root(pair[x])
pair[x]=tmp
return ... |
s082228931 | p03575 | u576432509 | 1597173215 | Python | Python (3.8.2) | py | Runtime Error | 33 | 9284 | 679 | import sys
sys.setrecursionlimit(10**7)
n,m=map(int,input().split())
pair=[i for i in range(n)]
a=[0]*n
b=[0]*n
for i in range(m):
ai,bi=map(int,input().split())
a[i]=ai-1
b[i]=bi-1
def root(x):
if x==pair[x]:
return x
else:
tmp=root(pair[x])
pair[x]=tmp
return ... |
s060179314 | p03575 | u576432509 | 1597173145 | Python | Python (3.8.2) | py | Runtime Error | 36 | 9260 | 679 | import sys
sys.setrecursionlimit(10**6)
n,m=map(int,input().split())
pair=[i for i in range(n)]
a=[0]*n
b=[0]*n
for i in range(m):
ai,bi=map(int,input().split())
a[i]=ai-1
b[i]=bi-1
def root(x):
if x==pair[x]:
return x
else:
tmp=root(pair[x])
pair[x]=tmp
return ... |
s576839178 | p03575 | u282860613 | 1596481773 | Python | PyPy3 (7.3.0) | py | Runtime Error | 87 | 74900 | 1197 | from heapq import heappush, heappop, heappushpop, heapreplace, heapify
n, e = map(int, input().split())
#edge_listに各辺の情報を格納する
edge_list = [[] for i in range(n)]
for _ in range(e):
s, t, u = map(int, input().split())
edge_list[s].append([u, t])
edge_list[t].append([u, s])
#隣接行列及びスタートを与えると、各頂点までの最短経路を算出するダイ... |
s503057999 | p03575 | u065099501 | 1595306310 | Python | Python (3.8.2) | py | Runtime Error | 28 | 9132 | 362 |
n,m = map(int,input().split())
dic={}
ans=[]
for _ in range(m):
a,b,=input().split()
dic.setdefault(a,[]).append(b)
ans.append((a,b))
for k,v in dic.items():
for i in v:
for j in dic.get(i,[]):
if j in v:
ans.remove((k,i))
ans.remove((k,j))
... |
s467308804 | p03575 | u946969297 | 1595093230 | Python | Python (3.8.2) | py | Runtime Error | 26 | 8868 | 1297 | import times, strutils, sequtils, math, algorithm, tables, sets, lists, intsets
import critbits, future, strformat, deques
template `max=`(x,y) = x = max(x,y)
template `min=`(x,y) = x = min(x,y)
let read* = iterator: string {.closure.} =
while true: (for s in stdin.readLine.split: yield s)
proc scan(): int = read()... |
s936167965 | p03575 | u885634168 | 1594427802 | Python | PyPy3 (7.3.0) | py | Runtime Error | 94 | 74484 | 1074 | N, M = list(map(int,input().split()))
graph = [[-1 for i in range(N)] for i in range(N)]
in_list = []
for i in range(M):
in_list.append([a, b])
a, b = list(map(int,input().split()))
graph[a - 1][b - 1] = 1
graph[b - 1][a - 1] = 1
# 頂点 node を含む連結成分が木なら 1 を返す
def dfs(node, parent):
ret = 1
gl... |
s485856247 | p03575 | u367701763 | 1594365272 | Python | PyPy3 (7.3.0) | py | Runtime Error | 87 | 74520 | 4834 | #####################################################################################################
##### Low Link (橋、関節点)
#####################################################################################################
"""
計算量
O(V+E)
参考
https://algo-logic.info/bridge-lowlink/
"""
import sys
input = sys.... |
s789642216 | p03575 | u020604402 | 1592879708 | Python | PyPy3 (7.3.0) | py | Runtime Error | 95 | 74884 | 603 | N,M = map(int,input().split())
path = [[] for _ in range(N)]
save = []
for _ in range(M):
a,b = map(int,input().split())
save.append([a-1,b-1])
path[b-1].append(a-1)
path[a-1].append(b-1)
def dfs(now):
if not 0 in vis:
cnt += 1
return None
for new in path[now]:
if vis[... |
s391332177 | p03575 | u201387466 | 1592787351 | Python | Python (3.8.2) | py | Runtime Error | 42 | 10596 | 1676 | import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bise... |
s296699901 | p03575 | u201387466 | 1592787074 | Python | Python (3.8.2) | py | Runtime Error | 50 | 10556 | 1634 | import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bise... |
s138380852 | p03575 | u201387466 | 1592787008 | Python | Python (3.8.2) | py | Runtime Error | 46 | 10572 | 1634 | import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bise... |
s098619821 | p03575 | u587589241 | 1592767718 | Python | Python (3.8.2) | py | Runtime Error | 24 | 9232 | 1210 | class UnionFind:
def __init__(self, n):
self.nodes=n
self.parents = [i for i in range(n)]
self.sizes = [1] * n
self.rank = [0] * n
def find(self, i):
if self.parents[i] == i:
return i
else:
self.parents[i] = self.find(self.parents[i]) # 経路... |
s513641320 | p03575 | u367701763 | 1592579524 | Python | PyPy3 (7.3.0) | py | Runtime Error | 82 | 74664 | 1081 | # https://atcoder.jp/contests/abc075/tasks/abc075_c?lang=ja
class UnionFind():
def __init__(self,n):
self.n = n
self.parents = [-1]*n
def sequence(self,x,res):
if self.parents[x] < 0:
res.append(x)
return res
res.append(x)
self.sequence(self.pare... |
s773661768 | p03575 | u277236383 | 1592086590 | Python | Python (3.4.3) | py | Runtime Error | 27 | 3064 | 567 |
def solve(pos):
for i in range(m):
if line[pos][i] == 1 and reach[i] == 0:
reach[i] = 1
solve(i)
return
n, m = list(map(int, input().split()))
line = [[0]*n for i in range(n)]
ms = []
for i in range(m):
a, b = list(map(int, input().split()))
line[a-1][b-1]=1
line[b-1][a-1]=1
ms.append([a, ... |
s171652301 | p03575 | u805011545 | 1591770370 | Python | Python (3.4.3) | py | Runtime Error | 201 | 12520 | 1090 | import numpy as np
import sys
import itertools
def DFS(g, ab):
g[ab[0]-1][ab[1]-1] = 0
g[ab[1]-1][ab[0]-1] = 0
seen = np.zeros((M))
seen[ab[0]-1] = 1
todo = list([i+1 for i, x in enumerate(g[ab[0]-1]) if(int(x)==1)])
if(len(todo)!=0):
while(len(todo)!=0):
n_todo = list()
for i in rang... |
s463724340 | p03575 | u805011545 | 1591769989 | Python | Python (3.4.3) | py | Runtime Error | 200 | 12520 | 1078 | import numpy as np
import sys
import itertools
def DFS(g, ab):
g[ab[0]-1][ab[1]-1] = 0
g[ab[1]-1][ab[0]-1] = 0
seen = np.zeros((M))
seen[ab[0]-1] = 1
todo = list([i+1 for i, x in enumerate(g[ab[0]-1]) if(int(x)==1)])
if(len(todo)!=0):
while(len(todo)!=0):
n_todo = list()
for i in rang... |
s862297414 | p03575 | u146597538 | 1591502639 | Python | Python (3.4.3) | py | Runtime Error | 26 | 3064 | 1009 | n, m = map(int, input().split())
edges = [[0 for _ in range(n+1)] for _ in range(n+1)]
for _ in range(m):
a,b = map(int, input().split())
edges[a-1][b-1] = 1
edges[b-1][a-1] = 1
def dfs(start):
if visited[start]:
return
visited[start] = 1
for i in range(n):
if edges[start][i]:
... |
s087001337 | p03575 | u146597538 | 1591502000 | Python | Python (3.4.3) | py | Runtime Error | 26 | 3192 | 1006 | n, m = map(int, input().split())
edges = [[0 for _ in range(n)] for _ in range(n)]
for i in range(m):
a,b = map(int, input().split())
edges[a-1][b-1] = 1
edges[b-1][a-1] = 1
def dfs(start):
if visited[start]:
return
visited[start] = 1
for i in range(n):
if edges[start][i]:
... |
s044248902 | p03575 | u726872801 | 1591492813 | Python | Python (3.4.3) | py | Runtime Error | 29 | 4208 | 1090 | import collections
import queue
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy
N, M = map(int, input().split())
X, Y = [0... |
s865792703 | p03575 | u726872801 | 1591492603 | Python | Python (3.4.3) | py | Runtime Error | 29 | 4200 | 1060 | import collections
import queue
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy
N, M = map(int, input().split())
X, Y = [0... |
s660522776 | p03575 | u726872801 | 1591492594 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 206 | /Users/a13937/Documents/workplace/atcoder-practice/venv/bin/python /Users/a13937/Documents/workplace/atcoder-practice/src/main/scala/abc075/C.py
6 5
1 2
2 3
3 4
4 5
5 6
5
Process finished with exit code 0
|
s367093442 | p03575 | u726872801 | 1591491958 | Python | Python (3.4.3) | py | Runtime Error | 45 | 4208 | 981 | import queue
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy
N, M = map(int, input().split())
X, Y = [0] * N, [0] * N
g = ... |
s839960835 | p03575 | u726872801 | 1591491734 | Python | Python (3.4.3) | py | Runtime Error | 43 | 4208 | 977 | import queue
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy
N, M = map(int, input().split())
X, Y = [0] * N, [0] * N
g = ... |
s238518034 | p03575 | u163783894 | 1590122247 | Python | PyPy3 (2.4.0) | py | Runtime Error | 192 | 41200 | 1863 | # import sys
# import math
# import itertools
# from collections import deque
# from collections import defaultdict
# import heapq
# import copy
# import bisect
# import numpy as np
# from scipy.special import comb
# def my_input(): return sys.stdin.readline().rstrip()
class UnionFind():
def __init__(self, n):
... |
s060433051 | p03575 | u103902792 | 1589921570 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 425 | n,m = map(int,input().split())
graph = {i+1:[] for i in range(1,n+1)}
for _ in range(m):
a,b = map(int,input().split())
graph[a].append(b)
graph[b].append(a)
bridge = set([])
ans = 0
while 1:
count = 0
for i in range(1,n+1):
if len(graph[i]) == 1:
count += 1
a = graph[i]
graph[a].re... |
s176489256 | p03575 | u802963389 | 1589762086 | Python | Python (3.4.3) | py | Runtime Error | 23 | 3436 | 716 | # C - Bridge
# https://atcoder.jp/contests/abc075/tasks/abc075_c
from collections import deque
def dfs(start, graph):
visited = [False] * n
stack = deque()
stack.append(start)
visited[start] = True
while stack:
q = stack.popleft()
nxts = graph[q]
for nxt in nxts:
if not visited[nxt]:
... |
s259263774 | p03575 | u802963389 | 1589761809 | Python | Python (3.4.3) | py | Runtime Error | 23 | 3316 | 696 | # C - Bridge
# https://atcoder.jp/contests/abc075/tasks/abc075_c
from collections import deque
def dfs(pos):
visited = [False] * n
stack = deque()
stack.append(pos)
visited[pos] = True
while stack:
q = stack.popleft()
nxts = graph[q]
for nxt in nxts:
if not visited[nxt]:
visited[nx... |
s411505659 | p03575 | u802963389 | 1589761704 | Python | Python (3.4.3) | py | Runtime Error | 22 | 3316 | 690 | # C - Bridge
# https://atcoder.jp/contests/abc075/tasks/abc075_c
from collections import deque
def dfs(i):
visited = [False] * n
stack = deque()
stack.append(i)
visited[i] = True
while stack:
q = stack.popleft()
nxts = graph[q]
for nxt in nxts:
if not visited[nxt]:
visited[nxt] = T... |
s540293292 | p03575 | u802963389 | 1589761160 | Python | Python (3.4.3) | py | Runtime Error | 23 | 3316 | 670 | # C - Bridge
# https://atcoder.jp/contests/abc075/tasks/abc075_c
from collections import deque
def dfs(i):
visited = [False] * n
stack = deque()
stack.append(i)
while stack:
q = stack.popleft()
nxts = graph[q]
for nxt in nxts:
if not visited[nxt]:
visited[nxt] = True
stack.ap... |
s502748922 | p03575 | u919730120 | 1589745994 | Python | PyPy3 (2.4.0) | py | Runtime Error | 189 | 40304 | 865 | def resolve():
n,m = map(int,input().split())
ab=[list(map(int,input().split())) for _ in range(m)]
cnt=0
for i in range(n):
edge = [[] for i in range(n)]
for j in range(n):
if j==i:
continue
else:
edge[ab[j][0]-1].append(ab[j][1]-1... |
s035466174 | p03575 | u252828980 | 1589722668 | Python | PyPy3 (2.4.0) | py | Runtime Error | 169 | 38256 | 599 | from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
from copy import deepcopy
n,m = map(int,input().split())
inf = float("inf")
L = [[inf for i in range(n)] for j in range(n)]
for i in range(m):
a,b = map(int,input().split())
L[a-1][b-1] = 1
L[b-1][a-1] = 1
#prin... |
s972941931 | p03575 | u678167152 | 1589606128 | Python | Python (3.4.3) | py | Runtime Error | 22 | 3064 | 1289 | class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def union(self, x, y):
x = self... |
s303661799 | p03575 | u678167152 | 1589606121 | Python | PyPy3 (2.4.0) | py | Runtime Error | 198 | 40944 | 1289 | class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def union(self, x, y):
x = self... |
s592462197 | p03575 | u638282348 | 1589482657 | Python | Python (3.4.3) | py | Runtime Error | 242 | 17048 | 410 | from scipy.sparse import coo_matrix, csgraph
N, M = map(int, input().split())
points = tuple(tuple(map(lambda n: int(n) - 1, input().split())) for _ in range(M))
matrix = coo_matrix(([1] * M, zip(*points)), shape=(N, N)).toarray()
total = 0
for point in points:
matrix[point] = 0
total += csgraph.connected_compo... |
s712678302 | p03575 | u344813796 | 1589415503 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 386 | #Nはノード数、Mはエッジ数
n,m = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(m)]
cnt=0
for x in ab:
ls=list(range(n))
for y in ab:
if y !=x:
for i in range(n)
ls=[ls[y[0]-1] if ls[i]==ls[y[1]-1] else ls[i] for i in range(n)] #bの値を根っこ(低い方a)にする
if len(set(ls)) !=1:
cn... |
s273670080 | p03575 | u127499732 | 1589400137 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 528 | def main():
n, m, *ab = map(int, open(0).read().split())
e = [set() for _ in range(n)]
for u, v in zip(*[iter(ab)] * 2):
e[u - 1].add(v - 1)
e[v - 1].add(u - 1)
ans = 0
for _ in range(m):
count = 0
for i, x in enumerate(e):
if len(x) == 1:
... |
s520807631 | p03575 | u054556734 | 1589371808 | Python | Python (3.4.3) | py | Runtime Error | 153 | 12448 | 557 | import numpy as np
def dfs(v1):
if all(visited): return 1
visited[v1] = 1
for v2 in range(n):
if graph[v1][v2] == 0: continue
if visited[v2] == 1: continue
dfs(v2)
return 0
# nは頂点の数
n, m = MI()
ab = np.array([list(map(int,input().split()))])
a,b = ab.T[0]-1,ab.T[1]-1
#隣接行列
grap... |
s305742982 | p03575 | u288430479 | 1588779832 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 447 | n,m = map(int,input().split())
l = list([] for _ in range(m+1))
li = list(list(map(int,input().split())) for _ in range(m))
bridge = 0
for a,b in li:
l[a].append(b)
l[b].append(a)
for a,b in li:
if len(l[a])==1 or len(l[b])==1:
bridge += 1
elif len(l[a])==2 :
c,d = l[a]
if len(l[c])==1 or len(l[d])=... |
s719515591 | p03575 | u390727364 | 1588635128 | Python | Python (3.4.3) | py | Runtime Error | 24 | 3064 | 929 | from sys import stdin
def dfs(g, v, visited):
visited[v] = True
for v2 in range(len(visited)):
if not g[v][v2]:
continue
if visited[v2]:
continue
dfs(g, v2, visited)
def main():
n, m = map(int, stdin.readline().split())
ab = [list(map(int, stdin.readl... |
s633030651 | p03575 | u390727364 | 1588634803 | Python | Python (3.4.3) | py | Runtime Error | 25 | 3188 | 901 | from sys import stdin
def dfs(g, v, visited):
visited[v] = True
for v2 in range(len(visited)):
if (not g[v][v2]) or visited[v2]:
continue
dfs(g, v2, visited)
def main():
n, m = map(int, stdin.readline().split())
ab = [list(map(int, stdin.readline().split())) for _ in ran... |
s478011172 | p03575 | u707124227 | 1588538662 | Python | PyPy3 (2.4.0) | py | Runtime Error | 174 | 38640 | 672 | from collections import deque
n,m=map(int,input().split())
ab=[list(map(int,input().split())) for _ in range(m)]
g=[[]for _ in range(n)]
for a,b in ab:
g[a-1].append(b-1)
g[b-1].append(a-1)
def bfs(i,j):# iからjへのルートの数が2本以上あるかどうか。
seen=[[-1]for _ in range(n)]
seen[i]=[]
todo=deque([[i]])
c=0
while len(tod... |
s714815811 | p03575 | u475675023 | 1587245867 | Python | Python (3.4.3) | py | Runtime Error | 27 | 3064 | 703 | n,m=map(int,input().split())
ab=[list(map(int,input().split())) for _ in range(m)]
graph=[[0 for _ in range(m)] for _ in range(m)]
for i in range(m):
graph[ab[i][0]-1][ab[i][1]-1]=1
graph[ab[i][1]-1][ab[i][0]-1]=1
visited=[0 for _ in range(m)]
def dfs(v):
visited[v]=1
for v2 in range(n):
if graph[v][v2]==0... |
s259308578 | p03575 | u281610856 | 1587228534 | Python | PyPy3 (2.4.0) | py | Runtime Error | 173 | 38256 | 1285 | from heapq import heappush, heappop
from itertools import permutations, accumulate, combinations
import math
import bisect
import numpy as np
from collections import defaultdict, deque
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
# MOD = 10 ** 9 + 7
INF = float("inf")
def dijkstra(s, n, graph):
... |
s468207116 | p03575 | u083960235 | 1587050596 | Python | Python (3.4.3) | py | Runtime Error | 55 | 3956 | 1478 | import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_upper... |
s993241328 | p03575 | u083960235 | 1587050478 | Python | Python (3.4.3) | py | Runtime Error | 53 | 3956 | 1463 | import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_upper... |
s525042036 | p03575 | u703214333 | 1586967743 | Python | PyPy3 (2.4.0) | py | Runtime Error | 185 | 38384 | 1429 | class UnionFind:
def __init__(self,n):
#par[x]==xならxというノードが根。xに親がいない
self.par = [i for i in range(n+1)]
self.rank = [0]*(n+1)
def find(self,x): #xの根を検索
#xが根ならxを返す
if self.par[x] == x:
return x
else:
self.par[x] = self.find(self.par[x]) #パス圧... |
s300136519 | p03575 | u978178314 | 1586864387 | Python | PyPy3 (2.4.0) | py | Runtime Error | 809 | 391452 | 943 | class UnionFind:
def __init__(self, n):
self.parents = list(range(n))
self.ranks = [1 for _ in range(n)]
def parent(self, x):
if x == self.parents[x]:
return x
else:
p = self.parent(self.parents[x])
self.parents[x] = p
return p
def union(self, x, y):
host = x if self.ra... |
s396496108 | p03575 | u978178314 | 1586864337 | Python | PyPy3 (2.4.0) | py | Runtime Error | 848 | 391836 | 943 | class UnionFind:
def __init__(self, n):
self.parents = list(range(n))
self.ranks = [1 for _ in range(n)]
def parent(self, x):
if x == self.parents[x]:
return x
else:
p = self.parent(self.parents[x])
self.parents[x] = p
return p
def union(self, x, y):
host = x if self.ra... |
s053930213 | p03575 | u978178314 | 1586864199 | Python | PyPy3 (2.4.0) | py | Runtime Error | 849 | 392348 | 943 | class UnionFind:
def __init__(self, n):
self.parents = list(range(n))
self.ranks = [1 for _ in range(n)]
def parent(self, x):
if x == self.parents[x]:
return x
else:
p = self.parent(self.parents[x])
self.parents[x] = p
return p
def union(self, x, y):
host = x if self.ra... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.