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
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a tree that consists of n nodes. You should label each of its n-1 edges with an integer in such way that satisfies the following conditions: * each integer must be greater than...
instruction
0
96,323
13
192,646
No
output
1
96,323
13
192,647
Provide tags and a correct Python 3 solution for this coding contest problem. Bajtek is learning to skate on ice. He's a beginner, so his only mode of transportation is pushing off from a snow drift to the north, east, south or west and sliding until he lands in another snow drift. He has noticed that in this way it's...
instruction
0
96,407
13
192,814
Tags: brute force, dfs and similar, dsu, graphs Correct Solution: ``` n = int(input()) visited = set() graph = {} def dfs(node): visited.add(node) for neighbor in graph[node]: if neighbor not in visited: dfs(neighbor) def is_connected(x, y): return x[0] == y[0] or x[1] == y[1] for...
output
1
96,407
13
192,815
Provide tags and a correct Python 3 solution for this coding contest problem. An undirected graph is called k-regular, if the degrees of all its vertices are equal k. An edge of a connected graph is called a bridge, if after removing it the graph is being split into two connected components. Build a connected undirec...
instruction
0
96,551
13
193,102
Tags: constructive algorithms, graphs, implementation Correct Solution: ``` import sys input = [] input_index = 0 def next(type, number = None): def next(): global input, input_index while input_index == len(input): if sys.stdin: input = sys.stdin.readline().split() input_index = 0...
output
1
96,551
13
193,103
Provide tags and a correct Python 3 solution for this coding contest problem. An undirected graph is called k-regular, if the degrees of all its vertices are equal k. An edge of a connected graph is called a bridge, if after removing it the graph is being split into two connected components. Build a connected undirec...
instruction
0
96,552
13
193,104
Tags: constructive algorithms, graphs, implementation Correct Solution: ``` import math,string,itertools,fractions,heapq,collections,re,array,bisect from itertools import chain, dropwhile, permutations, combinations from collections import defaultdict, deque def VI(): return list(map(int,input().split())) def main1(k...
output
1
96,552
13
193,105
Provide tags and a correct Python 3 solution for this coding contest problem. An undirected graph is called k-regular, if the degrees of all its vertices are equal k. An edge of a connected graph is called a bridge, if after removing it the graph is being split into two connected components. Build a connected undirec...
instruction
0
96,553
13
193,106
Tags: constructive algorithms, graphs, implementation Correct Solution: ``` def generate(cur, n): comp = [] edge = [] cur+=1 comp.append([cur]) layer1 = [] for _ in range(n-1): cur+=1 layer1.append(cur) comp.append(layer1) layer2 = [] for _ in range(n-...
output
1
96,553
13
193,107
Provide tags and a correct Python 3 solution for this coding contest problem. An undirected graph is called k-regular, if the degrees of all its vertices are equal k. An edge of a connected graph is called a bridge, if after removing it the graph is being split into two connected components. Build a connected undirec...
instruction
0
96,554
13
193,108
Tags: constructive algorithms, graphs, implementation Correct Solution: ``` def main(): k = int(input()) if k & 1: print("YES") n = 2 * (2 * k - 1) m = k * (2 * k - 1) print(n, m) n >>= 1 print(1, 1 + n) for i in range(2, k + 1): print(1, i) ...
output
1
96,554
13
193,109
Provide tags and a correct Python 3 solution for this coding contest problem. An undirected graph is called k-regular, if the degrees of all its vertices are equal k. An edge of a connected graph is called a bridge, if after removing it the graph is being split into two connected components. Build a connected undirec...
instruction
0
96,555
13
193,110
Tags: constructive algorithms, graphs, implementation Correct Solution: ``` k = int(input()) if k == 1: print('YES\n2 1\n1 2') elif k % 2 == 0: print('NO') else: print('YES') n = k+1 z = (k-1)//2 print(2*k+4, n*(n-1) + 1 + 2*z) l1 = list(range(1, 2*z+1, 2))+[-1] l2 = list(range(k+4, k+2*...
output
1
96,555
13
193,111
Provide tags and a correct Python 3 solution for this coding contest problem. An undirected graph is called k-regular, if the degrees of all its vertices are equal k. An edge of a connected graph is called a bridge, if after removing it the graph is being split into two connected components. Build a connected undirec...
instruction
0
96,556
13
193,112
Tags: constructive algorithms, graphs, implementation Correct Solution: ``` def constructK2( v , k ): res = set() for i in range(1,k): res.add( (v[0],v[i]) ) for i in range(1,k): for j in range(1,k): if i!=j: res.add( (min(v[i],v[j]),max(v[i],v[j])) ) for ...
output
1
96,556
13
193,113
Provide tags and a correct Python 3 solution for this coding contest problem. An undirected graph is called k-regular, if the degrees of all its vertices are equal k. An edge of a connected graph is called a bridge, if after removing it the graph is being split into two connected components. Build a connected undirec...
instruction
0
96,557
13
193,114
Tags: constructive algorithms, graphs, implementation Correct Solution: ``` def printWithSymmetry(u, v, offset): print("{0} {1}".format(u, v)) print("{0} {1}".format(u+offset, v+offset)) k = int(input()) if k % 2 == 0: print("NO") elif k == 1: # Caso Especial print("YES") print("2 1") print("...
output
1
96,557
13
193,115
Provide tags and a correct Python 3 solution for this coding contest problem. An undirected graph is called k-regular, if the degrees of all its vertices are equal k. An edge of a connected graph is called a bridge, if after removing it the graph is being split into two connected components. Build a connected undirec...
instruction
0
96,558
13
193,116
Tags: constructive algorithms, graphs, implementation Correct Solution: ``` x = int(input()) if x%2==0: print("NO") quit() print("WHY IS CF SO HARD Dx") if x == 1: print("YES") print(2, 1) print(1, 2) else: print("YES") sides = 2*x + 4 half = x+2 e = sides * x // 2 print(sid...
output
1
96,558
13
193,117
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. An undirected graph is called k-regular, if the degrees of all its vertices are equal k. An edge of a connected graph is called a bridge, if after removing it the graph is being split into two c...
instruction
0
96,559
13
193,118
Yes
output
1
96,559
13
193,119
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. An undirected graph is called k-regular, if the degrees of all its vertices are equal k. An edge of a connected graph is called a bridge, if after removing it the graph is being split into two c...
instruction
0
96,560
13
193,120
Yes
output
1
96,560
13
193,121
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. An undirected graph is called k-regular, if the degrees of all its vertices are equal k. An edge of a connected graph is called a bridge, if after removing it the graph is being split into two c...
instruction
0
96,561
13
193,122
Yes
output
1
96,561
13
193,123
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. An undirected graph is called k-regular, if the degrees of all its vertices are equal k. An edge of a connected graph is called a bridge, if after removing it the graph is being split into two c...
instruction
0
96,562
13
193,124
Yes
output
1
96,562
13
193,125
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. An undirected graph is called k-regular, if the degrees of all its vertices are equal k. An edge of a connected graph is called a bridge, if after removing it the graph is being split into two c...
instruction
0
96,563
13
193,126
No
output
1
96,563
13
193,127
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. An undirected graph is called k-regular, if the degrees of all its vertices are equal k. An edge of a connected graph is called a bridge, if after removing it the graph is being split into two c...
instruction
0
96,564
13
193,128
No
output
1
96,564
13
193,129
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. An undirected graph is called k-regular, if the degrees of all its vertices are equal k. An edge of a connected graph is called a bridge, if after removing it the graph is being split into two c...
instruction
0
96,565
13
193,130
No
output
1
96,565
13
193,131
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. An undirected graph is called k-regular, if the degrees of all its vertices are equal k. An edge of a connected graph is called a bridge, if after removing it the graph is being split into two c...
instruction
0
96,566
13
193,132
No
output
1
96,566
13
193,133
Provide tags and a correct Python 3 solution for this coding contest problem. Ostap already settled down in Rio de Janiero suburb and started to grow a tree in his garden. Recall that a tree is a connected undirected acyclic graph. Ostap's tree now has n vertices. He wants to paint some vertices of the tree black su...
instruction
0
96,647
13
193,294
Tags: dp, trees Correct Solution: ``` def main(): n, k = map(int, input().split()) cnt = [[[0] * 21 for _ in (0, 1)] for _ in range(n + 1)] edges, mod = [[] for _ in range(n + 1)], 1000000007 for _ in range(n - 1): u, v = map(int, input().split()) edges[u].append(v) edges[v].appe...
output
1
96,647
13
193,295
Provide tags and a correct Python 3 solution for this coding contest problem. Ostap already settled down in Rio de Janiero suburb and started to grow a tree in his garden. Recall that a tree is a connected undirected acyclic graph. Ostap's tree now has n vertices. He wants to paint some vertices of the tree black su...
instruction
0
96,648
13
193,296
Tags: dp, trees Correct Solution: ``` import sys #sys.stdin=open("data.txt") #sys.stdout=open("data.txt","w") input=sys.stdin.readline n,k=map(int,input().split()) g=[[] for _ in range(n+1)] vis=[0]*(n+1) for _ in range(n-1): u,v=map(int,input().split()) g[u].append(v) g[v].append(u) def getans(u,k): ...
output
1
96,648
13
193,297
Provide tags and a correct Python 3 solution for this coding contest problem. Ostap already settled down in Rio de Janiero suburb and started to grow a tree in his garden. Recall that a tree is a connected undirected acyclic graph. Ostap's tree now has n vertices. He wants to paint some vertices of the tree black su...
instruction
0
96,649
13
193,298
Tags: dp, trees Correct Solution: ``` n,m = map(int,input().split()) edge_to = [0 for i in range(n*2+1)] edge_next = [0 for i in range(n*2+1)] son = [0 for i in range(n+1)] def add_edge(u,v): global edge_next,edge_to,son,tot; tot += 1; edge_to[tot] = v; edge_next[tot] = son[u]; son[u] = tot; tot = 0; ...
output
1
96,649
13
193,299
Provide tags and a correct Python 3 solution for this coding contest problem. Ostap already settled down in Rio de Janiero suburb and started to grow a tree in his garden. Recall that a tree is a connected undirected acyclic graph. Ostap's tree now has n vertices. He wants to paint some vertices of the tree black su...
instruction
0
96,650
13
193,300
Tags: dp, trees Correct Solution: ``` import sys #sys.stdin=open("data.txt") #sys.stdout=open("data.txt","w") input=sys.stdin.readline n,k=map(int,input().split()) g=[[] for _ in range(n+1)] vis=[0]*(n+1) for _ in range(n-1): u,v=map(int,input().split()) g[u].append(v) g[v].append(u) def ...
output
1
96,650
13
193,301
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Ostap already settled down in Rio de Janiero suburb and started to grow a tree in his garden. Recall that a tree is a connected undirected acyclic graph. Ostap's tree now has n vertices. He wa...
instruction
0
96,651
13
193,302
No
output
1
96,651
13
193,303
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Ostap already settled down in Rio de Janiero suburb and started to grow a tree in his garden. Recall that a tree is a connected undirected acyclic graph. Ostap's tree now has n vertices. He wa...
instruction
0
96,652
13
193,304
No
output
1
96,652
13
193,305
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Ostap already settled down in Rio de Janiero suburb and started to grow a tree in his garden. Recall that a tree is a connected undirected acyclic graph. Ostap's tree now has n vertices. He wa...
instruction
0
96,653
13
193,306
No
output
1
96,653
13
193,307
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Pasha is a good student and one of MoJaK's best friends. He always have a problem to think about. Today they had a talk about the following problem. We have a forest (acyclic undirected graph) ...
instruction
0
96,670
13
193,340
No
output
1
96,670
13
193,341
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Pasha is a good student and one of MoJaK's best friends. He always have a problem to think about. Today they had a talk about the following problem. We have a forest (acyclic undirected graph) ...
instruction
0
96,671
13
193,342
No
output
1
96,671
13
193,343
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Pasha is a good student and one of MoJaK's best friends. He always have a problem to think about. Today they had a talk about the following problem. We have a forest (acyclic undirected graph) ...
instruction
0
96,672
13
193,344
No
output
1
96,672
13
193,345
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Pasha is a good student and one of MoJaK's best friends. He always have a problem to think about. Today they had a talk about the following problem. We have a forest (acyclic undirected graph) ...
instruction
0
96,673
13
193,346
No
output
1
96,673
13
193,347
Provide a correct Python 3 solution for this coding contest problem. Fox Ciel is developing an artificial intelligence (AI) for a game. This game is described as a game tree T with n vertices. Each node in the game has an evaluation value which shows how good a situation is. This value is the same as maximum value of ...
instruction
0
96,916
13
193,832
"Correct Solution: ``` from collections import deque import sys readline = sys.stdin.readline write = sys.stdout.write def solve(): N = int(readline()) *P, = map(int, readline().split()) G = [] prt = [0]*N for i in range(N): k, *t = map(int, readline().split()) G.append([e-1 for e in...
output
1
96,916
13
193,833
Provide tags and a correct Python 3 solution for this coding contest problem. You are given an undirected tree consisting of n vertices. An undirected tree is a connected undirected graph with n - 1 edges. Your task is to add the minimum number of edges in such a way that the length of the shortest path from the vert...
instruction
0
96,960
13
193,920
Tags: dp, graphs, greedy Correct Solution: ``` from sys import stdin n = int(stdin.readline()) g = dict() for i in range(n-1): u,v = map(int,stdin.readline().split()) g.setdefault(u-1,[]).append(v-1) g.setdefault(v-1, []).append(u-1) st = [0] rank = [0]*n tree = [0]*n msk = [0]*n rd = dict() while len(st)>0...
output
1
96,960
13
193,921
Provide tags and a correct Python 3 solution for this coding contest problem. You are given an undirected tree consisting of n vertices. An undirected tree is a connected undirected graph with n - 1 edges. Your task is to add the minimum number of edges in such a way that the length of the shortest path from the vert...
instruction
0
96,961
13
193,922
Tags: dp, graphs, greedy Correct Solution: ``` from collections import defaultdict from collections import deque import sys input = sys.stdin.readline def bfs(s): q = deque() q.append(s) dist = [-1] * (n + 1) dist[s] = 0 p = [] parent = [1] * (n + 1) ok = [0] * (n + 1) while q: ...
output
1
96,961
13
193,923
Provide tags and a correct Python 3 solution for this coding contest problem. You are given an undirected tree consisting of n vertices. An undirected tree is a connected undirected graph with n - 1 edges. Your task is to add the minimum number of edges in such a way that the length of the shortest path from the vert...
instruction
0
96,962
13
193,924
Tags: dp, graphs, greedy Correct Solution: ``` import sys def get_new_edges(graph): n = len(graph) far_vertex = [] pi = [None]*n visit = [False]*n visit[0] queue = [[0,0]] i = 0 while True: if i >= len(queue): break current, d = queue[i] i += 1 visit...
output
1
96,962
13
193,925
Provide tags and a correct Python 3 solution for this coding contest problem. You are given an undirected tree consisting of n vertices. An undirected tree is a connected undirected graph with n - 1 edges. Your task is to add the minimum number of edges in such a way that the length of the shortest path from the vert...
instruction
0
96,963
13
193,926
Tags: dp, graphs, greedy Correct Solution: ``` import sys from collections import deque import heapq input = sys.stdin.readline N=int(input()) EDGE=[list(map(int,input().split())) for i in range(N-1)] EDGELIST=[[] for i in range(N+1)] for i,j in EDGE: EDGELIST[i].append(j) EDGELIST[j].append(i) #EDGES=[[] f...
output
1
96,963
13
193,927
Provide tags and a correct Python 3 solution for this coding contest problem. You are given an undirected tree consisting of n vertices. An undirected tree is a connected undirected graph with n - 1 edges. Your task is to add the minimum number of edges in such a way that the length of the shortest path from the vert...
instruction
0
96,964
13
193,928
Tags: dp, graphs, greedy Correct Solution: ``` import sys from collections import deque mod = 10**9+7 INF = float('inf') def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.stdin.readline().split())) n = inp() edges = [[] for _ in range(n)] for _ in range(n-1): a,b = inpl() a,b = a...
output
1
96,964
13
193,929
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given an undirected tree consisting of n vertices. An undirected tree is a connected undirected graph with n - 1 edges. Your task is to add the minimum number of edges in such a way tha...
instruction
0
96,965
13
193,930
No
output
1
96,965
13
193,931
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given an undirected tree consisting of n vertices. An undirected tree is a connected undirected graph with n - 1 edges. Your task is to add the minimum number of edges in such a way tha...
instruction
0
96,966
13
193,932
No
output
1
96,966
13
193,933
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given an undirected tree consisting of n vertices. An undirected tree is a connected undirected graph with n - 1 edges. Your task is to add the minimum number of edges in such a way tha...
instruction
0
96,967
13
193,934
No
output
1
96,967
13
193,935
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given an undirected tree consisting of n vertices. An undirected tree is a connected undirected graph with n - 1 edges. Your task is to add the minimum number of edges in such a way tha...
instruction
0
96,968
13
193,936
No
output
1
96,968
13
193,937
Provide a correct Python 3 solution for this coding contest problem. G: Tree problem Given a tree consisting of N vertices. Each vertex of the tree is numbered from 1 to N. Of the N-1 edges, the i \ (= 1, 2, ..., N-1) edge connects the vertex u_i and the vertex v_i. Write a program to find the number of K non-empty...
instruction
0
97,796
13
195,592
"Correct Solution: ``` import sys def getpar(Edge, p): N = len(Edge) par = [0]*N par[0] = -1 par[p] -1 stack = [p] visited = set([p]) while stack: vn = stack.pop() for vf in Edge[vn]: if vf in visited: continue visited.add(vf)...
output
1
97,796
13
195,593
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A graph is called planar, if it can be drawn in such a way that its edges intersect only at their vertexes. An articulation point is such a vertex of an undirected graph, that when removed incr...
instruction
0
98,160
13
196,320
No
output
1
98,160
13
196,321
Provide tags and a correct Python 3 solution for this coding contest problem. "Eat a beaver, save a tree!" β€” That will be the motto of ecologists' urgent meeting in Beaverley Hills. And the whole point is that the population of beavers on the Earth has reached incredible sizes! Each day their number increases in seve...
instruction
0
98,328
13
196,656
Tags: dfs and similar, dp, dsu, greedy, trees Correct Solution: ``` import sys from array import array # noqa: F401 def input(): return sys.stdin.buffer.readline().decode('utf-8') n = int(input()) beaver = list(map(int, input().split())) adj = [[] for _ in range(n)] deg = [0] * n for u, v in (map(int, input()...
output
1
98,328
13
196,657
Provide tags and a correct Python 3 solution for this coding contest problem. Fox Ciel wants to write a task for a programming contest. The task is: "You are given a simple undirected graph with n vertexes. Each its edge has unit length. You should calculate the number of shortest paths between vertex 1 and vertex 2."...
instruction
0
98,976
13
197,952
Tags: bitmasks, constructive algorithms, graphs, implementation, math Correct Solution: ``` n, m, cnt = int(input()), 148, 0 ans = [['N'] * m for i in range(m)] def edge(i, j): ans[i][j] = ans[j][i] = 'Y' def node(*adj): global cnt i = cnt cnt += 1 for j in adj: edge(i, j) return i st...
output
1
98,976
13
197,953
Provide tags and a correct Python 3 solution for this coding contest problem. Fox Ciel wants to write a task for a programming contest. The task is: "You are given a simple undirected graph with n vertexes. Each its edge has unit length. You should calculate the number of shortest paths between vertex 1 and vertex 2."...
instruction
0
98,977
13
197,954
Tags: bitmasks, constructive algorithms, graphs, implementation, math Correct Solution: ``` n, m, cnt = int(input()), 148, 0 ans = [['N'] * m for i in range(m)] def edge(i, j): ans[i][j] = ans[j][i] = 'Y' def node(*adj): global cnt i = cnt cnt += 1 for j in adj: edge(i, j) return i st...
output
1
98,977
13
197,955
Provide tags and a correct Python 3 solution for this coding contest problem. Fox Ciel wants to write a task for a programming contest. The task is: "You are given a simple undirected graph with n vertexes. Each its edge has unit length. You should calculate the number of shortest paths between vertex 1 and vertex 2."...
instruction
0
98,978
13
197,956
Tags: bitmasks, constructive algorithms, graphs, implementation, math Correct Solution: ``` from collections import defaultdict k=int(input()) mask=0 d=defaultdict(lambda:0) while(mask<=30): if k&(1<<mask): d[mask]=1 ma=mask mask+=1 adj=defaultdict(lambda:"N") currl=1 currvu=3 prevu=[1] prevl...
output
1
98,978
13
197,957
Provide tags and a correct Python 3 solution for this coding contest problem. Fox Ciel wants to write a task for a programming contest. The task is: "You are given a simple undirected graph with n vertexes. Each its edge has unit length. You should calculate the number of shortest paths between vertex 1 and vertex 2."...
instruction
0
98,979
13
197,958
Tags: bitmasks, constructive algorithms, graphs, implementation, math Correct Solution: ``` class Node(object): cnt = 0 def __init__(_, adj=None): _.id = Node.cnt Node.cnt += 1 _.adj = adj if adj else [] _.seen = False def dfs(_): if _.seen: return ...
output
1
98,979
13
197,959
Provide tags and a correct Python 3 solution for this coding contest problem. Fox Ciel wants to write a task for a programming contest. The task is: "You are given a simple undirected graph with n vertexes. Each its edge has unit length. You should calculate the number of shortest paths between vertex 1 and vertex 2."...
instruction
0
98,980
13
197,960
Tags: bitmasks, constructive algorithms, graphs, implementation, math Correct Solution: ``` N = int(input()) b = bin(N)[2:][::-1] count = len(b)-1 def print_matrix(m): print(len(m)) for i in range(len(m)): print("".join(m[i])) m = [['N' for i in range(2*(len(b))+count)] for j in range(2*(len(b))+count...
output
1
98,980
13
197,961
Provide tags and a correct Python 3 solution for this coding contest problem. Fox Ciel wants to write a task for a programming contest. The task is: "You are given a simple undirected graph with n vertexes. Each its edge has unit length. You should calculate the number of shortest paths between vertex 1 and vertex 2."...
instruction
0
98,981
13
197,962
Tags: bitmasks, constructive algorithms, graphs, implementation, math Correct Solution: ``` k=str(input()) l=len(k) paths=[] for i in range(l): paths.append([1]*i+[int(k[i])]+[10]*(l-i-1)) lens = [sum(p) for p in paths] n = sum(lens)+2 m = ['']*n m[0] = 'N'*2 for i in range(len(paths)): m[0] += 'Y'*paths[i][0]+...
output
1
98,981
13
197,963
Provide tags and a correct Python 3 solution for this coding contest problem. Fox Ciel wants to write a task for a programming contest. The task is: "You are given a simple undirected graph with n vertexes. Each its edge has unit length. You should calculate the number of shortest paths between vertex 1 and vertex 2."...
instruction
0
98,982
13
197,964
Tags: bitmasks, constructive algorithms, graphs, implementation, math Correct Solution: ``` class Node(object): cnt = 0 def __init__(_, adj=None): _.id = Node.cnt Node.cnt += 1 _.adj = adj if adj else [] _.seen = False n = int(input()) start = Node() end = Node() choose = Node()...
output
1
98,982
13
197,965
Provide tags and a correct Python 3 solution for this coding contest problem. Fox Ciel wants to write a task for a programming contest. The task is: "You are given a simple undirected graph with n vertexes. Each its edge has unit length. You should calculate the number of shortest paths between vertex 1 and vertex 2."...
instruction
0
98,983
13
197,966
Tags: bitmasks, constructive algorithms, graphs, implementation, math Correct Solution: ``` k = int(input()) edges = [['N' for i in range(1010)] for j in range(1010)] vertices = 2 def add_edge(a, b): global edges edges[a][b] = edges[b][a] = 'Y' for i in range(1, 29 + 1): vertices += 3 add_edge(i * ...
output
1
98,983
13
197,967