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.
Anadi has a set of dominoes. Every domino has two parts, and each part contains some dots. For every a and b such that 1 ≤ a ≤ b ≤ 6, there is exactly one domino with a dots on one half and b do... | instruction | 0 | 73,416 | 13 | 146,832 |
Yes | output | 1 | 73,416 | 13 | 146,833 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Anadi has a set of dominoes. Every domino has two parts, and each part contains some dots. For every a and b such that 1 ≤ a ≤ b ≤ 6, there is exactly one domino with a dots on one half and b do... | instruction | 0 | 73,417 | 13 | 146,834 |
Yes | output | 1 | 73,417 | 13 | 146,835 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Anadi has a set of dominoes. Every domino has two parts, and each part contains some dots. For every a and b such that 1 ≤ a ≤ b ≤ 6, there is exactly one domino with a dots on one half and b do... | instruction | 0 | 73,418 | 13 | 146,836 |
No | output | 1 | 73,418 | 13 | 146,837 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Anadi has a set of dominoes. Every domino has two parts, and each part contains some dots. For every a and b such that 1 ≤ a ≤ b ≤ 6, there is exactly one domino with a dots on one half and b do... | instruction | 0 | 73,419 | 13 | 146,838 |
No | output | 1 | 73,419 | 13 | 146,839 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Anadi has a set of dominoes. Every domino has two parts, and each part contains some dots. For every a and b such that 1 ≤ a ≤ b ≤ 6, there is exactly one domino with a dots on one half and b do... | instruction | 0 | 73,420 | 13 | 146,840 |
No | output | 1 | 73,420 | 13 | 146,841 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Anadi has a set of dominoes. Every domino has two parts, and each part contains some dots. For every a and b such that 1 ≤ a ≤ b ≤ 6, there is exactly one domino with a dots on one half and b do... | instruction | 0 | 73,421 | 13 | 146,842 |
No | output | 1 | 73,421 | 13 | 146,843 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Kamil likes streaming the competitive programming videos. His MeTube channel has recently reached 100 million subscribers. In order to celebrate this, he posted a video with an interesting problem he couldn't solve yet. Can you help him?
Yo... | instruction | 0 | 73,422 | 13 | 146,844 |
Tags: math, number theory, trees
Correct Solution:
```
from math import gcd
from collections import deque
from bisect import bisect_left
from sys import setrecursionlimit
MOD = 1000000007
def modInt(mod):
class ModInt:
def __init__(self, value):
self.value = value % mod
def __int__(... | output | 1 | 73,422 | 13 | 146,845 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Kamil likes streaming the competitive programming videos. His MeTube channel has recently reached 100 million subscribers. In order to celebrate this, he posted a video with an interesting problem he couldn't solve yet. Can you help him?
Yo... | instruction | 0 | 73,423 | 13 | 146,846 |
Tags: math, number theory, trees
Correct Solution:
```
from math import gcd
from collections import deque
from bisect import bisect_left
from sys import setrecursionlimit
MOD = 1000000007
def main():
n = int(input())
setrecursionlimit(n+100)
xx = [0] + [int(x) for x in input().split()]
edges = []
... | output | 1 | 73,423 | 13 | 146,847 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Kamil likes streaming the competitive programming videos. His MeTube channel has recently reached 100 million subscribers. In order to celebrate this, he posted a video with an interesting problem he couldn't solve yet. Can you help him?
Yo... | instruction | 0 | 73,424 | 13 | 146,848 |
Tags: math, number theory, trees
Correct Solution:
```
from math import gcd
from collections import deque
from bisect import bisect_left
from sys import setrecursionlimit
MOD = 1000000007
def main():
n = int(input())
setrecursionlimit(n+100)
xx = [0] + [int(x) for x in input().split()]
edges = []
... | output | 1 | 73,424 | 13 | 146,849 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kamil likes streaming the competitive programming videos. His MeTube channel has recently reached 100 million subscribers. In order to celebrate this, he posted a video with an interesting probl... | instruction | 0 | 73,425 | 13 | 146,850 |
No | output | 1 | 73,425 | 13 | 146,851 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Finally, you have defeated Razor and now, you are the Most Wanted street racer. Sergeant Cross has sent the full police force after you in a deadly pursuit. Fortunately, you have found a hiding spot but you fear that Cross and his force will... | instruction | 0 | 73,592 | 13 | 147,184 |
Tags: bitmasks, constructive algorithms, divide and conquer, graphs, greedy, math
Correct Solution:
```
from collections import deque
from sys import stdin
import sys
tt = int(stdin.readline())
for loop in range(tt):
n = int(stdin.readline())
lis = [ [] for i in range(2**n)]
for i in range(n*(2**(n-1))... | output | 1 | 73,592 | 13 | 147,185 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Arkady needs your help again! This time he decided to build his own high-speed Internet exchange point. It should consist of n nodes connected with minimum possible number of wires into one network (a wire directly connects two nodes). Exact... | instruction | 0 | 73,844 | 13 | 147,688 |
Tags: constructive algorithms, greedy, implementation, trees
Correct Solution:
```
n, k = map(int, input().split())
r = (n-1)//k
l = n - 1
x, y, = 1, 2
diam = 2*r
if (n-1)%k == 1:
diam += 1
elif (n-1)%k >= 2:
diam += 2
print(diam)
for i in range(k):
br = r
if i < (n-1)%k:
br += 1
x = 1
f... | output | 1 | 73,844 | 13 | 147,689 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Arkady needs your help again! This time he decided to build his own high-speed Internet exchange point. It should consist of n nodes connected with minimum possible number of wires into one network (a wire directly connects two nodes). Exact... | instruction | 0 | 73,845 | 13 | 147,690 |
Tags: constructive algorithms, greedy, implementation, trees
Correct Solution:
```
n,k=list(map(int,input().strip().split(' ')))
import math
L=math.ceil((n-(k+1))/(k))
remain=(n-(k+1))%(k)
if (n-(k+1))%(k)==0:
remain+=k
#print(L,remain,'L,remain')
if remain%(k)==1:
print(2*(L)+1)
else:
print(2*(L+1))
... | output | 1 | 73,845 | 13 | 147,691 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Arkady needs your help again! This time he decided to build his own high-speed Internet exchange point. It should consist of n nodes connected with minimum possible number of wires into one network (a wire directly connects two nodes). Exact... | instruction | 0 | 73,846 | 13 | 147,692 |
Tags: constructive algorithms, greedy, implementation, trees
Correct Solution:
```
def pr(m):
for i in range(len(m)):
print(' '.join([str(x) for x in m[i]]))
n, k = map(int, input().split())
edge = [[1, v] if v < k+1 else [v-k, v] for v in range(2, n+1)]
def get_min_max_radius(n, k):
r = (n-1) % k
... | output | 1 | 73,846 | 13 | 147,693 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Arkady needs your help again! This time he decided to build his own high-speed Internet exchange point. It should consist of n nodes connected with minimum possible number of wires into one network (a wire directly connects two nodes). Exact... | instruction | 0 | 73,847 | 13 | 147,694 |
Tags: constructive algorithms, greedy, implementation, trees
Correct Solution:
```
n, k = map(int, input().split())
q = ((n-2) % k) +1
t = (n-1) // k
if q == 1:
print(2*t+1)
elif q == k:
print(2*t)
else:
print(2*t+2)
# print(t, q)
for i in range(2, n+1):
print(max(1, i-k), i)
``` | output | 1 | 73,847 | 13 | 147,695 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Arkady needs your help again! This time he decided to build his own high-speed Internet exchange point. It should consist of n nodes connected with minimum possible number of wires into one network (a wire directly connects two nodes). Exact... | instruction | 0 | 73,848 | 13 | 147,696 |
Tags: constructive algorithms, greedy, implementation, trees
Correct Solution:
```
n, k = map(int, input().split())
x = (n - 1) // k
r = (n - 1) % k
edges = []
u = 1
for j in range(k):
prv = 0
for i in range(x + 1 if j < r else x):
edges.append((u, prv))
prv = u
u += 1
cost = 2 * x + ... | output | 1 | 73,848 | 13 | 147,697 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Arkady needs your help again! This time he decided to build his own high-speed Internet exchange point. It should consist of n nodes connected with minimum possible number of wires into one network (a wire directly connects two nodes). Exact... | instruction | 0 | 73,849 | 13 | 147,698 |
Tags: constructive algorithms, greedy, implementation, trees
Correct Solution:
```
import math as mt
import sys,string
input=sys.stdin.readline
#print=sys.stdout.write
import random
from collections import deque,defaultdict
L=lambda : list(map(int,input().split()))
Ls=lambda : list(input().split())
M=lambda : map(int,... | output | 1 | 73,849 | 13 | 147,699 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Arkady needs your help again! This time he decided to build his own high-speed Internet exchange point. It should consist of n nodes connected with minimum possible number of wires into one network (a wire directly connects two nodes). Exact... | instruction | 0 | 73,850 | 13 | 147,700 |
Tags: constructive algorithms, greedy, implementation, trees
Correct Solution:
```
n, k = map(int, input().split())
mid = n-k-1
r = [0] * k
for i in range(n-1):
r[i%k] += 1
print(r[0]+r[1])
v1 = 2
ans = []
for i in range(k):
v0 = 1
for _ in range(r[i]):
ans.append("%d %d"%(v0, v1))
v0 = v1
v1 += 1
pri... | output | 1 | 73,850 | 13 | 147,701 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Arkady needs your help again! This time he decided to build his own high-speed Internet exchange point. It should consist of n nodes connected with minimum possible number of wires into one network (a wire directly connects two nodes). Exact... | instruction | 0 | 73,851 | 13 | 147,702 |
Tags: constructive algorithms, greedy, implementation, trees
Correct Solution:
```
n,k=map(int,input().split())
print(((n-1)//k)*2+min(2,(n-1)%k))
for i in range(2,n+1):
print(i,max(i-k,1))
``` | output | 1 | 73,851 | 13 | 147,703 |
Provide tags and a correct Python 2 solution for this coding contest problem.
Arkady needs your help again! This time he decided to build his own high-speed Internet exchange point. It should consist of n nodes connected with minimum possible number of wires into one network (a wire directly connects two nodes). Exact... | instruction | 0 | 73,852 | 13 | 147,704 |
Tags: constructive algorithms, greedy, implementation, trees
Correct Solution:
```
from sys import stdin, stdout
from collections import Counter, defaultdict
from itertools import permutations, combinations
raw_input = stdin.readline
pr = stdout.write
mod=10**9+7
def ni():
return int(raw_input())
def li():
r... | output | 1 | 73,852 | 13 | 147,705 |
Provide a correct Python 3 solution for this coding contest problem.
Write a program which reads two sequences of nodes obtained by the preorder tree walk and the inorder tree walk on a binary tree respectively, and prints a sequence of the nodes obtained by the postorder tree walk on the binary tree.
Constraints
* ... | instruction | 0 | 74,149 | 13 | 148,298 |
"Correct Solution:
```
n = int(input())
pretree = list(map(int, input().split()))
inotree = list(map(int, input().split()))
def get_postorder(pre, ino):
if not pre:
return []
root = pre[0]
root_index = ino.index(root)
result = []
result.extend(get_postorder(pre[1:root_index + 1], ino[:root_i... | output | 1 | 74,149 | 13 | 148,299 |
Provide a correct Python 3 solution for this coding contest problem.
Write a program which reads two sequences of nodes obtained by the preorder tree walk and the inorder tree walk on a binary tree respectively, and prints a sequence of the nodes obtained by the postorder tree walk on the binary tree.
Constraints
* ... | instruction | 0 | 74,150 | 13 | 148,300 |
"Correct Solution:
```
I = 0
L = 1
R = 2
P = 3
B = 4
D = 5
H = 6
def getidx(Tree,value):
idx = -1
for i in range(len(Tree)):
if Tree[i][I] == value:
idx = i
break
return idx
def search(Tree, A, B, num):
root = A[0]
rootidx = getidx(Tree,root)
ld = num
for i ... | output | 1 | 74,150 | 13 | 148,301 |
Provide a correct Python 3 solution for this coding contest problem.
Write a program which reads two sequences of nodes obtained by the preorder tree walk and the inorder tree walk on a binary tree respectively, and prints a sequence of the nodes obtained by the postorder tree walk on the binary tree.
Constraints
* ... | instruction | 0 | 74,151 | 13 | 148,302 |
"Correct Solution:
```
nil = -1
class Node:
def __init__(self):
self.parent = nil
self.left = nil
self.right = nil
def post_tw(node, ans):
if tree[node].left != nil:
post_tw(tree[node].left, ans)
if tree[node].right != nil:
post_tw(tree[node].right, ans)
ans.... | output | 1 | 74,151 | 13 | 148,303 |
Provide a correct Python 3 solution for this coding contest problem.
Write a program which reads two sequences of nodes obtained by the preorder tree walk and the inorder tree walk on a binary tree respectively, and prints a sequence of the nodes obtained by the postorder tree walk on the binary tree.
Constraints
* ... | instruction | 0 | 74,152 | 13 | 148,304 |
"Correct Solution:
```
n=int(input())
preorder=[int(i)for i in input().split()]
inorder=[int(i)for i in input().split()]
post=[]
pos=0
def recon(left,right):
global inorder
global pos
if left>=right:
return
root=preorder[pos]
pos+=1
mid=inorder.index(root)
recon(left,mid)
recon... | output | 1 | 74,152 | 13 | 148,305 |
Provide a correct Python 3 solution for this coding contest problem.
Write a program which reads two sequences of nodes obtained by the preorder tree walk and the inorder tree walk on a binary tree respectively, and prints a sequence of the nodes obtained by the postorder tree walk on the binary tree.
Constraints
* ... | instruction | 0 | 74,153 | 13 | 148,306 |
"Correct Solution:
```
def reconstract(l, r):
if l >= r:
return None
c = next(root)
m = in_hoge.index(c)
reconstract(l, m)
reconstract(m+1, r)
post_hoge.append(c)
if __name__ == '__main__':
_ = int(input())
pre_hoge = [int(x) for x in input().split()]
root = (x fo... | output | 1 | 74,153 | 13 | 148,307 |
Provide a correct Python 3 solution for this coding contest problem.
Write a program which reads two sequences of nodes obtained by the preorder tree walk and the inorder tree walk on a binary tree respectively, and prints a sequence of the nodes obtained by the postorder tree walk on the binary tree.
Constraints
* ... | instruction | 0 | 74,154 | 13 | 148,308 |
"Correct Solution:
```
pos = 0
def reconstruction(pre_order, in_order, post_order, left, right):
if left >= right:
return
global pos
root = pre_order[pos]
pos += 1
mid = in_order.index(root)
reconstruction(pre_order, in_order, post_order, left, mid)
reconstruction(pre_order, in_orde... | output | 1 | 74,154 | 13 | 148,309 |
Provide a correct Python 3 solution for this coding contest problem.
Write a program which reads two sequences of nodes obtained by the preorder tree walk and the inorder tree walk on a binary tree respectively, and prints a sequence of the nodes obtained by the postorder tree walk on the binary tree.
Constraints
* ... | instruction | 0 | 74,155 | 13 | 148,310 |
"Correct Solution:
```
# Tree Walk
N = int(input())
*A, = map(int, input().split())
*B, = map(int, input().split())
idx = 0
ans = []
def rec(l=0, r=N):
global idx
if l >= r:
return
c = A[idx]
idx += 1
m = B.index(c)
rec(l, m)
rec(m+1, r)
ans.append(c)
rec()
print(*ans)
... | output | 1 | 74,155 | 13 | 148,311 |
Provide a correct Python 3 solution for this coding contest problem.
Write a program which reads two sequences of nodes obtained by the preorder tree walk and the inorder tree walk on a binary tree respectively, and prints a sequence of the nodes obtained by the postorder tree walk on the binary tree.
Constraints
* ... | instruction | 0 | 74,156 | 13 | 148,312 |
"Correct Solution:
```
def reconstruction(left, right):
if left >= right:
return
global position, pre, ino, post
root = pre[position]
position += 1
mid = ino.index(root) # inoでのrootのポジション
reconstruction(left, mid)
reconstruction(mid + 1, right)
post.append(root)
n = int(in... | output | 1 | 74,156 | 13 | 148,313 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Write a program which reads two sequences of nodes obtained by the preorder tree walk and the inorder tree walk on a binary tree respectively, and prints a sequence of the nodes obtained by the ... | instruction | 0 | 74,157 | 13 | 148,314 |
Yes | output | 1 | 74,157 | 13 | 148,315 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Write a program which reads two sequences of nodes obtained by the preorder tree walk and the inorder tree walk on a binary tree respectively, and prints a sequence of the nodes obtained by the ... | instruction | 0 | 74,158 | 13 | 148,316 |
Yes | output | 1 | 74,158 | 13 | 148,317 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Write a program which reads two sequences of nodes obtained by the preorder tree walk and the inorder tree walk on a binary tree respectively, and prints a sequence of the nodes obtained by the ... | instruction | 0 | 74,159 | 13 | 148,318 |
Yes | output | 1 | 74,159 | 13 | 148,319 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Write a program which reads two sequences of nodes obtained by the preorder tree walk and the inorder tree walk on a binary tree respectively, and prints a sequence of the nodes obtained by the ... | instruction | 0 | 74,160 | 13 | 148,320 |
Yes | output | 1 | 74,160 | 13 | 148,321 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Write a program which reads two sequences of nodes obtained by the preorder tree walk and the inorder tree walk on a binary tree respectively, and prints a sequence of the nodes obtained by the ... | instruction | 0 | 74,161 | 13 | 148,322 |
No | output | 1 | 74,161 | 13 | 148,323 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Write a program which reads two sequences of nodes obtained by the preorder tree walk and the inorder tree walk on a binary tree respectively, and prints a sequence of the nodes obtained by the ... | instruction | 0 | 74,162 | 13 | 148,324 |
No | output | 1 | 74,162 | 13 | 148,325 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Write a program which reads two sequences of nodes obtained by the preorder tree walk and the inorder tree walk on a binary tree respectively, and prints a sequence of the nodes obtained by the ... | instruction | 0 | 74,163 | 13 | 148,326 |
No | output | 1 | 74,163 | 13 | 148,327 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Write a program which reads two sequences of nodes obtained by the preorder tree walk and the inorder tree walk on a binary tree respectively, and prints a sequence of the nodes obtained by the ... | instruction | 0 | 74,164 | 13 | 148,328 |
No | output | 1 | 74,164 | 13 | 148,329 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Consider a tree T (that is, a connected graph without cycles) with n vertices labelled 1 through n. We start the following process with T: while T has more than one vertex, do the following:
* choose a random edge of T equiprobably;
* s... | instruction | 0 | 74,197 | 13 | 148,394 |
Tags: combinatorics, dp
Correct Solution:
```
maxn=50+10
g=[None]*maxn
dp=[None]*maxn
c=[None]*maxn
size=[0]*maxn
for i in range(0,maxn):
c[i]=[0]*maxn
c[i][0]=1
for j in range(1,i+1):
c[i][j]=c[i-1][j-1]+c[i-1][j]
n=int(input())
for i in range(1,n+1):
g[i]=[]
for i in range(1,n):
u,v=inpu... | output | 1 | 74,197 | 13 | 148,395 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Graph constructive problems are back! This time the graph you are asked to build should match the following properties.
The graph is connected if and only if there exists a path between every pair of vertices.
The diameter (aka "longest sh... | instruction | 0 | 74,198 | 13 | 148,396 |
Tags: constructive algorithms, graphs, implementation
Correct Solution:
```
def out_edge(x,y):
a[x] -= 1
a[y] -= 1
print(x,y)
n = int(input())
a =list(map(int, input().split()))
sa = sum(a)
ma = min(a)
if (sa <2*(n-1)) or (ma<1):
print('NO')
exit()
verts = sorted(enumerate(a,1), key = lambda x: x... | output | 1 | 74,198 | 13 | 148,397 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Graph constructive problems are back! This time the graph you are asked to build should match the following properties.
The graph is connected if and only if there exists a path between every pair of vertices.
The diameter (aka "longest sh... | instruction | 0 | 74,199 | 13 | 148,398 |
Tags: constructive algorithms, graphs, implementation
Correct Solution:
```
from collections import namedtuple
vertex = namedtuple('vertex', ['degree', 'id'])
a, b, c = [], [], 0
n = int(input())
rr = list(map(int, input().split()))
for i in range(n):
if rr[i] > 1:
a.append(vertex(rr[i], i + 1))
else:... | output | 1 | 74,199 | 13 | 148,399 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Graph constructive problems are back! This time the graph you are asked to build should match the following properties.
The graph is connected if and only if there exists a path between every pair of vertices.
The diameter (aka "longest sh... | instruction | 0 | 74,200 | 13 | 148,400 |
Tags: constructive algorithms, graphs, implementation
Correct Solution:
```
n = int(input())
a = tuple(map(int, input().split()))
if n * 2 > sum(a) + 2:
print("NO")
else:
n1 = []
on = []
for i in range(n):
if a[i] != 1:
n1.append(i)
else:
on.append(i)
print("YES", len(n1) + min(2, len(on)) - 1)
print(n ... | output | 1 | 74,200 | 13 | 148,401 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Graph constructive problems are back! This time the graph you are asked to build should match the following properties.
The graph is connected if and only if there exists a path between every pair of vertices.
The diameter (aka "longest sh... | instruction | 0 | 74,201 | 13 | 148,402 |
Tags: constructive algorithms, graphs, implementation
Correct Solution:
```
n = int(input())
A = [0] + list(map(int,input().split()))
vec = []
for i in range(1, n+1) :
vec = vec + [[A[i], i]]
list.sort(vec)
list.reverse(vec)
# print(vec)
if vec[0][0] == 1 :
print("NO")
exit(0)
dia = 0
path = [vec[0][1]]
ans = []
... | output | 1 | 74,201 | 13 | 148,403 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Graph constructive problems are back! This time the graph you are asked to build should match the following properties.
The graph is connected if and only if there exists a path between every pair of vertices.
The diameter (aka "longest sh... | instruction | 0 | 74,202 | 13 | 148,404 |
Tags: constructive algorithms, graphs, implementation
Correct Solution:
```
n = int(input())
l = list(map(int, input().split()))
one,many = [],[]
a,b,c = 0,0,0
for i,d in enumerate(l):
if d==1:
one.append(i+1)
a+=1
else:
many.append((i+1,d))
b+=1
c+=d
if c-2*b+2<a:
... | output | 1 | 74,202 | 13 | 148,405 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Graph constructive problems are back! This time the graph you are asked to build should match the following properties.
The graph is connected if and only if there exists a path between every pair of vertices.
The diameter (aka "longest sh... | instruction | 0 | 74,203 | 13 | 148,406 |
Tags: constructive algorithms, graphs, implementation
Correct Solution:
```
n=int(input())
a=list(map(int,input().split()))
l=[]
for i in range(n):
l.append([a[i],i])
l.sort(key=lambda x:x[0])
for i in range(n):
if l[i][0]>1:
break
j=0
for k in range(i,n):
j+=l[k][0]-2
if j<i-2:
print("NO")
else:
... | output | 1 | 74,203 | 13 | 148,407 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Graph constructive problems are back! This time the graph you are asked to build should match the following properties.
The graph is connected if and only if there exists a path between every pair of vertices.
The diameter (aka "longest sh... | instruction | 0 | 74,204 | 13 | 148,408 |
Tags: constructive algorithms, graphs, implementation
Correct Solution:
```
# coding: utf-8
# Your code here!
import sys
n = int(input())
a = list(map(int,input().split()))
for i in range(n):
a[i] = [i,a[i]]
a.sort(key=lambda x: x[1],reverse=True)
ans = []
index = 0
cnt = 0
tmp = 1
right_bool = False
left_bool... | output | 1 | 74,204 | 13 | 148,409 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Graph constructive problems are back! This time the graph you are asked to build should match the following properties.
The graph is connected if and only if there exists a path between every pair of vertices.
The diameter (aka "longest sh... | instruction | 0 | 74,205 | 13 | 148,410 |
Tags: constructive algorithms, graphs, implementation
Correct Solution:
```
n=int(input());
deg=list(map(int,input().split()));
sumd=0;
deg_1=[];
deg_2=[];
for i in range(n):
sumd+=deg[i];
if (deg[i]>1):
deg_2.append(i);
else:
deg_1.append(i);
if (sumd<2*n-2):
print("NO");
else:
l1=len(deg_1);
l2=len(deg_2);... | output | 1 | 74,205 | 13 | 148,411 |
Provide tags and a correct Python 2 solution for this coding contest problem.
Graph constructive problems are back! This time the graph you are asked to build should match the following properties.
The graph is connected if and only if there exists a path between every pair of vertices.
The diameter (aka "longest sh... | instruction | 0 | 74,206 | 13 | 148,412 |
Tags: constructive algorithms, graphs, implementation
Correct Solution:
```
from sys import stdin, stdout
from collections import Counter, defaultdict
from itertools import permutations, combinations
raw_input = stdin.readline
pr = stdout.write
def in_arr():
return map(int,raw_input().split())
def pr_num(n):
... | output | 1 | 74,206 | 13 | 148,413 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Graph constructive problems are back! This time the graph you are asked to build should match the following properties.
The graph is connected if and only if there exists a path between every p... | instruction | 0 | 74,207 | 13 | 148,414 |
Yes | output | 1 | 74,207 | 13 | 148,415 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Graph constructive problems are back! This time the graph you are asked to build should match the following properties.
The graph is connected if and only if there exists a path between every p... | instruction | 0 | 74,208 | 13 | 148,416 |
Yes | output | 1 | 74,208 | 13 | 148,417 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Graph constructive problems are back! This time the graph you are asked to build should match the following properties.
The graph is connected if and only if there exists a path between every p... | instruction | 0 | 74,209 | 13 | 148,418 |
Yes | output | 1 | 74,209 | 13 | 148,419 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Graph constructive problems are back! This time the graph you are asked to build should match the following properties.
The graph is connected if and only if there exists a path between every p... | instruction | 0 | 74,210 | 13 | 148,420 |
Yes | output | 1 | 74,210 | 13 | 148,421 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.