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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
s638063635 | p03767 | u623819879 | 1558024317 | Python | PyPy3 (2.4.0) | py | Runtime Error | 326 | 121952 | 88 | n=int(input())
a=[int(i) for i in input().split()]
a=sorted(a)[::-1]
print(sum[1:2*n:2]) |
s602387895 | p03767 | u623819879 | 1558023923 | Python | PyPy3 (2.4.0) | py | Runtime Error | 167 | 38384 | 82 | n=int(input())
a=[int(i) in input().split()]
a=sorted(a)[::-1]
print(sum[1:2*n:2]) |
s585166764 | p03767 | u623819879 | 1558023908 | Python | PyPy3 (2.4.0) | py | Runtime Error | 166 | 38256 | 81 | n=int(input())
a=[int(i) in input().split()]
a=a.sort()[::-1]
print(sum[1:2*n:2]) |
s016169004 | p03767 | u623819879 | 1558023857 | Python | PyPy3 (2.4.0) | py | Runtime Error | 165 | 38448 | 79 | n=int(input())
a=[int(i) in input().split()]
a.sort()[::-1]
print(sum[1:2*n:2]) |
s383635325 | p03767 | u808373096 | 1558021160 | Python | PyPy3 (2.4.0) | py | Runtime Error | 171 | 38384 | 81 | N = int(input())
A = sorted(list(map(int, input().split())))
print(sum(A[N:2*N])
|
s094794928 | p03767 | u808373096 | 1558021104 | Python | PyPy3 (2.4.0) | py | Runtime Error | 262 | 38256 | 74 | N = int(input())
A = sorted(map(int, input().split()))
print(sum(A[N:2*N]) |
s247272293 | p03767 | u066455063 | 1557276731 | Python | Python (3.4.3) | py | Runtime Error | 2113 | 155996 | 495 | N = int(input())
a = list(map(int, input().split()))
ans = 0
def quicksort(seq):
if len(seq) < 1:
return seq
pivot = seq[0]
left = []
right = []
for x in range(1, len(seq)):
if seq[x] <= pivot:
left.append(seq[x])
else:
right.append(seq[x])
left =... |
s987730425 | p03767 | u411544692 | 1554782666 | Python | Python (3.4.3) | py | Runtime Error | 210 | 39492 | 95 | N = int(input())
A = list(map(int,input().split()))
A.sort(reverse=True)
print(sum(A[1::2][N])) |
s790940139 | p03767 | u865413330 | 1552323814 | Python | Python (3.4.3) | py | Runtime Error | 2186 | 1602268 | 194 | n = int(input())
l = list(map(int, input().split()))
l.sort()
def calc(l):
if len(l) == 3:
return l[1]
power = l[-2]
l = l[1:-2]
return calc(l) + power
print(calc(l))
|
s047807063 | p03767 | u865413330 | 1552323750 | Python | Python (3.4.3) | py | Runtime Error | 2184 | 1602268 | 193 | n = int(input())
l = list(map (int, input().split()))
l.sort()
def calc(l):
if len(l) == 3:
return l[1]
power = l[-2]
l = l[1:-2]
return calc(l) + power
print(calc(l)) |
s255313464 | p03767 | u865413330 | 1552322925 | Python | Python (3.4.3) | py | Runtime Error | 2185 | 1604316 | 193 | n = int(input())
l = list(map (int, input().split()))
l.sort()
def calc(l):
if len(l) == 3:
return l[1]
power = l[-2]
l = l[1:-2]
return calc(l) + power
print(calc(l)) |
s893944394 | p03767 | u865413330 | 1552322746 | Python | Python (3.4.3) | py | Runtime Error | 2188 | 1604572 | 175 | n = int(input())
l = list(map (int, input().split()))
l.sort()
def calc(l):
if len(l) == 3:
return l[1]
l = l[1:-2]
return calc(l) + l[-2]
print(calc(l)) |
s314420430 | p03767 | u785578220 | 1551612574 | Python | Python (3.4.3) | py | Runtime Error | 18 | 2940 | 120 | a =int(input())
x =list(map(int, input().split()))
x.sort()
s=0
for i in reversed(range(0,a//3,1):
s+=x[i+1]
print(s)
|
s411158797 | p03767 | u785578220 | 1551611785 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 122 | a =int(input())
x =list(map(int, input().split()))
x.sort()
s=0
for i in reversed(range(1,(a+1)//3,1):
s+=x[i]
print(s)
|
s769085937 | p03767 | u785578220 | 1551603633 | Python | Python (3.4.3) | py | Runtime Error | 18 | 2940 | 117 | a =int(input())
x =list(map(int, input().split()))
x.sort()
s=0
for I in reversed(range(1,a//3,1):
s+=x[i]
print(s) |
s919679686 | p03767 | u631238602 | 1546293907 | Python | Python (3.4.3) | py | Runtime Error | 49 | 27612 | 104 | n = int(input())
arr = map(int, input().strip().split())
arr.sort(reverse=True)
print(sum(arr[1:2*n:2])) |
s751137150 | p03767 | u816116805 | 1541962292 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 715 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
"""
agc012 C
"""
n, m = map(int, input().split())
graph = [[] for i in range(n+1)]
for i in range(m):
a, b = map(int, input().split())
graph[a].append(b)
graph[b].append(a)
q = int(input())
qlist = [tuple(map(int, input().split())) for i... |
s355842979 | p03767 | u064408584 | 1540948930 | Python | Python (3.4.3) | py | Runtime Error | 262 | 37084 | 211 | n=int(input())
a=list(map(int, input().split()))
a.sort()
m=a[n:2*n]
ans=sum(m)
for i in range(0,n,2):
if m[i]+m[i+1]<=a[2*n+i]+a[n-i-1]:
ans+= a[2*n+i]+a[n-i-1]-m[i]-m[i+1]
else:break
print(ans) |
s301206195 | p03767 | u366644013 | 1534444040 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 79 | n = int(input)
a = sorted(list(map(int, input().split())))
print(sum(a[n:3*n])) |
s705527930 | p03767 | u366644013 | 1534443988 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 78 | n = int(input)
a = sorted(list(map(int, input().split())))
print(sum(a[n:3n])) |
s820943191 | p03767 | u366644013 | 1534443952 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 77 | n = int(input)
a = sorted(list(map(int, input().split())))
print(sum(a[n:3])) |
s185776241 | p03767 | u918928910 | 1514687944 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 1069 | for t in range(1):
graph = {}
colors = {}
n, m = list(map(int, input().split()))
for i in range(m):
a, b = list(map(int, input().split()))
if a not in graph:
graph[a] = [b]
else:
graph[a].append(b)
if b not in graph:
graph[b] = [a]
... |
s491551451 | p03767 | u596276291 | 1512600282 | Python | PyPy3 (2.4.0) | py | Runtime Error | 250 | 41200 | 1333 | import sys
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt, ceil, floor
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache, ... |
s850821103 | p03767 | u556160473 | 1492562364 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 332 | 10
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 100000000... |
s191448718 | p03767 | u602860891 | 1491665618 | Python | Python (3.4.3) | py | Runtime Error | 262 | 37084 | 456 |
def main():
N = int(input())
a_list = get_a_list()
a_list.sort(reverse=True)
sum_second_a = 0
import pdb; pdb.set_trace()
while len(a_list) > 0:
a_list.pop(0)
sum_second_a += a_list.pop(0)
a_list.pop(-1)
print(sum_second_a)
def get_a_list():
a_list = []
... |
s127703551 | p03767 | u026450699 | 1491230703 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 181 | N = int(raw_input())
list = map(int, raw_input().split(" "))
list.sort(reverse=True)
total = 0
unit = len(list) / 3
for i in range(unit, unit * 2):
total += list[i]
print total
|
s526044905 | p03767 | u209551477 | 1491184895 | Python | PyPy3 (2.4.0) | py | Runtime Error | 170 | 38256 | 1470 | N, X, Y = map( int, input().split() )
C = []
W = []
for i in range( N ):
c, w = map( int, input().split() )
C.append( c - 1 )
W.append( w )
c2w = [ [] for i in range( N ) ]
for i in range( N ):
c2w[ C[ i ] ].append( W[ i ] )
for i in range( N ):
c2w[ C[ i ] ].sort()
minw, _minwp = 2e9, -1
for i in range( N... |
s399299349 | p03767 | u006493569 | 1491151186 | Python | PyPy3 (2.4.0) | py | Runtime Error | 168 | 38384 | 532 | n, m = map(int, input().split())
edges = [list(map(lambda x: int(x) - 1, input().split())) for _ in range(m)]
edges += [[i, i] for i in range(n)]
q = int(input())
color = [0] * q
dp = [[0 for j in range(n)] for i in range(11)]
for i in range(q):
v, d, color[i] = map(int, input().split())
dp[d][v - 1] = i
for... |
s886802575 | p03767 | u608297208 | 1491149913 | Python | Python (3.4.3) | py | Runtime Error | 303 | 20792 | 1065 | import numpy as np
N,M = map(int,input().split())
nodes = [[False]* N for j in range(N)]
for m in range(M):
a,b = map(int,input().split())
nodes[a-1][b-1] = True
nodes[b-1][a-1] = True
mat1 = np.matrix(nodes,dtype=bool)
mat2 = mat1.copy()
A = [mat1.tolist()]
for i in range(10):
mat2 = mat2.dot(mat1)
a = mat2.tolis... |
s433934644 | p03767 | u821262411 | 1491148770 | Python | Python (3.4.3) | py | Runtime Error | 251 | 39492 | 202 | N=int(input())
a=list(map(int,input().split()))
b=sorted(a)
ans1=sum(b[N:2*N])
ans2=0
for i in range(N):
ans2 += b[i*3+1]
ans3=0
for i in range(N):
ans3 += b[i*2+4]
print(max(ans1,ans2,ans3)) |
s946289015 | p03767 | u024612773 | 1491142768 | Python | PyPy3 (2.4.0) | py | Runtime Error | 173 | 38640 | 533 | import numpy as np
n,m=map(int,input().split())
e = []
for _ in range(1,m+1):
a,b=map(int,input().split())
e.append((a,b))
q = int(input())
cs = [0] * (q+1)
dp = np.zeros((n+1, 11), int)
for i in range(1, q+1):
v,d,c=map(int,input().split())
cs[i] = c
dp[v,d] = i
for d in range(9, -1, -1):
f... |
s339737418 | p03767 | u966695411 | 1491119278 | Python | Python (3.4.3) | py | Runtime Error | 35 | 9460 | 70 | print(sum(sorted(map(int,input().split()))[::-1][1:2*int(input()):2])) |
s988294771 | p03767 | u076936237 | 1491109240 | Python | Python (3.4.3) | py | Runtime Error | 152 | 12480 | 698 | import numpy as np
from collections import defaultdict
memo = {}
def dp(v, d, c):
if memo.get((v, d), False):
return None
memo[(v, d)] = True
if d == 0:
res[v-1] = c
return None
dp(v, d-1, c)
for e in dic.get(v, []):
dp(e, d-1, c)
N, M = tuple(map(int, input().sp... |
s559920375 | p03767 | u104282757 | 1491104482 | Python | Python (3.4.3) | py | Runtime Error | 21 | 3316 | 909 | from collections import deque
G = dict()
N, M = map(int, input().split())
color = [0]*(N+1)
for n in range(1, N+1):
G[n] = []
for _ in range(M):
a, b = map(int, input().split())
G[a].append(b)
G[b].append(a)
Q = int(input())
data = [list(map(int, input().split())) for _ in range(Q)]
data.reverse()
... |
s378947166 | p03767 | u608297208 | 1491103752 | Python | Python (3.4.3) | py | Runtime Error | 311 | 21336 | 744 | import numpy as np
N,M = map(int,input().split())
nodes = [[False]* N for j in range(N)]
for m in range(M):
a,b = map(int,input().split())
nodes[a-1][b-1] = True
nodes[b-1][a-1] = True
mat1 = np.matrix(nodes,dtype=bool)
mat2 = mat1.copy()
A = [mat1.tolist()]
for i in range(10):
mat2 = mat2.dot(mat1)
a = mat2.tolis... |
s363192506 | p03767 | u076936237 | 1491102310 | Python | Python (3.4.3) | py | Runtime Error | 148 | 12508 | 750 | import numpy as np
from numpy import linalg as LA
import math
mat_dic = {}
def f(mat, n):
if mat_dic.get(n, None) is not None:
return mat_dic.get(n, None)
if n == 1:
return mat
if int(math.sqrt(n))**2 == n:
return LA.matrix_power(f(mat, int(math.sqrt(n))), 2)
return mat.dot(... |
s644580471 | p03767 | u946912540 | 1491102298 | Python | Python (3.4.3) | py | Runtime Error | 208 | 37084 | 81 | n = input()
x = [int(_) for _ in input().split()]
x.sort()
print(sum(x[n:n*2]))
|
s261635964 | p03767 | u076936237 | 1491101204 | Python | Python (3.4.3) | py | Runtime Error | 565 | 46116 | 522 | import numpy as np
N = int(input())
a = list(map(int, input().split(' ')))
a.sort()
x = []
for n in range(N):
x.append([])
for i in range(3):
x[n].append(0)
for i in range(N*3):
x[i % N][i // N] = a[i]
for i in range(N-1, -1, -1):
for j in range(i-1, -1, -1):
if x[i][1] == x[j][1] a... |
s576078522 | p03767 | u794250528 | 1491100928 | Python | PyPy3 (2.4.0) | py | Runtime Error | 176 | 38640 | 1000 | import collections
if __name__ == '__main__':
n, m = map(int, input().split())
routes = collections.defaultdict(list)
for _ in range(m):
a, b = (int(x) - 1 for x in input().split())
routes[a].append(b)
routes[b].append(a)
matrix = [[None for _ in range(n)] for _ in range(n)]
... |
s923988382 | p03767 | u454697629 | 1491099310 | Python | Python (3.4.3) | py | Runtime Error | 1795 | 33804 | 320 | # -*- coding: utf-8 -*-
"""
Created on Sat Apr 1 22:07:55 2017
@author: taichiNakamura
"""
N = int(input())
# スペース区切りの整数の入力
num = map(int, input().split())
import numpy as np
num = np.array(num)
num = np.sort(num)
sum = 0
for i in range(N):
sum += num[3*N - 2 - i*2]
# 出力
print(sum) |
s861563223 | p03767 | u391812144 | 1491097021 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 379 | input_lines = str(input())
input_lines2 = str(input())
n = int(input_lines)
aAry = input_lines2.split(' ')
aAry = map(int,aAry)
aAry = sorted(aAry)
#print(aAry)
answer1 = 0L
for i in range(n):
answer1 += int(aAry[(-i-1)*2])
answer2 = 0L
for i in range(n):
answer2 += int(aAry[-i-3])
if answer1 >= answer2:
... |
s573180680 | p03767 | u943329882 | 1491096820 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 177 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
N = int(raw_input())
a = raw_input().split(" ")
output = 0
a.sort()
for i in a[N:2*N]:
output = output + int(i)
print output |
s456969319 | p03767 | u515802486 | 1491095316 | Python | Python (3.4.3) | py | Runtime Error | 208 | 37084 | 377 | import sys
INF = 10**9+7
stdin = sys.stdin
def na(): return map(int, stdin.readline().split())
def ns(): return stdin.readline().strip()
def nsl(): return list(stdin.readline().strip())
def ni(): return int(stdin.readline())
def nil(): return list(map(int, stdin.readline().split()))
n = ni()
a = nil()
a.sort()
an... |
s295789251 | p03768 | u456353530 | 1600969952 | Python | PyPy3 (7.3.0) | py | Runtime Error | 1157 | 143756 | 1083 | N, M = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(M)]
Q = int(input())
vdc = [list(map(int, input().split())) for _ in range(Q)]
L = [[] for _ in range(N)]
for a, b in ab:
a -= 1
b -= 1
L[a].append(b)
L[b].append(a)
D = [[0] * 10 for _ in range(N)]
Ans = [0] * N
def ... |
s386582497 | p03768 | u368796742 | 1600484884 | Python | Python (3.8.2) | py | Runtime Error | 2218 | 449556 | 1323 | import sys
sys.setrecursionlimit(10**6)
n,m = map(int,input().split())
e = [[] for i in range(n+1)]
for i in range(m):
a,b = map(int,input().split())
e[a].append(b)
e[b].append(a)
qv = int(input())
Q = [list(map(int,input().split())) for i in range(qv)]
Q = Q[::-1]
l = [[0]*(11) for i in range(n+1)]
for v,d... |
s624081518 | p03768 | u368796742 | 1600484726 | Python | Python (3.8.2) | py | Runtime Error | 2219 | 449452 | 1300 | import sys
sys.setrecursionlimit(10**6)
n,m = map(int,input().split())
e = [[] for i in range(n+1)]
for i in range(m):
a,b = map(int,input().split())
e[a].append(b)
e[b].append(a)
qv = int(input())
Q = [list(map(int,input().split())) for i in range(qv)]
Q = Q[::-1]
l = [[0]*(11) for i in range(n+1)]
for v,d... |
s121472303 | p03768 | u368796742 | 1600484618 | Python | Python (3.8.2) | py | Runtime Error | 2282 | 2565712 | 1300 | import sys
sys.setrecursionlimit(10**6)
n,m = map(int,input().split())
e = [[] for i in range(n+1)]
for i in range(m):
a,b = map(int,input().split())
e[a].append(b)
e[b].append(a)
qv = int(input())
Q = [list(map(int,input().split())) for i in range(qv)]
Q = Q[::-1]
l = [[0]*(11) for i in range(n+1)]
for v,d... |
s644983166 | p03768 | u368796742 | 1600484543 | Python | Python (3.8.2) | py | Runtime Error | 2266 | 2515072 | 1299 | import sys
sys.setrecursionlimit(10**6)
n,m = map(int,input().split())
e = [[] for i in range(n+1)]
for i in range(m):
a,b = map(int,input().split())
e[a].append(b)
e[b].append(a)
qv = int(input())
Q = [list(map(int,input().split())) for i in range(qv)]
Q = Q[::-1]
l = [[0]*(11) for i in range(n+1)]
for v,d... |
s316698858 | p03768 | u368796742 | 1600484383 | Python | PyPy3 (7.3.0) | py | Runtime Error | 2280 | 2674536 | 1290 | from collections import deque
n,m = map(int,input().split())
e = [[] for i in range(n+1)]
for i in range(m):
a,b = map(int,input().split())
e[a].append(b)
e[b].append(a)
qv = int(input())
Q = [list(map(int,input().split())) for i in range(qv)]
Q = Q[::-1]
l = [[0]*(11) for i in range(n+1)]
for v,d,c in Q:
... |
s120311933 | p03768 | u520276780 | 1600028834 | Python | Python (3.8.2) | py | Runtime Error | 2207 | 141436 | 730 | import sys
sys.setrecursionlimit(100000)
n,m=map(int, input().split())
e=[[] for _ in range(n)]
for _ in range(m):
ai,bi=map(int, input().split())
ai-=1;bi-=1
e[ai].append(bi);e[bi].append(ai)
Q=int(input())
q=[tuple(map(int, input().split())) for _ in range(Q)]
q.reverse()
color=[0]*n
from collections imp... |
s263671955 | p03768 | u520276780 | 1600028772 | Python | PyPy3 (7.3.0) | py | Runtime Error | 2213 | 234964 | 689 | n,m=map(int, input().split())
e=[[] for _ in range(n)]
for _ in range(m):
ai,bi=map(int, input().split())
ai-=1;bi-=1
e[ai].append(bi);e[bi].append(ai)
Q=int(input())
q=[tuple(map(int, input().split())) for _ in range(Q)]
q.reverse()
color=[0]*n
from collections import deque
que=deque()
used=set()
def bfs(... |
s056828270 | p03768 | u520276780 | 1600028288 | Python | PyPy3 (7.3.0) | py | Runtime Error | 601 | 159772 | 603 | n,m=map(int, input().split())
e=[[] for _ in range(n)]
for _ in range(m):
ai,bi=map(int, input().split())
ai-=1;bi-=1
e[ai].append(bi);e[bi].append(ai)
Q=int(input())
q=[tuple(map(int, input().split())) for _ in range(Q)]
q.reverse()
color=[0]*n
from collections import deque
que=deque()
def bfs(v,d,c):
... |
s789222202 | p03768 | u156302018 | 1599793297 | Python | Python (3.8.2) | py | Runtime Error | 25 | 8944 | 221 | N = int(input())
moti_list = []
for i in range(N):
moti_list.append(int(input()))
moti_list.sort(reverse=True)
tower = 1
for j in range(N - 1):
if moti_list[j] > moti_list[j + 1]:
tower += 1
print(tower) |
s384268022 | p03768 | u102461423 | 1592639677 | Python | Python (3.8.2) | py | Runtime Error | 431 | 62104 | 1381 | import sys
import numpy as np
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def graph_input(N, M):
G = [[] for _ in range(N + 1)]
for _ in range(M):
a, b = map(int, readline().split())
G[a].append(b)
G[b].append(a)
ind = np... |
s281355212 | p03768 | u102461423 | 1592639563 | Python | Python (3.8.2) | py | Runtime Error | 475 | 62272 | 1381 | import sys
import numpy as np
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def graph_input(N, M):
G = [[] for _ in range(N + 1)]
for _ in range(M):
a, b = map(int, readline().split())
G[a].append(b)
G[b].append(a)
ind = np... |
s317553841 | p03768 | u543954314 | 1589728502 | Python | Python (3.4.3) | py | Runtime Error | 728 | 43740 | 658 | from collections import deque
n, m = map(int, input().split())
G = [list() for _ in range(n)]
for _ in range(m):
a, b = map(int, input().split())
a -= 1; b -= 1
G[a].append(b)
G[b].append(a)
Q = int(input())
queries = [tuple(map(int, input().split())) for _ in range(Q)][::-1]
dp = [[Q]*n for _ in range(11)]
fo... |
s829273071 | p03768 | u543954314 | 1589728429 | Python | Python (3.4.3) | py | Runtime Error | 2223 | 1747400 | 656 | from collections import deque
n, m = map(int, input().split())
G = [list() for _ in range(n)]
for _ in range(m):
a, b = map(int, input().split())
a -= 1; b -= 1
G[a].append(b)
G[b].append(a)
Q = int(input())
queries = [tuple(map(int, input().split())) for _ in range(Q)][::-1]
dp = [[Q]*n for _ in range(n)]
for... |
s808084751 | p03768 | u693716675 | 1586978264 | Python | Python (3.4.3) | py | Runtime Error | 1803 | 56948 | 1024 | #b
#by using the condition d<=10, we should memorize V*d whether the pair is already searched.
#if searched, we can stop.
n,m = [int(i) for i in input().split()]
edges = [[] for _ in range(n)]
colors = [0]*n
checker = [[0 for _ in range(10)] for _ in range(n)]
def dfs(d,v,c):
if checker[v][d] != 0 or d<0:
... |
s541748232 | p03768 | u141610915 | 1584314873 | Python | PyPy3 (2.4.0) | py | Runtime Error | 2118 | 262012 | 966 | import sys
from collections import defaultdict as dd
input = sys.stdin.readline
N, M = map(int, input().split())
e = dd(list)
for _ in range(M):
u, v = map(int, input().split())
e[u].append(v)
e[v].append(u)
base = 10 ** 6
def clean():
global res
for i in range(1, N + 1):
if len(res[i]) == 0: continue
... |
s968990045 | p03768 | u141610915 | 1584313979 | Python | PyPy3 (2.4.0) | py | Runtime Error | 479 | 84956 | 885 | import sys
from collections import defaultdict as dd
input = sys.stdin.readline
N, M = map(int, input().split())
e = dd(list)
for _ in range(M):
u, v = map(int, input().split())
e[u].append(v)
e[v].append(u)
res = [set() for _ in range(N + 1)]
Q = int(input())
qd = [0] * Q
qc = [0] * Q
for i in range(Q):
v, d... |
s725843396 | p03768 | u597486843 | 1554514365 | Python | Python (3.4.3) | py | Runtime Error | 2112 | 58496 | 1069 | from collections import deque
import numpy as np
import sys
n, m = map(int, input().split())
g = {}
maxD = np.array([-1 for i in range(n)])
color = np.array([0 for _ in range(n)])
for u, v in (map(int, sys.stdin.readline().split()) for _ in [0]*n):
u-=1
v-=1
if u not in g:
g[u] = []
if ... |
s140751034 | p03768 | u597486843 | 1554502214 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 812 | n, m = map(int, input().split())
g = {}
used = {i:[False for _ in range(11)] for i in range(n)}
color = [0 for _ in range(n)]
for _ in range(m):
u, v = map(int, input().split())
u-=1
v-=1
if u not in g:
g[u] = []
if v not in g:
g[v] = []
g[u].append(v)
g[v].appen... |
s044026409 | p03768 | u597486843 | 1554501807 | Python | Python (3.4.3) | py | Runtime Error | 1966 | 74360 | 793 | n, m = map(int, input().split())
g = {}
used = {i:[False for _ in range(11)] for i in range(n)}
color = [0 for _ in range(n)]
for _ in range(m):
u, v = map(int, input().split())
u-=1
v-=1
if u not in g:
g[u] = []
if v not in g:
g[v] = []
g[u].append(v)
g[v].append... |
s870376264 | p03768 | u760171369 | 1553114345 | Python | Python (3.4.3) | py | Runtime Error | 2110 | 389864 | 960 | import numpy as np
N, M = map(int, input().split())
# グラフの初期化
A = [[] for i in range(N)]
# グラフの作成
for k in range(M):
a, b = map(int, input().split())
a, b = sorted([a, b])
A[a-1].append(b-1)
# 距離
distance = np.full((N, N), np.inf)
for i in range(N):
cnt = 0
distance[i, i] = cnt
places = A[i]
w... |
s371094304 | p03768 | u760171369 | 1553102638 | Python | Python (3.4.3) | py | Runtime Error | 2112 | 17860 | 575 | import numpy as np
N, M = map(int, input().split())
# グラフの初期化
a = []
for k in range(N):
a.append(set())
A = np.array(a)
# グラフの作成
for k in range(M):
a, b = map(int, input().split())
A[a-1].update([b-1])
A[b-1].update([a-1])
# 色塗り
Q = int(input())
colors = np.zeros(N)
for k in range(Q):
v, d, c = map(int... |
s705454079 | p03768 | u062147869 | 1552619254 | Python | PyPy3 (2.4.0) | py | Runtime Error | 425 | 81584 | 706 | import sys
input = sys.stdin.readline
from collections import deque
N,M=map(int,input().split())
table=[[] for i in range(N)]
for i in range(M):
a,b=map(int,input().split())
a,b=a-1,b-1
table[a].append(b)
table[b].append(a)
Q=int(input())
X=[[int(i) for i in input().split()] for i in range(Q)]
color=[0]... |
s371067788 | p03768 | u226155577 | 1519330982 | Python | Python (3.4.3) | py | Runtime Error | 2108 | 51448 | 622 | N, M = map(int, input().split())
G = [[] for i in range(N)]
for i in range(M):
a, b = map(int, input().split())
G[a-1].append(b-1)
G[b-1].append(a-1)
dp = [[-1]*10 for i in range(N)]
mark = {}
Q = int(input())
col = [0]*(Q+1)
col[-1] = 0
C = []
for i in range(Q):
v, d, c = map(int, input().split())
... |
s683429608 | p03768 | u918928910 | 1514687961 | Python | Python (3.4.3) | py | Runtime Error | 2108 | 103380 | 1069 | for t in range(1):
graph = {}
colors = {}
n, m = list(map(int, input().split()))
for i in range(m):
a, b = list(map(int, input().split()))
if a not in graph:
graph[a] = [b]
else:
graph[a].append(b)
if b not in graph:
graph[b] = [a]
... |
s836988671 | p03768 | u551313534 | 1491534296 | Python | Python (3.4.3) | py | Runtime Error | 2110 | 31932 | 731 | import scipy.sparse as sp
import numpy as np
def query(mat, v, d, c, color):
acc1 = acc2 = sp.identity(n, format='csr')
for i in range(d):
acc1 *= mat
# acc2 += acc1
# vec = acc2.getrow(v-1)
# mask = vec.sign()
# color -= color.multiply(mask)
# color += c*mask
return color
n,... |
s270922189 | p03768 | u551313534 | 1491534121 | Python | Python (3.4.3) | py | Runtime Error | 2110 | 32552 | 734 | import scipy.sparse as sp
import numpy as np
def query(mat, v, d, c, color):
acc1 = acc2 = sp.identity(n, format='csr')
for i in range(1, d+1):
acc1 *= mat
acc2 += acc1
# vec = acc2.getrow(v-1)
# mask = vec.sign()
# color -= color.multiply(mask)
# color += c*mask
return color
... |
s777842327 | p03768 | u551313534 | 1491533958 | Python | Python (3.4.3) | py | Runtime Error | 2110 | 30888 | 683 | import scipy.sparse as sp
import numpy as np
def query(mat, v, d, c, color):
acc1 = acc2 = sp.identity(n, format='csr')
for i in range(1, d+1):
acc1 *= mat
acc2 += acc1
vec = acc2.getrow(v-1)
mask = vec.sign()
color -= color.multiply(mask)
color += c*mask
return color
n, ... |
s548451116 | p03768 | u551313534 | 1491533904 | Python | Python (3.4.3) | py | Runtime Error | 2113 | 31536 | 730 | import scipy.sparse as sp
import numpy as np
def query(mat, v, d, c, color):
acc1 = acc2 = sp.identity(n, format='csr')
for i in range(1, d+1):
acc1 *= mat
acc2 += acc1
vec = acc2.getrow(v-1)
mask = vec.sign()
color -= color.multiply(mask)
color += c*mask
return color
n, ... |
s388222341 | p03768 | u551313534 | 1491533213 | Python | Python (3.4.3) | py | Runtime Error | 2110 | 31528 | 754 | #! /usr/bin/env python3
import scipy.sparse as sp
import numpy as np
def query(mat, v, d, c, color):
acc1 = acc2 = sp.identity(n, format='csr')
for i in range(1, d+1):
acc1 *= mat
acc2 += acc1
vec = acc2.getrow(v-1)
mask = vec.sign()
color -= color.multiply(mask)
color += c*ma... |
s625553384 | p03768 | u692632484 | 1491349720 | Python | Python (3.4.3) | py | Runtime Error | 845 | 55168 | 832 | import copy
temp=input().split()
N=int(temp[0])
M=int(temp[1])
ab=[[int(j)-1 for j in input().split()] for i in range(M)]
Q=int(input())
vdc=[[int(j)-1 for j in input().split()] for i in range(Q)]
#color=[-1 for i in range(N)]
chain=[[] for i in range(N)]
for i in range(M):
chain[ab[i][0]]+=[ab[i][1]]
chain[ab[i][1... |
s935140979 | p03768 | u594567187 | 1491194779 | Python | PyPy3 (2.4.0) | py | Runtime Error | 1442 | 112544 | 662 | vertices,edges = (int(n) for n in input().split(" "))
edge = [[n,n] for n in range(vertices)]
for e in range(edges):
u,v = (int(n) - 1 for n in input().split(" "))
edge.append([u,v])
color = [0 for n in range(vertices + 1)]
query = int(input())
dp = [[0 for n in range(11)] for m in range(vertices)]
for q in ran... |
s981845332 | p03768 | u594567187 | 1491194109 | Python | PyPy3 (2.4.0) | py | Runtime Error | 1229 | 99544 | 629 | vertices,edges = (int(n) for n in input().split(" "))
edge = []
for e in range(edges):
u,v = (int(n) - 1 for n in input().split(" "))
edge.append([u,v])
color = [0 for n in range(vertices)]
query = int(input())
dp = [[0 for n in range(11)] for m in range(vertices)]
for q in range(query):
e,d,col = (int(n) f... |
s835209492 | p03768 | u608297208 | 1491186025 | Python | Python (3.4.3) | py | Runtime Error | 2222 | 1953524 | 599 | def painting(N,A,v,d,c):
if d < 0:
return
if A[v][d] == 0:
A[v][d] = c
for ni,n in enumerate(N[v]):
if n == 1:
painting(N,A,ni,d-1,c)
N,M = list(map(int,input().split()))
nodes = [[0]*N for i in range(N)]
dp = [[0]*10 for i in range(N)]
for m in range(M):
a,b = map(int,input().split())
nodes[a-1][b-1] ... |
s590649519 | p03768 | u006493569 | 1491151172 | Python | PyPy2 (5.6.0) | py | Runtime Error | 34 | 28396 | 532 | n, m = map(int, input().split())
edges = [list(map(lambda x: int(x) - 1, input().split())) for _ in range(m)]
edges += [[i, i] for i in range(n)]
q = int(input())
color = [0] * q
dp = [[0 for j in range(n)] for i in range(11)]
for i in range(q):
v, d, color[i] = map(int, input().split())
dp[d][v - 1] = i
for... |
s237620267 | p03768 | u608297208 | 1491150016 | Python | Python (3.4.3) | py | Runtime Error | 2272 | 2003940 | 1070 | import numpy as np
N,M = map(int,input().split())
nodes = [[False]* N for j in range(N)]
for m in range(M):
a,b = map(int,input().split())
nodes[a-1][b-1] = True
nodes[b-1][a-1] = True
mat1 = np.matrix(nodes,dtype=bool)
mat2 = mat1.copy()
A = [mat1.tolist()]
for i in range(10):
mat2 = mat2.dot(mat1)
a = mat2.tolis... |
s027653641 | p03768 | u608297208 | 1491149939 | Python | Python (3.4.3) | py | Runtime Error | 2231 | 2023140 | 1065 | import numpy as np
N,M = map(int,input().split())
nodes = [[False]* N for j in range(N)]
for m in range(M):
a,b = map(int,input().split())
nodes[a-1][b-1] = True
nodes[b-1][a-1] = True
mat1 = np.matrix(nodes,dtype=bool)
mat2 = mat1.copy()
A = [mat1.tolist()]
for i in range(10):
mat2 = mat2.dot(mat1)
a = mat2.tolis... |
s640051356 | p03768 | u024612773 | 1491142784 | Python | PyPy3 (2.4.0) | py | Runtime Error | 179 | 38384 | 533 | import numpy as np
n,m=map(int,input().split())
e = []
for _ in range(1,m+1):
a,b=map(int,input().split())
e.append((a,b))
q = int(input())
cs = [0] * (q+1)
dp = np.zeros((n+1, 11), int)
for i in range(1, q+1):
v,d,c=map(int,input().split())
cs[i] = c
dp[v,d] = i
for d in range(9, -1, -1):
f... |
s823330118 | p03768 | u379559362 | 1491106085 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 537 | q = int(input())
node_color = [0 for _ in range(n + 1)]
vdc = [list(map(int, input().split())) for _ in range(q)]
vdc = vdc[::-1]
painted = set()
visited = [[0] * 11 for _ in range(n + 1)]
def dfs(now, dist, color):
if dist < 0:
return
if visited[now][dist]:
return
visited[now][dist] += ... |
s774064154 | p03768 | u076936237 | 1491102319 | Python | Python (3.4.3) | py | Runtime Error | 2111 | 776648 | 750 | import numpy as np
from numpy import linalg as LA
import math
mat_dic = {}
def f(mat, n):
if mat_dic.get(n, None) is not None:
return mat_dic.get(n, None)
if n == 1:
return mat
if int(math.sqrt(n))**2 == n:
return LA.matrix_power(f(mat, int(math.sqrt(n))), 2)
return mat.dot(... |
s707639581 | p03768 | u330205771 | 1491101398 | Python | Python (2.7.6) | py | Runtime Error | 2110 | 760556 | 1163 | import numpy as np
N, M = map(int, raw_input().split())
a = []
b = []
for i in range(M):
temp = map(int, raw_input().split())
a.append(temp[0])
b.append(temp[1])
Q = int(raw_input())
v = []
d = []
c = []
for i in range(Q):
temp = map(int, raw_input().split())
v.append(temp[0])
d.append(temp[1])... |
s336483641 | p03768 | u054556734 | 1491101384 | Python | Python (3.4.3) | py | Runtime Error | 2105 | 18368 | 404 | n,m=map(int,input().split())
a=[0 for i in range(m+1)]
b=[0 for i in range(m+1)]
for i in range(1,m+1): a[i],b[i]=map(int,input().split())
q=int(input())
v=[0 for i in range(m+1)]
d=[0 for i in range(m+1)]
c=[0 for i in range(m+1)]
for i in range(1,q+1): v[i],d[i],c[i]=map(int,input().split())
for i in range(1,q+1):
... |
s055157232 | p03768 | u330205771 | 1491100626 | Python | Python (2.7.6) | py | Runtime Error | 2110 | 760556 | 1170 | import numpy as np
N, M = map(int, raw_input().split())
a = []
b = []
for i in range(M):
temp = map(int, raw_input().split())
a.append(temp[0])
b.append(temp[1])
Q = int(raw_input())
v = []
d = []
c = []
for i in range(Q):
temp = map(int, raw_input().split())
v.append(temp[0])
d.append(temp[1])... |
s101512179 | p03768 | u608297208 | 1491100559 | Python | PyPy3 (2.4.0) | py | Runtime Error | 179 | 38640 | 666 | import numpy as np
N,M = map(int,input().split())
nodes = [[0 for i in range(N)] for j in range(N)]
for m in range(M):
a,b = map(int,input().split())
nodes[a-1][b-1] = 1
nodes[b-1][a-1] = 1
mat1 = np.matrix(nodes)
mat2 = mat1.copy()
A = [mat1.tolist()]
for i in range(10):
mat2 = mat2.dot(mat1)
a = mat2.tolist()
A... |
s831234009 | p03768 | u076936237 | 1491100490 | Python | Python (3.4.3) | py | Runtime Error | 2111 | 776396 | 750 | import numpy as np
from numpy import linalg as LA
import math
mat_dic = {}
def f(mat, n):
if mat_dic.get(n, None) is not None:
return mat_dic.get(n, None)
if n == 1:
return mat
if int(math.sqrt(n))**2 == n:
return LA.matrix_power(f(mat, int(math.sqrt(n))), 2)
return mat.dot(... |
s894191200 | p03768 | u039623862 | 1491100432 | Python | PyPy3 (2.4.0) | py | Runtime Error | 2117 | 205316 | 1527 | import collections
N,M = map(int, input().split())
nodes = [collections.defaultdict(int) for i in range(N)]
for i in range(M):
a,b = map(int, input().split())
nodes[a-1][b-1] = 1
nodes[b-1][a-1] = 1
shots = []
Q = int(input())
for i in range(Q):
v,d,c = map(int, input().split())
shots.append((v-1... |
s117056211 | p03768 | u076936237 | 1491100084 | Python | Python (3.4.3) | py | Runtime Error | 2111 | 778692 | 640 | import numpy as np
from numpy import linalg as LA
mat_dic = {}
def f(mat, n):
if mat_dic.get(n, None) is not None:
return mat_dic.get(n, None)
if n == 1:
return mat
return mat.dot(f(mat, n-1))
N, M = tuple(map(int, input().split(' ')))
mat = np.identity(N)
res = np.zeros(N)
for m in r... |
s885791362 | p03768 | u107077660 | 1491100051 | Python | Python (3.4.3) | py | Runtime Error | 2108 | 283500 | 485 | N, M = map(int, input().split())
G = [[set([j]) for i in range(11)] for j in range(N)]
for _ in range(M):
a, b = map(int, input().split())
G[a-1][1].add(b-1)
G[b-1][1].add(a-1)
for i in range(N):
if len(G[i][1]) == 1:
continue
for d in range(1,11):
for j in G[i][d-1]:
G[i][d] |= G[j][1]
if len(G[i][d] ... |
s847799752 | p03768 | u330205771 | 1491099897 | Python | Python (2.7.6) | py | Runtime Error | 2112 | 760568 | 1138 | import numpy as np
N, M = map(int, raw_input().split())
a = []
b = []
for i in range(M):
temp1, temp2 = map(int, raw_input().split())
a.append(temp1)
b.append(temp2)
Q = int(raw_input())
v = []
d = []
c = []
for i in range(Q):
temp = map(int, raw_input().split())
v.append(temp[0])
d.append(temp... |
s594591177 | p03768 | u330205771 | 1491099624 | Python | Python (2.7.6) | py | Runtime Error | 2110 | 760572 | 1120 | import numpy as np
N, M = map(int, raw_input().split())
a = []
b = []
for i in range(M):
temp1, temp2 = map(int, raw_input().split())
a.append(temp1)
b.append(temp2)
Q = int(raw_input())
v = []
d = []
c = []
for i in range(Q):
temp = map(int, raw_input().split())
v.append(temp[0])
d.append(temp... |
s862345943 | p03768 | u076936237 | 1491099581 | Python | Python (3.4.3) | py | Runtime Error | 2111 | 776904 | 480 | import numpy as np
from numpy import linalg as LA
N, M = tuple(map(int, input().split(' ')))
mat = np.identity(N)
res = np.zeros(N)
for m in range(M):
a, b = tuple(map(int, input().split(' ')))
mat[a-1, b-1] = 1
mat[b-1, a-1] = 1
mat[a-1, a-1] = 1
mat[b-1, b-1] = 1
Q = int(input())
for q in ra... |
s245493509 | p03768 | u330205771 | 1491099252 | Python | Python (2.7.6) | py | Runtime Error | 2112 | 760572 | 1118 | import numpy as np
N, M = map(int, raw_input().split())
a = []
b = []
for i in range(M):
temp1, temp2 = map(int, raw_input().split())
a.append(temp1)
b.append(temp2)
Q = int(raw_input())
v = []
d = []
c = []
for i in range(Q):
temp = map(int, raw_input().split())
v.append(temp[0])
d.append(temp... |
s881984706 | p03768 | u076936237 | 1491098512 | Python | Python (3.4.3) | py | Runtime Error | 2111 | 776396 | 483 | import numpy as np
from numpy import linalg as LA
N, M = tuple(map(int, input().split(' ')))
mat = np.zeros((N, N))
res = np.zeros(N)
for m in range(M):
a, b = tuple(map(int, input().split(' ')))
mat[a-1, b-1] = 1
mat[b-1, a-1] = 1
mat[a-1, a-1] = 1
mat[b-1, b-1] = 1
Q = int(input())
for q in... |
s993527938 | p03768 | u076936237 | 1491098512 | Python | Python (3.4.3) | py | Runtime Error | 2111 | 776012 | 483 | import numpy as np
from numpy import linalg as LA
N, M = tuple(map(int, input().split(' ')))
mat = np.zeros((N, N))
res = np.zeros(N)
for m in range(M):
a, b = tuple(map(int, input().split(' ')))
mat[a-1, b-1] = 1
mat[b-1, a-1] = 1
mat[a-1, a-1] = 1
mat[b-1, b-1] = 1
Q = int(input())
for q in... |
s261393373 | p03768 | u330205771 | 1491098496 | Python | Python (2.7.6) | py | Runtime Error | 2109 | 760572 | 1118 | import numpy as np
N, M = map(int, raw_input().split())
a = []
b = []
for i in range(M):
temp1, temp2 = map(int, raw_input().split())
a.append(temp1)
b.append(temp2)
Q = int(raw_input())
v = []
d = []
c = []
for i in range(Q):
temp = map(int, raw_input().split())
v.append(temp[0])
d.append(temp... |
s004363919 | p03768 | u477320129 | 1491098430 | Python | PyPy3 (2.4.0) | py | Runtime Error | 703 | 69152 | 1123 | # import heapq
from collections import deque
class Node:
def __init__(self):
self.color = 0
self.to = []
def bfs(graph, cur, color, dist):
visited = set()
q = deque([(0, cur)])
while q:
# d, c = heapq.heappop(q)
d, c = q.popleft()
if c in visited:
co... |
s479734277 | p03768 | u477320129 | 1491098339 | Python | PyPy3 (2.4.0) | py | Runtime Error | 695 | 69216 | 1156 | # import heapq
from collections import deque
class Node:
def __init__(self):
self.color = 0
self.to = []
def bfs(graph, cur, color, visited, dist):
q = deque([(0, cur)])
while q:
# d, c = heapq.heappop(q)
d, c = q.popleft()
if visited[c]:
continue
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.