message
stringlengths
2
49.9k
message_type
stringclasses
2 values
message_id
int64
0
1
conversation_id
int64
446
108k
cluster
float64
13
13
__index_level_0__
int64
892
217k
Provide a correct Python 3 solution for this coding contest problem. We have a rooted binary tree with N vertices, where the vertices are numbered 1 to N. Vertex 1 is the root, and the parent of Vertex i (i \geq 2) is Vertex \left[ \frac{i}{2} \right]. Each vertex has one item in it. The item in Vertex i has a value ...
instruction
0
61,255
13
122,510
"Correct Solution: ``` # coding: utf-8 # Your code here! import sys read = sys.stdin.read readline = sys.stdin.readline #n,k,*a = map(int,read().split()) n, = map(int,readline().split()) vw = [[0,0]]+[list(map(int,readline().split())) for _ in range(n)] def merge(av,aw,bv,bw): la,lb = len(aw),len(bw) rv = [0...
output
1
61,255
13
122,511
Provide a correct Python 3 solution for this coding contest problem. We have a rooted binary tree with N vertices, where the vertices are numbered 1 to N. Vertex 1 is the root, and the parent of Vertex i (i \geq 2) is Vertex \left[ \frac{i}{2} \right]. Each vertex has one item in it. The item in Vertex i has a value ...
instruction
0
61,256
13
122,512
"Correct Solution: ``` # coding: utf-8 # Your code here! import sys read = sys.stdin.read readline = sys.stdin.readline #n,k,*a = map(int,read().split()) n, = map(int,readline().split()) vw = [[0,0]]+[list(map(int,readline().split())) for _ in range(n)] def merge(av,aw,bv,bw): la,lb = len(aw),len(bw) rv = [0...
output
1
61,256
13
122,513
Provide a correct Python 3 solution for this coding contest problem. We have a rooted binary tree with N vertices, where the vertices are numbered 1 to N. Vertex 1 is the root, and the parent of Vertex i (i \geq 2) is Vertex \left[ \frac{i}{2} \right]. Each vertex has one item in it. The item in Vertex i has a value ...
instruction
0
61,257
13
122,514
"Correct Solution: ``` #!/usr/bin/env python3 def main(): import sys def I(): return int(sys.stdin.readline()) def LI(): return list(map(int,sys.stdin.readline().split())) n = I() V = [] W = [] maxL = 10**5 m = min(n, 1 << 10) dp = [[0]*(maxL + 1)] for i in range(n): ...
output
1
61,257
13
122,515
Provide a correct Python 3 solution for this coding contest problem. We have a rooted binary tree with N vertices, where the vertices are numbered 1 to N. Vertex 1 is the root, and the parent of Vertex i (i \geq 2) is Vertex \left[ \frac{i}{2} \right]. Each vertex has one item in it. The item in Vertex i has a value ...
instruction
0
61,258
13
122,516
"Correct Solution: ``` def main(): import sys input = sys.stdin.readline n = int(input()) L_MAX = 10**5 D_TH = 10 V_MAX = (1 << D_TH) - 1 dp = [[0] * (L_MAX + 1)] # items = [] items_v = [] items_w = [] for i in range(n): val, w = map(int, input().split()) i...
output
1
61,258
13
122,517
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. We have a rooted binary tree with N vertices, where the vertices are numbered 1 to N. Vertex 1 is the root, and the parent of Vertex i (i \geq 2) is Vertex \left[ \frac{i}{2} \right]. Each vert...
instruction
0
61,259
13
122,518
Yes
output
1
61,259
13
122,519
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. We have a rooted binary tree with N vertices, where the vertices are numbered 1 to N. Vertex 1 is the root, and the parent of Vertex i (i \geq 2) is Vertex \left[ \frac{i}{2} \right]. Each vert...
instruction
0
61,260
13
122,520
Yes
output
1
61,260
13
122,521
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. We have a rooted binary tree with N vertices, where the vertices are numbered 1 to N. Vertex 1 is the root, and the parent of Vertex i (i \geq 2) is Vertex \left[ \frac{i}{2} \right]. Each vert...
instruction
0
61,261
13
122,522
Yes
output
1
61,261
13
122,523
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. We have a rooted binary tree with N vertices, where the vertices are numbered 1 to N. Vertex 1 is the root, and the parent of Vertex i (i \geq 2) is Vertex \left[ \frac{i}{2} \right]. Each vert...
instruction
0
61,262
13
122,524
Yes
output
1
61,262
13
122,525
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. We have a rooted binary tree with N vertices, where the vertices are numbered 1 to N. Vertex 1 is the root, and the parent of Vertex i (i \geq 2) is Vertex \left[ \frac{i}{2} \right]. Each vert...
instruction
0
61,263
13
122,526
No
output
1
61,263
13
122,527
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. We have a rooted binary tree with N vertices, where the vertices are numbered 1 to N. Vertex 1 is the root, and the parent of Vertex i (i \geq 2) is Vertex \left[ \frac{i}{2} \right]. Each vert...
instruction
0
61,264
13
122,528
No
output
1
61,264
13
122,529
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. We have a rooted binary tree with N vertices, where the vertices are numbered 1 to N. Vertex 1 is the root, and the parent of Vertex i (i \geq 2) is Vertex \left[ \frac{i}{2} \right]. Each vert...
instruction
0
61,265
13
122,530
No
output
1
61,265
13
122,531
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. We have a rooted binary tree with N vertices, where the vertices are numbered 1 to N. Vertex 1 is the root, and the parent of Vertex i (i \geq 2) is Vertex \left[ \frac{i}{2} \right]. Each vert...
instruction
0
61,266
13
122,532
No
output
1
61,266
13
122,533
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There was no problem about a cactus at the NERC 2020 online round. That's a bad mistake, so judges decided to fix it. You shall not pass to the World Finals 2021 without solving a problem about ...
instruction
0
61,705
13
123,410
No
output
1
61,705
13
123,411
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There was no problem about a cactus at the NERC 2020 online round. That's a bad mistake, so judges decided to fix it. You shall not pass to the World Finals 2021 without solving a problem about ...
instruction
0
61,706
13
123,412
No
output
1
61,706
13
123,413
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There was no problem about a cactus at the NERC 2020 online round. That's a bad mistake, so judges decided to fix it. You shall not pass to the World Finals 2021 without solving a problem about ...
instruction
0
61,707
13
123,414
No
output
1
61,707
13
123,415
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There was no problem about a cactus at the NERC 2020 online round. That's a bad mistake, so judges decided to fix it. You shall not pass to the World Finals 2021 without solving a problem about ...
instruction
0
61,708
13
123,416
No
output
1
61,708
13
123,417
Provide a correct Python 3 solution for this coding contest problem. Inspired by the tv series Stranger Things, bear Limak is going for a walk between two mirror worlds. There are two perfect binary trees of height H, each with the standard numeration of vertices from 1 to 2^H-1. The root is 1 and the children of x a...
instruction
0
62,039
13
124,078
"Correct Solution: ``` #import random,time H=int(input()) #P=[i for i in range(2**(H-1))] #random.shuffle(P) P=list(map(lambda x:int(x)-1,input().split())) mod=10**9+7 inv=pow(2,mod-2,mod) L=2**(H-1) base_t=[1 for i in range(1+1<<H)] base_t[0]=0 for i in range(2,1+1<<H): base_t[i]=i*base_t[i>>1] base_t[i]%=m...
output
1
62,039
13
124,079
Provide a correct Python 3 solution for this coding contest problem. Inspired by the tv series Stranger Things, bear Limak is going for a walk between two mirror worlds. There are two perfect binary trees of height H, each with the standard numeration of vertices from 1 to 2^H-1. The root is 1 and the children of x a...
instruction
0
62,040
13
124,080
"Correct Solution: ``` import sys h, *ppp = map(int, sys.stdin.buffer.read().split()) n = 1 << (h - 1) ppp = [p + n - 1 for p in ppp] MOD = 10 ** 9 + 7 cumprods = [1] * (2 * n) # 根から頂点vまでの経路の累積積 cumprods_rev = [1] * n # ..の逆数 cumprods_through = [0] * n # 木1の根から木2の根まで、木1の i 番目の葉を経由する経路の積 for i in range(2, 2 * n): ...
output
1
62,040
13
124,081
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Inspired by the tv series Stranger Things, bear Limak is going for a walk between two mirror worlds. There are two perfect binary trees of height H, each with the standard numeration of vertice...
instruction
0
62,041
13
124,082
No
output
1
62,041
13
124,083
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Inspired by the tv series Stranger Things, bear Limak is going for a walk between two mirror worlds. There are two perfect binary trees of height H, each with the standard numeration of vertice...
instruction
0
62,042
13
124,084
No
output
1
62,042
13
124,085
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Inspired by the tv series Stranger Things, bear Limak is going for a walk between two mirror worlds. There are two perfect binary trees of height H, each with the standard numeration of vertice...
instruction
0
62,043
13
124,086
No
output
1
62,043
13
124,087
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Inspired by the tv series Stranger Things, bear Limak is going for a walk between two mirror worlds. There are two perfect binary trees of height H, each with the standard numeration of vertice...
instruction
0
62,044
13
124,088
No
output
1
62,044
13
124,089
Provide a correct Python 3 solution for this coding contest problem. You are given a connected undirected simple graph, which has N vertices and M edges. The vertices are numbered 1 through N, and the edges are numbered 1 through M. Edge i connects vertices A_i and B_i. Your task is to find a path that satisfies the f...
instruction
0
62,157
13
124,314
"Correct Solution: ``` import sys from collections import deque input = sys.stdin.readline n,m = map(int,input().split()) ab = [list(map(int,input().split())) for i in range(m)] graph = [[] for i in range(n+1)] for a,b in ab: graph[a].append(b) graph[b].append(a) vis = [0 for i in range(n+1)] vis[1] = 1 stack = [1]...
output
1
62,157
13
124,315
Provide a correct Python 3 solution for this coding contest problem. You are given a connected undirected simple graph, which has N vertices and M edges. The vertices are numbered 1 through N, and the edges are numbered 1 through M. Edge i connects vertices A_i and B_i. Your task is to find a path that satisfies the f...
instruction
0
62,158
13
124,316
"Correct Solution: ``` import sys input=sys.stdin.readline from collections import deque n,m=map(int,input().split()) E=[[] for _ in range(n)] for _ in range(m): a,b=map(int,input().split()) a-=1 b-=1 E[a].append(b) E[b].append(a) q=deque([0]) Visited=[False]*n Visited[0]=True while True: s=q[0]...
output
1
62,158
13
124,317
Provide a correct Python 3 solution for this coding contest problem. You are given a connected undirected simple graph, which has N vertices and M edges. The vertices are numbered 1 through N, and the edges are numbered 1 through M. Edge i connects vertices A_i and B_i. Your task is to find a path that satisfies the f...
instruction
0
62,159
13
124,318
"Correct Solution: ``` from collections import deque n,m=map(int,input().split()) g=[[] for i in range(1+n)] v=[0]*(1+n) for i in range(m): a,b=map(int,input().split()) g[a].append(b) g[b].append(a) if i==0: q=[a,b] v[a]=v[b]=1 p=[q[-1]] path=[] while p: cur=p.pop() path.append(...
output
1
62,159
13
124,319
Provide a correct Python 3 solution for this coding contest problem. You are given a connected undirected simple graph, which has N vertices and M edges. The vertices are numbered 1 through N, and the edges are numbered 1 through M. Edge i connects vertices A_i and B_i. Your task is to find a path that satisfies the f...
instruction
0
62,160
13
124,320
"Correct Solution: ``` #!usr/bin/env python3 from collections import defaultdict,deque from heapq import heappush, heappop import sys import math import bisect import random def LI(): return [int(x) for x in sys.stdin.readline().split()] def I(): return int(sys.stdin.readline()) def LS():return [list(x) for x in sys.st...
output
1
62,160
13
124,321
Provide a correct Python 3 solution for this coding contest problem. You are given a connected undirected simple graph, which has N vertices and M edges. The vertices are numbered 1 through N, and the edges are numbered 1 through M. Edge i connects vertices A_i and B_i. Your task is to find a path that satisfies the f...
instruction
0
62,161
13
124,322
"Correct Solution: ``` from collections import deque import sys input=sys.stdin.readline n,m=map(int,input().split()) path=[[] for i in range(n)] for i in range(m): a,b=map(int,input().split()) path[a-1].append(b-1) path[b-1].append(a-1) l=deque() s=set() l.append(0) s.add(0) while True: for i in path[l[0]]: ...
output
1
62,161
13
124,323
Provide a correct Python 3 solution for this coding contest problem. You are given a connected undirected simple graph, which has N vertices and M edges. The vertices are numbered 1 through N, and the edges are numbered 1 through M. Edge i connects vertices A_i and B_i. Your task is to find a path that satisfies the f...
instruction
0
62,162
13
124,324
"Correct Solution: ``` import sys from collections import deque sys.setrecursionlimit(10**7) def solve(): def dfs1(u, path, visited): for w in Adj[u]: if not visited[w]: path.append(w) visited[w] = True dfs1(w, path, visited) retu...
output
1
62,162
13
124,325
Provide a correct Python 3 solution for this coding contest problem. You are given a connected undirected simple graph, which has N vertices and M edges. The vertices are numbered 1 through N, and the edges are numbered 1 through M. Edge i connects vertices A_i and B_i. Your task is to find a path that satisfies the f...
instruction
0
62,163
13
124,326
"Correct Solution: ``` def examA(): N = I() A = LI() ans = 1 flag = None for i in range(N-1): cur = A[i+1] - A[i] if not flag: if cur<0: flag = "d" elif cur>0: flag = "u" else: if cur<0 and flag=="u": ...
output
1
62,163
13
124,327
Provide a correct Python 3 solution for this coding contest problem. You are given a connected undirected simple graph, which has N vertices and M edges. The vertices are numbered 1 through N, and the edges are numbered 1 through M. Edge i connects vertices A_i and B_i. Your task is to find a path that satisfies the f...
instruction
0
62,164
13
124,328
"Correct Solution: ``` from collections import deque import sys input = sys.stdin.readline 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) l = deque([1]) s = set([1]) while True: check = True for nex in e[l[...
output
1
62,164
13
124,329
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a connected undirected simple graph, which has N vertices and M edges. The vertices are numbered 1 through N, and the edges are numbered 1 through M. Edge i connects vertices A_i a...
instruction
0
62,165
13
124,330
Yes
output
1
62,165
13
124,331
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a connected undirected simple graph, which has N vertices and M edges. The vertices are numbered 1 through N, and the edges are numbered 1 through M. Edge i connects vertices A_i a...
instruction
0
62,166
13
124,332
Yes
output
1
62,166
13
124,333
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a connected undirected simple graph, which has N vertices and M edges. The vertices are numbered 1 through N, and the edges are numbered 1 through M. Edge i connects vertices A_i a...
instruction
0
62,167
13
124,334
Yes
output
1
62,167
13
124,335
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a connected undirected simple graph, which has N vertices and M edges. The vertices are numbered 1 through N, and the edges are numbered 1 through M. Edge i connects vertices A_i a...
instruction
0
62,168
13
124,336
Yes
output
1
62,168
13
124,337
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a connected undirected simple graph, which has N vertices and M edges. The vertices are numbered 1 through N, and the edges are numbered 1 through M. Edge i connects vertices A_i a...
instruction
0
62,169
13
124,338
No
output
1
62,169
13
124,339
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a connected undirected simple graph, which has N vertices and M edges. The vertices are numbered 1 through N, and the edges are numbered 1 through M. Edge i connects vertices A_i a...
instruction
0
62,170
13
124,340
No
output
1
62,170
13
124,341
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a connected undirected simple graph, which has N vertices and M edges. The vertices are numbered 1 through N, and the edges are numbered 1 through M. Edge i connects vertices A_i a...
instruction
0
62,171
13
124,342
No
output
1
62,171
13
124,343
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a connected undirected simple graph, which has N vertices and M edges. The vertices are numbered 1 through N, and the edges are numbered 1 through M. Edge i connects vertices A_i a...
instruction
0
62,172
13
124,344
No
output
1
62,172
13
124,345
Provide a correct Python 3 solution for this coding contest problem. Optimal Binary Search Tree is a binary search tree constructed from $n$ keys and $n+1$ dummy keys so as to minimize the expected value of cost for a search operation. We are given a sequence $K = {k_1, k_2, ..., k_n}$ of $n$ distinct keys in sorted ...
instruction
0
62,243
13
124,486
"Correct Solution: ``` import sys readline = sys.stdin.readline write = sys.stdout.write N = int(readline()) *P, = map(float, readline().split()) *Q, = map(float, readline().split()) K = [[None]*(N+1) for i in range(N+1)] C = [[None]*(N+1) for i in range(N+1)] S = [0]*(2*N+2) for i in range(2*N+1): S[i+1] = S[i] ...
output
1
62,243
13
124,487
Provide a correct Python 3 solution for this coding contest problem. Optimal Binary Search Tree is a binary search tree constructed from $n$ keys and $n+1$ dummy keys so as to minimize the expected value of cost for a search operation. We are given a sequence $K = {k_1, k_2, ..., k_n}$ of $n$ distinct keys in sorted ...
instruction
0
62,244
13
124,488
"Correct Solution: ``` #!/usr/bin/env python3 # ALDS_10_D: Dynamic Programming - Optimal Binary Search Tree def optimal_cost(n, kp, dp): sums = [sum(kp[0:i]) + sum(dp[0:i+1]) for i in range(n+1)] expects = [[kp[i] + (dp[i] + dp[i+1])*2 for i in range(n)]] for w in range(2, n+1): exps = [] ...
output
1
62,244
13
124,489
Provide a correct Python 3 solution for this coding contest problem. Optimal Binary Search Tree is a binary search tree constructed from $n$ keys and $n+1$ dummy keys so as to minimize the expected value of cost for a search operation. We are given a sequence $K = {k_1, k_2, ..., k_n}$ of $n$ distinct keys in sorted ...
instruction
0
62,245
13
124,490
"Correct Solution: ``` def main(): """最適二分探索木での探索一回あたりの期待値の最小値を求める """ inf = 10*6 n = int(input()) # 内包よりはやい P = [0.0] + list(map(float, input().split())) Q = list(map(float, input().split())) E = [[0.0]*(n+1) for _ in range(n+1)] W = [[0.0]*(n+1) for _ in range(n+1)] for i in ra...
output
1
62,245
13
124,491
Provide a correct Python 3 solution for this coding contest problem. Optimal Binary Search Tree is a binary search tree constructed from $n$ keys and $n+1$ dummy keys so as to minimize the expected value of cost for a search operation. We are given a sequence $K = {k_1, k_2, ..., k_n}$ of $n$ distinct keys in sorted ...
instruction
0
62,246
13
124,492
"Correct Solution: ``` if __name__ == "__main__": num_nodes = int(input()) P = list(map(lambda x: float(x), input().split())) Q = list(map(lambda x: float(x), input().split())) Depth = [[0] * (num_nodes + 1) for i in range(num_nodes + 1)] Exp = [[0.0] * (num_nodes + 1) for i in range(num_nodes + 1)...
output
1
62,246
13
124,493
Provide a correct Python 3 solution for this coding contest problem. Optimal Binary Search Tree is a binary search tree constructed from $n$ keys and $n+1$ dummy keys so as to minimize the expected value of cost for a search operation. We are given a sequence $K = {k_1, k_2, ..., k_n}$ of $n$ distinct keys in sorted ...
instruction
0
62,247
13
124,494
"Correct Solution: ``` n=int(input()) A=[0.0]+[float(i) for i in input().split()] B=[float(i) for i in input().split()] W={} E={} for i in range(1,n+2): W[i,i-1] = B[i-1] E[i,i-1] = B[i-1],i for i in range(1,n+1): for j in range(i,n+1): W[i,j] = W[i,j-1]+A[j]+B[j] for i in range(1,n+1): E[i,i] =...
output
1
62,247
13
124,495
Provide a correct Python 3 solution for this coding contest problem. Optimal Binary Search Tree is a binary search tree constructed from $n$ keys and $n+1$ dummy keys so as to minimize the expected value of cost for a search operation. We are given a sequence $K = {k_1, k_2, ..., k_n}$ of $n$ distinct keys in sorted ...
instruction
0
62,248
13
124,496
"Correct Solution: ``` import sys def input(): return sys.stdin.readline()[:-1] n = int(input()) p = [None] + list(map(float, input().split())) q = list(map(float, input().split())) T = [[500 for i in range(n+1)] for j in range(n+1)] psum = [0] * (n+1) qsum = [0] * (n+1) qsum[0] = q[0] for i in range(1,n+1): ...
output
1
62,248
13
124,497
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Optimal Binary Search Tree is a binary search tree constructed from $n$ keys and $n+1$ dummy keys so as to minimize the expected value of cost for a search operation. We are given a sequence $K...
instruction
0
62,249
13
124,498
No
output
1
62,249
13
124,499
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Optimal Binary Search Tree is a binary search tree constructed from $n$ keys and $n+1$ dummy keys so as to minimize the expected value of cost for a search operation. We are given a sequence $K...
instruction
0
62,250
13
124,500
No
output
1
62,250
13
124,501
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Optimal Binary Search Tree is a binary search tree constructed from $n$ keys and $n+1$ dummy keys so as to minimize the expected value of cost for a search operation. We are given a sequence $K...
instruction
0
62,251
13
124,502
No
output
1
62,251
13
124,503
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Optimal Binary Search Tree is a binary search tree constructed from $n$ keys and $n+1$ dummy keys so as to minimize the expected value of cost for a search operation. We are given a sequence $K...
instruction
0
62,252
13
124,504
No
output
1
62,252
13
124,505
Provide tags and a correct Python 3 solution for this coding contest problem. You've got a undirected graph G, consisting of n nodes. We will consider the nodes of the graph indexed by integers from 1 to n. We know that each node of graph G is connected by edges with at least k other nodes of this graph. Your task is ...
instruction
0
62,610
13
125,220
Tags: dfs and similar, graphs Correct Solution: ``` n, m, k = map(int, input().split()) d = {} for _ in range(m): u, v = map(int, input().split()) if u not in d: d[u] = [v] else: d[u].append(v) if v not in d: d[v] = [u] else: d[v].append(u) # print(d) stack = [] not...
output
1
62,610
13
125,221
Provide tags and a correct Python 3 solution for this coding contest problem. You've got a undirected graph G, consisting of n nodes. We will consider the nodes of the graph indexed by integers from 1 to n. We know that each node of graph G is connected by edges with at least k other nodes of this graph. Your task is ...
instruction
0
62,611
13
125,222
Tags: dfs and similar, graphs Correct Solution: ``` #!/usr/local/bin/python3 from __future__ import print_function import sys from collections import defaultdict DEBUG = '-d' in sys.argv def debug(*args, **kwargs): if DEBUG: print(*args, file=sys.stderr, **kwargs) return None def main(): n, m, ...
output
1
62,611
13
125,223