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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
s677199437 | p03682 | u360515075 | 1570292707 | Python | Python (3.4.3) | py | Runtime Error | 475 | 27604 | 367 | import numpy as np
from scipy.sparse.csgraph import csgraph_from_dense,dijkstra,floyd_warshall
N = int(input())
L = []
for i in range(N):
x, y = map(int, input().split())
L.append((x, y))
D = np.zeros((N, N))
for i in range(N):
for j in range(N):
D[i][j] = min(abs(L[i][0] - L[j][0]), abs(L[i][1] - L[j][1]))... |
s312678373 | p03682 | u552192779 | 1569505082 | Python | Python (3.4.3) | py | Runtime Error | 1965 | 72984 | 972 | from collections import deque
import sys
sys.setrecursionlimit(2000000000)
n = int(input())
nodes = []
done = [0 for _ in range(n)]
par = {}
for _ in range(n):
x, y = map(int,input().split())
nodes.append((x,y))
par[(x,y)]=(x,y)
nodesx = sorted(nodes)
nodesy = sorted(nodes,key=lambda z:z[1])
s = []
for... |
s117183279 | p03682 | u552192779 | 1569505058 | Python | PyPy3 (2.4.0) | py | Runtime Error | 2110 | 115992 | 972 | from collections import deque
import sys
sys.setrecursionlimit(2000000000)
n = int(input())
nodes = []
done = [0 for _ in range(n)]
par = {}
for _ in range(n):
x, y = map(int,input().split())
nodes.append((x,y))
par[(x,y)]=(x,y)
nodesx = sorted(nodes)
nodesy = sorted(nodes,key=lambda z:z[1])
s = []
for... |
s303213343 | p03682 | u552192779 | 1569504620 | Python | Python (3.4.3) | py | Runtime Error | 1980 | 75228 | 938 | from collections import deque
import sys
sys.setrecursionlimit(1000000000)
n = int(input())
nodes = []
done = [0 for _ in range(n)]
par = {}
for _ in range(n):
x, y = map(int,input().split())
nodes.append((x,y))
par[(x,y)]=(x,y)
nodesx = sorted(nodes)
nodesy = sorted(nodes,key=lambda z:z[1])
s = []
for... |
s729611759 | p03682 | u552192779 | 1569504548 | Python | Python (3.4.3) | py | Runtime Error | 28 | 3316 | 945 | from collections import deque
import sys
sys.setrecursionlimit(10000000000000000)
n = int(input())
nodes = []
done = [0 for _ in range(n)]
par = {}
for _ in range(n):
x, y = map(int,input().split())
nodes.append((x,y))
par[(x,y)]=(x,y)
nodesx = sorted(nodes)
nodesy = sorted(nodes,key=lambda z:z[1])
s = [... |
s024890892 | p03682 | u552192779 | 1569504376 | Python | Python (3.4.3) | py | Runtime Error | 1868 | 73224 | 893 | from collections import deque
n = int(input())
nodes = []
done = [0 for _ in range(n)]
par = {}
for _ in range(n):
x, y = map(int,input().split())
nodes.append((x,y))
par[(x,y)]=(x,y)
nodesx = sorted(nodes)
nodesy = sorted(nodes,key=lambda z:z[1])
s = []
for i in range(n-1):
xcost =nodesx[i+1][0]-... |
s745235142 | p03682 | u552192779 | 1569445385 | Python | Python (3.4.3) | py | Runtime Error | 2108 | 71180 | 869 | import heapq as hq
n = int(input())
nodes = []
done = [0 for _ in range(n)]
par = {}
for _ in range(n):
x, y = map(int,input().split())
nodes.append((x,y))
par[(x,y)]=(x,y)
nodesx = sorted(nodes)
nodesy = sorted(nodes,key=lambda z:z[1])
s = []
for i in range(n-1):
xcost =nodesx[i+1][0]-nodesx[i][0]
... |
s130099922 | p03682 | u552192779 | 1569445047 | Python | PyPy3 (2.4.0) | py | Runtime Error | 2111 | 135588 | 852 | import heapq as hq
n = int(input())
nodes = []
done = [0 for _ in range(n)]
par = {}
for _ in range(n):
x, y = map(int,input().split())
nodes.append((x,y))
par[(x,y)]=(x,y)
nodesx = sorted(nodes)
nodesy = sorted(nodes,key=lambda z:z[1])
s = []
for i in range(n-1):
xcost =nodesx[i+1][0]-nodesx[i][0]
... |
s413224959 | p03682 | u552192779 | 1569445001 | Python | Python (3.4.3) | py | Runtime Error | 2107 | 71420 | 852 | import heapq as hq
n = int(input())
nodes = []
done = [0 for _ in range(n)]
par = {}
for _ in range(n):
x, y = map(int,input().split())
nodes.append((x,y))
par[(x,y)]=(x,y)
nodesx = sorted(nodes)
nodesy = sorted(nodes,key=lambda z:z[1])
s = []
for i in range(n-1):
xcost =nodesx[i+1][0]-nodesx[i][0]
... |
s363605574 | p03682 | u552192779 | 1569419734 | Python | Python (3.4.3) | py | Runtime Error | 2105 | 19380 | 1242 |
n = int(input())
nords = []
done = [0 for _ in range(n)]
for _ in range(n):
x, y = map(int,input().split())
nords.append((x,y))
ans = 0
tree = [nords[0]]
done[0] = 1
count = 0
while count <n-1:
cost = float("inf")
merge = ()
donei = 0
for (xt, yt) in tree:
for i,(xi,yi) in enumerate(no... |
s317905162 | p03682 | u619819312 | 1569290510 | Python | Python (3.4.3) | py | Runtime Error | 1929 | 51408 | 471 | n=int(input())
a=sorted([[i]+list(map(int,input().split()))for i in range(n)],key=lambda x:x[1])
s=[]
for i in range(n-1):
s.append((a[i+1][1]-a[i][1],a[i][0],a[i+1][0]))
a=sorted(a,key=lambda x:x[2])
for i in range(n-1):
s.append((a[i+1][2]-a[i][2],a[i][0],a[i+1][0]))
s.sort()
t=[i for i in range(n)]
def f(x):... |
s268891416 | p03682 | u231685196 | 1568439513 | Python | PyPy3 (2.4.0) | py | Runtime Error | 2111 | 451944 | 1560 | class uf_tree():
def __init__(self,n):
self.n = n
self.par = [i for i in range(n)]
def indep(self):
dep =0
for i in range(self.n):
if i == self.par[i]:
dep += 1
return dep
def unite(self,child,mas):
if self.root(child) == self.r... |
s557077180 | p03682 | u231685196 | 1568439102 | Python | Python (3.4.3) | py | Runtime Error | 1884 | 55256 | 1560 | class uf_tree():
def __init__(self,n):
self.n = n
self.par = [i for i in range(n)]
def indep(self):
dep =0
for i in range(self.n):
if i == self.par[i]:
dep += 1
return dep
def unite(self,child,mas):
if self.root(child) == self.r... |
s428406111 | p03682 | u533885955 | 1567558394 | Python | Python (3.4.3) | py | Runtime Error | 1233 | 60964 | 1046 | #D問題
def find(A,x) -> int:
p = A[x]
if p == x:
return x
a = find(A,p)
A[x] = a
return a
def union(A, x, y):
if find(A,x) > find(A,y):
bx, by = find(A,y), find(A,x)
else:
bx, by = find(A,x), find(A,y)
A[y] = bx
A[by] = bx
import heapq
N = int(input())
XY0 =... |
s428040796 | p03682 | u423585790 | 1566770125 | Python | PyPy3 (2.4.0) | py | Runtime Error | 204 | 42096 | 2618 | #!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): re... |
s481361034 | p03682 | u423585790 | 1566769713 | Python | PyPy3 (2.4.0) | py | Runtime Error | 659 | 68400 | 2562 | #!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): re... |
s596025120 | p03682 | u423585790 | 1566769137 | Python | PyPy3 (2.4.0) | py | Runtime Error | 167 | 38384 | 2579 | #!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): re... |
s229348829 | p03682 | u423585790 | 1566767882 | Python | PyPy3 (2.4.0) | py | Runtime Error | 739 | 79024 | 2480 | #!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): re... |
s988728817 | p03682 | u472065247 | 1565925940 | Python | Python (3.4.3) | py | Runtime Error | 1197 | 76208 | 462 | from scipy.sparse.csgraph import minimum_spanning_tree
from scipy.sparse import csr_matrix
N = int(input())
iXY = [[i] + list(map(int, input().split())) for i in range(N)]
P = []
for j in [1, 2]:
iXY.sort(key=lambda a: a[j])
for i in range(1, N):
i0, x0, y0 = iXY[i - 1]
i1, x1, y1 = iXY[i]
P.append(... |
s354839673 | p03682 | u584174687 | 1562011756 | Python | PyPy3 (2.4.0) | py | Runtime Error | 1189 | 138408 | 1452 | from collections import defaultdict
import sys
input = sys.stdin.readline
parent_node = []
def get_parent(ind):
global parent_node
if ind != parent_node[ind]:
parent_node[ind] = get_parent(parent_node[ind])
return parent_node[ind]
def main():
num = int(input())
data = defaultdict(tupl... |
s879941450 | p03682 | u879309973 | 1560859225 | Python | Python (3.4.3) | py | Runtime Error | 2112 | 71268 | 780 | import numpy as np
def solve(n, x, y):
def dist(i, j):
return min(abs(x[i]-x[j]), abs(y[i]-y[j]))
que = []
for v in [x, y]:
p = np.argsort(v)
for i in range(n-1):
u, v = p[i], p[i+1]
que.append((u, v, dist(u, v)))
parent = {i: i for i in range(n)}
def ... |
s543033571 | p03682 | u879309973 | 1560858942 | Python | Python (3.4.3) | py | Runtime Error | 2112 | 69668 | 854 | from collections import deque
import numpy as np
def solve(n, x, y):
def dist(i, j):
return min(abs(x[i]-x[j]), abs(y[i]-y[j]))
que = []
for v in [x, y]:
p = np.argsort(v)
for i in range(n-1):
u, v = p[i], p[i+1]
que.append((u, v, dist(u, v)))
parent = {i:... |
s748594221 | p03682 | u102461423 | 1558680772 | Python | PyPy3 (2.4.0) | py | Runtime Error | 195 | 39408 | 594 | import sys
input = sys.stdin.readline
from operator import itemgetter
from scipy.sparse import lil_matrix
N = int(input())
edge = lil_matrix((N,N))
XY = [[i] + [int(x) for x in input().split()] for i in range(N)]
for key in [itemgetter(1), itemgetter(2)]:
XY.sort(key = key)
for i in range(N-1):
i1,x1,y1 = XY[... |
s575329382 | p03682 | u864197622 | 1558133284 | Python | Python (3.4.3) | py | Runtime Error | 1027 | 153840 | 761 | import sys
sys.setrecursionlimit(100000)
def MST(n, E):
def par(m):
if UF[m] == m:
return m
ret = par(UF[m])
UF[m] = ret
return ret
UF = [i for i in range(n)]
E = sorted(E, key=lambda x: x[2])
ans = 0
for i, j, d in E:
if par(i) != par(j):
... |
s121432653 | p03682 | u864197622 | 1558133199 | Python | Python (3.4.3) | py | Runtime Error | 1042 | 52712 | 719 | def MST(n, E):
def par(m):
if UF[m] == m:
return m
ret = par(UF[m])
UF[m] = ret
return ret
UF = [i for i in range(n)]
E = sorted(E, key=lambda x: x[2])
ans = 0
for i, j, d in E:
if par(i) != par(j):
ans += d
UF[par(i)] ... |
s101362185 | p03682 | u298297089 | 1557941743 | Python | Python (3.4.3) | py | Runtime Error | 1100 | 48728 | 807 | def unite(par, i, j):
j = get_par(par, j)
par[j] = get_par(par, i)
def get_par(par, p):
while par[p] != None:
p = par[p]
return par[p]
N = int(input())
points = []
edges = []
for i in range(N):
x,y = map(int, input().split())
points.append([x,y,i])
points.sort()
for i in range(N-1):
... |
s038759703 | p03682 | u298297089 | 1557941623 | Python | Python (3.4.3) | py | Runtime Error | 1041 | 48728 | 813 | def unite(par, i, j):
j = get_par(par, j)
par[j] = get_par(par, i)
def get_par(par, p):
while par[p] != None:
p = par[p]
return par[p]
N = int(input())
points = []
edges = []
for i in range(N):
x,y = map(int, input().split())
points.append([x,y,i])
points.sort()
for i in range(N-1):
... |
s065541723 | p03682 | u298297089 | 1557846738 | Python | PyPy3 (2.4.0) | py | Runtime Error | 619 | 68408 | 1150 |
def update_tree(par, a, b):
frm = par[a][0] if par[par[a][0]][1] < par[par[b][0]][1] else par[b][0]
to = par[b][0] if frm == par[a][0] else par[a][0]
if par[par[frm][0]][1] > par[par[to][0]][1]:
par[par[to][0]][1] = par[par[frm][0]][1]
while par[frm][0] != par[par[frm][0]][0]:
par... |
s791766809 | p03682 | u391731808 | 1557374157 | Python | Python (3.4.3) | py | Runtime Error | 1585 | 47012 | 726 | import heapq
N=int(input())
xy=[list(map(int,input().split()))+[i] for i in range(N)]
xy.sort()
path = []
def get_par(n):
if par[n] is None:return n
return get_par(par[n])
def same(i,j):
return get_par(i) == get_par(j)
def unite(i,j):
j = get_par(j)
par[j] = i
return
for k in range(N-1):
... |
s591843766 | p03682 | u391731808 | 1557372740 | Python | Python (3.4.3) | py | Runtime Error | 1402 | 57864 | 1092 | import heapq
N=int(input())
xy=[list(map(int,input().split()))+[i] for i in range(N)]
xy.sort()
path = []
def get_root(n):
if tree[n][0] is None:return n
return get_root(tree[n][0])
def in_tree(i,j):
i = get_root(i)
while i is not None:
if i == j : return True
elif j < i : i = tree[... |
s528548636 | p03682 | u391731808 | 1557368371 | Python | Python (3.4.3) | py | Runtime Error | 2108 | 59268 | 804 | import heapq
N=int(input())
xy=[list(map(int,input().split()))+[i] for i in range(N)]
def bin_search_in(n,a):
l = 0
r = len(a)-1
while l+1<r:
i = (l+r)//2
if a[i] <= n:
l = i
else:
r = i
return a[l]==n or a[r]==n
xy.sort()
path = []
for k in range(N-1):
... |
s122868283 | p03682 | u171366497 | 1553338011 | Python | Python (3.4.3) | py | Runtime Error | 1203 | 46544 | 841 | N=int(input())
city=[]
for i in range(N):
x,y=map(int,input().split())
city.append((i,x,y))
city.sort(key=lambda x:x[1])
data=[]
for i in range(N-1):
data.append((city[i][0],city[i+1][0],city[i+1][1]-city[i][1]))
city.sort(key=lambda y:y[2])
for i in range(N-1):
data.append((city[i][0],city[i+1][0],city... |
s194428851 | p03682 | u585482323 | 1552425050 | Python | PyPy3 (2.4.0) | py | Runtime Error | 1508 | 228816 | 1670 | #!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): ... |
s720316416 | p03682 | u621935300 | 1548131036 | Python | PyPy2 (5.6.0) | py | Runtime Error | 2110 | 96240 | 743 | import sys
from heapq import heappush, heappop, heapify
N=input()
par=[ i for i in range(N) ]
def root(x):
if par[x]==x:
return x
else:
par[x]=root( par[x] )
return par[x]
def same(x,y):
return root(x)==root(y)
def unite(x,y):
x=root(x)
y=root(y)
if x==y: return
par[x]=y
X=[]
Y=[]
for i in range(N... |
s003575432 | p03682 | u215329188 | 1546576322 | Python | Python (3.4.3) | py | Runtime Error | 1274 | 52348 | 1632 | class UnionFind:
def __init__(self, n: int) -> None:
#マイナスならルートでその深さを表す。プラスならルートのノードを指す。
self.nodes = [-1]*(n+1)
def find_root(self, x: int) -> int:
if self.nodes[x] < 0:
return x
else:
self.nodes[x] = self.find_root(self.nodes[x])
return sel... |
s979372297 | p03682 | u215329188 | 1546575925 | Python | Python (3.4.3) | py | Runtime Error | 1302 | 52396 | 1636 | class UnionFind:
def __init__(self, n: int) -> None:
#マイナスならルートでその深さを表す。プラスならルートのノードを指す。
self.nodes = [-1]*n
def find_root(self, x: int) -> int:
if self.nodes[x] < 0:
return x
else:
self.nodes[x] = self.find_root(self.nodes[x])
return self.no... |
s844371058 | p03682 | u215329188 | 1546575826 | Python | Python (3.4.3) | py | Runtime Error | 1268 | 52348 | 1628 | class UnionFind:
def __init__(self, n: int) -> None:
#マイナスならルートでその深さを表す。プラスならルートのノードを指す。
self.nodes = [-1]*n
def find_root(self, x: int) -> int:
if self.nodes[x] < 0:
return x
else:
self.nodes[x] = self.find_root(self.nodes[x])
return self.no... |
s443327510 | p03682 | u658993896 | 1539994445 | Python | Python (3.4.3) | py | Runtime Error | 2109 | 92788 | 1009 | import heapq
def add(i,pj,T):
if T[i]['p']!=i:
add(T[i]['p'],pj,T)
T[i]['p']=pj
def parent(i,T):
if T[i]['p']!=i:
T[i]['p']= parent(T[i]['p'],T)
return T[i]['p']
else:
return i
N=int(input())
town=[]
for i in range(N):
x,y=list(map(int,input().split()))
tow... |
s238321874 | p03682 | u608088992 | 1539727340 | Python | Python (3.4.3) | py | Runtime Error | 2104 | 6548 | 1401 | import heapq
def cost(a, b, c, d):
return min(abs(a-c), abs(b-d))
N = int(input())
T, Visit = [], {}
for i in range(N):
x, y = map(int, input().split())
Visit[(x, y)] = False
if (x, y) not in T:
T.append((x, y))
lenT = len(T)
Tx, Ty = sorted(T, key = lambda t:t[0]), sorted(T, key = lambda t:t[1... |
s679207498 | p03682 | u826263061 | 1537569508 | Python | Python (3.4.3) | py | Runtime Error | 1091 | 79368 | 1139 | # -*- coding: utf-8 -*-
"""
Created on Thu Sep 20 21:40:30 2018
ABC065D
@author: maezawa
i=0...n (0-origin)
"""
import heapq
n = int(input())
a = []
b = []
for i in range(n): # i is a name of the city (0-origin)
xy = list(map(int, input().split()))
a.append([i,xy[0]])
b.append([i,xy[1]])
a.sort(key=lambda... |
s467474870 | p03682 | u826263061 | 1537568322 | Python | Python (3.4.3) | py | Runtime Error | 536 | 35556 | 1239 | # -*- coding: utf-8 -*-
"""
Created on Thu Sep 20 21:40:30 2018
ABC065D
@author: maezawa
i=0...n (0-origin)
"""
import heapq
n = int(input())
a = []
b = []
for i in range(n): # i is a name of the city (0-origin)
xy = list(map(int, input().split()))
a.append([i,xy[0]])
b.append([i,xy[1]])
a.sort(key=lambda... |
s768074431 | p03682 | u439396449 | 1534516596 | Python | Python (3.4.3) | py | Runtime Error | 2108 | 99072 | 1909 | from collections import defaultdict
from heapq import heappop, heappush
from operator import itemgetter
N = int(input())
town = [[int(x) for x in input().split()] + [i] for i in range(N)]
class UnionFind(object):
def __init__(self, n=1):
self.par = [i for i in range(n)]
self.rank = [0 for _ in ra... |
s061381169 | p03682 | u467736898 | 1529365677 | Python | Python (3.4.3) | py | Runtime Error | 1546 | 55140 | 725 | N = int(input())
T = [[i] + list(map(int, input().split())) for i in range(N)]
E = [[] for i in range(N)]
E = []
T.sort(key=lambda x: x[1])
for i in range(N-1):
s, l = T[i:i+2]
E.append([s[0], l[0], l[1]-s[1]])
T.sort(key=lambda x: x[2])
for i in range(N-1):
s, l = T[i:i+2]
E.append([s[0], l[0], l[2]-s[... |
s696291987 | p03682 | u048945791 | 1529030873 | Python | Python (3.4.3) | py | Runtime Error | 1752 | 63552 | 1039 | n = int(input())
x = []
y = []
for i in range(n):
s = list(map(int, input().split()))
x.append([s[0], i])
y.append([s[1], i])
x.sort()
y.sort()
xdiff = []
ydiff = []
for i in range(1, n):
xdiff.append([x[i][0] - x[i - 1][0], x[i - 1][1], x[i][1]])
ydiff.append([y[i][0] - y[i - 1][0], y[i - 1][1], ... |
s562048979 | p03682 | u394271841 | 1528230845 | Python | Python (3.4.3) | py | Runtime Error | 1007 | 52860 | 1791 | import sys
import collections
import itertools
class UnionFind:
def __init__(self, n):
self.par = [i for i in range(n+1)]
self.rank = [0] * (n+1)
def find(self, x):
if self.par[x] == x:
return x
else:
self.par[x] = self.find(self.par[x])
retu... |
s927737799 | p03682 | u394271841 | 1528225058 | Python | Python (3.4.3) | py | Runtime Error | 2115 | 180312 | 1468 | import sys
import collections
import itertools
class UnionFind:
def __init__(self, n):
self.par = [i for i in range(n+1)]
self.rank = [0] * (n+1)
def find(self, x):
if self.par[x] == x:
return x
else:
self.par[x] = self.find(self.par[x])
retu... |
s146776130 | p03682 | u394271841 | 1528225016 | Python | Python (3.4.3) | py | Runtime Error | 28 | 3436 | 1515 | import sys
import collections
import itertools
# COMMENT OUT BEFORE SUBMISSION
sys.stdin = f
class UnionFind:
def __init__(self, n):
self.par = [i for i in range(n+1)]
self.rank = [0] * (n+1)
def find(self, x):
if self.par[x] == x:
return x
else:
self.p... |
s599129208 | p03682 | u694433776 | 1525815710 | Python | PyPy3 (2.4.0) | py | Runtime Error | 1215 | 85720 | 996 | n = int(input())
p = [list(map(int, input().split())) for i in range(n)]
# x,yだけのリストを作る。座標順にソートもします。
x = sorted([[p[i][0], i] for i in range(n)])
y = sorted([[p[i][1], i] for i in range(n)])
# x,yについて隣り合ったものだけをedgeとしてみればよい(これもソートします)
edge = sorted([abs(x[i][0] - x[i-1][0]), x[i][1], x[i-1][1]] + [abs(y[i][0] - y[i-1][0... |
s533591656 | p03682 | u694433776 | 1525814892 | Python | PyPy3 (2.4.0) | py | Runtime Error | 171 | 38512 | 972 | n = int(input())
p = [list(map(int, input().split())) for i in range(n)]
# x,yだけのリストを作る。座標順にソートもします。
x = sorted([[p[i][0], i] for i in range(n)])
y = sorted([[p[i][1], i] for i in range(n)])
# x,yについて隣り合ったものだけをedgeとしてみればよい(これもソートします)
edge = [0]*(2*n)
for i in range(n):
edge[2*i] = [abs(x[i][0] - x[i-1][0]), x[i][1]... |
s689946314 | p03682 | u621935300 | 1511551507 | Python | Python (2.7.6) | py | Runtime Error | 1469 | 53652 | 1083 | # -*- coding: utf-8 -*-
import heapq
N = input()
a = []
for i in range(N):
x,y=map(int,raw_input().split())
a.append((i,x,y))
#a => point,x,y
a1=sorted(a, key=lambda x: x[1])
a2=sorted(a, key=lambda x: x[2])
#Union Find
#初めは各頂点が根
par=[ i for i in range(N) ]
#木の根を求める
def root(x):
if par[x]==x:
return x
else:
... |
s726246391 | p03682 | u621935300 | 1511551257 | Python | Python (2.7.6) | py | Runtime Error | 1666 | 52104 | 986 | # -*- coding: utf-8 -*-
import heapq
N = input()
a = []
for i in range(N):
x,y=map(int,raw_input().split())
a.append((i,x,y))
#a => point,x,y
a1=sorted(a, key=lambda x: x[1])
a2=sorted(a, key=lambda x: x[2])
#Union Find
#初めは各頂点が根
par=[ i for i in range(N) ]
#木の根を求める
def root(x):
if par[x]==x:
return x
else:
... |
s913846231 | p03682 | u840684628 | 1507491665 | Python | Python (3.4.3) | py | Runtime Error | 2109 | 79184 | 1172 | def list_to_dict(val_list):
return list(zip(range(0,len(val_list)), val_list))
class Edge():
def __init__(self,_start,_end,_cost):
self.start = _start
self.end = _end
self.cost = _cost
def __str__(self):
return ",".join([str(self.start),str(self.end),str(self.cost)])
n = int(i... |
s578258988 | p03682 | u840684628 | 1507491207 | Python | Python (3.4.3) | py | Runtime Error | 2108 | 78476 | 1093 | def list_to_dict(val_list):
return list(zip(range(0,len(val_list)), val_list))
class Edge():
def __init__(self,_start,_end,_cost):
self.start = _start
self.end = _end
self.cost = _cost
def __str__(self):
return ",".join([str(self.start),str(self.end),str(self.cost)])
n = int(i... |
s847983524 | p03682 | u425351967 | 1506697871 | Python | PyPy3 (2.4.0) | py | Runtime Error | 2113 | 178720 | 770 | N = int(input())
P = [n for n in range(N)]
points = []
def root(a):
if P[a] == a:
return a
P[a] = root(P[a])
return P[a]
def is_same_set(a, b):
return root(a) == root(b)
def unite(a, b):
P[root(a)] = root(b)
for i in range(N):
x, y = [int(n) for n in input().split()]
points.append((i, x, y))
xs... |
s580604613 | p03682 | u425351967 | 1506697855 | Python | Python (3.4.3) | py | Runtime Error | 1271 | 66624 | 770 | N = int(input())
P = [n for n in range(N)]
points = []
def root(a):
if P[a] == a:
return a
P[a] = root(P[a])
return P[a]
def is_same_set(a, b):
return root(a) == root(b)
def unite(a, b):
P[root(a)] = root(b)
for i in range(N):
x, y = [int(n) for n in input().split()]
points.append((i, x, y))
xs... |
s771953836 | p03682 | u839537730 | 1502560075 | Python | Python (3.4.3) | py | Runtime Error | 1464 | 70612 | 1002 | from operator import itemgetter
from queue import deque
N = int(input())
xin = []
yin = []
for _ in range(N):
x, y = map(int, input().split())
xin.append(x)
yin.append(y)
xin = sorted(list(enumerate(xin)), key=itemgetter(1))
yin = sorted(list(enumerate(yin)), key=itemgetter(1))
xd = []
yd = []
for... |
s137438604 | p03682 | u839537730 | 1501698677 | Python | Python (3.4.3) | py | Runtime Error | 1443 | 72196 | 945 | from operator import itemgetter
from queue import deque
N = int(input())
xin, yin = [], []
for _ in range(N):
x, y = map(int, input().split())
xin.append(x)
yin.append(y)
x = sorted(list(enumerate(xin)), key=itemgetter(1))
y = sorted(list(enumerate(yin)), key=itemgetter(1))
xds = []
yds = []
for i in r... |
s384286107 | p03682 | u839537730 | 1501698591 | Python | Python (3.4.3) | py | Runtime Error | 1473 | 71676 | 1018 | from operator import itemgetter
from queue import deque
N = int(input())
x_in = []
y_in = []
for _ in range(N):
x, y = list(map(int, input().split(" ")))
x_in.append(x)
y_in.append(y)
x_in = sorted(list(enumerate(x_in)), key=itemgetter(1))
y_in = sorted(list(enumerate(y_in)), key=itemgetter(1))
xd = []... |
s129801901 | p03682 | u410717334 | 1498956781 | Python | Python (3.4.3) | py | Runtime Error | 1702 | 60464 | 1482 | class UnionFind:
def __init__(self, size):
self.table = [-1 for _ in range(size)]
def find(self, x):
if self.table[x] < 0:
return x
else:
self.table[x] = self.find(self.table[x])
return self.table[x]
def union(self, x, y):
s1 = self.find(... |
s345169720 | p03682 | u323969672 | 1498705132 | Python | Python (2.7.6) | py | Runtime Error | 1542 | 57732 | 919 | class UnionFind3:
def __init__(self, size):
self.table = [-1 for _ in xrange(size)]
def find(self, x):
if self.table[x] < 0:
return x
else:
self.table[x] = self.find(self.table[x])
return self.table[x]
def union(self, x, y):
s1 = self.fi... |
s677403545 | p03682 | u323969672 | 1498705108 | Python | Python (2.7.6) | py | Runtime Error | 1459 | 56340 | 919 | class UnionFind3:
def __init__(self, size):
self.table = [-1 for _ in xrange(size)]
def find(self, x):
if self.table[x] < 0:
return x
else:
self.table[x] = self.find(self.table[x])
return self.table[x]
def union(self, x, y):
s1 = self.fi... |
s070787305 | p03682 | u323969672 | 1498704587 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 925 | class UnionFind3:
def __init__(self, size):
self.table = [-1 for _ in xrange(size)]
def find(self, x):
if self.table[x] < 0:
return x
else:
self.table[x] = self.find(self.table[x])
return self.table[x]
def union(self, x, y):
s1 = self.fi... |
s979307217 | p03682 | u323969672 | 1498704307 | Python | Python (2.7.6) | py | Runtime Error | 1727 | 64420 | 932 | class UnionFind3:
def __init__(self, size):
self.table = [-1 for _ in xrange(size)]
def find(self, x):
if self.table[x] < 0:
return x
else:
self.table[x] = self.find(self.table[x])
return self.table[x]
def union(self, x, y):
s1 = self.fi... |
s440283668 | p03682 | u323969672 | 1498703501 | Python | Python (2.7.6) | py | Runtime Error | 1461 | 58748 | 913 | class UnionFind3:
def __init__(self, size):
self.table = [-1 for _ in xrange(size)]
def find(self, x):
if self.table[x] < 0:
return x
else:
self.table[x] = self.find(self.table[x])
return self.table[x]
def union(self, x, y):
s1 = self.fi... |
s367874886 | p03682 | u323969672 | 1498703034 | Python | Python (2.7.6) | py | Runtime Error | 1416 | 57724 | 912 | class UnionFind3:
def __init__(self, size):
self.table = [-1 for _ in xrange(size)]
def find(self, x):
if self.table[x] < 0:
return x
else:
self.table[x] = self.find(self.table[x])
return self.table[x]
def union(self, x, y):
s1 = self.fi... |
s871194701 | p03682 | u085883871 | 1498619846 | Python | Python (3.4.3) | py | Runtime Error | 2135 | 454064 | 884 | import math
max_val = 1000000000
def solve():
n = int(input())
l = []
mat = [[0 for i in range(n)] for j in range(n)]
for i in range(n):
l.append(list(map(int,input().split())))
for j in range(i+1):
mat[i][j] = min(abs(l[i][0]-l[j][0]), abs(l[i][1]-l[j][1]))
mat... |
s653612365 | p03682 | u846372029 | 1498616392 | Python | Python (3.4.3) | py | Runtime Error | 558 | 36356 | 603 | #Built?
import numpy as np
import sys
n = int(input())
p = []
for i in range(n):
p.append(list(map(int, input().split())))
#最小木問題プリム法
c = p #city point
v = [] #vertex
e = [] #edge
v.append(c[0])
c.remove(c[0])
sumcost=0
while 1:
mincost = sys.float_info.max
for vp in v:
for cp i... |
s050575738 | p03682 | u846372029 | 1498615974 | Python | Python (3.4.3) | py | Runtime Error | 685 | 42148 | 728 | #Built?
#最小木問題
import numpy as np
import math as mt
import sys
n = int(input())
p = []
for i in range(n):
p.append(list(map(int, input().split())))
#プリム法
c = p #city point
v = [] #vertex
e = [] #edge
v.append(c[0])
c.remove(c[0])
sumcost=0
while 1:
mincost = sys.float_info.max
stA = None
... |
s773560001 | p03682 | u203900263 | 1498611647 | Python | Python (3.4.3) | py | Runtime Error | 450 | 20116 | 686 | import numpy as np
import sys
N = int(input())
x = []
y = []
for i in range(N):
a, b = map(int, input().split())
x.append(a)
y.append(b)
howmuch = np.zeros((N, N))
towngroup = np.array(list(range(N)))
for i in range(N):
for j in range(i, N):
howmuch[i][j] = min(abs(x[i] - x[j]), abs(y[i] - ... |
s976050507 | p03682 | u203900263 | 1498611600 | Python | Python (3.4.3) | py | Runtime Error | 453 | 20104 | 709 | import numpy as np
import sys
N = int(input())
x = []
y = []
for i in range(N):
a, b = map(int, input().split())
x.append(a)
y.append(b)
howmuch = np.zeros((N, N))
towngroup = np.array(list(range(N)))
for i in range(N):
for j in range(i, N):
howmuch[i][j] = min(abs(x[i] - x[j]), abs(y[i] - ... |
s350989268 | p03682 | u262900844 | 1498537288 | Python | Python (2.7.6) | py | Runtime Error | 1432 | 57356 | 896 | class UnionFind3:
def __init__(self, size):
self.table = [-1 for _ in xrange(size)]
def find(self, x):
if self.table[x] < 0:
return x
else:
self.table[x] = self.find(self.table[x])
return self.table[x]
def union(self, x, y):
s1 = self.f... |
s061352595 | p03682 | u262900844 | 1498537073 | Python | Python (2.7.6) | py | Runtime Error | 926 | 55700 | 894 | class UnionFind3:
def __init__(self, size):
self.table = [-1 for _ in xrange(size)]
def find(self, x):
if self.table[x] < 0:
return x
else:
self.table[x] = self.find(self.table[x])
return self.table[x]
def union(self, x, y):
s1 = self.f... |
s485260198 | p03682 | u262900844 | 1498535273 | Python | Python (2.7.6) | py | Runtime Error | 1421 | 56348 | 896 | class UnionFind3:
def __init__(self, size):
self.table = [-1 for _ in xrange(size)]
def find(self, x):
if self.table[x] < 0:
return x
else:
self.table[x] = self.find(self.table[x])
return self.table[x]
def union(self, x, y):
s1 = self.f... |
s319781671 | p03682 | u262900844 | 1498535068 | Python | Python (2.7.6) | py | Runtime Error | 1376 | 58268 | 896 | class UnionFind3:
def __init__(self, size):
self.table = [-1 for _ in xrange(size)]
def find(self, x):
if self.table[x] < 0:
return x
else:
self.table[x] = self.find(self.table[x])
return self.table[x]
def union(self, x, y):
s1 = self.f... |
s598148573 | p03682 | u262900844 | 1498534439 | Python | Python (2.7.6) | py | Runtime Error | 10 | 2696 | 896 | class UnionFind3:
def __init__(self, size):
self.table = [-1 for _ in xrange(size)]
def find(self, x):
if self.table[x] < 0:
return x
else:
self.table[x] = self.find(self.table[x])
return self.table[x]
def union(self, x, y):
s1 = self.f... |
s427616482 | p03682 | u455591217 | 1498435185 | Python | Python (3.4.3) | py | Runtime Error | 1615 | 58128 | 912 |
def distance(P, p1, p2):
return min(abs(P[p1][1]-P[p2][1]), abs(P[p1][2]-P[p2][2]))
def root(CI, p):
if CI[p] == p:
return p
else:
CI[p] = root(CI, CI[p])
return CI[p]
N = int(input())
P = [[j]+[int(i) for i in input().split(' ')] for j in range(N)]
sortX = sorted(P,key=lambda x:x... |
s414960324 | p03682 | u602740328 | 1498370811 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3192 | 1125 | import sys
sys.setrecursionlimit(1e9)
class obj:
def __init__(self, N):
self.fa = [i for i in range(N)]
def find(self, x):
if x == self.fa[x]:
return x
else:
self.fa[x] = self.find(self.fa[x])
return self.fa[x]
N = int(input())
node = [{"x":0, "y":0, ... |
s512685704 | p03682 | u602740328 | 1498370607 | Python | Python (3.4.3) | py | Runtime Error | 1827 | 121472 | 1087 | class obj:
def __init__(self, N):
self.fa = [i for i in range(N)]
def find(self, x):
if x == self.fa[x]:
return x
else:
self.fa[x] = self.find(self.fa[x])
return self.fa[x]
N = int(input())
node = [{"x":0, "y":0, "id":i} for i in range(N)]
edge = [{"u... |
s541603848 | p03682 | u353917577 | 1498369645 | Python | Python (2.7.6) | py | Runtime Error | 1629 | 58772 | 633 | UF=[i for i in range(100001)]
def u(a,b):
UF[f(a)] = UF[f(b)]
def f(c):
if(c==UF[c]):
return c
else:
UF[c]=f(UF[c])
return UF[c]
n = input()
cities = [map(int,raw_input().split(" "))+[i] for i in range(n)]
cities_x = sorted(cities, key=lambda a:a[0])
cities_y = sorted(cities, key=... |
s439089854 | p03682 | u602740328 | 1498367110 | Python | Python (3.4.3) | py | Runtime Error | 1562 | 123148 | 1105 | class obj:
def __init__(self, N):
self.fa = [i for i in range(N)]
def find(self, x):
if x == self.fa[x]:
return x
else:
self.fa[x] = self.find(self.fa[x])
return self.fa[x]
N = int(input())
node = [{"x":0, "y":0, "id":i} for i in range(N)]
edge = [{"u... |
s830441766 | p03682 | u190525112 | 1498364577 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 340 | N = int(input())
x=[-1]*(10**9+1)
for i in range(0,N):
y = list(map(int, input().split()))
x[y[0]]=y[1]
for i in range(N):
if x[i]!=-1:
pre=x[i]
prei=i
break
res=0
for i in range(N):
if x[i]!=-1:
res += min(i-prei,x[i]-pre)
pre=x[i]
prei=i
... |
s796326853 | p03682 | u580225095 | 1498358466 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 1521 | # -*- coding: utf-8 -*-
#平面上に、N 個の街があります。i 個目の街は、座標 (xi,yi) にあります。
#同じ座標に、複数の街があるかもしれません。
#座標 (a,b) にある街と座標 (c,d) にある街の間に道を造るのには、
#min(|a−c|,|b−d|) 円かかります。街と街の間以外に、道を造ることはできません。
#任意の 2つの街の間を、道を何本か通って行き来できるようにするためは、最低で何円必要でしょうか。
N = int(input())
X = []
Y = []
for i in range(N):
Data = input().split()
X.appen... |
s116798485 | p03683 | u023229441 | 1599851021 | Python | Python (3.8.2) | py | Runtime Error | 26 | 9184 | 613 | n,m=map(int,input().split())
def C(n, r ,mod=10**9+7):
if n-r<r: r=n-r
if r == 0: return 1
if r == 1: return n
numerator = [n - r + k + 1 for k in range(r)]
denominator = [k + 1 for k in range(r)]
for p in range(2,r+1):
pivot = denominator[p - 1]
if pivot > 1:
offse... |
s166801845 | p03683 | u033602950 | 1591669882 | Python | PyPy3 (2.4.0) | py | Runtime Error | 167 | 38256 | 1823 | import sys
#import time
import copy
#from collections import deque, Counter, defaultdict
#from fractions import gcd
#import bisect
#import heapq
#import time
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
inf = 10**18
MOD = 1000000007
ri = lambda : int(input())
rs = lambda : input().strip()
rl = lambda : list... |
s722603933 | p03683 | u033602950 | 1591669220 | Python | Python (3.4.3) | py | Runtime Error | 23 | 3444 | 1818 | import sys
#import time
import copy
#from collections import deque, Counter, defaultdict
#from fractions import gcd
#import bisect
#import heapq
#import time
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
inf = 10**18
MOD = 1000000007
ri = lambda : int(input())
rs = lambda : input().strip()
rl = lambda : list... |
s889536887 | p03683 | u994521204 | 1583740738 | Python | Python (3.4.3) | py | Runtime Error | 26 | 4760 | 466 | ###ncrのmodあまりの話
mod=10**9+7
N=100005
kaidan=[1 for i in range(N)]
gyaku=[1 for i in range(N)]
for i in range(1,N):
kaidan[i] = (i * kaidan[i-1])%mod
gyaku[i]=pow(bikkuri[i], mod-2, mod)
def comb(a,b):
return kaidan[a]*gyaku[b]*gyaku[a-b]
n,m=map(int,input().split())
if abs(n-m)>=2:
print(0)
else:
if... |
s356500594 | p03683 | u993435350 | 1580175490 | Python | Python (3.4.3) | py | Runtime Error | 293 | 98816 | 611 | import sys
from functools import reduce,lru_cache
from operator import mul
def main():
sys.setrecursionlimit(10 ** 5)
N,M = map(int,input().split())
@lru_cache(maxsize = None)
def recur(n):
if n == 0:
return 1
else:
m = n * recur(n - 1)
return m
if N == M:
L = [i for i... |
s160615417 | p03683 | u980322611 | 1569451125 | Python | PyPy3 (2.4.0) | py | Runtime Error | 169 | 38256 | 8 | [].pop() |
s324541038 | p03683 | u077291787 | 1561402890 | Python | Python (3.4.3) | py | Runtime Error | 29 | 3064 | 512 | # ARC076C - Reconciled?
def factorial_mod(x):
MOD = 10 ** 9 + 7
ret = 1
for i in range(1, x + 1):
ret = (ret * i) % MOD
return ret
n, m = list(map(int, input().rstrip().split()))
MOD = 10 ** 9 + 7
n, m = min(n, m), max(n, m)
dif = m - n
if dif > 1: # must be ...DDM...
print(0)
else:
i... |
s330205940 | p03683 | u077291787 | 1561402438 | Python | Python (3.4.3) | py | Runtime Error | 28 | 3064 | 616 | # ARC076C - Reconciled?
def factorial_mod(x):
MOD = 10 ** 9 + 7
ret = 1
for i in range(1, x + 1):
ret = (ret * i) % MOD
return ret
def main():
n, m = list(map(int, input().rstrip().split()))
MOD = 10 ** 9 + 7
n, m = min(n, m), max(n, m)
dif = m - n
if dif > 1: # must be ..... |
s519120084 | p03683 | u077291787 | 1561402147 | Python | Python (3.4.3) | py | Runtime Error | 40 | 3064 | 609 | # ARC076C - Reconciled?
def factorial_mod(x):
MOD = 10 ** 9 + 7
ret = 1
for i in range(1, x + 1):
ret = (ret * i) % MOD
return ret
def main():
n, m = list(map(int, input().rstrip().split()))
MOD = 10 ** 9 + 7
dif = abs(n - m)
if dif > 1: # must be ...DDM...
print(0)
... |
s917333899 | p03683 | u310678820 | 1560111347 | Python | PyPy3 (2.4.0) | py | Runtime Error | 193 | 38384 | 1433 | import sys
input = sys.stdin.readline
class UnionFind(object):
def __init__(self, size):
self.parent = [i for i in range(size)]
self.rank = [0 for _ in range(size)]
def find(self, x):
if self.parent[x] == x:
return x
else:
return self.find(self.parent[x]... |
s493803101 | p03683 | u448354193 | 1557877795 | Python | PyPy3 (2.4.0) | py | Runtime Error | 2111 | 133384 | 213 | m,n=map(int,input().split())
if abs(m-n)>2:
print(0)
sys.exit()
def factorial(x):
pie=x
for i in range(1,x):
pie*=i
return pie
result=factorial(m)*factorial(n)
if m==n:
result*=2
print(result) |
s325988110 | p03683 | u667024514 | 1537582630 | Python | Python (3.4.3) | py | Runtime Error | 81 | 3060 | 243 | n,m = map(int,input().split())
if abs(n - m) >= 2:
print("0")
else:
if n == m:cou = 2
else:cou = 1
while n > 1:
cou *= n
cou %= (10 ** 9 + 7)
n -= 1
while m > 1:
cou *= m
cou %= (10 ** 9 + 7)
m -= 1
print(cou) |
s822595684 | p03683 | u667024514 | 1537582503 | Python | Python (3.4.3) | py | Runtime Error | 83 | 3060 | 218 | n,m = map(int,input().split())
if abs(n - m) >= 2:
print("0")
else:
cou = 2
while n > 1:
cou *= n
cou %= (10 ** 9 + 7)
n -= 1
while m > 1:
cou *= m
cou %= (10 ** 9 + 7)
m -= 1
print(cou) |
s342722426 | p03683 | u218843509 | 1527360202 | Python | PyPy3 (2.4.0) | py | Runtime Error | 191 | 40432 | 1095 | from operator import itemgetter
class UnionFind():
def __init__(self, size):
self.table = [-1 for _ in range(size)]
def find(self, x):
while self.table[x] >= 0:
x = self.table[x]
return x
def union(self, x, y):
s1 = self.find(x)
s2 = self.find(y)
if s1 != s2:
if self.table[s1] > self.table[s2]:
... |
s169046069 | p03683 | u777923818 | 1526786277 | Python | PyPy3 (2.4.0) | py | Runtime Error | 172 | 38768 | 833 | # -*- coding: utf-8 -*-
from heapq import heappop, heappush
def inpl(): return map(int, input().split())
N = int(input())
X = []
Y = []
for i in range(N):
x, y = inpl()
X.append((i, x))
Y.append((i, y))
X = sorted(X, key=lambda x: x[1])
Y = sorted(Y, key=lambda y: y[1])
G = [[] for _ in range(N)]
for i ... |
s968260924 | p03683 | u596276291 | 1505400185 | Python | Python (3.4.3) | py | Runtime Error | 20 | 3316 | 606 | from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt, gcd, factorial
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = 10 ** 10
MOD = 10 ** 9 + 7
def main():
N, M = map(int, input().sp... |
s597628650 | p03683 | u352021237 | 1498861196 | Python | Python (2.7.6) | py | Runtime Error | 11 | 2568 | 276 | n,m=map(int,raw_input())
mul1=mul2=1
if abs(n-m)>1:
print 0
else:
for i in range(1,n+1):
mul1*=i
mul1%=mod
for i in range(1,m+1):
mul2*=i
mul2%=mod
if n==m:
print (2*mul1*mul2)%mod
else:
print (mul1*mul2)%mod |
s341180218 | p03683 | u293072892 | 1498509482 | Python | Python (2.7.6) | py | Runtime Error | 10 | 2692 | 1095 | N, M = (int(i) for i in input().split())
ans = 1
# N = 100000 ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.