problem_id stringlengths 6 6 | user_id stringlengths 10 10 | time_limit float64 1k 8k | memory_limit float64 262k 1.05M | problem_description stringlengths 48 1.55k | codes stringlengths 35 98.9k | status stringlengths 28 1.7k | submission_ids stringlengths 28 1.41k | memories stringlengths 13 808 | cpu_times stringlengths 11 610 | code_sizes stringlengths 7 505 |
|---|---|---|---|---|---|---|---|---|---|---|
p03634 | u001024152 | 2,000 | 262,144 | You are given a tree with N vertices. Here, a _tree_ is a kind of graph, and more specifically, a connected undirected graph with N-1 edges, where N is the number of its vertices. The i-th edge (1≤i≤N-1) connects Vertices a_i and b_i, and has a length of c_i. You are also given Q queries and an integer K. In the j... | ["# D\nN = int(input())\nedge = [[] for _ in range(N)]\nfor _ in range(N):\n ai,bi,ci = map(int, input().split())\n edge[ai-1].append((bi-1, ci))\n edge[bi-1].append((ai-1, ci))\nQ,K = map(int, input().split())\nK = K-1\nx,y = [],[]\nfor _ in range(Q):\n xi,yi = map(int, input().split())\n x.append(xi-1)... | ['Runtime Error', 'Accepted'] | ['s820657278', 's538656599'] | [37040.0, 54188.0] | [493.0, 1109.0] | [661, 949] |
p03634 | u007550226 | 2,000 | 262,144 | You are given a tree with N vertices. Here, a _tree_ is a kind of graph, and more specifically, a connected undirected graph with N-1 edges, where N is the number of its vertices. The i-th edge (1≤i≤N-1) connects Vertices a_i and b_i, and has a length of c_i. You are also given Q queries and an integer K. In the j... | ['n= int(input())\nbranchdict = {}\nfor i in range(n-1):\n a,b,c= map(int,input().split())\n branchdict[a-1] = branchdict.get(a-1,[]) + [(b-1,c)]\n branchdict[b-1] = branchdict.get(b-1,[]) + [(a-1,c)]\nq,k= map(int,input().split())\ncost = [0] * n\ndef dfs(curnode,pre,addcost):\n cost[curnode]=addcost\n ... | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s583981719', 's709435413', 's008879740'] | [44948.0, 136496.0, 135728.0] | [2104.0, 686.0, 702.0] | [583, 588, 540] |
p03634 | u067729694 | 2,000 | 262,144 | You are given a tree with N vertices. Here, a _tree_ is a kind of graph, and more specifically, a connected undirected graph with N-1 edges, where N is the number of its vertices. The i-th edge (1≤i≤N-1) connects Vertices a_i and b_i, and has a length of c_i. You are also given Q queries and an integer K. In the j... | ['N, M, R = map(int, input().split())\nR_LIST = list(map(int, input().split()))\nABC = []\nfor _ in range(M):\n a,b,c = map(int, input().split())\n ABC.append((a,b,c))\n\nedges = ABC[:]\n\n\ndef warshall_floyd(d, n):\n \n \n \n for k in range(n):\n for i in range(n):\n for j in range... | ['Runtime Error', 'Accepted'] | ['s656699334', 's344897469'] | [3192.0, 85856.0] | [18.0, 1122.0] | [1093, 1073] |
p03634 | u067983636 | 2,000 | 262,144 | You are given a tree with N vertices. Here, a _tree_ is a kind of graph, and more specifically, a connected undirected graph with N-1 edges, where N is the number of its vertices. The i-th edge (1≤i≤N-1) connects Vertices a_i and b_i, and has a length of c_i. You are also given Q queries and an integer K. In the j... | ['import queue\n\nN = int(input())\nE = {n: set() for n in range(N)}\n\nfor _ in range(N - 1):\n a, b, c = map(int, input().split())\n a -= 1\n b -= 1\n E[a].add((b, c))\n E[b].add((a, c))\n\ndef m():\n Q, K = map(int, input().split())\n K -= 1\n dist = [-1] * N\n already = set()\n que = q... | ['Wrong Answer', 'Accepted'] | ['s351902116', 's006989207'] | [61272.0, 65628.0] | [568.0, 1274.0] | [742, 770] |
p03634 | u089142196 | 2,000 | 262,144 | You are given a tree with N vertices. Here, a _tree_ is a kind of graph, and more specifically, a connected undirected graph with N-1 edges, where N is the number of its vertices. The i-th edge (1≤i≤N-1) connects Vertices a_i and b_i, and has a length of c_i. You are also given Q queries and an integer K. In the j... | ['from collections import deque\n\nN=int(input())\na=[0]*(N-1)\nb=[0]*(N-1)\nc=[0]*(N-1)\nL=[ [] for _ in range(N)]\nfor i in range(N-1):\n a[i],b[i],c[i]= map(int,input().split())\n L[a[i]-1].append((b[i]-1,c[i]))\n L[b[i]-1].append((a[i]-1,c[i]))\nQ,K= map(int,input().split())\n \n\n\nd=[ -1 for i in range... | ['Runtime Error', 'Accepted'] | ['s198186541', 's374591768'] | [54068.0, 60320.0] | [1495.0, 771.0] | [654, 697] |
p03634 | u102461423 | 2,000 | 262,144 | You are given a tree with N vertices. Here, a _tree_ is a kind of graph, and more specifically, a connected undirected graph with N-1 edges, where N is the number of its vertices. The i-th edge (1≤i≤N-1) connects Vertices a_i and b_i, and has a length of c_i. You are also given Q queries and an integer K. In the j... | ['from scipy.sparse import csc_matrix\nimport sys\ninput = sys.stdin.readline\n\nN = int(input())\nABC = [[int(x) for x in input().split()] for _ in range(N-1)]\nrow,col,val = zip(*ABC)\n\nedge = csc_matrix((val,(row,col)),(N+1,N+1))\n', 'from scipy.sparse import lil_matrix\nimport sys\ninput = sys.stdin.readline\n\npr... | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s660628181', 's999425583', 's669420511'] | [44468.0, 13676.0, 131756.0] | [404.0, 171.0, 632.0] | [224, 443, 491] |
p03634 | u111497285 | 2,000 | 262,144 | You are given a tree with N vertices. Here, a _tree_ is a kind of graph, and more specifically, a connected undirected graph with N-1 edges, where N is the number of its vertices. The i-th edge (1≤i≤N-1) connects Vertices a_i and b_i, and has a length of c_i. You are also given Q queries and an integer K. In the j... | ['# http://wakabame.hatenablog.com/entry/2017/09/03/213522\n\nimport sys\ninput = sys.stdin.readline\n\n\nN = int(input())\n\n\nedges = [list(map(int, input().split())) for i in range(N)]\n\n\nQ, K = map(int, input().split())\n\n\nxy = [list(map(int, input().split())) for i in range(Q)]\n\n\n\ndef BFS(K, edges, N):\n ... | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s720701785', 's808018813', 's263566018'] | [3064.0, 81208.0, 85984.0] | [17.0, 546.0, 806.0] | [1509, 1512, 1516] |
p03634 | u114920558 | 2,000 | 262,144 | You are given a tree with N vertices. Here, a _tree_ is a kind of graph, and more specifically, a connected undirected graph with N-1 edges, where N is the number of its vertices. The i-th edge (1≤i≤N-1) connects Vertices a_i and b_i, and has a length of c_i. You are also given Q queries and an integer K. In the j... | ['from collections import deque\n\nN = int(input())\ngraph = [[] for _ in range(N+1)] \nlong = [0] * (N+1) \n\nfor i in range(N-1):\n x, y, z = map(int, input().split())\n graph[x].append([y, z])\n graph[y].append([x, z])\n \nQ, K = map(int, input().split())\nx = list()\ny = list()\n\nfor i in range(Q):\n x_i, y_i... | ['Time Limit Exceeded', 'Time Limit Exceeded', 'Accepted'] | ['s774645311', 's847691102', 's661866830'] | [58108.0, 57848.0, 152280.0] | [2107.0, 2107.0, 1649.0] | [838, 812, 520] |
p03634 | u119714109 | 2,000 | 262,144 | You are given a tree with N vertices. Here, a _tree_ is a kind of graph, and more specifically, a connected undirected graph with N-1 edges, where N is the number of its vertices. The i-th edge (1≤i≤N-1) connects Vertices a_i and b_i, and has a length of c_i. You are also given Q queries and an integer K. In the j... | ['import sys\n\nstdin = sys.stdin\n\nni = lambda: int(ns())\nna = lambda: list(map(int, stdin.readline().split()))\nns = lambda: stdin.readline()\n\nn = ni()\ng = []\nfor i in range(n+1): g.append([])\n\nfor i in range(n-1):\n a, b, c = na()\n g[a].append((b,c))\n g[b].append((a,c))\n\nq,k = na()\n\ndef dfs(cu... | ['Wrong Answer', 'Accepted'] | ['s232729023', 's325046446'] | [49916.0, 54588.0] | [688.0, 1050.0] | [824, 843] |
p03634 | u123756661 | 2,000 | 262,144 | You are given a tree with N vertices. Here, a _tree_ is a kind of graph, and more specifically, a connected undirected graph with N-1 edges, where N is the number of its vertices. The i-th edge (1≤i≤N-1) connects Vertices a_i and b_i, and has a length of c_i. You are also given Q queries and an integer K. In the j... | ["from collections import deque\n\ndef main()\n n=int(input())\n l=[0]*n\n d={}\n for i in range(n-1):\n a,b,c=map(int,input().split())\n a-=1\n b-=1\n if a in d:\n d[a].add((b,c))\n else:\n d[a]={(b,c)}\n if b in d:\n d[b].add((a,c)... | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s287143624', 's756435033', 's627477292'] | [2940.0, 2940.0, 61732.0] | [17.0, 17.0, 1451.0] | [738, 707, 738] |
p03634 | u129836004 | 2,000 | 262,144 | You are given a tree with N vertices. Here, a _tree_ is a kind of graph, and more specifically, a connected undirected graph with N-1 edges, where N is the number of its vertices. The i-th edge (1≤i≤N-1) connects Vertices a_i and b_i, and has a length of c_i. You are also given Q queries and an integer K. In the j... | ['import sys\nsys.setrecursionlimit(10**6)\nn=int(input())\nG=[[]for i in range(n+1)]\nfor i in range(n-1):\n a, b, c = map(int,input().split())\n G[a] += (b,c)\n G[b] += (a,c)\nq, k = map(int,input().split())\nd = [0]*(n+1) \ndef f(v,p,u): \n d[v] = u\n for t, c in G[v]:\n if p != t:\n ... | ['Runtime Error', 'Accepted'] | ['s064909144', 's925308527'] | [26156.0, 132400.0] | [459.0, 1407.0] | [496, 500] |
p03634 | u170183831 | 2,000 | 262,144 | You are given a tree with N vertices. Here, a _tree_ is a kind of graph, and more specifically, a connected undirected graph with N-1 edges, where N is the number of its vertices. The i-th edge (1≤i≤N-1) connects Vertices a_i and b_i, and has a length of c_i. You are also given Q queries and an integer K. In the j... | ['from collections import deque\n\ndef solve(n, ABC, q, k, XY):\n graph = [[] for _ in range(n)]\n for a, b, c in ABC:\n graph[a - 1].append((b - 1, c))\n graph[b - 1].append((a - 1, c))\n\n q = deque(maxlen=n)\n q.append((k - 1, 0))\n used = {k - 1}\n l = [] * n\n while len(q) > 0:\n... | ['Wrong Answer', 'Accepted'] | ['s114202645', 's449977985'] | [3316.0, 95204.0] | [20.0, 1049.0] | [556, 816] |
p03634 | u170201762 | 2,000 | 262,144 | You are given a tree with N vertices. Here, a _tree_ is a kind of graph, and more specifically, a connected undirected graph with N-1 edges, where N is the number of its vertices. The i-th edge (1≤i≤N-1) connects Vertices a_i and b_i, and has a length of c_i. You are also given Q queries and an integer K. In the j... | ['from scipy.sparse.csgraph import dijkstra\nimport numpy as np\n\nN = int(input())\nedge = [[np.inf for i in range(N+1)] for i in range(N+1)]\nfor i in range(N-1):\n a,b,c = map(int,input().split())\n edge[a][b] = c\n edge[b][a] = c\ncost = dijkstra(edge)\nQ,K = map(int,input().split())\nfor i in range(Q):\n ... | ['Wrong Answer', 'Accepted'] | ['s267106196', 's021984254'] | [261296.0, 48288.0] | [2126.0, 1521.0] | [372, 873] |
p03634 | u179169725 | 2,000 | 262,144 | You are given a tree with N vertices. Here, a _tree_ is a kind of graph, and more specifically, a connected undirected graph with N-1 edges, where N is the number of its vertices. The i-th edge (1≤i≤N-1) connects Vertices a_i and b_i, and has a length of c_i. You are also given Q queries and an integer K. In the j... | ['import sys\nsys.setrecursionlimit(1000000)\n\nN = int(input())\nX, Y = [], []\n\ntree = {key+1: [] for key in range(N)} \n\n\n\nfor n in range(N - 1):\n a, b, c = list(map(int, input().split()))\n tree[a].append((b, c))\n tree[b].append((a, c)) \n\n# for n in tree.keys():\n\n\n\nQ, K = list(map(int, input(... | ['Wrong Answer', 'Accepted'] | ['s925365727', 's413141247'] | [157276.0, 151636.0] | [1142.0, 1136.0] | [1159, 1161] |
p03634 | u195608881 | 2,000 | 262,144 | You are given a tree with N vertices. Here, a _tree_ is a kind of graph, and more specifically, a connected undirected graph with N-1 edges, where N is the number of its vertices. The i-th edge (1≤i≤N-1) connects Vertices a_i and b_i, and has a length of c_i. You are also given Q queries and an integer K. In the j... | ['n = int(input())\n\npath = [None]*(n + 1)\nadjacent_list = [[] for i in range(n+1)]\n\nfor i in range(n - 1):\n a, b, c = list(map(int,input().split()))\n adjacent_list[a].append([b,c])\n adjacent_list[b].append([a,c])\n\ndef dfs(node_n ,distance,finished):\n \n finished.add(node_n)\n \n path[nod... | ['Runtime Error', 'Accepted'] | ['s194925882', 's618027117'] | [3064.0, 140580.0] | [17.0, 1705.0] | [1039, 1041] |
p03634 | u200030766 | 2,000 | 262,144 | You are given a tree with N vertices. Here, a _tree_ is a kind of graph, and more specifically, a connected undirected graph with N-1 edges, where N is the number of its vertices. The i-th edge (1≤i≤N-1) connects Vertices a_i and b_i, and has a length of c_i. You are also given Q queries and an integer K. In the j... | ["import sys\n\nsys.setrecursionlimit(100000)\n\n\nfileobj=open('subtask_1_28.txt','rt')\n\nV=int(fileobj.readline().strip())\nE=V-1\ninf=3*10**15\nG=[]\ndist=[inf]*V\nvisited=[False]*V\n\nfor i in range(V):\n G.append([])\nfor i in range(E):\n at,bt,ct=map(int,fileobj.readline().strip().split(' '))\n G[at-1].... | ['Runtime Error', 'Accepted'] | ['s521156381', 's315196159'] | [3064.0, 140456.0] | [17.0, 1428.0] | [934, 798] |
p03634 | u201802797 | 2,000 | 262,144 | You are given a tree with N vertices. Here, a _tree_ is a kind of graph, and more specifically, a connected undirected graph with N-1 edges, where N is the number of its vertices. The i-th edge (1≤i≤N-1) connects Vertices a_i and b_i, and has a length of c_i. You are also given Q queries and an integer K. In the j... | ['import sys\ninput = sys.stdin.readline\n\ndata = int(input())\nE = [[] for _ in range(data)]\nfor _ in range(data-1):\n a, b, c = list(map(int, input().split()))\n E[a-1].append((b-1,c))\n E[b-1].append((a-1,c))\n\nnim, mike = list(map(int, input().split()))\n\nqueue = [mike-1]\ndist = [None]*data\ndist[K-1] = 0\n... | ['Runtime Error', 'Accepted'] | ['s775118870', 's240603741'] | [42828.0, 91044.0] | [376.0, 1348.0] | [586, 499] |
p03634 | u223904637 | 2,000 | 262,144 | You are given a tree with N vertices. Here, a _tree_ is a kind of graph, and more specifically, a connected undirected graph with N-1 edges, where N is the number of its vertices. The i-th edge (1≤i≤N-1) connects Vertices a_i and b_i, and has a length of c_i. You are also given Q queries and an integer K. In the j... | ['fron collections import deque\nn=int(input())\ng=[[] for i in range(n)]\nfor i in range(n-1):\n a,b,c=map(int,input().split())\n g[a-1].append([b-1,c])\n g[b-1].append([a-1,c])\nq,k=map(int,input().split())\nqu=deque([[k-1,0]])\nv=[0]*n\nd=[0]*n\nwhile len(qu)>0:\n s=qu.popleft()\n v[s[0]]=1\n for j... | ['Runtime Error', 'Accepted'] | ['s769623703', 's304634627'] | [2940.0, 58452.0] | [17.0, 1604.0] | [503, 503] |
p03634 | u225388820 | 2,000 | 262,144 | You are given a tree with N vertices. Here, a _tree_ is a kind of graph, and more specifically, a connected undirected graph with N-1 edges, where N is the number of its vertices. The i-th edge (1≤i≤N-1) connects Vertices a_i and b_i, and has a length of c_i. You are also given Q queries and an integer K. In the j... | ['from heapq import heappush,heapify,heappop\nINF = 10**10\n\nn = int(input())\n\ncost = [[INF]*n for _ in range(n)] \nes=[[] for _ in range(n)] \nd = [INF]*n \n\n\nfor i in range(n-1):\n a,b,c = map(int,input().split())\n a,b = a-1, b-1\n es[a].append((b,c))\n es[b].append((a,c))\n cost[a][b], cost[b][a... | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s400769850', 's450798519', 's396049923'] | [1947872.0, 47212.0, 46284.0] | [2228.0, 1500.0, 774.0] | [930, 546, 823] |
p03634 | u266874640 | 2,000 | 262,144 | You are given a tree with N vertices. Here, a _tree_ is a kind of graph, and more specifically, a connected undirected graph with N-1 edges, where N is the number of its vertices. The i-th edge (1≤i≤N-1) connects Vertices a_i and b_i, and has a length of c_i. You are also given Q queries and an integer K. In the j... | ['N = int(input())\nedge = [[] for _ in range(N+1)]\nfor _ in range(N-1):\n a,b,c = map(int,input().split())\n edge[a].append((b,c))\n edge[b].append((a,c))\nQ,K = map(int,input().split())\ndistance = [-1] * (N+1)\ndef dfs(v1,d):\n distance[v1] = d\n for v2,dd in edge[v1]:\n if distance[v2] is not... | ['Runtime Error', 'Accepted'] | ['s785279221', 's402411456'] | [49732.0, 132712.0] | [960.0, 994.0] | [512, 541] |
p03634 | u268210555 | 2,000 | 262,144 | You are given a tree with N vertices. Here, a _tree_ is a kind of graph, and more specifically, a connected undirected graph with N-1 edges, where N is the number of its vertices. The i-th edge (1≤i≤N-1) connects Vertices a_i and b_i, and has a length of c_i. You are also given Q queries and an integer K. In the j... | ['n=int(input())\ng=[[] for _ in range(n)]\nfor _ in range(n-1):\n a,b,c=map(int,input().split())\n g[a-1].append((b-1,c))\n g[b-1].append((a-1,c))\nq,k=map(int,input().split())\nd=[-1]*n\ndef f(k,c):\n d[k]=c\n for i,v in g[k]:\n if d[i]==-1:\n f(i,c+v)\nf(k-1,0)\nprint(d)\nfor _ in ra... | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s390618214', 's627141266', 's092474144'] | [46492.0, 3064.0, 131632.0] | [1388.0, 17.0, 1436.0] | [368, 399, 401] |
p03634 | u273084112 | 2,000 | 262,144 | You are given a tree with N vertices. Here, a _tree_ is a kind of graph, and more specifically, a connected undirected graph with N-1 edges, where N is the number of its vertices. The i-th edge (1≤i≤N-1) connects Vertices a_i and b_i, and has a length of c_i. You are also given Q queries and an integer K. In the j... | ['import sys\nimport collections\n\nsys.setrecursionlimit(1e7)\n\ndef dfs(node, parent, distance):\n depth[node] = distance\n for next_node, cost in Tree[node]:\n if next_node != parent:\n dfs(next_node, node, distance + cost)\n\nN = int(input())\n\nTree = collections.defaultdict(list)\n\nfor i ... | ['Runtime Error', 'Accepted'] | ['s839945412', 's609541905'] | [3316.0, 58528.0] | [20.0, 1531.0] | [562, 700] |
p03634 | u278868910 | 2,000 | 262,144 | You are given a tree with N vertices. Here, a _tree_ is a kind of graph, and more specifically, a connected undirected graph with N-1 edges, where N is the number of its vertices. The i-th edge (1≤i≤N-1) connects Vertices a_i and b_i, and has a length of c_i. You are also given Q queries and an integer K. In the j... | ['import sys\nsys.setrecursionlimit(1000000000)\n\nN = int(input())\nG = [[] for _ in range(N)]\nfor i in range(N - 1):\n a, b, c = list(map(int, input().split()))\n a = a - 1\n b = b - 1\n G[a].append((b, c))\n G[b].append((a, c))\n \nprint (G)\nQ, K = list(map(int,input().split()))\n\nD = [0] * N\nd... | ['Wrong Answer', 'Accepted'] | ['s996343116', 's797575861'] | [142944.0, 136780.0] | [1810.0, 1638.0] | [589, 579] |
p03634 | u281303342 | 2,000 | 262,144 | You are given a tree with N vertices. Here, a _tree_ is a kind of graph, and more specifically, a connected undirected graph with N-1 edges, where N is the number of its vertices. The i-th edge (1≤i≤N-1) connects Vertices a_i and b_i, and has a length of c_i. You are also given Q queries and an integer K. In the j... | ['import sys\nsys.setrecursionlimit(1000000)\n\nN = int(input())\nX = [[] for _ in range(N)]\n\nfor i in range(N-1):\n a,b,c = map(int,input().split())\n X[a-1].append((b-1,c))\n X[b-1].append((a-1,c))\n\ncost = [-1]*N\ndef calc(i,c):\n \n cost[i] = c\n \n for ni,nc in X[i]:\n \n if c... | ['Wrong Answer', 'Accepted'] | ['s292144085', 's064556406'] | [130096.0, 146028.0] | [838.0, 1080.0] | [614, 549] |
p03634 | u318127926 | 2,000 | 262,144 | You are given a tree with N vertices. Here, a _tree_ is a kind of graph, and more specifically, a connected undirected graph with N-1 edges, where N is the number of its vertices. The i-th edge (1≤i≤N-1) connects Vertices a_i and b_i, and has a length of c_i. You are also given Q queries and an integer K. In the j... | ['n = int(input())\ngraph = [[] for _ in range(n)]\nfor _ in range(n-1):\n a, b, c = map(int, input().split())\n a-=1\n b-=1\n graph[a].append((b, c))\n graph[b].append((a, c))\nq, k = map(int, input().split())\nk-=1\nseen = [False]*n\nl = [0]*n\n\nfor _ in range(q):\n x, y = map(int, input().split())\n print(l[... | ['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s284125998', 's693210220', 's782001988', 's703108143'] | [38832.0, 50736.0, 56756.0, 145140.0] | [1284.0, 819.0, 892.0, 1035.0] | [315, 584, 468, 584] |
p03634 | u341926204 | 2,000 | 262,144 | You are given a tree with N vertices. Here, a _tree_ is a kind of graph, and more specifically, a connected undirected graph with N-1 edges, where N is the number of its vertices. The i-th edge (1≤i≤N-1) connects Vertices a_i and b_i, and has a length of c_i. You are also given Q queries and an integer K. In the j... | ['from collections import deque\n\nN = int(input())\nedges = [[] for _ in range(N+1)]\nfor _ in range(N-1):\n ai, bi, ci = map(int, input().split())\n edges[ai].append((bi, ci))\n edges[bi].append((ai, ci))\nQ, K = map(int, input().split())\n\ndistance = [-1]*(N+1)\n# def add_weight(k, pre):\n# for v in ed... | ['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s488309758', 's894970193', 's906059423', 's920215264', 's436158899'] | [46740.0, 39192.0, 37812.0, 3064.0, 44568.0] | [1361.0, 1383.0, 454.0, 17.0, 1352.0] | [768, 744, 713, 529, 770] |
p03634 | u346222974 | 2,000 | 262,144 | You are given a tree with N vertices. Here, a _tree_ is a kind of graph, and more specifically, a connected undirected graph with N-1 edges, where N is the number of its vertices. The i-th edge (1≤i≤N-1) connects Vertices a_i and b_i, and has a length of c_i. You are also given Q queries and an integer K. In the j... | ['#include <bits/stdc++.h>\n\nusing namespace std;\n\nconst int N = 100005;\n\nlong long d[N];\nvector<pair<int, int>> g[N];\n\nvoid dfs(int u, int f, long long w) {\n d[u] = w;\n for (auto &go : g[u]) {\n if (go.first != f) {\n dfs(go.first, u, w + go.second);\n }\n }\n}\n\nint main() {\n int n;\n scan... | ['Runtime Error', 'Accepted'] | ['s443639790', 's266715716'] | [2940.0, 51408.0] | [17.0, 1641.0] | [618, 544] |
p03634 | u360515075 | 2,000 | 262,144 | You are given a tree with N vertices. Here, a _tree_ is a kind of graph, and more specifically, a connected undirected graph with N-1 edges, where N is the number of its vertices. The i-th edge (1≤i≤N-1) connects Vertices a_i and b_i, and has a length of c_i. You are also given Q queries and an integer K. In the j... | ['import numpy as np\nfrom scipy.sparse.csgraph import floyd_warshall\nfrom scipy.sparse import csr_matrix\nN = int(input())\nL = np.full((N, N), np.inf)\nfor i in range(N-1):\n a, b, c = map(int, input().split())\n L[a-1][b-1] = c\n L[b-1][a-1] = c\nL = csr_matrix(L)\nL = floyd_warshall(L, 0)\nprint (L)\nQ, K = map... | ['Runtime Error', 'Accepted'] | ['s296157798', 's415657171'] | [1830356.0, 53280.0] | [2114.0, 1526.0] | [440, 495] |
p03634 | u367130284 | 2,000 | 262,144 | You are given a tree with N vertices. Here, a _tree_ is a kind of graph, and more specifically, a connected undirected graph with N-1 edges, where N is the number of its vertices. The i-th edge (1≤i≤N-1) connects Vertices a_i and b_i, and has a length of c_i. You are also given Q queries and an integer K. In the j... | ['#from numpy import*\nfrom scipy.sparse.csgraph import shortest_path\nfrom scipy.sparse import csr_matrix\n\nfrom collections import* \nfrom fractions import gcd\nfrom functools import* #reduce\nfrom itertools import* #permutations("AB",repeat=2) combinations("AB",2) product("AB",2) groupby accumulate\nfrom operator i... | ['Runtime Error', 'Accepted'] | ['s939846541', 's990992120'] | [1980956.0, 56308.0] | [2249.0, 807.0] | [1033, 633] |
p03634 | u368780724 | 2,000 | 262,144 | You are given a tree with N vertices. Here, a _tree_ is a kind of graph, and more specifically, a connected undirected graph with N-1 edges, where N is the number of its vertices. The i-th edge (1≤i≤N-1) connects Vertices a_i and b_i, and has a length of c_i. You are also given Q queries and an integer K. In the j... | ['from collections import defaultdict\ndef inpl(): return [int(i) for i in input().split()]\n\npath = defaultdict(lambda: [])\nN = int(input())\nfor _ in range(N-1):\n a, b, c = inpl()\n path[a].append((b,c))\n path[b].append((a,c))\n\nctr = 1\nQ, K = inpl()\nnow = [K]\ndist = [0 for _ in range(N+1)]\nwhile Tr... | ['Runtime Error', 'Accepted'] | ['s796438769', 's399354819'] | [43544.0, 52372.0] | [610.0, 1587.0] | [603, 603] |
p03634 | u373047809 | 2,000 | 262,144 | You are given a tree with N vertices. Here, a _tree_ is a kind of graph, and more specifically, a connected undirected graph with N-1 edges, where N is the number of its vertices. The i-th edge (1≤i≤N-1) connects Vertices a_i and b_i, and has a length of c_i. You are also given Q queries and an integer K. In the j... | ['import sys\nsys.setrecursionlimit(10**6);l=lambda:map(int, input().split());n=int(input()):s=[0for _ in[0]*n];j=[[]for _ in[0]*n]\nfor _ in range(n-1):a,b,c=l();j[a-1].append([b-1,c]);j[b-1].append([a-1,c])\ndef f(v,p,d):\n s[v]=d\n for i,c in j[v]:\n if i==p:\n continue\n f(i,v,d+c)\nq,k=l()\ndfs(k-1,-1,0)\nfor ... | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s372820946', 's790370305', 's071444952'] | [2940.0, 44104.0, 137984.0] | [17.0, 693.0, 816.0] | [346, 346, 636] |
p03634 | u429843511 | 2,000 | 262,144 | You are given a tree with N vertices. Here, a _tree_ is a kind of graph, and more specifically, a connected undirected graph with N-1 edges, where N is the number of its vertices. The i-th edge (1≤i≤N-1) connects Vertices a_i and b_i, and has a length of c_i. You are also given Q queries and an integer K. In the j... | ['N = int(input())\nedges = []\nconnected = [[] for i in range(N+1)]\nfor i in range(N-1):\n x=list(map(int, input().split()))\n x[0] -= 1\n x[1] -= 1\n edges.append(x)\n connected[x[0]].append([x[1], x[2]])\n connected[x[1]].append([x[0], x[2]])\n\nQ,K = map(int, input().split())\ndepth = [0]*N\ndef ... | ['Runtime Error', 'Accepted'] | ['s382949222', 's590129915'] | [63656.0, 151232.0] | [1727.0, 1750.0] | [563, 614] |
p03634 | u477977638 | 2,000 | 262,144 | You are given a tree with N vertices. Here, a _tree_ is a kind of graph, and more specifically, a connected undirected graph with N-1 edges, where N is the number of its vertices. The i-th edge (1≤i≤N-1) connects Vertices a_i and b_i, and has a length of c_i. You are also given Q queries and an integer K. In the j... | ['from collections import defaultdict\n\nn=int(input())\ndct=defaultdict(list)\n\nfor i in range(n-1):\n a,b,c=map(int,input().split())\n dct[a]+=[[b,c]]\n dct[b]+=[[a,c]]\nprint(dct)\n\nq,k=map(int,input().split())\nlk=[0]*(n)\n\ndef dfs(v,p,d):\n lk[v-1]=d\n print(k,v,p,d,lk)\n for l in dct[v]:\n if l[0]==p:... | ['Runtime Error', 'Accepted'] | ['s958896386', 's006010686'] | [138884.0, 143648.0] | [2107.0, 1652.0] | [477, 479] |
p03634 | u496687522 | 2,000 | 262,144 | You are given a tree with N vertices. Here, a _tree_ is a kind of graph, and more specifically, a connected undirected graph with N-1 edges, where N is the number of its vertices. The i-th edge (1≤i≤N-1) connects Vertices a_i and b_i, and has a length of c_i. You are also given Q queries and an integer K. In the j... | ["import heapq\nN = int(input())\nedges = []\nfor i in range(N-1):\n a, b, c = map(int, input().split())\n edges.append([a-1, b-1, c])\n edges.append([b-1, a-1, c])\nQ, K = map(int, input().split())\nK -= 1\n\n\nans_list = []\ndef dijkstra(edges, num_v, start):\n dist = [float('inf')] * num_v\n dist[star... | ['Wrong Answer', 'Accepted'] | ['s423485423', 's181521105'] | [63816.0, 58396.0] | [2107.0, 1294.0] | [824, 843] |
p03634 | u498620941 | 2,000 | 262,144 | You are given a tree with N vertices. Here, a _tree_ is a kind of graph, and more specifically, a connected undirected graph with N-1 edges, where N is the number of its vertices. The i-th edge (1≤i≤N-1) connects Vertices a_i and b_i, and has a length of c_i. You are also given Q queries and an integer K. In the j... | ['N = int(input())\n\nclass Edge:\n def __init__(self,to,cost):\n self.to = to\n self.cost = cost\n\ngraph = [[] for i in range(N)]\nfor i in range(N-1):\n a,b,c = map(int,input().split())\n graph[a-1].append(Edge(b-1,c))\n graph[b-1].append(Edge(a-1,c))\ndp = [0 for i in range(N)]\n\ndef dfs(... | ['Runtime Error', 'Accepted'] | ['s851340336', 's259890974'] | [67008.0, 152208.0] | [1868.0, 1856.0] | [572, 655] |
p03634 | u551909378 | 2,000 | 262,144 | You are given a tree with N vertices. Here, a _tree_ is a kind of graph, and more specifically, a connected undirected graph with N-1 edges, where N is the number of its vertices. The i-th edge (1≤i≤N-1) connects Vertices a_i and b_i, and has a length of c_i. You are also given Q queries and an integer K. In the j... | ['N = int(input())\nT = [{} for i in range(N+1)]\nfor _ in range(N-1):\n a, b, c = map(int, input().split())\n T[a][b] = c\n T[b][a] = c\n\nQ, K = map(int, input().split())\nshortest_path = [0 for _ in range(N+1)]\nqueue = [[v, T[K][v], K] for v in T[K].keys()]\n\nfor _ in range(N-1):\n v = queue.pop(0)\n ... | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s418127108', 's720423658', 's600911120'] | [61024.0, 61024.0, 62432.0] | [1982.0, 2000.0, 1432.0] | [414, 404, 563] |
p03634 | u577170763 | 2,000 | 262,144 | You are given a tree with N vertices. Here, a _tree_ is a kind of graph, and more specifically, a connected undirected graph with N-1 edges, where N is the number of its vertices. The i-th edge (1≤i≤N-1) connects Vertices a_i and b_i, and has a length of c_i. You are also given Q queries and an integer K. In the j... | ['10\n1 2 1000000000\n2 3 1000000000\n3 4 1000000000\n4 5 1000000000\n5 6 1000000000\n6 7 1000000000\n7 8 1000000000\n8 9 1000000000\n9 10 1000000000\n1 1\n9 10', 'sys.setrecursionlimit(10**5 + 5)\n\nN = int(input())\n\ng = {i: [] for i in range(1, N+1)}\n\nfor _ in range(N-1):\n a, b, c = map(int, input().split())\... | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s326365287', 's332974670', 's529325913', 's808453418'] | [2940.0, 3064.0, 3064.0, 153648.0] | [19.0, 18.0, 18.0, 1031.0] | [147, 503, 504, 513] |
p03634 | u620868411 | 2,000 | 262,144 | You are given a tree with N vertices. Here, a _tree_ is a kind of graph, and more specifically, a connected undirected graph with N-1 edges, where N is the number of its vertices. The i-th edge (1≤i≤N-1) connects Vertices a_i and b_i, and has a length of c_i. You are also given Q queries and an integer K. In the j... | ['# coding=utf-8\n\nN = int(input())\ntree = [[]for x in range(N)]\ndepth = [0 for x in range(N)]\nfor _ in range(N-1):\n line = input().split(" ")\n a = int(line[0])-1\n b = int(line[1])-1\n c = int(line[2])\n tree[a].append((b, c))\n tree[b].append((a, c))\n\nline = input().split(" ")\nQ = int(line[... | ['Runtime Error', 'Accepted'] | ['s981846262', 's230006320'] | [43792.0, 48196.0] | [1378.0, 1004.0] | [603, 588] |
p03634 | u634208461 | 2,000 | 262,144 | You are given a tree with N vertices. Here, a _tree_ is a kind of graph, and more specifically, a connected undirected graph with N-1 edges, where N is the number of its vertices. The i-th edge (1≤i≤N-1) connects Vertices a_i and b_i, and has a length of c_i. You are also given Q queries and an integer K. In the j... | ["import sys\nsys.setrecursionlimit(10 ** 10)\n\n\nclass Solve():\n def __init__(self):\n self.N = int(input())\n self.route = [dict() for _ in range(self.N)]\n for _ in range(self.N - 1):\n a, b, c = map(int, input().split())\n self.route[a - 1][b - 1] = c\n sel... | ['Runtime Error', 'Accepted'] | ['s064769811', 's488389193'] | [3064.0, 163100.0] | [19.0, 991.0] | [981, 980] |
p03634 | u642905089 | 2,000 | 262,144 | You are given a tree with N vertices. Here, a _tree_ is a kind of graph, and more specifically, a connected undirected graph with N-1 edges, where N is the number of its vertices. The i-th edge (1≤i≤N-1) connects Vertices a_i and b_i, and has a length of c_i. You are also given Q queries and an integer K. In the j... | ['from collections import deque \n\nn = int(input())\n\npreroots = []\npreroots_appd = preroots.append\n\nfor i in range(n-1):\n preroots_appd(list(map(int,input().split())))\n \nroots = [[] for x in range(n+1)]\n\nfor i in preroots:\n roots[i[0]].append((i[1],i[2])) \n roots[i[1]].append((i[0],i[2]... | ['Wrong Answer', 'Accepted'] | ['s741396666', 's645528498'] | [81024.0, 88720.0] | [1112.0, 1389.0] | [852, 750] |
p03634 | u653807637 | 2,000 | 262,144 | You are given a tree with N vertices. Here, a _tree_ is a kind of graph, and more specifically, a connected undirected graph with N-1 edges, where N is the number of its vertices. The i-th edge (1≤i≤N-1) connects Vertices a_i and b_i, and has a length of c_i. You are also given Q queries and an integer K. In the j... | ["# encoding:utf-8\n\nimport sys\nsys.setrecursionlimit(100000)\n\ndef main():\n\tn = int(input())\n\tvers = [list(map(int, input().split())) for _ in range(n - 1)]\n\tq, k = list(map(int, input().split()))\n\tqueries = [list(map(int, input().split())) for _ in range(q)]\n\n\tn = 10 ** 5\n\tvers = [[i + 1, i + 2, 10 **... | ['Runtime Error', 'Accepted'] | ['s231295136', 's229285926'] | [180748.0, 181772.0] | [1274.0, 1214.0] | [1308, 1294] |
p03634 | u665038048 | 2,000 | 262,144 | You are given a tree with N vertices. Here, a _tree_ is a kind of graph, and more specifically, a connected undirected graph with N-1 edges, where N is the number of its vertices. The i-th edge (1≤i≤N-1) connects Vertices a_i and b_i, and has a length of c_i. You are also given Q queries and an integer K. In the j... | ['import numpy as np\nfrom scipy.sparse.csgraph import floyd_warshall\n\n\n\nn = int(input())\nmatrix = np.zeros((n, n))\nfor i in range(n-1):\n a, b, c = map(int, input().split())\n matrix[a-1][b-1] = c\n matrix[b-1][a-1] = c\nmin_span_matrix = floyd_warshall(matrix, directed=False,\n ... | ['Runtime Error', 'Accepted'] | ['s396572704', 's491947330'] | [1466888.0, 50528.0] | [2212.0, 868.0] | [495, 627] |
p03634 | u667084803 | 2,000 | 262,144 | You are given a tree with N vertices. Here, a _tree_ is a kind of graph, and more specifically, a connected undirected graph with N-1 edges, where N is the number of its vertices. The i-th edge (1≤i≤N-1) connects Vertices a_i and b_i, and has a length of c_i. You are also given Q queries and an integer K. In the j... | ['def BFS(K,edges,N):\n roots=[ [] for i in range(N)]\n for a,b,c in edges:\n roots[a-1]+=[(b-1,c)]\n roots[b-1]+=[(a-1,c)]\n dist=[-1]*N\n stack=[]\n stack.append(K)\n dist[K]=0\n while stack:\n label=stack.pop(-1)\n for i,c in edges[label]:\n if dist[i]==-1:\n dist[i]=dist[label]+c\n ... | ['Runtime Error', 'Accepted'] | ['s476885866', 's422334567'] | [82044.0, 86008.0] | [917.0, 1163.0] | [601, 601] |
p03634 | u682985065 | 2,000 | 262,144 | You are given a tree with N vertices. Here, a _tree_ is a kind of graph, and more specifically, a connected undirected graph with N-1 edges, where N is the number of its vertices. The i-th edge (1≤i≤N-1) connects Vertices a_i and b_i, and has a length of c_i. You are also given Q queries and an integer K. In the j... | ["import heapq\nn = int(f.readline())\ncost = [[float('inf') for _ in range(n+1)] for _ in range(n+1)]\nfor _ in range(n-1):\n From, To, d = map(int, f.readline().split())\n cost[From][To] = d\n cost[To][From] = d\n\nq, k = map(int, f.readline().split())\ndist = [[float('inf') for _ in range(n+1)] for _ in ran... | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s611877562', 's626221995', 's710137775', 's167186461'] | [3188.0, 38704.0, 357452.0, 47884.0] | [18.0, 491.0, 2127.0, 1506.0] | [933, 888, 918, 850] |
p03634 | u690536347 | 2,000 | 262,144 | You are given a tree with N vertices. Here, a _tree_ is a kind of graph, and more specifically, a connected undirected graph with N-1 edges, where N is the number of its vertices. The i-th edge (1≤i≤N-1) connects Vertices a_i and b_i, and has a length of c_i. You are also given Q queries and an integer K. In the j... | ['from collections import defaultdict\nimport sys\n\nsys.setrecursionlimit(1000000)\nd=defaultdict(list)\n\nN=int(input())\nfor _ in range(N-1):\n a,b,c=map(int,input().split())\n d[a].append((b,c))\n d[b].append((a,c))\n\nQ,K=map(int,input().split())\n\n\ndists=[None]*(N+1)\nisused=[False]*(N+1)\ndists[K]=0\n... | ['Wrong Answer', 'Accepted'] | ['s638960303', 's764328980'] | [139988.0, 138144.0] | [1721.0, 1562.0] | [591, 572] |
p03634 | u784022244 | 2,000 | 262,144 | You are given a tree with N vertices. Here, a _tree_ is a kind of graph, and more specifically, a connected undirected graph with N-1 edges, where N is the number of its vertices. The i-th edge (1≤i≤N-1) connects Vertices a_i and b_i, and has a length of c_i. You are also given Q queries and an integer K. In the j... | ['\nfrom collections import deque\nN=int(input())\nT=[[] for _ in range(N)]\nfor i in range(N-1):\n a,b,c=map(int, input().split())\n T[a-1].append((b-1,c))\n T[b-1].append((a-1,c))\n\nQ,K=map(int, input().split())\nque=[(K-1,0)\ndone=[-1]*N\nwhile que:\n t=que.pop(0)\n now,nowd=t\n done[now]=nowd\n ... | ['Runtime Error', 'Accepted'] | ['s030427272', 's014572252'] | [2940.0, 47120.0] | [17.0, 1446.0] | [555, 566] |
p03634 | u786020649 | 2,000 | 262,144 | You are given a tree with N vertices. Here, a _tree_ is a kind of graph, and more specifically, a connected undirected graph with N-1 edges, where N is the number of its vertices. The i-th edge (1≤i≤N-1) connects Vertices a_i and b_i, and has a length of c_i. You are also given Q queries and an integer K. In the j... | ["\nfrom collections import defaultdict,deque\nimport sys\nfinput=lambda: sys.stdin.readline().strip()\n\ndef main():\n n=int(finput())\n edges=[tuple(map(int,finput().split())) for _ in range(n-1)]\n q,k=map(int,finput().split())\n xy=[tuple(map(int,finput().split())) for _ in range(q)]\n ed=defaultdict(deque)\n ... | ['Wrong Answer', 'Accepted'] | ['s980885183', 's327647374'] | [147012.0, 144868.0] | [686.0, 661.0] | [873, 858] |
p03634 | u790710233 | 2,000 | 262,144 | You are given a tree with N vertices. Here, a _tree_ is a kind of graph, and more specifically, a connected undirected graph with N-1 edges, where N is the number of its vertices. The i-th edge (1≤i≤N-1) connects Vertices a_i and b_i, and has a length of c_i. You are also given Q queries and an integer K. In the j... | ["import sys\nfrom collections import deque\ninput = sys.stdin.readline\nn = int(input())\nedges = [[]for _ in range(n)]\nfor _ in range(n-1):\n a, b, c = map(int, input().split())\n a -= 1\n b -= 1\n edges[a].append((c, b))\n edges[b].append((c, a))\nINF = float('inf')\n\n\ndef bfs(init_v):\n dist = ... | ['Wrong Answer', 'Accepted'] | ['s704627664', 's682557398'] | [138520.0, 131772.0] | [2107.0, 703.0] | [769, 594] |
p03634 | u814986259 | 2,000 | 262,144 | You are given a tree with N vertices. Here, a _tree_ is a kind of graph, and more specifically, a connected undirected graph with N-1 edges, where N is the number of its vertices. The i-th edge (1≤i≤N-1) connects Vertices a_i and b_i, and has a length of c_i. You are also given Q queries and an integer K. In the j... | ['N=int(input())\nabc=[tuple(map(int,input().split())) for i in range(N-1)]\ng=[set() for i in range(N)]\nfor a,b,c in abc:\n g[a-1].add((b-1,c))\n g[b-1].add((a-1,c))\nmemo=[0]*N\nmemo[K-1]=0\nQ,K=map(int,input().split())\nimport collections\nq=collections.deque([(K-1,0)])\nwhile(q):\n x,w = q.popleft()\n for a,b ... | ['Runtime Error', 'Accepted'] | ['s583622723', 's818599889'] | [63468.0, 76884.0] | [550.0, 1495.0] | [457, 463] |
p03634 | u858994158 | 2,000 | 262,144 | You are given a tree with N vertices. Here, a _tree_ is a kind of graph, and more specifically, a connected undirected graph with N-1 edges, where N is the number of its vertices. The i-th edge (1≤i≤N-1) connects Vertices a_i and b_i, and has a length of c_i. You are also given Q queries and an integer K. In the j... | ['n=int(input())-1\n\nedges = {}\nlens = {}\nfor _ in range(n):\n [a, b, c] = map(int, input().split())\n if a > b:\n a,b=b,a\n edges.setdefault(a, []).append(b)\n edges.setdefault(b, []).append(a)\n lens[(a,b)] = c\n\nq, k = map(int, input().split())\n\nused = set()\ndists = {}\ndef build(x, d=0)... | ['Runtime Error', 'Accepted'] | ['s187980498', 's965310369'] | [65724.0, 71212.0] | [1607.0, 1645.0] | [547, 600] |
p03634 | u860002137 | 2,000 | 262,144 | You are given a tree with N vertices. Here, a _tree_ is a kind of graph, and more specifically, a connected undirected graph with N-1 edges, where N is the number of its vertices. The i-th edge (1≤i≤N-1) connects Vertices a_i and b_i, and has a length of c_i. You are also given Q queries and an integer K. In the j... | ['from heapq import heappush, heappop\nfrom collections import defaultdict\n\nn = int(input())\ngraph = defaultdict(list)\n\n\nfor _ in range(n - 1):\n a, b, c = map(int, input().split())\n graph[a].append((b, c))\n graph[b].append((a, c))\n\nq, k = map(int, input().split())\n\n\n\nINF = 1 << 60\ndist = [INF] ... | ['Runtime Error', 'Accepted'] | ['s920581700', 's699584540'] | [57988.0, 60704.0] | [581.0, 780.0] | [799, 785] |
p03634 | u879870653 | 2,000 | 262,144 | You are given a tree with N vertices. Here, a _tree_ is a kind of graph, and more specifically, a connected undirected graph with N-1 edges, where N is the number of its vertices. The i-th edge (1≤i≤N-1) connects Vertices a_i and b_i, and has a length of c_i. You are also given Q queries and an integer K. In the j... | ['import sys\nsys.setrecursionlimit(10**9)\n\ninput = sys.stdin.readline\n\nN = int(input())\nT = [[] for _ in range(N+1)]\n\nfor _ in range(N-1) :\n a,b,c = map(int,input().split())\n T[a].append([b,c])\n T[b].append([a,c])\n\nQ,K = map(int,input().split())\n\ndist = [None]*(N+1)\n\ndef dfs(now,d) :\n dist... | ['Runtime Error', 'Accepted'] | ['s810954990', 's332595378'] | [137164.0, 140492.0] | [566.0, 752.0] | [540, 542] |
p03634 | u893209854 | 2,000 | 262,144 | You are given a tree with N vertices. Here, a _tree_ is a kind of graph, and more specifically, a connected undirected graph with N-1 edges, where N is the number of its vertices. The i-th edge (1≤i≤N-1) connects Vertices a_i and b_i, and has a length of c_i. You are also given Q queries and an integer K. In the j... | ['tree = dict()\ncost = dict()\n\nN = int(input())\nfor i in range(N - 1):\n a, b, c = map(int, input().split())\n if a in tree:\n tree[a].append(b)\n else:\n tree[a] = []\n tree[a].append(b)\n if b in tree:\n tree[b].append(a)\n else:\n tree[b] = []\n tree[b].ap... | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s018749553', 's633276901', 's626550986'] | [65188.0, 3192.0, 157784.0] | [1102.0, 18.0, 1343.0] | [934, 1011, 999] |
p03634 | u921773161 | 2,000 | 262,144 | You are given a tree with N vertices. Here, a _tree_ is a kind of graph, and more specifically, a connected undirected graph with N-1 edges, where N is the number of its vertices. The i-th edge (1≤i≤N-1) connects Vertices a_i and b_i, and has a length of c_i. You are also given Q queries and an integer K. In the j... | ['#%%\nn = int(input())\na, b, c = [0] * n, [0] * n, [0] * n\nfor i in range(n-1):\n a[i], b[i], c[i] = map(int, input().split())\n\nq, k = map(int, input().split())\nx, y = [0] * q, [0] * q\nfor i in range(q):\n x[i], y[i] = map(int, input().split())\n\nl = [[] for _ in range(n+1)]\nfor i in range(n-1):\n l[a... | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s177319149', 's436377280', 's747633057'] | [48052.0, 48052.0, 60484.0] | [784.0, 768.0, 1711.0] | [701, 704, 733] |
p03634 | u932465688 | 2,000 | 262,144 | You are given a tree with N vertices. Here, a _tree_ is a kind of graph, and more specifically, a connected undirected graph with N-1 edges, where N is the number of its vertices. The i-th edge (1≤i≤N-1) connects Vertices a_i and b_i, and has a length of c_i. You are also given Q queries and an integer K. In the j... | ['from collections import deque\n\nN = int(input())\ngraph = [[] for _ in range(N+1)] \nlong = [0] * (N+1) \n\nfor i in range(N-1):\n x, y, z = map(int, input().split())\n graph[x].append([y, z])\n graph[y].append([x, z])\n \nQ, K = map(int, input().split())\nx = list()\ny = list()\n \nfor i in range(1,N+1): を求める\... | ['Time Limit Exceeded', 'Accepted'] | ['s259356283', 's045458038'] | [49908.0, 74124.0] | [2106.0, 1654.0] | [784, 865] |
p03634 | u947883560 | 2,000 | 262,144 | You are given a tree with N vertices. Here, a _tree_ is a kind of graph, and more specifically, a connected undirected graph with N-1 edges, where N is the number of its vertices. The i-th edge (1≤i≤N-1) connects Vertices a_i and b_i, and has a length of c_i. You are also given Q queries and an integer K. In the j... | ['#!/usr/bin/env python3\nimport sys\nimport math\nfrom collections import defaultdict\nsys.setrecursionlimit(10**6)\nINF = float("inf")\n\n\nclass Graph(object):\n \n\n def __init__(self, N):\n self.N = N\n self.edges = defaultdict(list)\n pass\n\n def add_edges(self, from_, to_, weight):... | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s463848695', 's567522051', 's173795998'] | [180360.0, 72044.0, 85280.0] | [828.0, 802.0, 1149.0] | [1917, 1937, 3367] |
p03634 | u950708010 | 2,000 | 262,144 | You are given a tree with N vertices. Here, a _tree_ is a kind of graph, and more specifically, a connected undirected graph with N-1 edges, where N is the number of its vertices. The i-th edge (1≤i≤N-1) connects Vertices a_i and b_i, and has a length of c_i. You are also given Q queries and an integer K. In the j... | ['\nimport sys \ninput = sys.stdin.readline\nfrom collections import deque\ndef solve():\n n = int(input())\n d = [[]*n for _ in range(n)]\n for i in range(n-1):\n a,b,c = (int(i) for i in input().split())\n d[a-1].append((b-1,c))\n d[b-1].append((a-1,c))\n q,k = (int(i) for i in input().split())\n \n d2... | ['Wrong Answer', 'Accepted'] | ['s940961173', 's966924179'] | [58124.0, 47948.0] | [920.0, 702.0] | [808, 790] |
p03634 | u969708690 | 2,000 | 262,144 | You are given a tree with N vertices. Here, a _tree_ is a kind of graph, and more specifically, a connected undirected graph with N-1 edges, where N is the number of its vertices. The i-th edge (1≤i≤N-1) connects Vertices a_i and b_i, and has a length of c_i. You are also given Q queries and an integer K. In the j... | ['import sys\nsys.setrecursionlimit(10 ** 7)\ndef input() : return sys.stdin.readline().strip()\ndef INT() : return int(input())\ndef MAP() : return map(int,input().split())\ndef LIST() : return list(MAP())\ndef NIJIGEN(H): return [list(input()) for i in range(H)]\ndef bfs(place,dis):\n for i in tree[place]:\n ... | ['Wrong Answer', 'Accepted'] | ['s513663824', 's919138716'] | [147896.0, 147884.0] | [672.0, 646.0] | [658, 662] |
p03639 | u048176319 | 2,000 | 262,144 | We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective. | ['n = int(input())\nl = list(map(int, input().split()))\n\nfor i in range(n):\n if l[i] % 4 == 0:\n l[i] = 2\n elif l[i] % 4 == 2:\n l[i] = 1\n else:\n l[i] = 0\n\nprint(l)\n\nif n - (l.count(2)*2 + 1) <= 0:\n print("Yes")\nelif n - (l.count(2)*2 + 1) < l.count(1):\n print("Yes")\nel... | ['Wrong Answer', 'Accepted'] | ['s074135688', 's376257447'] | [14252.0, 14252.0] | [82.0, 78.0] | [320, 310] |
p03639 | u054106284 | 2,000 | 262,144 | We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective. | ['H, W = (int(i) for i in input().split())\nN = int(input())\nA = [int(i) for i in input().split()]\nC = []\nfor i in range(N):\n for j in range(A[i]):\n C.append(i+1)\nans = [[0]*W for i in range(H)]\nfor i in range(H*W):\n y = i // W\n if y%2==0:\n x = i%W\n else:\n x = W-1-i%W\n ans[x][y] = C[i]\nfor i... | ['Runtime Error', 'Accepted'] | ['s182790772', 's710826656'] | [3064.0, 14228.0] | [17.0, 76.0] | [378, 268] |
p03639 | u057993957 | 2,000 | 262,144 | We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective. | ['import numpy as np\nn = int(input())\na = np.array(list(map(int, input().split())))\n\na4 = len(a[a % 4 == 0])\na2 = len(a[a % 2 == 0 and a % 4 != 0])\na4n = len(a[a % 4 != 0]) - a2 \n\nif a2 != 0:\n print("Yes" if a4 + 1 >= a4n+1 else "No")\n\nelse:\n print("Yes" if a4 + 1 >= a4n else "No")', 'n = int(input())\na ... | ['Runtime Error', 'Accepted'] | ['s919462204', 's724474699'] | [23120.0, 14252.0] | [186.0, 64.0] | [282, 280] |
p03639 | u101225820 | 2,000 | 262,144 | We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective. | ['import sys\nN=int(input())\nl=map(int,input().split())\na,b,c=0,0,True\nfor i in l:\n if i%4==0:b+=1\n else:\n if i%2!=0:a+=1\n else:c=False\n\nprint(c)\nif a==0:\n print("Yes")\n sys.exit()\nif c:\n if b==0:\n print("No")\n sys.exit()\n if b>=a-1:print("Yes")\n else:p... | ['Wrong Answer', 'Accepted'] | ['s966533889', 's025812729'] | [11100.0, 11096.0] | [65.0, 66.0] | [361, 352] |
p03639 | u130900604 | 2,000 | 262,144 | We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective. | ['\n\nn=int(input())\namod4=[i%4 for i in map(int,input().split())]\nprint(amod4)\nfrom collections import Counter\ns=Counter(amod4)\nnum4=s[0]\nnum2=s[2]\n\n#print(num4,num2,another)\n\ndef ok():print("Yes");exit()\ndef ng():print("No");exit()\n\nif num2==n:\n ok()\n \nif num4>=(n-(num2-1)*(n>num2>0))//2:ok()\n\nels... | ['Wrong Answer', 'Accepted'] | ['s598307096', 's563798872'] | [11096.0, 11096.0] | [66.0, 58.0] | [340, 341] |
p03639 | u131464432 | 2,000 | 262,144 | We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective. | ['N = int(input())\na = list(map(int,input().split()))\nzero,one,two = 0,0,0\nfor i in a:\n if i%4 == 0:\n two += 1\n elif i%2 == 0:\n one += 1\n else:\n zero += 1\nif one = N:\n print("Yes")\n exit()\nprint("Yes" if two+int(two>0) >= zero+int(one>0) else "No")', 'N = int(input())\na... | ['Runtime Error', 'Accepted'] | ['s805044134', 's310327829'] | [9032.0, 20104.0] | [26.0, 63.0] | [282, 283] |
p03639 | u131881594 | 2,000 | 262,144 | We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective. | ['n = int(input)\na=list(map(int,input().split()))\ncnt,cnt2,cnt4=0,0,0\nfor val in a:\n if val%4==0:\n cnt4+=1\n elif val%2==0:\n cnt2+=1\n else:\n cnt+=1\nif cnt2==n: print("Yes")\nelse:\n if cnt4>=cnt: print("Yes")\n else: print("No")', 'h,w=map(int,input().split())\nn=int(input()... | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s091486243', 's136184415', 's063162573'] | [3064.0, 3064.0, 14252.0] | [18.0, 17.0, 65.0] | [258, 429, 302] |
p03639 | u166340293 | 2,000 | 262,144 | We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective. | ['N=int(input())\na=list(map(int,input().split()))\nodd=0\nfour=0\nfor i in range(N):\n if a[i]%4==0:\n four+=1\n elif a[i]%2!=0:\n odd+=1\nif four>=odd or four+odd=N:\n print("Yes")\nelse:\n print("No")', 'N=int(input())\na=list(map(int,input().split()))\nodd=0\nfour=0\nfor i in range(N):\n if a[i]%4==0:\n ... | ['Runtime Error', 'Accepted'] | ['s745814547', 's902911832'] | [2940.0, 15020.0] | [18.0, 72.0] | [199, 246] |
p03639 | u167681750 | 2,000 | 262,144 | We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective. | ['n = int(input())\na = list(map(int, input().split()))\naa = [2 if i % 4 == 0 else 1 if i % 2 == 0 else 0 for i in a]\na4, a2, a0 = aa.count(2),aa.count(1), aa.count(0)\n\nif a2 == 0:\n a4 += 1\n\nprint("YES" if a4 >= a0 else "NO")', 'n = int(input())\na = list(map(int, input().split()))\naa = [2 if i % 4 == 0 else... | ['Wrong Answer', 'Accepted'] | ['s888890328', 's966573212'] | [14252.0, 15020.0] | [61.0, 60.0] | [225, 225] |
p03639 | u197457087 | 2,000 | 262,144 | We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective. | ['N = int(input())\n\na=0;b=0;c=0\nL = list(map(int,input().split()))\nfor i in range(N):\n if L[i]%4 == 0:\n c += 1\n elif L[i]%2 == 0:\n b += 1\n else:\n a += 1\nt = a+b+c\nprint(a,b,c)\nans = "No"\nif a == 0:\n ans = "Yes"\nelif c >= a:\n ans = "Yes"\nelif b == 0 and a == c+1:\n ans ="Yes"\nprint(ans)... | ['Wrong Answer', 'Accepted'] | ['s984093469', 's867565749'] | [14480.0, 14480.0] | [71.0, 80.0] | [298, 299] |
p03639 | u243492642 | 2,000 | 262,144 | We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective. | ['# coding: utf-8\nINF = 10 ** 20\nMOD = 10 ** 9 + 7\n\n\ndef II(): return int(input())\ndef ILI(): return list(map(int, input().split()))\n\n\ndef read():\n N = II()\n a = ILI()\n return N, a\n\n\ndef solve(N, a):\n n_odd = 0\n n_div_2 = 0\n n_div_4 = 0\n for _a in a:\n if _a % 2 == 1:\n ... | ['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s029406198', 's200333336', 's349481277', 's286823625'] | [14480.0, 3064.0, 14480.0, 14480.0] | [59.0, 18.0, 59.0, 59.0] | [778, 13, 835, 780] |
p03639 | u247554097 | 2,000 | 262,144 | We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective. | ["\n\nn = int(input())\narr = list(map(int, input().split()))\ndividable_four = 0\nodds = 0\nfor a in arr:\n if a % 4 == 0:\n dividable_four += 1\n elif a % 2 == 1:\n odds += 1\nif dividable_four >= odds:\n print('YES')\nelif odds - dividable_four == 1 and odds + dividable_four == n:\n print('... | ['Wrong Answer', 'Accepted'] | ['s012347533', 's389501800'] | [14252.0, 14252.0] | [63.0, 64.0] | [480, 480] |
p03639 | u249447366 | 2,000 | 262,144 | We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective. | ["N = int(input())\nA = list(map(int, input().split()))\nmaru = len([a for a in A if a % 4 == 0])\nsankaku = len([a for a in A if a == 2])\nbatu = len(A) - maru - sankaku\n\nif sankaku:\n if batu <= maru + 1:\n print('Yes')\n else:\n print('No')\nelse:\n if batu <= maru:\n print('Yes')\n ... | ['Wrong Answer', 'Accepted'] | ['s491574035', 's844168222'] | [15020.0, 15020.0] | [53.0, 58.0] | [332, 328] |
p03639 | u278356323 | 2,000 | 262,144 | We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective. | ['n = int(input())\na = list(map(int, input().split()))\n\nfor i in range(n):\n if a[i] % 4 == 0:\n a[i] = 2\n elif a[i] % 2 == 0:\n a[i] = 1\n else:\n a[i] = 0\nprint(a)\n', "n = int(input())\na = list(map(int, input().split()))\n\nfor i in range(n):\n if a[i] % 4 == 0:\n a[i] =... | ['Wrong Answer', 'Accepted'] | ['s248797732', 's363051197'] | [14224.0, 14224.0] | [80.0, 73.0] | [189, 285] |
p03639 | u278670845 | 2,000 | 262,144 | We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective. | ['n=int(input())\na=list(map(int,input().split()))\na1=0\na2=0\na3=0\nfor i in a:\n if a%4==0:\n a1+=1\n elif a%4==2:\n a2+=1\n else:\n a3+=1\n \nif a3==0:\n print("Yes")\nelse:\n if a2==0:\n if a1>=a3-1:\n print("Yes")\n else:\n print("No")\n else:\n if a1>=a3:\n print("Yes")\... | ['Runtime Error', 'Accepted'] | ['s780463064', 's286495859'] | [14252.0, 14252.0] | [43.0, 65.0] | [322, 322] |
p03639 | u278886389 | 2,000 | 262,144 | We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective. | ['from collections import Counter\n\ndef a():\n N = int(input())\n A = map(int,input().split(" "))\n c = Counter(map(lambda x:(x%4 and 1)+x%2,A))\n if c[1]:\n return c[2] <= c[0]\n else:\n return c[2] <= c[0] + 1\n\nprint([\'NO\',\'YES\'][a()])', 'from collections import Counter\n\ndef a():... | ['Wrong Answer', 'Accepted'] | ['s167588506', 's129581932'] | [11436.0, 11436.0] | [79.0, 72.0] | [256, 256] |
p03639 | u280512618 | 2,000 | 262,144 | We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective. | ["from collections import Counter\nn=int(input())\ncounter=Counter(1 if x % 2 else 2 if x % 4 else 4 for x in (int(s) for s in input().split()))\nprint('Yes' if counter[1] < counter[4] else 'No')\n", "from collections import Counter\nn=int(input())\ncounter=Counter(1 if x % 2 else 2 if x % 4 else 4 for x in (int(s) for... | ['Wrong Answer', 'Accepted'] | ['s839845995', 's945467292'] | [11436.0, 11436.0] | [71.0, 72.0] | [191, 243] |
p03639 | u306412379 | 2,000 | 262,144 | We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective. | ["n = int(input())\naa = list(map(int, input().split()))\nc2 = 0\nc4 = 0\n\nfor a in aa:\n if a % 4 == 0:\n c4 += 1\n elif a % 2 == 0:\n c2 += 1\n else:\n print('No')\n exit()\n\nif c4 + c2 == n:\n print('Yes')\n\nelif n/2 -1 < c4 < n/2 + 1:\n print('Yes')\n \nelif n % 4 == 2:\n if c4 == n / 2 - 1 an... | ['Wrong Answer', 'Accepted'] | ['s912316414', 's331646024'] | [20096.0, 20172.0] | [64.0, 66.0] | [344, 343] |
p03639 | u306950978 | 2,000 | 262,144 | We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective. | ['n = int(input())\na = list(map(lambda x: int(x)%4 , input().split()))\nprint(a)\np = a.count(0)\nq = a.count(2)\nr = n-p-q\n\nif r > p:\n print("No")\nelse:\n print("Yes")', 'n = int(input())\na = list(map(lambda x: int(x)%4 , input().split()))\n\np = a.count(0)\nq = a.count(2)\nr = n-p-q\n\nif r > p:\n if r... | ['Wrong Answer', 'Accepted'] | ['s835117345', 's162523495'] | [11096.0, 11096.0] | [67.0, 58.0] | [167, 223] |
p03639 | u311636831 | 2,000 | 262,144 | We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective. | ['a = list(map(int, input().split()))\nfor i in range(N):\n A += [i + 1] * a[i]\n \nL = [[0 for i in range(W)] for j in range(H)]\nfor i in range(H * W):\n if int((i // W)) % 2 == 0:\n L[int((i // W))][i % W] = A[i]\n else:\n L[int((i // W))][-1 - i % W] = A[i]\n \nfor i in range(H):\n L[i] = ... | ['Runtime Error', 'Accepted'] | ['s843053313', 's172351705'] | [3064.0, 15020.0] | [18.0, 68.0] | [375, 290] |
p03639 | u329407311 | 2,000 | 262,144 | We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective. | ['N = int(input())\nList=list(map(int,input().split()))\n\ncnt4 = 0\nfor i in range(N):\n a = List[i]\n if a%4 == 0:\n cnt4 += 1\n\ncnt2 = 0\nfor i in range(N):\n a = List[i]\n if a%2 == 0:\n cnt2 += 1\ncnt2 = int(cnt2 - cnt4)\n\nif cnt2 == 0:\n if cnt4 > N -cnt4:\n print("Yes")\n else:\n print("No")\... | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s050045192', 's967633798', 's257791457'] | [14224.0, 14252.0, 14252.0] | [86.0, 86.0, 87.0] | [374, 286, 381] |
p03639 | u330205771 | 2,000 | 262,144 | We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective. | ["N = int(input())\np = list(map(int, input().split()))\n\nq = []\nsummation = [p[i] + p[i + 1] for i in range(N - 1)]\nfor i in range(int(N / 2)):\n if len(p) == 2:\n q = p + q\n else:\n index = summation.index(max(summation))\n q = p[index:index + 2] + q\n p = p[:index] + p[index + 2... | ['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s241316552', 's379912471', 's735713522', 's967998946', 's104644717'] | [14660.0, 15712.0, 147612.0, 14624.0, 14252.0] | [2104.0, 2104.0, 1910.0, 2104.0, 69.0] | [599, 602, 630, 602, 339] |
p03639 | u337626942 | 2,000 | 262,144 | We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective. | ['n=int(input())\na=list(map(int, input().split()))\ncnt_2=0\ncnt_1=0\ncnt_0=0\n\nfor num in a:\n if num%4==0:\n cnt_2+=1\n elif num%2==0:\n cnt_1+=1\n else:\n cnt_0+=1\n\nif cnt_1=0:\n if cnt_2+1>=cnt_0:\n print("Yes")\n else:\n print("No")\n\nelse:\n if cnt_2>=cnt_... | ['Runtime Error', 'Accepted'] | ['s712060016', 's213968216'] | [2940.0, 14252.0] | [17.0, 64.0] | [350, 351] |
p03639 | u419645731 | 2,000 | 262,144 | We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective. | ["h, w = map(int,input().split())\nn = int(input())\na = list(map(int,input().split()))\ngrid = [[' ']*w for i in range(h)]\n\nci = 0\nfor i in range(h):\n for j in range(w):\n if not a[ci]: ci+= 1\n if i%2==0: grid[i][j] = ci+1\n else: grid[i][~j] = ci+1\n a[ci]-= 1\nfor row in grid: pri... | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s047804105', 's083681859', 's059608979'] | [3064.0, 3060.0, 11480.0] | [17.0, 18.0, 69.0] | [314, 83, 385] |
p03639 | u440975163 | 2,000 | 262,144 | We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective. | ["n = int(input())\nb = list(map(int, input().split()))\nln = []\nln2 = []\nfor i in b:\n if i % 4 == 0:\n ln.append(i)\n if i % 2 == 0 and i % 4 != 0:\n ln2.append(i)\nif n % 2 == 0:\n if len(ln) >= n//2:\n print('Yes')\nif n % 2 == 1:\n if len(ln) >= (n + 1)//2:\n print('Yes')... | ['Wrong Answer', 'Accepted'] | ['s202082201', 's988029596'] | [14252.0, 14480.0] | [74.0, 74.0] | [377, 643] |
p03639 | u485319545 | 2,000 | 262,144 | We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective. | ["n=int(input())\na=list(map(int,input().split()))\n\nborder_4 = n//2\nborder_2 = n\n\ncnt_4=0\ncnt_2=0\n\nfor i in range(n):\n if a[i]%4==0:\n cnt_4+=1\n cnt_2+=1\n elif a[i]%2==0:\n cnt_2+=1\n else:\n continue\n\n\nif cnt_4>=border_4:\n print('YES')\nelif n-cnt_4*2<=(cnt_2-cnt_... | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s740337146', 's800233353', 's676740477'] | [14252.0, 14252.0, 14252.0] | [71.0, 81.0, 70.0] | [339, 328, 340] |
p03639 | u488884575 | 2,000 | 262,144 | We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective. | ["n = int(input())\nA = list(map(int, input().split()))\nf2 = 0\nf4 = 0\nfor a in A:\n \n if a%4 == 0:\n f4 += 1\n elif a%2 == 0:\n f2 += 1\nif n -f2//2 *2 -f4 *2 <= 0:\n print('Yes')\nelse:\n print('No')", "n = int(input())\nA = list(map(int, input().split()))\nf2 = 0\nf4 = 0\nf_another = ... | ['Wrong Answer', 'Accepted'] | ['s821816986', 's741827398'] | [15020.0, 14252.0] | [63.0, 67.0] | [262, 385] |
p03639 | u509739538 | 2,000 | 262,144 | We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective. | ['from collections import defaultdict\nfrom collections import deque\nimport itertools\nimport math\n\ndef readInt():\n\treturn int(input())\ndef readInts():\n\treturn list(map(int, input().split()))\ndef readChar():\n\treturn input()\ndef readChars():\n\treturn input().split()\n\nn = readInt()\nd = {"2":0,"4":0,"other... | ['Wrong Answer', 'Accepted'] | ['s296055413', 's777294142'] | [20428.0, 20804.0] | [72.0, 70.0] | [621, 470] |
p03639 | u524922893 | 2,000 | 262,144 | We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective. | ['n=int(input())\na=list(map(int,input().split()))\nb=0\nc=0\nfor i in range(n):\n if a[i]%2==0:\n if a[i]%4==0:\n c+=1\n else:\n b+=1\nif b==0:\n print("Yes") if n<=3*c else print("No")\nelse:\n print("Yes") if n<=3c+b-1 else print("No")', 'n=int(input())\na=list(map(int,input().split()))\nb=0\nc=0\... | ['Runtime Error', 'Accepted'] | ['s616513109', 's601544600'] | [3064.0, 14252.0] | [17.0, 72.0] | [242, 294] |
p03639 | u545368057 | 2,000 | 262,144 | We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective. | ['n = int(input())\nAs = list(map(int, input().split()))\n\n# four = sum([1 for a in As if a%4 == 0])\n# odd = sum([1 for a in As if a%2 == 1])\n# two = sum([1 for a in As if a%2 == 0 and a%4 != 0])\nfour = 0\nodd = 0\ntwo = 0\nfor a in As:\n if a % 2 == 1:\n odd += 1\n elif a % 4 == 0:\n four += 1\... | ['Runtime Error', 'Accepted'] | ['s142039187', 's014513539'] | [2940.0, 15020.0] | [17.0, 65.0] | [473, 401] |
p03639 | u609814378 | 2,000 | 262,144 | We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective. | ['N = int(input())\nA = list(map(int, input().split()))\n\neight = 0\none = 0\ntwo = 0\n\n\nfor i in A:\n print(i%4)\n if i%4 == 0:\n eight = eight + 1\n if i == 1:\n one = one + 1\n if i%2 == 0:\n two = two + 1\n\nif len(A)//2 <= eight:\n print("Yes")\nelif (len(A)//2) <= (eight + (... | ['Wrong Answer', 'Accepted'] | ['s080984795', 's427388539'] | [20024.0, 20028.0] | [100.0, 72.0] | [470, 437] |
p03639 | u631277801 | 2,000 | 262,144 | We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective. | ['import sys\n\n\nsys.setrecursionlimit(10 ** 7)\n\ndef li(): return map(int, stdin.readline().split())\ndef li_(): return map(lambda x: int(x) - 1, stdin.readline().split())\ndef lf(): return map(float, stdin.readline().split())\ndef ls(): return stdin.readline().split()\ndef ns(): return stdin.readline().rstrip()\nde... | ['Runtime Error', 'Accepted'] | ['s502774439', 's503597629'] | [3064.0, 14168.0] | [18.0, 62.0] | [639, 638] |
p03639 | u640922335 | 2,000 | 262,144 | We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective. | ["N=int(input())\nA=list(map(int,input().split()))\na=0\nb=0\nfor num in A:\n if num%2==1:\n a+=1\n elif num%4==0:\n b+=1\n\nif N==3:\n if a==3 or (a>=1 and b==0):\n print('No')\n else:\n print('Yes')\nelse:\n if a=<b:\n print('Yes')\n else:\n print('No')", "N... | ['Runtime Error', 'Accepted'] | ['s783144384', 's064464440'] | [9008.0, 20108.0] | [23.0, 65.0] | [294, 278] |
p03639 | u667024514 | 2,000 | 262,144 | We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective. | ['h,w=map(int,input().split())\nn=int(input())\nlis=list(map(int,input().split()))\nans=[]\ncnt=0\ns=""\nhh=0\nfor i in range(n):\n for j in range(lis[i]):\n if hh==0:\n s=s+str(i+1)+" "\n else:\n s=str(i+1)+" "+s\n cnt+=1\n if cnt==w:\n ans.append(s)\n s=""\n cnt=0\n hh=(hh+1... | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s246051108', 's707519727', 's018898883'] | [3064.0, 15020.0, 14252.0] | [18.0, 62.0, 62.0] | [339, 268, 272] |
p03639 | u671211357 | 2,000 | 262,144 | We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective. | ['N=int(input())\nA=list(map(int,input().split()))\ncount_4=0\ncount_2=0\ncount_1=0\nfor i in A:\n if i%4==0:\n count_4+=1\n elif i%2==0:\n count_2+=1\n else:\n count_1+=1\nif count_2<2:\n if count_1+count_2<count_4:\n print("Yes")\n else:\n print("No")\nelse:\n if c... | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s713715112', 's974476627', 's098666288'] | [15020.0, 14252.0, 14252.0] | [64.0, 63.0, 63.0] | [366, 368, 370] |
p03639 | u674588203 | 2,000 | 262,144 | We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective. | ['\n# C - 4-adjacent\n\nN=int(input())\nalist=list(map(int,input().split()))\n\noddcount=0\nmod40=0\nother=0\n\nfor a in alist:\n if a%2==1:\n oddcount+=1\n elif a%4==0:\n mod40+=1\n else:\n other+=1\n\nif N==1:\n if mod40==N:\n print("Yes")\n else:\n print("No")\nif N=... | ['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s127463463', 's278857804', 's484886189', 's838824896', 's846436619', 's919349634', 's353635563'] | [20120.0, 20428.0, 20128.0, 20136.0, 8840.0, 8844.0, 19968.0] | [64.0, 66.0, 64.0, 65.0, 25.0, 28.0, 65.0] | [590, 614, 580, 673, 650, 1148, 639] |
p03639 | u676264453 | 2,000 | 262,144 | We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective. | ["import sys\n\nN = int(input())\nls = list(map(int, input().split()))\nk = len(ls)\np = [ i for i in ls if (i%4) == 0]\nj = [ i for i in ls if (i%4) != 0]\nr = [ i for i in j if (i%2) == 0]\n\nif(len(p) >= int(k/2)):\n print('Yes')\nelif (len(p) >= (len(j) - len(r))):\n print('Yes')\nelse:\n print('No')\n----... | ['Runtime Error', 'Accepted'] | ['s885120613', 's380933490'] | [3064.0, 14252.0] | [19.0, 65.0] | [303, 298] |
p03639 | u692632484 | 2,000 | 262,144 | We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective. | ['N=int(input())\na=[int(i) for i in input().split()]\nnum4=0\nnum2=0\nnum1=0\nfor i in a:\n if i%4==0:\n num4+=1\n elif i%2==0:\n num2+=1\nnum1=N-num4-num2\n\nif num2>0:\n num1+=1\n\nif num1<=num4+1:\n print("Yes")\nelse:\n print("No") ... | ['Runtime Error', 'Accepted'] | ['s384969802', 's748661050'] | [3064.0, 14252.0] | [17.0, 67.0] | [468, 281] |
p03639 | u729133443 | 2,000 | 262,144 | We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective. | ["n,a=open(0)\na=[int(i)%4for i in a.split()]\nf,g=a.count(0),a.count(2)\nprint('YNeos'[int(n)-f-g>f+(g==0)])", "n,a=open(0)\nc=[int(i)%4for i in a.split()].count\nf,g=c(0),c(2)\nprint('YNeos'[int(n)-f-g>f+(g==0)::2])"] | ['Wrong Answer', 'Accepted'] | ['s518931366', 's553596136'] | [11936.0, 11936.0] | [52.0, 54.0] | [104, 101] |
p03639 | u742729271 | 2,000 | 262,144 | We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective. | ['N = int(input())\na = list(map(int, input().split()))\nc2=c4=0\n\nfor i in range(len(N)):\n if a[i]%4==0:\n c4+=1\n if a[i]%2==0:\n c2+=1\n\nnodd=N-c2\nc4=c4-c2\n\nif nodd<c4:\n print("Yes")\nelse:\n print("No")', 'N = int(input())\na = list(map(int, input().split()))\nc2=c4=0\n\nfor i in range(N):\n if a[... | ['Runtime Error', 'Accepted'] | ['s405068405', 's532477886'] | [14252.0, 14252.0] | [41.0, 80.0] | [205, 222] |
p03639 | u802772880 | 2,000 | 262,144 | We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective. | ["n=int(input())\na=list(map(int,input().split()))\nans='No'\na2=[i//2 for i in a if i%2==0]\na4=[i for i in a2 if i%2==0]\nla2=len(a2)\nla4=len(a4)\nif la2+la4>=n:\n ans='Yes'\nprint(ans)\nprint(a2)\nprint(a4)", "n=int(input())\na=list(map(int,input().split()))\nans='No'\na2=[i//2 for i in a if i%2==0]\na4=[i for i... | ['Wrong Answer', 'Accepted'] | ['s837870253', 's861563149'] | [17184.0, 14252.0] | [83.0, 63.0] | [200, 234] |
p03639 | u817328209 | 2,000 | 262,144 | We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective. | ["n = int(input())\na = list(map(int, input().split()))\nodds = 0\nevens2 = 0\nevens4 = \nfor ai in a :\n if ai % 4 == 0 :\n evens4 += 1\n elif ai % 2 == 0 :\n evens2 += 1\n else :\n odds += 1\n\nif evens4 >= odds :\n print('Yes')\nelif odds - evens4 == 1 and evens2 == 0 :\n print('Y... | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s354376888', 's764451190', 's913094954'] | [2940.0, 2940.0, 14252.0] | [17.0, 17.0, 63.0] | [329, 329, 330] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.