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 with N vertices. The vertices are numbered 0 through N-1, and the edges are numbered 1 through N-1. Edge i connects Vertex x_i and y_i, and has a value a_i. You can perform ... | instruction | 0 | 22,702 | 13 | 45,404 |
No | output | 1 | 22,702 | 13 | 45,405 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have a simple undirected graph consisting of n vertices and m edges. The graph doesn't contain self-loops, there is at most one edge between a pair of vertices. The given graph can be disconnected.
Let's make a definition.
Let v_1 and ... | instruction | 0 | 22,944 | 13 | 45,888 |
Tags: brute force, constructive algorithms, graphs, hashing, implementation
Correct Solution:
```
class SortedList:
def __init__(self, iterable=[], _load=200):
"""Initialize sorted list instance."""
values = sorted(iterable)
self._len = _len = len(values)
self._load = _load
s... | output | 1 | 22,944 | 13 | 45,889 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have a simple undirected graph consisting of n vertices and m edges. The graph doesn't contain self-loops, there is at most one edge between a pair of vertices. The given graph can be disconnected.
Let's make a definition.
Let v_1 and ... | instruction | 0 | 22,945 | 13 | 45,890 |
Tags: brute force, constructive algorithms, graphs, hashing, implementation
Correct Solution:
```
from collections import defaultdict, deque
def threeSets(vs, es, d):
sets = [3] * vs
s1 = 0
dist = [float('inf')] * vs
sets[s1] = 1
dist[s1] = 0
queue = deque([s1])
while queue:
v... | output | 1 | 22,945 | 13 | 45,891 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have a simple undirected graph consisting of n vertices and m edges. The graph doesn't contain self-loops, there is at most one edge between a pair of vertices. The given graph can be disconnected.
Let's make a definition.
Let v_1 and ... | instruction | 0 | 22,946 | 13 | 45,892 |
Tags: brute force, constructive algorithms, graphs, hashing, implementation
Correct Solution:
```
n, m = map(int, input().split())
G = [[] for _ in range(n)]
for i in range(m):
a, b = map(int, input().split())
a -= 1
b -= 1
G[a].append(b)
G[b].append(a)
if len(G[0]) < 2:
print(-1)
exit(0)
res = [1]*n
for a in ... | output | 1 | 22,946 | 13 | 45,893 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have a simple undirected graph consisting of n vertices and m edges. The graph doesn't contain self-loops, there is at most one edge between a pair of vertices. The given graph can be disconnected.
Let's make a definition.
Let v_1 and ... | instruction | 0 | 22,947 | 13 | 45,894 |
Tags: brute force, constructive algorithms, graphs, hashing, implementation
Correct Solution:
```
a=list(map(int,input().split()))
n=a[0]
e=a[1]
g={}
for itr in range(1,n+1):
g[itr]=[]
for i in range(e):
a=list(map(int,input().split()))
g[a[0]].append(a[1])
g[a[1]].append(a[0])
for itr in range(1,n+1):
... | output | 1 | 22,947 | 13 | 45,895 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have a simple undirected graph consisting of n vertices and m edges. The graph doesn't contain self-loops, there is at most one edge between a pair of vertices. The given graph can be disconnected.
Let's make a definition.
Let v_1 and ... | instruction | 0 | 22,948 | 13 | 45,896 |
Tags: brute force, constructive algorithms, graphs, hashing, implementation
Correct Solution:
```
import sys
def fill(graph,n):
dp=[[True,True,True] for _ in range(n+1)]
l=[-1 for i in range(n+1)]
from collections import defaultdict
vis=defaultdict(int)
count1,count2,count3=0,0,0
for i in g... | output | 1 | 22,948 | 13 | 45,897 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have a simple undirected graph consisting of n vertices and m edges. The graph doesn't contain self-loops, there is at most one edge between a pair of vertices. The given graph can be disconnected.
Let's make a definition.
Let v_1 and ... | instruction | 0 | 22,949 | 13 | 45,898 |
Tags: brute force, constructive algorithms, graphs, hashing, implementation
Correct Solution:
```
#!/usr/bin/python3
import math
import os
import sys
DEBUG = 'DEBUG' in os.environ
def inp():
return sys.stdin.readline().rstrip()
def dprint(*value, sep=' ', end='\n'):
if DEBUG:
print(*value, sep=se... | output | 1 | 22,949 | 13 | 45,899 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have a simple undirected graph consisting of n vertices and m edges. The graph doesn't contain self-loops, there is at most one edge between a pair of vertices. The given graph can be disconnected.
Let's make a definition.
Let v_1 and ... | instruction | 0 | 22,950 | 13 | 45,900 |
Tags: brute force, constructive algorithms, graphs, hashing, implementation
Correct Solution:
```
import collections
from collections import defaultdict
graph1=defaultdict(list)
n,m=map(int,input().split())
groups=[0]*(n)
for i in range(m):
u,v=map(int, input().split())
graph1[u].append(v)
graph1[v].append(... | output | 1 | 22,950 | 13 | 45,901 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have a simple undirected graph consisting of n vertices and m edges. The graph doesn't contain self-loops, there is at most one edge between a pair of vertices. The given graph can be disconnected.
Let's make a definition.
Let v_1 and ... | instruction | 0 | 22,951 | 13 | 45,902 |
Tags: brute force, constructive algorithms, graphs, hashing, implementation
Correct Solution:
```
"""
Satwik_Tiwari ;) .
25th AUGUST , 2020 - TUESDAY
"""
#===============================================================================================
#importing some useful libraries.
from __future__ import di... | output | 1 | 22,951 | 13 | 45,903 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have a simple undirected graph consisting of n vertices and m edges. The graph doesn't contain self-loops, there is at most one edge between a pair of vertices. The given graph can be discon... | instruction | 0 | 22,952 | 13 | 45,904 |
Yes | output | 1 | 22,952 | 13 | 45,905 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have a simple undirected graph consisting of n vertices and m edges. The graph doesn't contain self-loops, there is at most one edge between a pair of vertices. The given graph can be discon... | instruction | 0 | 22,953 | 13 | 45,906 |
Yes | output | 1 | 22,953 | 13 | 45,907 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have a simple undirected graph consisting of n vertices and m edges. The graph doesn't contain self-loops, there is at most one edge between a pair of vertices. The given graph can be discon... | instruction | 0 | 22,954 | 13 | 45,908 |
Yes | output | 1 | 22,954 | 13 | 45,909 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have a simple undirected graph consisting of n vertices and m edges. The graph doesn't contain self-loops, there is at most one edge between a pair of vertices. The given graph can be discon... | instruction | 0 | 22,955 | 13 | 45,910 |
Yes | output | 1 | 22,955 | 13 | 45,911 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have a simple undirected graph consisting of n vertices and m edges. The graph doesn't contain self-loops, there is at most one edge between a pair of vertices. The given graph can be discon... | instruction | 0 | 22,956 | 13 | 45,912 |
No | output | 1 | 22,956 | 13 | 45,913 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have a simple undirected graph consisting of n vertices and m edges. The graph doesn't contain self-loops, there is at most one edge between a pair of vertices. The given graph can be discon... | instruction | 0 | 22,957 | 13 | 45,914 |
No | output | 1 | 22,957 | 13 | 45,915 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have a simple undirected graph consisting of n vertices and m edges. The graph doesn't contain self-loops, there is at most one edge between a pair of vertices. The given graph can be discon... | instruction | 0 | 22,958 | 13 | 45,916 |
No | output | 1 | 22,958 | 13 | 45,917 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have a simple undirected graph consisting of n vertices and m edges. The graph doesn't contain self-loops, there is at most one edge between a pair of vertices. The given graph can be discon... | instruction | 0 | 22,959 | 13 | 45,918 |
No | output | 1 | 22,959 | 13 | 45,919 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a tree with n vertices. You are allowed to modify the structure of the tree through the following multi-step operation:
1. Choose three vertices a, b, and c such that b is adjacent to both a and c.
2. For every vertex d o... | instruction | 0 | 23,041 | 13 | 46,082 |
Tags: brute force, constructive algorithms, dfs and similar, graph matchings, graphs, trees
Correct Solution:
```
import sys
def minp():
return sys.stdin.readline().strip()
def mint():
return int(minp())
def mints():
return map(int, minp().split())
def solve():
n = mint()
e = [[] for i in range(n)]
for _ in r... | output | 1 | 23,041 | 13 | 46,083 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a tree with n vertices. You are allowed to modify the structure of the tree through the following multi-step operation:
1. Choose three vertices a, b, and c such that b is adjacent to both a and c.
2. For every vertex d o... | instruction | 0 | 23,042 | 13 | 46,084 |
Tags: brute force, constructive algorithms, dfs and similar, graph matchings, graphs, trees
Correct Solution:
```
n = int(input())
allNodes = []
for i in range(n):
allNodes.append([i])
for i in range(n-1):
u, v = map(int, input().split())
allNodes[u-1].append(v-1)
allNodes[v-1].append(u-1)
black = 0
white = 0
... | output | 1 | 23,042 | 13 | 46,085 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a tree with n vertices. You are allowed to modify the structure of the tree through the following multi-step operation:
1. Choose three vertices a, b, and c such that b is adjacent to both a and c.
2. For every vertex d o... | instruction | 0 | 23,043 | 13 | 46,086 |
Tags: brute force, constructive algorithms, dfs and similar, graph matchings, graphs, trees
Correct Solution:
```
import sys
import collections
inpy = [int(x) for x in sys.stdin.read().split()]
n = inpy[0]
memo = [set() for _ in range(n + 1)]
for i in range(1, len(inpy), 2):
memo[inpy[i]].add(inpy[i+1])
memo[in... | output | 1 | 23,043 | 13 | 46,087 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a tree with n vertices. You are allowed to modify the structure of the tree through the following multi-step operation:
1. Choose three vertices a, b, and c such that b is adjacent to both a and c.
2. For every vertex d o... | instruction | 0 | 23,044 | 13 | 46,088 |
Tags: brute force, constructive algorithms, dfs and similar, graph matchings, graphs, trees
Correct Solution:
```
import sys
input = sys.stdin.readline
n=int(input())
graph=[[] for _ in range(n)]
for j in range(n-1):
x,y=map(int,input().split())
x-=1
y-=1
graph[x].append(y)
graph[y].append(x)
color... | output | 1 | 23,044 | 13 | 46,089 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a tree with n vertices. You are allowed to modify the structure of the tree through the following multi-step operation:
1. Choose three vertices a, b, and c such that b is adjacent to both a and c.
2. For every vertex d o... | instruction | 0 | 23,045 | 13 | 46,090 |
Tags: brute force, constructive algorithms, dfs and similar, graph matchings, graphs, trees
Correct Solution:
```
import sys
import collections
def input():
return sys.stdin.readline().rstrip()
def split_input():
return [int(i) for i in input().split()]
n = int(input())
color = {}
edges = [[] for _ in range(n)]
f... | output | 1 | 23,045 | 13 | 46,091 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a tree with n vertices. You are allowed to modify the structure of the tree through the following multi-step operation:
1. Choose three vertices a, b, and c such that b is adjacent to both a and c.
2. For every vertex d o... | instruction | 0 | 23,046 | 13 | 46,092 |
Tags: brute force, constructive algorithms, dfs and similar, graph matchings, graphs, trees
Correct Solution:
```
# Fast IO (only use in integer input) or take care about string
import os,io
input=io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
n = int(input())
connectionList = []
for _ in range(n):
connectio... | output | 1 | 23,046 | 13 | 46,093 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a tree with n vertices. You are allowed to modify the structure of the tree through the following multi-step operation:
1. Choose three vertices a, b, and c such that b is adjacent to both a and c.
2. For every vertex d o... | instruction | 0 | 23,047 | 13 | 46,094 |
Tags: brute force, constructive algorithms, dfs and similar, graph matchings, graphs, trees
Correct Solution:
```
n = int(input())
adj = [[] for i in range(n)]
for _ in range(n - 1):
u, v = map(int, input().split())
adj[u-1].append(v-1)
adj[v-1].append(u-1)
depth = [-1] * n
depth[0] = 0
odd = 0
even =... | output | 1 | 23,047 | 13 | 46,095 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a tree with n vertices. You are allowed to modify the structure of the tree through the following multi-step operation:
1. Choose three vertices a, b, and c such that b is adjacent to both a and c.
2. For every vertex d o... | instruction | 0 | 23,048 | 13 | 46,096 |
Tags: brute force, constructive algorithms, dfs and similar, graph matchings, graphs, trees
Correct Solution:
```
from collections import defaultdict, deque
NONE = -1
WHITE = 0
BLACK = 1
nw = 0
def colorize(G, color, v, c):
global nw
nw += (c == WHITE)
color[v] = c
for u in G[v]:
if color[u] ... | output | 1 | 23,048 | 13 | 46,097 |
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 with n vertices. You are allowed to modify the structure of the tree through the following multi-step operation:
1. Choose three vertices a, b, and c such that b is adjac... | instruction | 0 | 23,049 | 13 | 46,098 |
Yes | output | 1 | 23,049 | 13 | 46,099 |
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 with n vertices. You are allowed to modify the structure of the tree through the following multi-step operation:
1. Choose three vertices a, b, and c such that b is adjac... | instruction | 0 | 23,050 | 13 | 46,100 |
Yes | output | 1 | 23,050 | 13 | 46,101 |
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 with n vertices. You are allowed to modify the structure of the tree through the following multi-step operation:
1. Choose three vertices a, b, and c such that b is adjac... | instruction | 0 | 23,051 | 13 | 46,102 |
Yes | output | 1 | 23,051 | 13 | 46,103 |
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 with n vertices. You are allowed to modify the structure of the tree through the following multi-step operation:
1. Choose three vertices a, b, and c such that b is adjac... | instruction | 0 | 23,052 | 13 | 46,104 |
Yes | output | 1 | 23,052 | 13 | 46,105 |
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 with n vertices. You are allowed to modify the structure of the tree through the following multi-step operation:
1. Choose three vertices a, b, and c such that b is adjac... | instruction | 0 | 23,053 | 13 | 46,106 |
No | output | 1 | 23,053 | 13 | 46,107 |
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 with n vertices. You are allowed to modify the structure of the tree through the following multi-step operation:
1. Choose three vertices a, b, and c such that b is adjac... | instruction | 0 | 23,054 | 13 | 46,108 |
No | output | 1 | 23,054 | 13 | 46,109 |
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 with n vertices. You are allowed to modify the structure of the tree through the following multi-step operation:
1. Choose three vertices a, b, and c such that b is adjac... | instruction | 0 | 23,055 | 13 | 46,110 |
No | output | 1 | 23,055 | 13 | 46,111 |
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 with n vertices. You are allowed to modify the structure of the tree through the following multi-step operation:
1. Choose three vertices a, b, and c such that b is adjac... | instruction | 0 | 23,056 | 13 | 46,112 |
No | output | 1 | 23,056 | 13 | 46,113 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an undirected graph with n vertices and m edges. Also, you are given an integer k.
Find either a clique of size k or a non-empty subset of vertices such that each vertex of this subset has at least k neighbors in the subset. I... | instruction | 0 | 23,077 | 13 | 46,154 |
Tags: constructive algorithms, data structures, graphs
Correct Solution:
```
from __future__ import division,print_function
from heapq import*
import sys
le = sys.__stdin__.read().split("\n")[::-1]
af = []
for ezo in range(int(le.pop())):
n,m,k = list(map(int, le.pop().split()))
ar = [set() for _ in range(n)]
... | output | 1 | 23,077 | 13 | 46,155 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an undirected graph with n vertices and m edges. Also, you are given an integer k.
Find either a clique of size k or a non-empty subset of vertices such that each vertex of this subset has at least k neighbors in the subset. I... | instruction | 0 | 23,078 | 13 | 46,156 |
Tags: constructive algorithms, data structures, graphs
Correct Solution:
```
from __future__ import division,print_function
from heapq import*
import sys
t = list(map(int, sys.stdin.readline().strip().split()))[0]
af = []
for _ in range(t):
n,m,k = list(map(int, sys.stdin.readline().strip().split()))
ar = [set... | output | 1 | 23,078 | 13 | 46,157 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an undirected graph with n vertices and m edges. Also, you are given an integer k.
Find either a clique of size k or a non-empty subset of vertices such that each vertex of this subset has at least k neighbors in the subset. I... | instruction | 0 | 23,079 | 13 | 46,158 |
Tags: constructive algorithms, data structures, graphs
Correct Solution:
```
from __future__ import division, print_function
from heapq import *
import sys
le = sys.__stdin__.read().split("\n")[::-1]
af = []
for ezo in range(int(le.pop())):
n, m, k = list(map(int, le.pop().split()))
ar = [set() for i in range(... | output | 1 | 23,079 | 13 | 46,159 |
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 graph with n vertices and m edges. Also, you are given an integer k.
Find either a clique of size k or a non-empty subset of vertices such that each vertex of this s... | instruction | 0 | 23,080 | 13 | 46,160 |
No | output | 1 | 23,080 | 13 | 46,161 |
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 graph with n vertices and m edges. Also, you are given an integer k.
Find either a clique of size k or a non-empty subset of vertices such that each vertex of this s... | instruction | 0 | 23,081 | 13 | 46,162 |
No | output | 1 | 23,081 | 13 | 46,163 |
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 graph with n vertices and m edges. Also, you are given an integer k.
Find either a clique of size k or a non-empty subset of vertices such that each vertex of this s... | instruction | 0 | 23,082 | 13 | 46,164 |
No | output | 1 | 23,082 | 13 | 46,165 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Jamie has recently found undirected weighted graphs with the following properties very interesting:
* The graph is connected and contains exactly n vertices and m edges.
* All edge weights are integers and are in range [1, 109] inclusi... | instruction | 0 | 23,494 | 13 | 46,988 |
Tags: constructive algorithms, graphs, shortest paths
Correct Solution:
```
def doit(n, m):
if (n == 2):
print(2, 2)
print(1, 2, 2)
return
sp = 2
mstw = 100003
print(sp, mstw)
print(1, n, sp)
print(2, n, mstw - n + 3 - sp)
for i in range(3, n):
print(i, n, 1)
... | output | 1 | 23,494 | 13 | 46,989 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Jamie has recently found undirected weighted graphs with the following properties very interesting:
* The graph is connected and contains exactly n vertices and m edges.
* All edge weights are integers and are in range [1, 109] inclusi... | instruction | 0 | 23,495 | 13 | 46,990 |
Tags: constructive algorithms, graphs, shortest paths
Correct Solution:
```
(n, m) = (int(i) for i in input().split())
if n == 2:
print(2, 2)
print(1, 2, 2)
else:
u, v, w = [], [], []
l = list(range(1, 1000000 + 1))
l[0] = 0
for i in range(2, 5 * n + 1):
if l[i - 1] != 0 :
fo... | output | 1 | 23,495 | 13 | 46,991 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Jamie has recently found undirected weighted graphs with the following properties very interesting:
* The graph is connected and contains exactly n vertices and m edges.
* All edge weights are integers and are in range [1, 109] inclusi... | instruction | 0 | 23,496 | 13 | 46,992 |
Tags: constructive algorithms, graphs, shortest paths
Correct Solution:
```
INF = 1000000
erast = [1] * INF
erast[1] = 0
primes = []
for i in range(2, INF):
if erast[i] == 1:
for j in range(i * 2, INF, i):
erast[j] = 0
primes.append(i)
# print(primes)
lastp = primes[-1]
n, m = map(int, ... | output | 1 | 23,496 | 13 | 46,993 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Jamie has recently found undirected weighted graphs with the following properties very interesting:
* The graph is connected and contains exactly n vertices and m edges.
* All edge weights are integers and are in range [1, 109] inclusi... | instruction | 0 | 23,497 | 13 | 46,994 |
Tags: constructive algorithms, graphs, shortest paths
Correct Solution:
```
# n_, k_ = [int(i) for i in input().split()]
# for i in range(k_):
# L = -10 ** 18
# R = 10 ** 18
# n = n_
# k = k_
# for kkk in range(70):
# m = (L + R) // 2
# n -= 2 ** m
# k -= m
# if n <
n... | output | 1 | 23,497 | 13 | 46,995 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Jamie has recently found undirected weighted graphs with the following properties very interesting:
* The graph is connected and contains exactly n vertices and m edges.
* All edge weights are integers and are in range [1, 109] inclusi... | instruction | 0 | 23,498 | 13 | 46,996 |
Tags: constructive algorithms, graphs, shortest paths
Correct Solution:
```
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
read = lambda: map(int, input().split())
def generate_first_prime(lower, upper):
if upper < lower:
return -1
if lower is 2:
return 2
lower = lower + 1 if lower & 1 is ... | output | 1 | 23,498 | 13 | 46,997 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Jamie has recently found undirected weighted graphs with the following properties very interesting:
* The graph is connected and contains exactly n vertices and m edges.
* All edge weights are integers and are in range [1, 109] inclusi... | instruction | 0 | 23,499 | 13 | 46,998 |
Tags: constructive algorithms, graphs, shortest paths
Correct Solution:
```
n,m=map(int,input().split())
if(n==2):
print(3,3)
print(1,2,3)
else:
ini=1
print(3,100003)
print(1,n,3)
for i in range(2,n-1):
print(1,i,1)
print(1,n-1,10**5-(n-3))
count=n-1
ini=2
... | output | 1 | 23,499 | 13 | 46,999 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Jamie has recently found undirected weighted graphs with the following properties very interesting:
* The graph is connected and contains exactly n vertices and m edges.
* All edge weights are integers and are in range [1, 109] inclusi... | instruction | 0 | 23,500 | 13 | 47,000 |
Tags: constructive algorithms, graphs, shortest paths
Correct Solution:
```
n, m = map(int, input().split())
if n == 2:
print(2, 2)
print(1, 2, 2)
exit(0)
SMALL_PRIME = 2
BIG_PRIME = 86028121
print(SMALL_PRIME, BIG_PRIME)
print(1, n, SMALL_PRIME)
# print('----')
some_value = BIG_PRIME // (n-2)
for i ... | output | 1 | 23,500 | 13 | 47,001 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Jamie has recently found undirected weighted graphs with the following properties very interesting:
* The graph is connected and contains exactly n vertices and m edges.
* All edge weights are integers and are in range [1, 109] inclusi... | instruction | 0 | 23,501 | 13 | 47,002 |
Tags: constructive algorithms, graphs, shortest paths
Correct Solution:
```
n,m=map(int,input().split())
x=0
for i in range(n,2*n):
r=0
for j in range(2,int(i**0.5+1)):
if (i%j==0):
r=1
break
if (r==0):
x=i
break
a=[[] for i in range(n+1)]
for i in range(1,n-1... | output | 1 | 23,501 | 13 | 47,003 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Jamie has recently found undirected weighted graphs with the following properties very interesting:
* The graph is connected and contains exactly n vertices and m edges.
* All edge weights... | instruction | 0 | 23,502 | 13 | 47,004 |
Yes | output | 1 | 23,502 | 13 | 47,005 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Jamie has recently found undirected weighted graphs with the following properties very interesting:
* The graph is connected and contains exactly n vertices and m edges.
* All edge weights... | instruction | 0 | 23,503 | 13 | 47,006 |
Yes | output | 1 | 23,503 | 13 | 47,007 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Jamie has recently found undirected weighted graphs with the following properties very interesting:
* The graph is connected and contains exactly n vertices and m edges.
* All edge weights... | instruction | 0 | 23,504 | 13 | 47,008 |
Yes | output | 1 | 23,504 | 13 | 47,009 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.