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.
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 | 101,287 | 13 | 202,574 |
Tags: bitmasks, brute force, graphs, shortest paths
Correct Solution:
```
import math
edges = []
result = -1
def dfs(ns, path, visited, last, now):
visited[now] = True
global edges
for i in edges[now]:
if i == last:
continue
if i in path:
new_result = len(path) - pa... | output | 1 | 101,287 | 13 | 202,575 |
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 | 101,288 | 13 | 202,576 |
Tags: bitmasks, brute force, graphs, shortest paths
Correct Solution:
```
# Using BFS
from collections import defaultdict
import queue
class Graph:
def __init__(self, length):
self.length = length
self.graph = defaultdict(list)
def addEdge(self,u,v):
self.graph[u].append(v)
... | output | 1 | 101,288 | 13 | 202,577 |
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 | 101,289 | 13 | 202,578 |
Tags: bitmasks, brute force, graphs, shortest paths
Correct Solution:
```
import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int, input().split()))
L = max(A).bit_length()
ans = -1
graph = [[] for _ in range(N)]
V = []
for l in range(L):
P = []
for i in range(N):
if (1 << l) & A[i]:
... | output | 1 | 101,289 | 13 | 202,579 |
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 | 101,290 | 13 | 202,580 |
Tags: bitmasks, brute force, graphs, shortest paths
Correct Solution:
```
from collections import *
import sys
# "". join(strings)
def ri():
return int(input())
def rl():
return list(map(int, input().split()))
n = ri()
aa = rl()
zero_cnt = 0
aa = [value for value in aa if value != 0]
... | output | 1 | 101,290 | 13 | 202,581 |
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 | 101,291 | 13 | 202,582 |
Tags: bitmasks, brute force, graphs, shortest paths
Correct Solution:
```
def bfs(g, src, dest):
visited = {}
dist = {}
for i in g:
visited[i] = False
dist[i] = 1e18
dist[src] = 0
visited[src] = True
q = []
q.append(src)
while q:
src = q.pop(0)
for i in g[src]:
if visited[i] == False:
visited[i] ... | output | 1 | 101,291 | 13 | 202,583 |
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 | 101,292 | 13 | 202,584 |
Tags: bitmasks, brute force, graphs, shortest paths
Correct Solution:
```
# ------------------- fast io --------------------
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = ... | output | 1 | 101,292 | 13 | 202,585 |
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 | 101,293 | 13 | 202,586 |
Tags: bitmasks, brute force, graphs, shortest paths
Correct Solution:
```
from collections import *
import sys
def ri():
return int(input())
def rl():
return list(map(int, input().split()))
n = ri()
aa = rl()
zero_cnt = 0
aa = [value for value in aa if value != 0]
n = len(aa)
edges = set... | output | 1 | 101,293 | 13 | 202,587 |
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 | 101,294 | 13 | 202,588 |
Yes | output | 1 | 101,294 | 13 | 202,589 |
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 | 101,295 | 13 | 202,590 |
Yes | output | 1 | 101,295 | 13 | 202,591 |
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 | 101,296 | 13 | 202,592 |
Yes | output | 1 | 101,296 | 13 | 202,593 |
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 | 101,297 | 13 | 202,594 |
Yes | output | 1 | 101,297 | 13 | 202,595 |
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 | 101,298 | 13 | 202,596 |
No | output | 1 | 101,298 | 13 | 202,597 |
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 | 101,299 | 13 | 202,598 |
No | output | 1 | 101,299 | 13 | 202,599 |
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 | 101,300 | 13 | 202,600 |
No | output | 1 | 101,300 | 13 | 202,601 |
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 | 101,301 | 13 | 202,602 |
No | output | 1 | 101,301 | 13 | 202,603 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Let's define a non-oriented connected graph of n vertices and n - 1 edges as a beard, if all of its vertices except, perhaps, one, have the degree of 2 or 1 (that is, there exists no more than o... | instruction | 0 | 101,468 | 13 | 202,936 |
No | output | 1 | 101,468 | 13 | 202,937 |
Provide tags and a correct Python 3 solution for this coding contest problem.
After the piece of a devilish mirror hit the Kay's eye, he is no longer interested in the beauty of the roses. Now he likes to watch snowflakes.
Once upon a time, he found a huge snowflake that has a form of the tree (connected acyclic grap... | instruction | 0 | 101,649 | 13 | 203,298 |
Tags: data structures, dfs and similar, dp, trees
Correct Solution:
```
import operator
import bisect
n, q = [int(s) for s in input().split()]
ps = [int(s) for s in input().split()]
childs = [[] for _ in range(n)]
for (c,pa) in enumerate(ps):
childs[pa-1].append(c+1)
toposort = []
this_level = [0]
next_level = ... | output | 1 | 101,649 | 13 | 203,299 |
Provide tags and a correct Python 3 solution for this coding contest problem.
After the piece of a devilish mirror hit the Kay's eye, he is no longer interested in the beauty of the roses. Now he likes to watch snowflakes.
Once upon a time, he found a huge snowflake that has a form of the tree (connected acyclic grap... | instruction | 0 | 101,650 | 13 | 203,300 |
Tags: data structures, dfs and similar, dp, trees
Correct Solution:
```
def main():
import sys
E=sys.stdin
R=E.readline
n,q=map(int,R().split())
P=[0,0]+[int(i) for i in R().split()]
#n=q=300000
#P=[0]+list(range(n))
#exit()
C=[[]]
i=0
while i<n:
i+=1
C.append([])
i=2
j=len(P)
while i<j:
C[P[i]].app... | output | 1 | 101,650 | 13 | 203,301 |
Provide tags and a correct Python 3 solution for this coding contest problem.
After the piece of a devilish mirror hit the Kay's eye, he is no longer interested in the beauty of the roses. Now he likes to watch snowflakes.
Once upon a time, he found a huge snowflake that has a form of the tree (connected acyclic grap... | instruction | 0 | 101,651 | 13 | 203,302 |
Tags: data structures, dfs and similar, dp, trees
Correct Solution:
```
# [https://codeforces.com/contest/685/submission/42128998 <- https://codeforces.com/contest/685/status/B <- https://codeforces.com/contest/685 <- https://codeforces.com/blog/entry/45556 <- https://codeforces.com/problemset/problem/685/B <- https://... | output | 1 | 101,651 | 13 | 203,303 |
Provide tags and a correct Python 3 solution for this coding contest problem.
After the piece of a devilish mirror hit the Kay's eye, he is no longer interested in the beauty of the roses. Now he likes to watch snowflakes.
Once upon a time, he found a huge snowflake that has a form of the tree (connected acyclic grap... | instruction | 0 | 101,652 | 13 | 203,304 |
Tags: data structures, dfs and similar, dp, trees
Correct Solution:
```
import operator
import bisect
n, q = [int(s) for s in input().split()]
ps = [int(s) for s in input().split()]
childs = [[] for _ in range(n)]
for (c,pa) in enumerate(ps):
childs[pa-1].append(c+1)
toposort = []
this_level = [0]
next_level = ... | output | 1 | 101,652 | 13 | 203,305 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
After the piece of a devilish mirror hit the Kay's eye, he is no longer interested in the beauty of the roses. Now he likes to watch snowflakes.
Once upon a time, he found a huge snowflake that... | instruction | 0 | 101,653 | 13 | 203,306 |
No | output | 1 | 101,653 | 13 | 203,307 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
After the piece of a devilish mirror hit the Kay's eye, he is no longer interested in the beauty of the roses. Now he likes to watch snowflakes.
Once upon a time, he found a huge snowflake that... | instruction | 0 | 101,654 | 13 | 203,308 |
No | output | 1 | 101,654 | 13 | 203,309 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
After the piece of a devilish mirror hit the Kay's eye, he is no longer interested in the beauty of the roses. Now he likes to watch snowflakes.
Once upon a time, he found a huge snowflake that... | instruction | 0 | 101,655 | 13 | 203,310 |
No | output | 1 | 101,655 | 13 | 203,311 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
After the piece of a devilish mirror hit the Kay's eye, he is no longer interested in the beauty of the roses. Now he likes to watch snowflakes.
Once upon a time, he found a huge snowflake that... | instruction | 0 | 101,656 | 13 | 203,312 |
No | output | 1 | 101,656 | 13 | 203,313 |
Provide a correct Python 3 solution for this coding contest problem.
We have a tree with N vertices. The vertices are numbered 0 through N - 1, and the i-th edge (0 ≤ i < N - 1) comnnects Vertex a_i and b_i. For each pair of vertices u and v (0 ≤ u, v < N), we define the distance d(u, v) as the number of edges in the ... | instruction | 0 | 101,888 | 13 | 203,776 |
"Correct Solution:
```
def main():
n = int(input())
ab = [list(map(int, input().split())) for _ in [0]*(n-1)]
g = [[] for _ in [0]*n]
[g[a].append(b) for a, b in ab]
[g[b].append(a) for a, b in ab]
for i in range(n):
if len(g[i]) > 2:
root = i
break
else:
... | output | 1 | 101,888 | 13 | 203,777 |
Provide a correct Python 3 solution for this coding contest problem.
We have a tree with N vertices. The vertices are numbered 0 through N - 1, and the i-th edge (0 ≤ i < N - 1) comnnects Vertex a_i and b_i. For each pair of vertices u and v (0 ≤ u, v < N), we define the distance d(u, v) as the number of edges in the ... | instruction | 0 | 101,889 | 13 | 203,778 |
"Correct Solution:
```
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
def main():
n = int(ipt())... | output | 1 | 101,889 | 13 | 203,779 |
Provide a correct Python 3 solution for this coding contest problem.
We have a tree with N vertices. The vertices are numbered 0 through N - 1, and the i-th edge (0 ≤ i < N - 1) comnnects Vertex a_i and b_i. For each pair of vertices u and v (0 ≤ u, v < N), we define the distance d(u, v) as the number of edges in the ... | instruction | 0 | 101,890 | 13 | 203,780 |
"Correct Solution:
```
import sys
sys.setrecursionlimit(100000)
def dfs(v, p, links):
lv = links[v]
if len(lv) == 1:
return 0
cnt0 = 0
ret = 0
for l in lv:
if l == p:
continue
res = dfs(l, v, links)
ret += res
if res == 0:
cnt0 += 1
... | output | 1 | 101,890 | 13 | 203,781 |
Provide a correct Python 3 solution for this coding contest problem.
We have a tree with N vertices. The vertices are numbered 0 through N - 1, and the i-th edge (0 ≤ i < N - 1) comnnects Vertex a_i and b_i. For each pair of vertices u and v (0 ≤ u, v < N), we define the distance d(u, v) as the number of edges in the ... | instruction | 0 | 101,891 | 13 | 203,782 |
"Correct Solution:
```
# 大混乱したので乱択 # これ嘘じゃないのか???
def main():
import sys
sys.setrecursionlimit(500000)
N = int(input())
if N==2:
print(1)
exit()
E = [[] for _ in range(N)]
for _ in range(N-1):
a, b = map(int, input().split())
E[a].append(b)
E[b].append(a... | output | 1 | 101,891 | 13 | 203,783 |
Provide a correct Python 3 solution for this coding contest problem.
We have a tree with N vertices. The vertices are numbered 0 through N - 1, and the i-th edge (0 ≤ i < N - 1) comnnects Vertex a_i and b_i. For each pair of vertices u and v (0 ≤ u, v < N), we define the distance d(u, v) as the number of edges in the ... | instruction | 0 | 101,892 | 13 | 203,784 |
"Correct Solution:
```
import sys
readline = sys.stdin.readline
from collections import Counter
from random import randrange
def parorder(Edge, p):
N = len(Edge)
par = [0]*N
par[p] = -1
stack = [p]
order = []
visited = set([p])
ast = stack.append
apo = order.append
while stack:
... | output | 1 | 101,892 | 13 | 203,785 |
Provide a correct Python 3 solution for this coding contest problem.
We have a tree with N vertices. The vertices are numbered 0 through N - 1, and the i-th edge (0 ≤ i < N - 1) comnnects Vertex a_i and b_i. For each pair of vertices u and v (0 ≤ u, v < N), we define the distance d(u, v) as the number of edges in the ... | instruction | 0 | 101,893 | 13 | 203,786 |
"Correct Solution:
```
"""
Writer: SPD_9X2
https://atcoder.jp/contests/apc001/tasks/apc001_e
厳密な照明は難しいが…
直径を取る
直径の端点からbfs
全ての頂点に関して、部分木に少なくとも一つのアンテナを持つかのフラグを管理
子の数をkとする。その内x個がtrueの場合、k-1-x個のアンテナを追加。自分のflagをtrueにする
子がfalseで、子が0 or 1つしかない場合のみfalse継続
簡単な木では最適になることを実験したがどうだろうか…?
"""
import sys
sys.setrecursionlimit(3*1... | output | 1 | 101,893 | 13 | 203,787 |
Provide a correct Python 3 solution for this coding contest problem.
We have a tree with N vertices. The vertices are numbered 0 through N - 1, and the i-th edge (0 ≤ i < N - 1) comnnects Vertex a_i and b_i. For each pair of vertices u and v (0 ≤ u, v < N), we define the distance d(u, v) as the number of edges in the ... | instruction | 0 | 101,894 | 13 | 203,788 |
"Correct Solution:
```
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
from bisect import bisect_left, bisect_right
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from copy import deepcopy
INF = 10 ** 20
s... | output | 1 | 101,894 | 13 | 203,789 |
Provide a correct Python 3 solution for this coding contest problem.
We have a tree with N vertices. The vertices are numbered 0 through N - 1, and the i-th edge (0 ≤ i < N - 1) comnnects Vertex a_i and b_i. For each pair of vertices u and v (0 ≤ u, v < N), we define the distance d(u, v) as the number of edges in the ... | instruction | 0 | 101,895 | 13 | 203,790 |
"Correct Solution:
```
#設定
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
#ライブラリインポート
from collections import defaultdict
#入力受け取り
def getlist():
return list(map(int, input().split()))
class Graph(object):
def __init__(self):
self.graph = defaultdict(list)
def __len__(self):
return ... | output | 1 | 101,895 | 13 | 203,791 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We have a tree with N vertices. The vertices are numbered 0 through N - 1, and the i-th edge (0 ≤ i < N - 1) comnnects Vertex a_i and b_i. For each pair of vertices u and v (0 ≤ u, v < N), we de... | instruction | 0 | 101,896 | 13 | 203,792 |
Yes | output | 1 | 101,896 | 13 | 203,793 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We have a tree with N vertices. The vertices are numbered 0 through N - 1, and the i-th edge (0 ≤ i < N - 1) comnnects Vertex a_i and b_i. For each pair of vertices u and v (0 ≤ u, v < N), we de... | instruction | 0 | 101,897 | 13 | 203,794 |
Yes | output | 1 | 101,897 | 13 | 203,795 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We have a tree with N vertices. The vertices are numbered 0 through N - 1, and the i-th edge (0 ≤ i < N - 1) comnnects Vertex a_i and b_i. For each pair of vertices u and v (0 ≤ u, v < N), we de... | instruction | 0 | 101,898 | 13 | 203,796 |
Yes | output | 1 | 101,898 | 13 | 203,797 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We have a tree with N vertices. The vertices are numbered 0 through N - 1, and the i-th edge (0 ≤ i < N - 1) comnnects Vertex a_i and b_i. For each pair of vertices u and v (0 ≤ u, v < N), we de... | instruction | 0 | 101,899 | 13 | 203,798 |
Yes | output | 1 | 101,899 | 13 | 203,799 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We have a tree with N vertices. The vertices are numbered 0 through N - 1, and the i-th edge (0 ≤ i < N - 1) comnnects Vertex a_i and b_i. For each pair of vertices u and v (0 ≤ u, v < N), we de... | instruction | 0 | 101,900 | 13 | 203,800 |
No | output | 1 | 101,900 | 13 | 203,801 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We have a tree with N vertices. The vertices are numbered 0 through N - 1, and the i-th edge (0 ≤ i < N - 1) comnnects Vertex a_i and b_i. For each pair of vertices u and v (0 ≤ u, v < N), we de... | instruction | 0 | 101,901 | 13 | 203,802 |
No | output | 1 | 101,901 | 13 | 203,803 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We have a tree with N vertices. The vertices are numbered 0 through N - 1, and the i-th edge (0 ≤ i < N - 1) comnnects Vertex a_i and b_i. For each pair of vertices u and v (0 ≤ u, v < N), we de... | instruction | 0 | 101,902 | 13 | 203,804 |
No | output | 1 | 101,902 | 13 | 203,805 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We have a tree with N vertices. The vertices are numbered 0 through N - 1, and the i-th edge (0 ≤ i < N - 1) comnnects Vertex a_i and b_i. For each pair of vertices u and v (0 ≤ u, v < N), we de... | instruction | 0 | 101,903 | 13 | 203,806 |
No | output | 1 | 101,903 | 13 | 203,807 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Ivan is developing his own computer game. Now he tries to create some levels for his game. But firstly for each level he needs to draw a graph representing the structure of the level.
Ivan decided that there should be exactly ni vertices in... | instruction | 0 | 102,582 | 13 | 205,164 |
Tags: binary search, math, ternary search
Correct Solution:
```
#! /usr/bin/env python
# http://codeforces.com/problemset/problem/818/F
# Problem name ::: F. Level Generation
# submission number
#212055293
#508427854
def newest_approach(n):
from math import floor, ceil, sqrt
quad_solv = sqrt(2*n+1/4)-1/2
... | output | 1 | 102,582 | 13 | 205,165 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Ivan is developing his own computer game. Now he tries to create some levels for his game. But firstly for each level he needs to draw a graph representing the structure of the level.
Ivan deci... | instruction | 0 | 102,583 | 13 | 205,166 |
No | output | 1 | 102,583 | 13 | 205,167 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Ivan is developing his own computer game. Now he tries to create some levels for his game. But firstly for each level he needs to draw a graph representing the structure of the level.
Ivan deci... | instruction | 0 | 102,584 | 13 | 205,168 |
No | output | 1 | 102,584 | 13 | 205,169 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Ivan is developing his own computer game. Now he tries to create some levels for his game. But firstly for each level he needs to draw a graph representing the structure of the level.
Ivan deci... | instruction | 0 | 102,585 | 13 | 205,170 |
No | output | 1 | 102,585 | 13 | 205,171 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Ivan is developing his own computer game. Now he tries to create some levels for his game. But firstly for each level he needs to draw a graph representing the structure of the level.
Ivan deci... | instruction | 0 | 102,586 | 13 | 205,172 |
No | output | 1 | 102,586 | 13 | 205,173 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Consider a rooted tree. A rooted tree has one special vertex called the root. All edges are directed from the root. Vertex u is called a child of vertex v and vertex v is called a parent of vertex u if there exists a directed edge from v to ... | instruction | 0 | 102,625 | 13 | 205,250 |
Tags: implementation, trees
Correct Solution:
```
n = int(input())
tree = {}
for i in range(n-1):
parent = int(input())
tree[parent] = tree.get(parent, []) + [i+2]
def check_vertices():
for vertex in tree.keys():
leaf_cnt = 0
if len(tree[vertex]) >= 3:
for child in tree[vertex]... | output | 1 | 102,625 | 13 | 205,251 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Consider a rooted tree. A rooted tree has one special vertex called the root. All edges are directed from the root. Vertex u is called a child of vertex v and vertex v is called a parent of vertex u if there exists a directed edge from v to ... | instruction | 0 | 102,626 | 13 | 205,252 |
Tags: implementation, trees
Correct Solution:
```
from collections import defaultdict
N = int(input())
Check, MyDict = [True] + [False] * (N - 1), defaultdict(list)
for i in range(N - 1):
Temp = int(input())
MyDict[Temp].append(i + 2)
Check[Temp - 1] = True
for key in MyDict:
if len([True for value in ... | output | 1 | 102,626 | 13 | 205,253 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Consider a rooted tree. A rooted tree has one special vertex called the root. All edges are directed from the root. Vertex u is called a child of vertex v and vertex v is called a parent of vertex u if there exists a directed edge from v to ... | instruction | 0 | 102,627 | 13 | 205,254 |
Tags: implementation, trees
Correct Solution:
```
import sys
sys.setrecursionlimit(10000)
n=int(input())
vs = {}
for c in range(2, n+1):
p = int(input())
if p in vs:
vs[p].append(c)
else:
vs[p] = [c]
def check(n):
if n not in vs:
return 1
ch = vs[n]
s = 0
for c in c... | output | 1 | 102,627 | 13 | 205,255 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Consider a rooted tree. A rooted tree has one special vertex called the root. All edges are directed from the root. Vertex u is called a child of vertex v and vertex v is called a parent of vertex u if there exists a directed edge from v to ... | instruction | 0 | 102,628 | 13 | 205,256 |
Tags: implementation, trees
Correct Solution:
```
# -*- coding: utf-8 -*-
"""
Created on Thu Jun 11 11:00:21 2020
@author: Harshal
"""
import collections,sys
n=int(input())
graph=collections.defaultdict(list)
for i in range(2,n+1):
a=int(input())
graph[a].append(i)
for i in range(1,n+1):
if i not in grap... | output | 1 | 102,628 | 13 | 205,257 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Consider a rooted tree. A rooted tree has one special vertex called the root. All edges are directed from the root. Vertex u is called a child of vertex v and vertex v is called a parent of vertex u if there exists a directed edge from v to ... | instruction | 0 | 102,629 | 13 | 205,258 |
Tags: implementation, trees
Correct Solution:
```
import sys
from collections import Counter
L=sys.stdin.readlines()
n=int(L[0])
l=list(map(lambda x:int(x),L[1:]) )
cnt=Counter(l)
cntl=Counter([l[i-2] for i in range(2,n+1) if i not in cnt ] )
for a in cnt:
if cntl[a]<3:
print("No")
break
else:
... | output | 1 | 102,629 | 13 | 205,259 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.