message stringlengths 2 49.9k | message_type stringclasses 2
values | message_id int64 0 1 | conversation_id int64 446 108k | cluster float64 13 13 | __index_level_0__ int64 892 217k |
|---|---|---|---|---|---|
Provide tags and a correct Python 3 solution for this coding contest problem.
The clique problem is one of the most well-known NP-complete problems. Under some simplification it can be formulated as follows. Consider an undirected graph G. It is required to find a subset of vertices C of the maximum size such that any... | instruction | 0 | 75,452 | 13 | 150,904 |
Tags: data structures, dp, greedy, implementation, sortings
Correct Solution:
```
N = int(input())
pairs = []
for i in range(N):
x, w = map(int, input().split())
pairs.append((x, w))
sorted_pairs = sorted(pairs, key=lambda x: x[0])
stack = []
stack.append(sorted_pairs[0])
for x, w in sorted_pairs[1:N]:
r... | output | 1 | 75,452 | 13 | 150,905 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The clique problem is one of the most well-known NP-complete problems. Under some simplification it can be formulated as follows. Consider an undirected graph G. It is required to find a subset of vertices C of the maximum size such that any... | instruction | 0 | 75,453 | 13 | 150,906 |
Tags: data structures, dp, greedy, implementation, sortings
Correct Solution:
```
n = int(input())
S=[]
for _ in range(n):
x,w = list(map(int,input().split()))
S.append((x,w))
S = sorted(S,key=lambda kv:kv[0]+kv[1])
m=1
last=S[0]
for kv in S[1:]:
if abs(kv[0]-last[0]) >= kv[1]+last[1]:
m+=1
... | output | 1 | 75,453 | 13 | 150,907 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The clique problem is one of the most well-known NP-complete problems. Under some simplification it can be formulated as follows. Consider an undirected graph G. It is required to find a subset of vertices C of the maximum size such that any... | instruction | 0 | 75,454 | 13 | 150,908 |
Tags: data structures, dp, greedy, implementation, sortings
Correct Solution:
```
def on(l1, l2):
return(abs(l1[0]-l2[0])>=l1[1]+l2[1])
n = int(input())
inf = []
for i in range(n):
a,b = map(int,input().split())
inf.append([a+b,a-b])
inf.sort()
res = 1
last = 0
for i in range(1,n):
if inf[i][1] >= inf[l... | output | 1 | 75,454 | 13 | 150,909 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The clique problem is one of the most well-known NP-complete problems. Under some simplification it can be formulated as follows. Consider an undirected graph G. It is required to find a subset of vertices C of the maximum size such that any... | instruction | 0 | 75,455 | 13 | 150,910 |
Tags: data structures, dp, greedy, implementation, sortings
Correct Solution:
```
from sys import stdin
from sys import stdout
from collections import defaultdict
n=int(stdin.readline())
a=[map(int,stdin.readline().split(),(10,10)) for i in range(n)]
v=defaultdict(list)
for i,e in enumerate(a,1):
q,f=e
v[q-f].a... | output | 1 | 75,455 | 13 | 150,911 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The clique problem is one of the most well-known NP-complete problems. Under some simplification it can be formulated as follows. Consider an undirected graph G. It is required to find a subset of vertices C of the maximum size such that any... | instruction | 0 | 75,456 | 13 | 150,912 |
Tags: data structures, dp, greedy, implementation, sortings
Correct Solution:
```
def main():
from bisect import bisect_right as br
n = int(input())
ab = [list(map(int, input().split())) for _ in [0]*n]
ab.sort()
ans = [-10**20]
l = 1
for a, b in ab:
c = br(ans, a-b)
d = a+... | output | 1 | 75,456 | 13 | 150,913 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The clique problem is one of the most well-known NP-complete problems. Under some simplification it can be formulated as follows. Consider an undirected graph G. It is required to find a subset of vertices C of the maximum size such that any... | instruction | 0 | 75,457 | 13 | 150,914 |
Tags: data structures, dp, greedy, implementation, sortings
Correct Solution:
```
R = lambda: list(map(int,input().split()))
n = int(input())
a = []
for _ in range(n):
a.append(R())
a.sort(key=lambda x:(x[0]+x[1]))
j = 0; ans = 1
for i in range(1,n):
if a[j][0]+a[j][1]<=a[i][0]-a[i][1]:
ans += 1
... | output | 1 | 75,457 | 13 | 150,915 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The clique problem is one of the most well-known NP-complete problems. Under some simplification it can be formulated as follows. Consider an undirected graph G. It is required to find a subset of vertices C of the maximum size such that any... | instruction | 0 | 75,458 | 13 | 150,916 |
Tags: data structures, dp, greedy, implementation, sortings
Correct Solution:
```
#!/usr/bin/env python
# coding=utf-8
n = int(input())
l = []
for i in range(n):
x, y = map(int, input().split())
l += [(x + y, x - y)]
l.sort()
r = -2000000000
a = 0
for u in l:
if u[1] >= r:
a += 1
r = u[0]
p... | output | 1 | 75,458 | 13 | 150,917 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The clique problem is one of the most well-known NP-complete problems. Under some simplification it can be formulated as follows. Consider an undirected graph G. It is required to find a subset of vertices C of the maximum size such that any... | instruction | 0 | 75,459 | 13 | 150,918 |
Tags: data structures, dp, greedy, implementation, sortings
Correct Solution:
```
import sys
n = int(input())
ranges = []
for xw in sys.stdin:
x, w = map(int, xw.split())
ranges.append((x + w, x - w))
ranges.sort()
result = 0
end = - float('inf')
for e, b in ranges:
if b >= end:
result += 1
... | output | 1 | 75,459 | 13 | 150,919 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The clique problem is one of the most well-known NP-complete problems. Under some simplification it can be formulated as follows. Consider an undirected graph G. It is required to find a subset ... | instruction | 0 | 75,460 | 13 | 150,920 |
Yes | output | 1 | 75,460 | 13 | 150,921 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The clique problem is one of the most well-known NP-complete problems. Under some simplification it can be formulated as follows. Consider an undirected graph G. It is required to find a subset ... | instruction | 0 | 75,461 | 13 | 150,922 |
No | output | 1 | 75,461 | 13 | 150,923 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The clique problem is one of the most well-known NP-complete problems. Under some simplification it can be formulated as follows. Consider an undirected graph G. It is required to find a subset ... | instruction | 0 | 75,462 | 13 | 150,924 |
No | output | 1 | 75,462 | 13 | 150,925 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The clique problem is one of the most well-known NP-complete problems. Under some simplification it can be formulated as follows. Consider an undirected graph G. It is required to find a subset ... | instruction | 0 | 75,463 | 13 | 150,926 |
No | output | 1 | 75,463 | 13 | 150,927 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The clique problem is one of the most well-known NP-complete problems. Under some simplification it can be formulated as follows. Consider an undirected graph G. It is required to find a subset ... | instruction | 0 | 75,464 | 13 | 150,928 |
No | output | 1 | 75,464 | 13 | 150,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 bipartite graph without multiple edges. You should paint the edges of graph to minimal number of colours, so that no two adjacent edges have the same colour.
Input
... | instruction | 0 | 75,496 | 13 | 150,992 |
No | output | 1 | 75,496 | 13 | 150,993 |
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 bipartite graph without multiple edges. You should paint the edges of graph to minimal number of colours, so that no two adjacent edges have the same colour.
Input
... | instruction | 0 | 75,497 | 13 | 150,994 |
No | output | 1 | 75,497 | 13 | 150,995 |
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 bipartite graph without multiple edges. You should paint the edges of graph to minimal number of colours, so that no two adjacent edges have the same colour.
Input
... | instruction | 0 | 75,498 | 13 | 150,996 |
No | output | 1 | 75,498 | 13 | 150,997 |
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 bipartite graph without multiple edges. You should paint the edges of graph to minimal number of colours, so that no two adjacent edges have the same colour.
Input
... | instruction | 0 | 75,499 | 13 | 150,998 |
No | output | 1 | 75,499 | 13 | 150,999 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Bob has a simple undirected connected graph (without self-loops and multiple edges). He wants to learn whether his graph is bipartite (that is, you can paint all vertices of the graph into two c... | instruction | 0 | 75,890 | 13 | 151,780 |
No | output | 1 | 75,890 | 13 | 151,781 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Bob has a simple undirected connected graph (without self-loops and multiple edges). He wants to learn whether his graph is bipartite (that is, you can paint all vertices of the graph into two c... | instruction | 0 | 75,891 | 13 | 151,782 |
No | output | 1 | 75,891 | 13 | 151,783 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Mitya has a rooted tree with n vertices indexed from 1 to n, where the root has index 1. Each vertex v initially had an integer number a_v ≥ 0 written on it. For every vertex v Mitya has computed s_v: the sum of all values written on the ver... | instruction | 0 | 75,901 | 13 | 151,802 |
Tags: constructive algorithms, dfs and similar, greedy, trees
Correct Solution:
```
#!/usr/bin/env python
# coding: utf-8
# In[ ]:
n=int(input())
parents=['None']+list(map(int, input().rstrip().split()))
weights=list(map(int, input().rstrip().split()))
# In[102]:
# In[113]:
children = [[] for i in range(0,n)... | output | 1 | 75,901 | 13 | 151,803 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Mitya has a rooted tree with n vertices indexed from 1 to n, where the root has index 1. Each vertex v initially had an integer number a_v ≥ 0 written on it. For every vertex v Mitya has computed s_v: the sum of all values written on the ver... | instruction | 0 | 75,902 | 13 | 151,804 |
Tags: constructive algorithms, dfs and similar, greedy, trees
Correct Solution:
```
n = int(input())
p = list(map(int, input().split()))
p = [-1] + [i - 1 for i in p]
s = list(map(int, input().split()))
g = {}
for i in range(n):
g[i] = []
for i in range(1, len(p)):
g[p[i]].append(i)
d = {}
md = 1
q = [(0, 1)]
... | output | 1 | 75,902 | 13 | 151,805 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Mitya has a rooted tree with n vertices indexed from 1 to n, where the root has index 1. Each vertex v initially had an integer number a_v ≥ 0 written on it. For every vertex v Mitya has computed s_v: the sum of all values written on the ver... | instruction | 0 | 75,903 | 13 | 151,806 |
Tags: constructive algorithms, dfs and similar, greedy, trees
Correct Solution:
```
n = int(input())
p = [0, 0] + list(map(int, input().split()))
s = [0] + list(map(int, input().split()))
for i in range(2,n+1):
if s[i]!=-1 and (s[p[i]]==-1 or s[p[i]]>s[i]):
s[p[i]]=s[i]
a=s[::]
for i in range(2,n+1):
if... | output | 1 | 75,903 | 13 | 151,807 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Mitya has a rooted tree with n vertices indexed from 1 to n, where the root has index 1. Each vertex v initially had an integer number a_v ≥ 0 written on it. For every vertex v Mitya has computed s_v: the sum of all values written on the ver... | instruction | 0 | 75,904 | 13 | 151,808 |
Tags: constructive algorithms, dfs and similar, greedy, trees
Correct Solution:
```
import sys
input = sys.stdin.readline
n=int(input())
P=[0,0]+list(map(int,input().split()))
S=[0]+list(map(int,input().split()))
SONS=[[] for i in range(n+1)]
for i in range(n+1):
SONS[P[i]].append(i)
from collections import de... | output | 1 | 75,904 | 13 | 151,809 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Mitya has a rooted tree with n vertices indexed from 1 to n, where the root has index 1. Each vertex v initially had an integer number a_v ≥ 0 written on it. For every vertex v Mitya has computed s_v: the sum of all values written on the ver... | instruction | 0 | 75,905 | 13 | 151,810 |
Tags: constructive algorithms, dfs and similar, greedy, trees
Correct Solution:
```
n = int(input())
p = [1] + list(map(int, input().split()))
s = list(map(int, input().split()))
p = [i-1 for i in p]
for i in range(1,n):
if s[i] != -1 and (s[p[i]] == -1 or s[p[i]] > s[i]):
s[p[i]] = s[i]
a = [s[0]]+[0]*(n-1... | output | 1 | 75,905 | 13 | 151,811 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Mitya has a rooted tree with n vertices indexed from 1 to n, where the root has index 1. Each vertex v initially had an integer number a_v ≥ 0 written on it. For every vertex v Mitya has computed s_v: the sum of all values written on the ver... | instruction | 0 | 75,906 | 13 | 151,812 |
Tags: constructive algorithms, dfs and similar, greedy, trees
Correct Solution:
```
def solve():
n = int(input())
p = list(map(int, input().split(" "))) # 2...n
s = list(map(int, input().split(" "))) # 1...n
MAX_VAL = 10**9 + 2
v_child = [None] * n # 1...n
for i, p_i in enumera... | output | 1 | 75,906 | 13 | 151,813 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Mitya has a rooted tree with n vertices indexed from 1 to n, where the root has index 1. Each vertex v initially had an integer number a_v ≥ 0 written on it. For every vertex v Mitya has computed s_v: the sum of all values written on the ver... | instruction | 0 | 75,907 | 13 | 151,814 |
Tags: constructive algorithms, dfs and similar, greedy, trees
Correct Solution:
```
from itertools import combinations
from sys import stdin
import math
def listIn():
return list((map(int,stdin.readline().strip().split())))
def stringIn():
return([x for x in stdin.readline().split()])
def intIn():
re... | output | 1 | 75,907 | 13 | 151,815 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Mitya has a rooted tree with n vertices indexed from 1 to n, where the root has index 1. Each vertex v initially had an integer number a_v ≥ 0 written on it. For every vertex v Mitya has computed s_v: the sum of all values written on the ver... | instruction | 0 | 75,908 | 13 | 151,816 |
Tags: constructive algorithms, dfs and similar, greedy, trees
Correct Solution:
```
import sys
amount = int(input())
preds = [int(s) for s in input().split()]
s = [int(s) for s in input().split()]
min_ = 10e18
childs = [[] for i in range(len(s))]
a = [0] * len(s)
a[0] = s[0]
for i in range(len(preds)):
childs[preds... | output | 1 | 75,908 | 13 | 151,817 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Mitya has a rooted tree with n vertices indexed from 1 to n, where the root has index 1. Each vertex v initially had an integer number a_v ≥ 0 written on it. For every vertex v Mitya has compute... | instruction | 0 | 75,909 | 13 | 151,818 |
Yes | output | 1 | 75,909 | 13 | 151,819 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Mitya has a rooted tree with n vertices indexed from 1 to n, where the root has index 1. Each vertex v initially had an integer number a_v ≥ 0 written on it. For every vertex v Mitya has compute... | instruction | 0 | 75,910 | 13 | 151,820 |
Yes | output | 1 | 75,910 | 13 | 151,821 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Mitya has a rooted tree with n vertices indexed from 1 to n, where the root has index 1. Each vertex v initially had an integer number a_v ≥ 0 written on it. For every vertex v Mitya has compute... | instruction | 0 | 75,911 | 13 | 151,822 |
Yes | output | 1 | 75,911 | 13 | 151,823 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Mitya has a rooted tree with n vertices indexed from 1 to n, where the root has index 1. Each vertex v initially had an integer number a_v ≥ 0 written on it. For every vertex v Mitya has compute... | instruction | 0 | 75,912 | 13 | 151,824 |
Yes | output | 1 | 75,912 | 13 | 151,825 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Mitya has a rooted tree with n vertices indexed from 1 to n, where the root has index 1. Each vertex v initially had an integer number a_v ≥ 0 written on it. For every vertex v Mitya has compute... | instruction | 0 | 75,913 | 13 | 151,826 |
No | output | 1 | 75,913 | 13 | 151,827 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Mitya has a rooted tree with n vertices indexed from 1 to n, where the root has index 1. Each vertex v initially had an integer number a_v ≥ 0 written on it. For every vertex v Mitya has compute... | instruction | 0 | 75,914 | 13 | 151,828 |
No | output | 1 | 75,914 | 13 | 151,829 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Mitya has a rooted tree with n vertices indexed from 1 to n, where the root has index 1. Each vertex v initially had an integer number a_v ≥ 0 written on it. For every vertex v Mitya has compute... | instruction | 0 | 75,915 | 13 | 151,830 |
No | output | 1 | 75,915 | 13 | 151,831 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Mitya has a rooted tree with n vertices indexed from 1 to n, where the root has index 1. Each vertex v initially had an integer number a_v ≥ 0 written on it. For every vertex v Mitya has compute... | instruction | 0 | 75,916 | 13 | 151,832 |
No | output | 1 | 75,916 | 13 | 151,833 |
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. You have to write a number on each vertex of this graph, each number should be either 0 or 1. After that, you write a number on eac... | instruction | 0 | 75,969 | 13 | 151,938 |
No | output | 1 | 75,969 | 13 | 151,939 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a directed graph on n vertices numbered 1 through n where each vertex (except n) has two outgoing arcs, red and blue. At any point in time, exactly one of the arcs is active for each ve... | instruction | 0 | 75,986 | 13 | 151,972 |
No | output | 1 | 75,986 | 13 | 151,973 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a directed graph on n vertices numbered 1 through n where each vertex (except n) has two outgoing arcs, red and blue. At any point in time, exactly one of the arcs is active for each ve... | instruction | 0 | 75,987 | 13 | 151,974 |
No | output | 1 | 75,987 | 13 | 151,975 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a directed graph on n vertices numbered 1 through n where each vertex (except n) has two outgoing arcs, red and blue. At any point in time, exactly one of the arcs is active for each ve... | instruction | 0 | 75,988 | 13 | 151,976 |
No | output | 1 | 75,988 | 13 | 151,977 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a directed graph on n vertices numbered 1 through n where each vertex (except n) has two outgoing arcs, red and blue. At any point in time, exactly one of the arcs is active for each ve... | instruction | 0 | 75,989 | 13 | 151,978 |
No | output | 1 | 75,989 | 13 | 151,979 |
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 consisting of n vertices, and m simple vertex paths. Your task is to find how many pairs of those paths intersect at exactly one vertex. More formally you have to find the n... | instruction | 0 | 76,104 | 13 | 152,208 |
No | output | 1 | 76,104 | 13 | 152,209 |
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 consisting of n vertices, and m simple vertex paths. Your task is to find how many pairs of those paths intersect at exactly one vertex. More formally you have to find the n... | instruction | 0 | 76,105 | 13 | 152,210 |
No | output | 1 | 76,105 | 13 | 152,211 |
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 consisting of n vertices, and m simple vertex paths. Your task is to find how many pairs of those paths intersect at exactly one vertex. More formally you have to find the n... | instruction | 0 | 76,106 | 13 | 152,212 |
No | output | 1 | 76,106 | 13 | 152,213 |
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 consisting of n vertices, and m simple vertex paths. Your task is to find how many pairs of those paths intersect at exactly one vertex. More formally you have to find the n... | instruction | 0 | 76,107 | 13 | 152,214 |
No | output | 1 | 76,107 | 13 | 152,215 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Momiji has got a rooted tree, consisting of n nodes. The tree nodes are numbered by integers from 1 to n. The root has number 1. Momiji decided to play a game on this tree.
The game consists of several steps. On each step, Momiji chooses on... | instruction | 0 | 76,161 | 13 | 152,322 |
Tags: implementation, math, probabilities, trees
Correct Solution:
```
# https://codeforces.com/problemset/problem/280/C
from collections import defaultdict, deque
import sys
nodes = int(sys.stdin.readline())
edges = defaultdict(list)
for line in sys.stdin:
a, b = line.split()
a = int(a)
b = int(b)
edg... | output | 1 | 76,161 | 13 | 152,323 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Momiji has got a rooted tree, consisting of n nodes. The tree nodes are numbered by integers from 1 to n. The root has number 1. Momiji decided to play a game on this tree.
The game consists of several steps. On each step, Momiji chooses on... | instruction | 0 | 76,162 | 13 | 152,324 |
Tags: implementation, math, probabilities, trees
Correct Solution:
```
from collections import deque
from sys import stdin
input = stdin.readline
n = int(input())
a = [list(map(int, line.split())) for line in stdin.read().splitlines()]
adj = [[] for _ in range(n + 1)]
for (u, v) in a:
adj[u].append(v)
adj[v].a... | output | 1 | 76,162 | 13 | 152,325 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Given a tree with n nodes numbered from 1 to n. Each node i has an associated value V_i.
If the simple path from u_1 to u_m consists of m nodes namely u_1 → u_2 → u_3 → ... u_{m-1} → u_{m}, the... | instruction | 0 | 76,440 | 13 | 152,880 |
No | output | 1 | 76,440 | 13 | 152,881 |
Provide a correct Python 3 solution for this coding contest problem.
Let N be an even number.
There is a tree with N vertices. The vertices are numbered 1, 2, ..., N. For each i (1 \leq i \leq N - 1), the i-th edge connects Vertex x_i and y_i.
Snuke would like to decorate the tree with ribbons, as follows.
First, h... | instruction | 0 | 76,537 | 13 | 153,074 |
"Correct Solution:
```
import sys
sys.setrecursionlimit(5001)
MOD = 10 ** 9 + 7
n = int(input())
links = [set() for _ in range(n)]
for line in sys.stdin.readlines():
x, y = map(int, line.split())
x -= 1
y -= 1
links[x].add(y)
links[y].add(x)
double_factorial_odd = [0] * (n // 2)
prev = 1
for i in... | output | 1 | 76,537 | 13 | 153,075 |
Provide a correct Python 3 solution for this coding contest problem.
Let N be an even number.
There is a tree with N vertices. The vertices are numbered 1, 2, ..., N. For each i (1 \leq i \leq N - 1), the i-th edge connects Vertex x_i and y_i.
Snuke would like to decorate the tree with ribbons, as follows.
First, h... | instruction | 0 | 76,538 | 13 | 153,076 |
"Correct Solution:
```
mod = 10**9+7 #出力の制限
N = 2*10**5
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル
for i in range( 2, N + 1 ):
g1.append( ( g1[-1] * i ) % mod )
inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
g2.append( (g2[-1] * inverse[-1]) % mod )
import sys
sys.s... | output | 1 | 76,538 | 13 | 153,077 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Let N be an even number.
There is a tree with N vertices. The vertices are numbered 1, 2, ..., N. For each i (1 \leq i \leq N - 1), the i-th edge connects Vertex x_i and y_i.
Snuke would like ... | instruction | 0 | 76,539 | 13 | 153,078 |
No | output | 1 | 76,539 | 13 | 153,079 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.