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're given an undirected graph with n nodes and m edges. Nodes are numbered from 1 to n.
The graph is considered harmonious if and only if the following property holds:
* For every triple of integers (l, m, r) such that 1 ≤ l < m < r ≤... | instruction | 0 | 32,639 | 13 | 65,278 |
Tags: constructive algorithms, dfs and similar, dsu, graphs, greedy, sortings
Correct Solution:
```
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
class DisjointSet:
def __init__(self, n):
self.par = [i for i in range(n)]
self.size = [1] * n
self.r... | output | 1 | 32,639 | 13 | 65,279 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You're given an undirected graph with n nodes and m edges. Nodes are numbered from 1 to n.
The graph is considered harmonious if and only if the following property holds:
* For every triple of integers (l, m, r) such that 1 ≤ l < m < r ≤... | instruction | 0 | 32,640 | 13 | 65,280 |
Tags: constructive algorithms, dfs and similar, dsu, graphs, greedy, sortings
Correct Solution:
```
import sys
import collections
def main():
n,m = [int(x) for x in sys.stdin.readline().split(" ")]
adj = collections.defaultdict(list)
vis = [0]*(n+1)
for i in range(m):
u,v = [int(x) for x in sys.stdin.readlin... | output | 1 | 32,640 | 13 | 65,281 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You're given an undirected graph with n nodes and m edges. Nodes are numbered from 1 to n.
The graph is considered harmonious if and only if the following property holds:
* For every triple of integers (l, m, r) such that 1 ≤ l < m < r ≤... | instruction | 0 | 32,641 | 13 | 65,282 |
Tags: constructive algorithms, dfs and similar, dsu, graphs, greedy, sortings
Correct Solution:
```
import sys
input = sys.stdin.buffer.readline
class UnionFind():
def __init__(self, n):
self.n = n
self.root = [-1] * (n + 1)
self.rnk = [0] * (n + 1)
def find_root(self, x):
if ... | output | 1 | 32,641 | 13 | 65,283 |
Provide tags and a correct Python 2 solution for this coding contest problem.
You're given an undirected graph with n nodes and m edges. Nodes are numbered from 1 to n.
The graph is considered harmonious if and only if the following property holds:
* For every triple of integers (l, m, r) such that 1 ≤ l < m < r ≤... | instruction | 0 | 32,642 | 13 | 65,284 |
Tags: constructive algorithms, dfs and similar, dsu, graphs, greedy, sortings
Correct Solution:
```
from sys import stdin, stdout
from collections import Counter, defaultdict
pr=stdout.write
raw_input = stdin.readline
def ni():
return int(raw_input())
def li():
return list(map(int,raw_input().split()))
def... | output | 1 | 32,642 | 13 | 65,285 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You're given an undirected graph with n nodes and m edges. Nodes are numbered from 1 to n.
The graph is considered harmonious if and only if the following property holds:
* For every triple ... | instruction | 0 | 32,643 | 13 | 65,286 |
Yes | output | 1 | 32,643 | 13 | 65,287 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You're given an undirected graph with n nodes and m edges. Nodes are numbered from 1 to n.
The graph is considered harmonious if and only if the following property holds:
* For every triple ... | instruction | 0 | 32,644 | 13 | 65,288 |
Yes | output | 1 | 32,644 | 13 | 65,289 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You're given an undirected graph with n nodes and m edges. Nodes are numbered from 1 to n.
The graph is considered harmonious if and only if the following property holds:
* For every triple ... | instruction | 0 | 32,645 | 13 | 65,290 |
Yes | output | 1 | 32,645 | 13 | 65,291 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You're given an undirected graph with n nodes and m edges. Nodes are numbered from 1 to n.
The graph is considered harmonious if and only if the following property holds:
* For every triple ... | instruction | 0 | 32,646 | 13 | 65,292 |
Yes | output | 1 | 32,646 | 13 | 65,293 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You're given an undirected graph with n nodes and m edges. Nodes are numbered from 1 to n.
The graph is considered harmonious if and only if the following property holds:
* For every triple ... | instruction | 0 | 32,647 | 13 | 65,294 |
No | output | 1 | 32,647 | 13 | 65,295 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You're given an undirected graph with n nodes and m edges. Nodes are numbered from 1 to n.
The graph is considered harmonious if and only if the following property holds:
* For every triple ... | instruction | 0 | 32,648 | 13 | 65,296 |
No | output | 1 | 32,648 | 13 | 65,297 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You're given an undirected graph with n nodes and m edges. Nodes are numbered from 1 to n.
The graph is considered harmonious if and only if the following property holds:
* For every triple ... | instruction | 0 | 32,649 | 13 | 65,298 |
No | output | 1 | 32,649 | 13 | 65,299 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You're given an undirected graph with n nodes and m edges. Nodes are numbered from 1 to n.
The graph is considered harmonious if and only if the following property holds:
* For every triple ... | instruction | 0 | 32,650 | 13 | 65,300 |
No | output | 1 | 32,650 | 13 | 65,301 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There is an undirected tree of n vertices, connected by n-1 bidirectional edges. There is also a snake stuck inside of this tree. Its head is at vertex a and its tail is at vertex b. The snake's body occupies all vertices on the unique simpl... | instruction | 0 | 32,689 | 13 | 65,378 |
Tags: dfs and similar, dp, greedy, trees, two pointers
Correct Solution:
```
class Solution:
def __init__(self):
self.his = set()
self.dp = {}
self.get_input()
def get_input(self):
self.n, head, tail = [int(tmp) for tmp in input().strip().split(' ')]
head -= 1
ta... | output | 1 | 32,689 | 13 | 65,379 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There is an undirected tree of n vertices, connected by n-1 bidirectional edges. There is also a snake stuck inside of this tree. Its head is at vertex a and its tail is at vertex b. The snake's body occupies all vertices on the unique simpl... | instruction | 0 | 32,690 | 13 | 65,380 |
Tags: dfs and similar, dp, greedy, trees, two pointers
Correct Solution:
```
import sys
from collections import deque
t = int(input())
for _ in range(t):
n, a, b = [int(x) for x in input().split()]
a -= 1
b -= 1
edges = set()
adj = [[] for x in range(n)]
for _ in range(n-1):
u, v = [int... | output | 1 | 32,690 | 13 | 65,381 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There is an undirected tree of n vertices, connected by n-1 bidirectional edges. There is also a snake stuck inside of this tree. Its head is at vertex a and its tail is at vertex b. The snake's body occupies all vertices on the unique simpl... | instruction | 0 | 32,691 | 13 | 65,382 |
Tags: dfs and similar, dp, greedy, trees, two pointers
Correct Solution:
```
import sys
T=int(sys.stdin.readline().strip())
#T=1
def dfs(x, h, fa):
stack_queue=[]
stack_queue.append((x,h,fa,0, 0))
while (len(stack_queue)>0) :
now=stack_queue.pop()
x,h,fa,r, idone=now
#print (x,r,idone,fa,stack_queue)
if... | output | 1 | 32,691 | 13 | 65,383 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There is an undirected tree of n vertices, connected by n-1 bidirectional edges. There is also a snake stuck inside of this tree. Its head is at vertex a and its tail is at vertex b. The snake's body occupies all vertices on the unique simpl... | instruction | 0 | 32,692 | 13 | 65,384 |
Tags: dfs and similar, dp, greedy, trees, two pointers
Correct Solution:
```
import sys
import time
tstart=int(round(time.time()*1000) )
casecount = int(sys.stdin.readline())
debug = False
for icase in range(0, casecount):
ss = sys.stdin.readline().strip().split(' ')
n = int(ss[0])
a = int(ss[1])
b = in... | output | 1 | 32,692 | 13 | 65,385 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There is an undirected tree of n vertices, connected by n-1 bidirectional edges. There is also a snake stuck inside of this tree. Its head is at vertex a and its tail is at vertex b. The snake's body occupies all vertices on the unique simpl... | instruction | 0 | 32,693 | 13 | 65,386 |
Tags: dfs and similar, dp, greedy, trees, two pointers
Correct Solution:
```
from sys import stdin
import itertools
input = stdin.readline
def getint(): return int(input())
def getints(): return list(map(int, input().split()))
def getint1(): return list(map(lambda x: int(x) - 1, input().split()))
def getstr(): return i... | output | 1 | 32,693 | 13 | 65,387 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There is an undirected tree of n vertices, connected by n-1 bidirectional edges. There is also a snake stuck inside of this tree. Its head is at vertex a and its tail is at vertex b. The snake's body occupies all vertices on the unique simpl... | instruction | 0 | 32,694 | 13 | 65,388 |
Tags: dfs and similar, dp, greedy, trees, two pointers
Correct Solution:
```
import sys
T=int(sys.stdin.readline().strip())
#T=1
def dfs(x, h, fa):
stack_queue=[]
stack_queue.append((x,h,fa,0, 0))
while (len(stack_queue)>0) :
now=stack_queue.pop()
x,h,fa,r, idone=now
#print (x,r,idone,fa,stack_queue)
if... | output | 1 | 32,694 | 13 | 65,389 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There is an undirected tree of n vertices, connected by n-1 bidirectional edges. There is also a snake stuck inside of this tree. Its head is at vertex a and its tail is at vertex b. The snake's body occupies all vertices on the unique simpl... | instruction | 0 | 32,695 | 13 | 65,390 |
Tags: dfs and similar, dp, greedy, trees, two pointers
Correct Solution:
```
import sys
T=int(sys.stdin.readline().strip())
while T>0:
T-=1
n, st, en = sys.stdin.readline().strip().split(" ")
n=int(n)
st=int(st)
en=int(en)
d=[[0,0,0]]
height=[0]
#d[n]=[0,0,0] #深度, 最深
e={}
flag=[]
maxson=[-1]
target... | output | 1 | 32,695 | 13 | 65,391 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is an undirected tree of n vertices, connected by n-1 bidirectional edges. There is also a snake stuck inside of this tree. Its head is at vertex a and its tail is at vertex b. The snake's... | instruction | 0 | 32,696 | 13 | 65,392 |
No | output | 1 | 32,696 | 13 | 65,393 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is an undirected tree of n vertices, connected by n-1 bidirectional edges. There is also a snake stuck inside of this tree. Its head is at vertex a and its tail is at vertex b. The snake's... | instruction | 0 | 32,697 | 13 | 65,394 |
No | output | 1 | 32,697 | 13 | 65,395 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is an undirected tree of n vertices, connected by n-1 bidirectional edges. There is also a snake stuck inside of this tree. Its head is at vertex a and its tail is at vertex b. The snake's... | instruction | 0 | 32,698 | 13 | 65,396 |
No | output | 1 | 32,698 | 13 | 65,397 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is an undirected tree of n vertices, connected by n-1 bidirectional edges. There is also a snake stuck inside of this tree. Its head is at vertex a and its tail is at vertex b. The snake's... | instruction | 0 | 32,699 | 13 | 65,398 |
No | output | 1 | 32,699 | 13 | 65,399 |
Provide tags and a correct Python 3 solution for this coding contest problem.
For a given sequence of distinct non-negative integers (b_1, b_2, ..., b_k) we determine if it is good in the following way:
* Consider a graph on k nodes, with numbers from b_1 to b_k written on them.
* For every i from 1 to k: find su... | instruction | 0 | 32,719 | 13 | 65,438 |
Tags: binary search, bitmasks, data structures, divide and conquer, dp, trees
Correct Solution:
```
#Chaitanya Bhutada
see = [1]
for i in range(41):
see.append(see[-1]*2)
def func(arr, num):
if num == 0:
return len(arr)
if len(arr) == 1:
return 1
arr1, arr2 = [], [] # arr1 msb is 1... | output | 1 | 32,719 | 13 | 65,439 |
Provide tags and a correct Python 3 solution for this coding contest problem.
For a given sequence of distinct non-negative integers (b_1, b_2, ..., b_k) we determine if it is good in the following way:
* Consider a graph on k nodes, with numbers from b_1 to b_k written on them.
* For every i from 1 to k: find su... | instruction | 0 | 32,720 | 13 | 65,440 |
Tags: binary search, bitmasks, data structures, divide and conquer, dp, trees
Correct Solution:
```
import sys
input = sys.stdin.buffer.readline
n = int(input())
a = list(map(int,input().split()))
dp = {a[i]:1 for i in range(n)}
for i in range(30):
next = {}
for val in dp:
if not val>>1 in next:
... | output | 1 | 32,720 | 13 | 65,441 |
Provide tags and a correct Python 3 solution for this coding contest problem.
For a given sequence of distinct non-negative integers (b_1, b_2, ..., b_k) we determine if it is good in the following way:
* Consider a graph on k nodes, with numbers from b_1 to b_k written on them.
* For every i from 1 to k: find su... | instruction | 0 | 32,721 | 13 | 65,442 |
Tags: binary search, bitmasks, data structures, divide and conquer, dp, trees
Correct Solution:
```
def main():
n = int(input())
a = [int(word) for word in input().rstrip().split()]
x = max(a)
arr = {}
for num in a:
arr[num] = 1
ans = 0
while True:
x >>= 1
dp = {}
... | output | 1 | 32,721 | 13 | 65,443 |
Provide tags and a correct Python 3 solution for this coding contest problem.
For a given sequence of distinct non-negative integers (b_1, b_2, ..., b_k) we determine if it is good in the following way:
* Consider a graph on k nodes, with numbers from b_1 to b_k written on them.
* For every i from 1 to k: find su... | instruction | 0 | 32,722 | 13 | 65,444 |
Tags: binary search, bitmasks, data structures, divide and conquer, dp, trees
Correct Solution:
```
import sys
from collections import defaultdict
import sys
import os
from io import BytesIO, IOBase
#Fast IO Region
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = f... | output | 1 | 32,722 | 13 | 65,445 |
Provide tags and a correct Python 3 solution for this coding contest problem.
For a given sequence of distinct non-negative integers (b_1, b_2, ..., b_k) we determine if it is good in the following way:
* Consider a graph on k nodes, with numbers from b_1 to b_k written on them.
* For every i from 1 to k: find su... | instruction | 0 | 32,723 | 13 | 65,446 |
Tags: binary search, bitmasks, data structures, divide and conquer, dp, trees
Correct Solution:
```
n = int(input());a = sorted([int(x) for x in input().split()])
def solve(l, bit):
if len(l) <= 1: return 0
if bit == 0: return 0
high = [x ^ (1 << bit) for x in l if x & (1 << bit)];low = [x for x in l if not x & (1... | output | 1 | 32,723 | 13 | 65,447 |
Provide tags and a correct Python 3 solution for this coding contest problem.
For a given sequence of distinct non-negative integers (b_1, b_2, ..., b_k) we determine if it is good in the following way:
* Consider a graph on k nodes, with numbers from b_1 to b_k written on them.
* For every i from 1 to k: find su... | instruction | 0 | 32,724 | 13 | 65,448 |
Tags: binary search, bitmasks, data structures, divide and conquer, dp, trees
Correct Solution:
```
import io
import os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
def costs(l, bit = 32):
if len(l) <= 2:
return 0
left = []
right = []
for el in l:
if el & (1<<bit):... | output | 1 | 32,724 | 13 | 65,449 |
Provide tags and a correct Python 3 solution for this coding contest problem.
For a given sequence of distinct non-negative integers (b_1, b_2, ..., b_k) we determine if it is good in the following way:
* Consider a graph on k nodes, with numbers from b_1 to b_k written on them.
* For every i from 1 to k: find su... | instruction | 0 | 32,725 | 13 | 65,450 |
Tags: binary search, bitmasks, data structures, divide and conquer, dp, trees
Correct Solution:
```
# according to editorial
import math
# def binary_search(l, target): // this has not been tested
# # returns index i such that l[j] < target iff j < i
# if l[0] >= target:
# return 0
# if l[-1] < t... | output | 1 | 32,725 | 13 | 65,451 |
Provide tags and a correct Python 3 solution for this coding contest problem.
For a given sequence of distinct non-negative integers (b_1, b_2, ..., b_k) we determine if it is good in the following way:
* Consider a graph on k nodes, with numbers from b_1 to b_k written on them.
* For every i from 1 to k: find su... | instruction | 0 | 32,726 | 13 | 65,452 |
Tags: binary search, bitmasks, data structures, divide and conquer, dp, trees
Correct Solution:
```
import os
import sys
from io import BytesIO, IOBase
# region fastio
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
... | output | 1 | 32,726 | 13 | 65,453 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
For a given sequence of distinct non-negative integers (b_1, b_2, ..., b_k) we determine if it is good in the following way:
* Consider a graph on k nodes, with numbers from b_1 to b_k writte... | instruction | 0 | 32,727 | 13 | 65,454 |
Yes | output | 1 | 32,727 | 13 | 65,455 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
For a given sequence of distinct non-negative integers (b_1, b_2, ..., b_k) we determine if it is good in the following way:
* Consider a graph on k nodes, with numbers from b_1 to b_k writte... | instruction | 0 | 32,728 | 13 | 65,456 |
Yes | output | 1 | 32,728 | 13 | 65,457 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
For a given sequence of distinct non-negative integers (b_1, b_2, ..., b_k) we determine if it is good in the following way:
* Consider a graph on k nodes, with numbers from b_1 to b_k writte... | instruction | 0 | 32,729 | 13 | 65,458 |
Yes | output | 1 | 32,729 | 13 | 65,459 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
For a given sequence of distinct non-negative integers (b_1, b_2, ..., b_k) we determine if it is good in the following way:
* Consider a graph on k nodes, with numbers from b_1 to b_k writte... | instruction | 0 | 32,730 | 13 | 65,460 |
Yes | output | 1 | 32,730 | 13 | 65,461 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
For a given sequence of distinct non-negative integers (b_1, b_2, ..., b_k) we determine if it is good in the following way:
* Consider a graph on k nodes, with numbers from b_1 to b_k writte... | instruction | 0 | 32,731 | 13 | 65,462 |
No | output | 1 | 32,731 | 13 | 65,463 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
For a given sequence of distinct non-negative integers (b_1, b_2, ..., b_k) we determine if it is good in the following way:
* Consider a graph on k nodes, with numbers from b_1 to b_k writte... | instruction | 0 | 32,732 | 13 | 65,464 |
No | output | 1 | 32,732 | 13 | 65,465 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
For a given sequence of distinct non-negative integers (b_1, b_2, ..., b_k) we determine if it is good in the following way:
* Consider a graph on k nodes, with numbers from b_1 to b_k writte... | instruction | 0 | 32,733 | 13 | 65,466 |
No | output | 1 | 32,733 | 13 | 65,467 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
For a given sequence of distinct non-negative integers (b_1, b_2, ..., b_k) we determine if it is good in the following way:
* Consider a graph on k nodes, with numbers from b_1 to b_k writte... | instruction | 0 | 32,734 | 13 | 65,468 |
No | output | 1 | 32,734 | 13 | 65,469 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a bipartite graph G = (U, V, E), U is the set of vertices of the first part, V is the set of vertices of the second part and E is the set of edges. There might be multiple edges.
... | instruction | 0 | 33,109 | 13 | 66,218 |
No | output | 1 | 33,109 | 13 | 66,219 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a bipartite graph G = (U, V, E), U is the set of vertices of the first part, V is the set of vertices of the second part and E is the set of edges. There might be multiple edges.
... | instruction | 0 | 33,110 | 13 | 66,220 |
No | output | 1 | 33,110 | 13 | 66,221 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a bipartite graph G = (U, V, E), U is the set of vertices of the first part, V is the set of vertices of the second part and E is the set of edges. There might be multiple edges.
... | instruction | 0 | 33,111 | 13 | 66,222 |
No | output | 1 | 33,111 | 13 | 66,223 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a bipartite graph G = (U, V, E), U is the set of vertices of the first part, V is the set of vertices of the second part and E is the set of edges. There might be multiple edges.
... | instruction | 0 | 33,112 | 13 | 66,224 |
No | output | 1 | 33,112 | 13 | 66,225 |
Provide a correct Python 3 solution for this coding contest problem.
We have an undirected weighted graph with N vertices and M edges. The i-th edge in the graph connects Vertex U_i and Vertex V_i, and has a weight of W_i. Additionally, you are given an integer X.
Find the number of ways to paint each edge in this gr... | instruction | 0 | 34,098 | 13 | 68,196 |
"Correct Solution:
```
import sys
input=sys.stdin.readline
def find_parent(x):
y=parent[x]
if y<0:
return x
parent[x]=find_parent(y)
return parent[x]
def connect(a,b):
c=find_parent(a)
d=find_parent(b)
if c==d:
return
if parent[c]<parent[d]:
parent[c]+=parent[d]... | output | 1 | 34,098 | 13 | 68,197 |
Provide a correct Python 3 solution for this coding contest problem.
We have an undirected weighted graph with N vertices and M edges. The i-th edge in the graph connects Vertex U_i and Vertex V_i, and has a weight of W_i. Additionally, you are given an integer X.
Find the number of ways to paint each edge in this gr... | instruction | 0 | 34,099 | 13 | 68,198 |
"Correct Solution:
```
import sys
from bisect import *
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
def main():
md = 10 ** 9 + 7
def get_group(k):
g = pd[k]
if g < 0:
return k
gg = get_group(g)
pd[k] = gg
return gg
def merge(j, k):
... | output | 1 | 34,099 | 13 | 68,199 |
Provide a correct Python 3 solution for this coding contest problem.
We have an undirected weighted graph with N vertices and M edges. The i-th edge in the graph connects Vertex U_i and Vertex V_i, and has a weight of W_i. Additionally, you are given an integer X.
Find the number of ways to paint each edge in this gr... | instruction | 0 | 34,100 | 13 | 68,200 |
"Correct Solution:
```
"""
https://atcoder.jp/contests/arc093/tasks/arc093_c
各辺を含む最小全域木を考える
→重みがX未満なら、その全域木に含まれる辺は全て同一色で塗る必要がある
全ての辺に対してやれば十分?
→ではない
むしろ、X未満の全域木となった辺すべて同一色で塗る必要がある?
辺A,Bを含む全域偽は重みがX未満だが、同一色で塗る必要がないとする
→AとBの最小全域木は共有辺を一切持たない
A,Bを二つの頂点集合に分ける。頂点集合間は、別の辺l,Lで結ばれている
元の辺を除いた重みの輪を a,bとすると、 a+l < X b+L < X で... | output | 1 | 34,100 | 13 | 68,201 |
Provide a correct Python 3 solution for this coding contest problem.
We have an undirected weighted graph with N vertices and M edges. The i-th edge in the graph connects Vertex U_i and Vertex V_i, and has a weight of W_i. Additionally, you are given an integer X.
Find the number of ways to paint each edge in this gr... | instruction | 0 | 34,101 | 13 | 68,202 |
"Correct Solution:
```
import sys
mod = 10 ** 9 + 7
sys.setrecursionlimit(mod)
input = sys.stdin.readline
def root(v):
if v == par[v]:
return v
par[v] = root(par[v])
return par[v]
def unite(u, v):
u = root(u)
v = root(v)
if u == v:
return
if rank[u] < rank[v]:
u, v ... | output | 1 | 34,101 | 13 | 68,203 |
Provide a correct Python 3 solution for this coding contest problem.
We have an undirected weighted graph with N vertices and M edges. The i-th edge in the graph connects Vertex U_i and Vertex V_i, and has a weight of W_i. Additionally, you are given an integer X.
Find the number of ways to paint each edge in this gr... | instruction | 0 | 34,102 | 13 | 68,204 |
"Correct Solution:
```
import sys
from operator import itemgetter
readline = sys.stdin.readline
sys.setrecursionlimit(2*10**6)
class UF():
def __init__(self, num):
self.par = [-1]*num
self.size = [1]*num
def find(self, x):
if self.par[x] < 0:
return x
else:
... | output | 1 | 34,102 | 13 | 68,205 |
Provide a correct Python 3 solution for this coding contest problem.
We have an undirected weighted graph with N vertices and M edges. The i-th edge in the graph connects Vertex U_i and Vertex V_i, and has a weight of W_i. Additionally, you are given an integer X.
Find the number of ways to paint each edge in this gr... | instruction | 0 | 34,103 | 13 | 68,206 |
"Correct Solution:
```
N, M = map(int, input().split())
X = int(input())
E = []
C = {}
for i in range(M):
u, v, w = map(int, input().split())
E.append((w, u-1, v-1))
C[w] = C.get(w, 0) + 1
E.sort()
*p, = range(N)
def root(x):
if x == p[x]:
return x
y = p[x] = root(p[x])
return y
def uni... | output | 1 | 34,103 | 13 | 68,207 |
Provide a correct Python 3 solution for this coding contest problem.
We have an undirected weighted graph with N vertices and M edges. The i-th edge in the graph connects Vertex U_i and Vertex V_i, and has a weight of W_i. Additionally, you are given an integer X.
Find the number of ways to paint each edge in this gr... | instruction | 0 | 34,104 | 13 | 68,208 |
"Correct Solution:
```
N, M = map(int, input().split())
X = int(input())
E = []
C = {}
for i in range(M):
u, v, w = map(int, input().split())
E.append((w, u-1, v-1))
C[w] = C.get(w, 0) + 1
E.sort()
*p, = range(N)
def root(x):
if x == p[x]:
return x
y = p[x] = root(p[x])
return y
def uni... | output | 1 | 34,104 | 13 | 68,209 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.