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 an integer N. Determine if there exists a tree with 2N vertices numbered 1 to 2N satisfying the following condition, and show one such tree if the answer is yes. * Assume that, fo...
instruction
0
79,744
13
159,488
Yes
output
1
79,744
13
159,489
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given an integer N. Determine if there exists a tree with 2N vertices numbered 1 to 2N satisfying the following condition, and show one such tree if the answer is yes. * Assume that, fo...
instruction
0
79,745
13
159,490
No
output
1
79,745
13
159,491
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given an integer N. Determine if there exists a tree with 2N vertices numbered 1 to 2N satisfying the following condition, and show one such tree if the answer is yes. * Assume that, fo...
instruction
0
79,746
13
159,492
No
output
1
79,746
13
159,493
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given an integer N. Determine if there exists a tree with 2N vertices numbered 1 to 2N satisfying the following condition, and show one such tree if the answer is yes. * Assume that, fo...
instruction
0
79,747
13
159,494
No
output
1
79,747
13
159,495
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given an integer N. Determine if there exists a tree with 2N vertices numbered 1 to 2N satisfying the following condition, and show one such tree if the answer is yes. * Assume that, fo...
instruction
0
79,748
13
159,496
No
output
1
79,748
13
159,497
Provide a correct Python 3 solution for this coding contest problem. The best night ever in the world has come! It's 8 p.m. of December 24th, yes, the night of Cristmas Eve. Santa Clause comes to a silent city with ringing bells. Overtaking north wind, from a sleigh a reindeer pulls she shoot presents to soxes hanged ...
instruction
0
79,863
13
159,726
"Correct Solution: ``` from heapq import heappush, heappop INF = 10 ** 20 while True: n, m, p = map(int, input().split()) if n == 0: break edges = [[] for _ in range(n)] for _ in range(m): x, y, w = map(int, input().split()) edges[x].append((y, w)) edges[y].append((x, w)) que = [] heappush(q...
output
1
79,863
13
159,727
Provide a correct Python 3 solution for this coding contest problem. The best night ever in the world has come! It's 8 p.m. of December 24th, yes, the night of Cristmas Eve. Santa Clause comes to a silent city with ringing bells. Overtaking north wind, from a sleigh a reindeer pulls she shoot presents to soxes hanged ...
instruction
0
79,864
13
159,728
"Correct Solution: ``` # AOJ 1058 Winter Bells # Python3 2018.7.7 bal4u import heapq INF = 0x7fffffff def dijkstra(V, to, start): dist, path = [INF]*V, [0]*V Q = [] dist[start], path[start] = 0, 1 heapq.heappush(Q, (0, start)) while Q: t, s = heapq.heappop(Q) if dist[s] < t: continue for e, cost in to[s]: ...
output
1
79,864
13
159,729
Provide a correct Python 3 solution for this coding contest problem. The best night ever in the world has come! It's 8 p.m. of December 24th, yes, the night of Cristmas Eve. Santa Clause comes to a silent city with ringing bells. Overtaking north wind, from a sleigh a reindeer pulls she shoot presents to soxes hanged ...
instruction
0
79,865
13
159,730
"Correct Solution: ``` while 1: n,m,p=map(int,input().split()) if (n,m,p)==(0,0,0): break es=[] for i in range(m): u,v,w=map(int,input().split()) es.extend([(u,v,w),(v,u,w)]) d=[[float("inf")]*n for _ in range(n)] for i in range(n): d[i][i]=0 for e in es: d[e[0]][e[1]]=e[2] for k in range(n):...
output
1
79,865
13
159,731
Provide a correct Python 3 solution for this coding contest problem. The best night ever in the world has come! It's 8 p.m. of December 24th, yes, the night of Cristmas Eve. Santa Clause comes to a silent city with ringing bells. Overtaking north wind, from a sleigh a reindeer pulls she shoot presents to soxes hanged ...
instruction
0
79,866
13
159,732
"Correct Solution: ``` INF=int(1e9) while 1: n,m,p=map(int,input().split()) if (n,m,p)==(0,0,0): break es=[] for i in range(m): u,v,w=map(int,input().split()) es.extend([(u,v,w),(v,u,w)]) d=[[INF]*n for _ in range(n)] for i in range(n): d[i][i]=0 for e in es: d[e[0]][e[1]]=e[2] for k in rang...
output
1
79,866
13
159,733
Provide a correct Python 3 solution for this coding contest problem. Diameter of a Tree Given a tree T with non-negative weight, find the diameter of the tree. The diameter of a tree is the maximum distance between two nodes in a tree. Constraints * 1 ≤ n ≤ 100,000 * 0 ≤ wi ≤ 1,000 Input n s1 t1 w1 s2 t2 w2 ...
instruction
0
79,905
13
159,810
"Correct Solution: ``` import sys import queue # input n = int(input()) tree = [[] for _ in range(n)] for _ in range(n - 1): s, t, w = map(int, sys.stdin.readline().strip().split()) tree[s].append((t, w)) tree[t].append((s, w)) def search(current): distance = [0] * n foot_print = [False] * n ...
output
1
79,905
13
159,811
Provide a correct Python 3 solution for this coding contest problem. Diameter of a Tree Given a tree T with non-negative weight, find the diameter of the tree. The diameter of a tree is the maximum distance between two nodes in a tree. Constraints * 1 ≤ n ≤ 100,000 * 0 ≤ wi ≤ 1,000 Input n s1 t1 w1 s2 t2 w2 ...
instruction
0
79,906
13
159,812
"Correct Solution: ``` # -*- coding: utf-8 -*- from collections import deque if __name__ == '__main__': n = int(input()) E = [set() for _ in range(n)] for _ in range(n - 1): s, t, d = map(int, input().split()) E[s].add((t, d)) E[t].add((s, d)) Q = deque() def bfs(s): ...
output
1
79,906
13
159,813
Provide a correct Python 3 solution for this coding contest problem. Diameter of a Tree Given a tree T with non-negative weight, find the diameter of the tree. The diameter of a tree is the maximum distance between two nodes in a tree. Constraints * 1 ≤ n ≤ 100,000 * 0 ≤ wi ≤ 1,000 Input n s1 t1 w1 s2 t2 w2 ...
instruction
0
79,907
13
159,814
"Correct Solution: ``` import sys readline = sys.stdin.readline def dfs(root): visited = [False] * n queue = [(0, root)] longest = (-1, -1) while queue: total_weight, node = queue.pop() if visited[node]: continue visited[node] = True longest = max(longest, (total_weight, ...
output
1
79,907
13
159,815
Provide a correct Python 3 solution for this coding contest problem. Diameter of a Tree Given a tree T with non-negative weight, find the diameter of the tree. The diameter of a tree is the maximum distance between two nodes in a tree. Constraints * 1 ≤ n ≤ 100,000 * 0 ≤ wi ≤ 1,000 Input n s1 t1 w1 s2 t2 w2 ...
instruction
0
79,908
13
159,816
"Correct Solution: ``` import sys readline = sys.stdin.readline from collections import deque def dfs(root): visited = [False] * n queue = deque([(0, root)]) longest = (-1, -1) while queue: total_weight, node = queue.pop() if visited[node]: continue visited[node] = Tr...
output
1
79,908
13
159,817
Provide a correct Python 3 solution for this coding contest problem. Diameter of a Tree Given a tree T with non-negative weight, find the diameter of the tree. The diameter of a tree is the maximum distance between two nodes in a tree. Constraints * 1 ≤ n ≤ 100,000 * 0 ≤ wi ≤ 1,000 Input n s1 t1 w1 s2 t2 w2 ...
instruction
0
79,909
13
159,818
"Correct Solution: ``` import sys input = sys.stdin.readline from operator import itemgetter sys.setrecursionlimit(10000000) INF = 10**30 G = [] class Edge: def __init__(self, to, w): self.to = to self.w = w def dfs(s, d, fr, dist): dist[s] = d for edge in G[s]: if edge.to != fr: ...
output
1
79,909
13
159,819
Provide a correct Python 3 solution for this coding contest problem. Diameter of a Tree Given a tree T with non-negative weight, find the diameter of the tree. The diameter of a tree is the maximum distance between two nodes in a tree. Constraints * 1 ≤ n ≤ 100,000 * 0 ≤ wi ≤ 1,000 Input n s1 t1 w1 s2 t2 w2 ...
instruction
0
79,910
13
159,820
"Correct Solution: ``` import sys input = sys.stdin.readline class Tree(): def __init__(self,n,edge): self.n = n self.tree = [[] for _ in range(n)] for e in edge: self.tree[e[0]].append((e[1],e[2])) self.tree[e[1]].append((e[0],e[2])) def setroot(self,root): ...
output
1
79,910
13
159,821
Provide a correct Python 3 solution for this coding contest problem. Diameter of a Tree Given a tree T with non-negative weight, find the diameter of the tree. The diameter of a tree is the maximum distance between two nodes in a tree. Constraints * 1 ≤ n ≤ 100,000 * 0 ≤ wi ≤ 1,000 Input n s1 t1 w1 s2 t2 w2 ...
instruction
0
79,911
13
159,822
"Correct Solution: ``` #!/usr/bin/env python3 # GRL_5_A: Tree - Diameter of a Tree class Edge: __slots__ = ('v', 'w') def __init__(self, v, w): self.v = v self.w = w def either(self): return self.v def other(self, v): if v == self.v: return self.w ...
output
1
79,911
13
159,823
Provide a correct Python 3 solution for this coding contest problem. Diameter of a Tree Given a tree T with non-negative weight, find the diameter of the tree. The diameter of a tree is the maximum distance between two nodes in a tree. Constraints * 1 ≤ n ≤ 100,000 * 0 ≤ wi ≤ 1,000 Input n s1 t1 w1 s2 t2 w2 ...
instruction
0
79,912
13
159,824
"Correct Solution: ``` import sys readline = sys.stdin.readline def dfs(root): visited = [False] * n queue = [(0, root)] longest = (-1, -1) while queue: total_weight, node = queue.pop() if visited[node]: continue visited[node] = True longest = max(longest, (to...
output
1
79,912
13
159,825
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Diameter of a Tree Given a tree T with non-negative weight, find the diameter of the tree. The diameter of a tree is the maximum distance between two nodes in a tree. Constraints * 1 ≤ n ...
instruction
0
79,913
13
159,826
Yes
output
1
79,913
13
159,827
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Diameter of a Tree Given a tree T with non-negative weight, find the diameter of the tree. The diameter of a tree is the maximum distance between two nodes in a tree. Constraints * 1 ≤ n ...
instruction
0
79,914
13
159,828
Yes
output
1
79,914
13
159,829
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Diameter of a Tree Given a tree T with non-negative weight, find the diameter of the tree. The diameter of a tree is the maximum distance between two nodes in a tree. Constraints * 1 ≤ n ...
instruction
0
79,915
13
159,830
Yes
output
1
79,915
13
159,831
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Diameter of a Tree Given a tree T with non-negative weight, find the diameter of the tree. The diameter of a tree is the maximum distance between two nodes in a tree. Constraints * 1 ≤ n ...
instruction
0
79,916
13
159,832
Yes
output
1
79,916
13
159,833
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Diameter of a Tree Given a tree T with non-negative weight, find the diameter of the tree. The diameter of a tree is the maximum distance between two nodes in a tree. Constraints * 1 ≤ n ...
instruction
0
79,917
13
159,834
No
output
1
79,917
13
159,835
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Diameter of a Tree Given a tree T with non-negative weight, find the diameter of the tree. The diameter of a tree is the maximum distance between two nodes in a tree. Constraints * 1 ≤ n ...
instruction
0
79,918
13
159,836
No
output
1
79,918
13
159,837
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Diameter of a Tree Given a tree T with non-negative weight, find the diameter of the tree. The diameter of a tree is the maximum distance between two nodes in a tree. Constraints * 1 ≤ n ...
instruction
0
79,919
13
159,838
No
output
1
79,919
13
159,839
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Diameter of a Tree Given a tree T with non-negative weight, find the diameter of the tree. The diameter of a tree is the maximum distance between two nodes in a tree. Constraints * 1 ≤ n ...
instruction
0
79,920
13
159,840
No
output
1
79,920
13
159,841
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya has got a tree consisting of n vertices. He wants to delete some (possibly zero) edges in this tree such that the maximum matching in the resulting graph is unique. He asks you to calculat...
instruction
0
79,953
13
159,906
No
output
1
79,953
13
159,907
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya has got a tree consisting of n vertices. He wants to delete some (possibly zero) edges in this tree such that the maximum matching in the resulting graph is unique. He asks you to calculat...
instruction
0
79,954
13
159,908
No
output
1
79,954
13
159,909
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya has got a tree consisting of n vertices. He wants to delete some (possibly zero) edges in this tree such that the maximum matching in the resulting graph is unique. He asks you to calculat...
instruction
0
79,955
13
159,910
No
output
1
79,955
13
159,911
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya has got a tree consisting of n vertices. He wants to delete some (possibly zero) edges in this tree such that the maximum matching in the resulting graph is unique. He asks you to calculat...
instruction
0
79,956
13
159,912
No
output
1
79,956
13
159,913
Provide tags and a correct Python 3 solution for this coding contest problem. You are given n integer numbers a_1, a_2, ..., a_n. Consider graph on n nodes, in which nodes i, j (i≠ j) are connected if and only if, a_i AND a_j≠ 0, where AND denotes the [bitwise AND operation](https://en.wikipedia.org/wiki/Bitwise_opera...
instruction
0
80,003
13
160,006
Tags: bitmasks, brute force, graphs, shortest paths Correct Solution: ``` def naiveSolve(n): return from collections import deque def main(): n=int(input()) a=readIntArr() setCnts=[0]*60 b=[] for x in a: cnt=0 for i in range(60): if (x&(1<<...
output
1
80,003
13
160,007
Provide tags and a correct Python 3 solution for this coding contest problem. You are given n integer numbers a_1, a_2, ..., a_n. Consider graph on n nodes, in which nodes i, j (i≠ j) are connected if and only if, a_i AND a_j≠ 0, where AND denotes the [bitwise AND operation](https://en.wikipedia.org/wiki/Bitwise_opera...
instruction
0
80,004
13
160,008
Tags: bitmasks, brute force, graphs, shortest paths Correct Solution: ``` import sys input = sys.stdin.readline from collections import deque class Graph(object): """docstring for Graph""" def __init__(self,n,d): # Number of nodes and d is True if directed self.n = n self.graph = [[] for i in range(n)] self.pa...
output
1
80,004
13
160,009
Provide tags and a correct Python 3 solution for this coding contest problem. You are given n integer numbers a_1, a_2, ..., a_n. Consider graph on n nodes, in which nodes i, j (i≠ j) are connected if and only if, a_i AND a_j≠ 0, where AND denotes the [bitwise AND operation](https://en.wikipedia.org/wiki/Bitwise_opera...
instruction
0
80,005
13
160,010
Tags: bitmasks, brute force, graphs, shortest paths Correct Solution: ``` from collections import deque input() h = [list(bin(int(i)))[2:] for i in input().split()] sas = min(map(len, h)) ans = 1e9 graf = [[] for _ in range(100000)] rebra = [] def bfs(assx, sasx): q = deque() q.append(assx) metka = [1 for...
output
1
80,005
13
160,011
Provide tags and a correct Python 3 solution for this coding contest problem. You are given n integer numbers a_1, a_2, ..., a_n. Consider graph on n nodes, in which nodes i, j (i≠ j) are connected if and only if, a_i AND a_j≠ 0, where AND denotes the [bitwise AND operation](https://en.wikipedia.org/wiki/Bitwise_opera...
instruction
0
80,006
13
160,012
Tags: bitmasks, brute force, graphs, shortest paths Correct Solution: ``` import sys #import math #import random #import time input = sys.stdin.readline # #start = time.time() n = int(input()) m = n a = list(map(int, input().split())) s = [list() for i in range(0, 61)] v = [] for _v in a: if _v: v.append(_v) ...
output
1
80,006
13
160,013
Provide tags and a correct Python 3 solution for this coding contest problem. You are given n integer numbers a_1, a_2, ..., a_n. Consider graph on n nodes, in which nodes i, j (i≠ j) are connected if and only if, a_i AND a_j≠ 0, where AND denotes the [bitwise AND operation](https://en.wikipedia.org/wiki/Bitwise_opera...
instruction
0
80,007
13
160,014
Tags: bitmasks, brute force, graphs, shortest paths Correct Solution: ``` # CODE BEGINS HERE................. from collections import deque def bfs(graph, root, prune_level): """make a pruned BFS search of the graph starting at root. returns the BFS tree, and possibly a traversal edge (u,v) that with the tree...
output
1
80,007
13
160,015
Provide tags and a correct Python 3 solution for this coding contest problem. You are given n integer numbers a_1, a_2, ..., a_n. Consider graph on n nodes, in which nodes i, j (i≠ j) are connected if and only if, a_i AND a_j≠ 0, where AND denotes the [bitwise AND operation](https://en.wikipedia.org/wiki/Bitwise_opera...
instruction
0
80,008
13
160,016
Tags: bitmasks, brute force, graphs, shortest paths Correct Solution: ``` import sys, os, re, datetime from collections import * from bisect import * def mat(v, *dims): def submat(i): if i == len(dims)-1: return [v for _ in range(dims[-1])] return [submat(i+1) for _ in range(dims[i])] return sub...
output
1
80,008
13
160,017
Provide tags and a correct Python 3 solution for this coding contest problem. You are given n integer numbers a_1, a_2, ..., a_n. Consider graph on n nodes, in which nodes i, j (i≠ j) are connected if and only if, a_i AND a_j≠ 0, where AND denotes the [bitwise AND operation](https://en.wikipedia.org/wiki/Bitwise_opera...
instruction
0
80,009
13
160,018
Tags: bitmasks, brute force, graphs, shortest paths Correct Solution: ``` # -*- coding: utf-8 -*- import math import collections import bisect import heapq import time import random import itertools import sys from typing import List """ created by shhuan at 2020/1/10 01:32 """ def shortest_path(u, v, g): q = ...
output
1
80,009
13
160,019
Provide tags and a correct Python 3 solution for this coding contest problem. You are given n integer numbers a_1, a_2, ..., a_n. Consider graph on n nodes, in which nodes i, j (i≠ j) are connected if and only if, a_i AND a_j≠ 0, where AND denotes the [bitwise AND operation](https://en.wikipedia.org/wiki/Bitwise_opera...
instruction
0
80,010
13
160,020
Tags: bitmasks, brute force, graphs, shortest paths Correct Solution: ``` # 1205B def do(): n = int(input()) nums = [int(c) for c in input().split(" ")] valid = set() for i in range(64): count = [] for j in range(n): if (1 << i) & nums[j]: count.append(nums[j]...
output
1
80,010
13
160,021
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given n integer numbers a_1, a_2, ..., a_n. Consider graph on n nodes, in which nodes i, j (i≠ j) are connected if and only if, a_i AND a_j≠ 0, where AND denotes the [bitwise AND operati...
instruction
0
80,011
13
160,022
Yes
output
1
80,011
13
160,023
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given n integer numbers a_1, a_2, ..., a_n. Consider graph on n nodes, in which nodes i, j (i≠ j) are connected if and only if, a_i AND a_j≠ 0, where AND denotes the [bitwise AND operati...
instruction
0
80,012
13
160,024
Yes
output
1
80,012
13
160,025
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given n integer numbers a_1, a_2, ..., a_n. Consider graph on n nodes, in which nodes i, j (i≠ j) are connected if and only if, a_i AND a_j≠ 0, where AND denotes the [bitwise AND operati...
instruction
0
80,013
13
160,026
Yes
output
1
80,013
13
160,027
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given n integer numbers a_1, a_2, ..., a_n. Consider graph on n nodes, in which nodes i, j (i≠ j) are connected if and only if, a_i AND a_j≠ 0, where AND denotes the [bitwise AND operati...
instruction
0
80,014
13
160,028
Yes
output
1
80,014
13
160,029
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given n integer numbers a_1, a_2, ..., a_n. Consider graph on n nodes, in which nodes i, j (i≠ j) are connected if and only if, a_i AND a_j≠ 0, where AND denotes the [bitwise AND operati...
instruction
0
80,015
13
160,030
No
output
1
80,015
13
160,031
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given n integer numbers a_1, a_2, ..., a_n. Consider graph on n nodes, in which nodes i, j (i≠ j) are connected if and only if, a_i AND a_j≠ 0, where AND denotes the [bitwise AND operati...
instruction
0
80,016
13
160,032
No
output
1
80,016
13
160,033
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given n integer numbers a_1, a_2, ..., a_n. Consider graph on n nodes, in which nodes i, j (i≠ j) are connected if and only if, a_i AND a_j≠ 0, where AND denotes the [bitwise AND operati...
instruction
0
80,017
13
160,034
No
output
1
80,017
13
160,035
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given n integer numbers a_1, a_2, ..., a_n. Consider graph on n nodes, in which nodes i, j (i≠ j) are connected if and only if, a_i AND a_j≠ 0, where AND denotes the [bitwise AND operati...
instruction
0
80,018
13
160,036
No
output
1
80,018
13
160,037
Provide tags and a correct Python 3 solution for this coding contest problem. Boboniu has a directed graph with n vertices and m edges. The out-degree of each vertex is at most k. Each edge has an integer weight between 1 and m. No two edges have equal weights. Boboniu likes to walk on the graph with some specific ...
instruction
0
80,119
13
160,238
Tags: brute force, dfs and similar, graphs, hashing Correct Solution: ``` import sys input = lambda: sys.stdin.readline().rstrip() N, M, K = map(int, input().split()) IN = [[] for _ in range(N)] OUT = [[] for _ in range(N)] t, m = 12345, (1 << 30) - 1 HASH = [] # s = 987654321 s = 97531 H = 0 for _ in range(N): s =...
output
1
80,119
13
160,239
Provide tags and a correct Python 3 solution for this coding contest problem. Boboniu has a directed graph with n vertices and m edges. The out-degree of each vertex is at most k. Each edge has an integer weight between 1 and m. No two edges have equal weights. Boboniu likes to walk on the graph with some specific ...
instruction
0
80,120
13
160,240
Tags: brute force, dfs and similar, graphs, hashing Correct Solution: ``` import copy from itertools import permutations from collections import defaultdict import sys import io import os input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline def main(): n, m, k = map(int, input().split()) out = [[] for...
output
1
80,120
13
160,241
Provide tags and a correct Python 3 solution for this coding contest problem. Boboniu has a directed graph with n vertices and m edges. The out-degree of each vertex is at most k. Each edge has an integer weight between 1 and m. No two edges have equal weights. Boboniu likes to walk on the graph with some specific ...
instruction
0
80,121
13
160,242
Tags: brute force, dfs and similar, graphs, hashing Correct Solution: ``` import sys input = sys.stdin.buffer.readline n,m,k = map(int,input().split()) edge = [[] for _ in range(n)] dg = 10**6 MOD = 10**9+7 for _ in range(m): u,v,w = map(int,input().split()) edge[u-1].append(w*dg + v-1) num = [[] for i ...
output
1
80,121
13
160,243
Provide tags and a correct Python 3 solution for this coding contest problem. Boboniu has a directed graph with n vertices and m edges. The out-degree of each vertex is at most k. Each edge has an integer weight between 1 and m. No two edges have equal weights. Boboniu likes to walk on the graph with some specific ...
instruction
0
80,122
13
160,244
Tags: brute force, dfs and similar, graphs, hashing Correct Solution: ``` import io, os input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline from operator import itemgetter n,m,k=map(int,input().split()) e=[[] for i in range(n+1)] for i in range(m): u,v,w=map(int,input().split()) e[u].append((w,v)) come=...
output
1
80,122
13
160,245
Provide tags and a correct Python 3 solution for this coding contest problem. Boboniu has a directed graph with n vertices and m edges. The out-degree of each vertex is at most k. Each edge has an integer weight between 1 and m. No two edges have equal weights. Boboniu likes to walk on the graph with some specific ...
instruction
0
80,123
13
160,246
Tags: brute force, dfs and similar, graphs, hashing Correct Solution: ``` from random import randrange import sys input = sys.stdin.buffer.readline def solve(digit, res): ans = 0 if digit == k: return int(res == zob_all) for i in range(digit + 1): ans += solve(digit + 1, res^zob[digit][i])...
output
1
80,123
13
160,247