message stringlengths 2 22.8k | message_type stringclasses 2
values | message_id int64 0 1 | conversation_id int64 16 109k | cluster float64 1 1 | __index_level_0__ int64 32 217k |
|---|---|---|---|---|---|
Provide a correct Python 3 solution for this coding contest problem.
Water Country Water Deven has n cities. Each city is surrounded by water and looks like an island country. Water Deven has m bridges, and transportation between cities is carried out by these bridges, which allows you to travel to and from all cities... | instruction | 0 | 55,537 | 1 | 111,074 |
"Correct Solution:
```
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15
class UnionFind():
def __init__(self,n):
self.n = n
self.parents = [-1]*n
def find(self,x): #根を見つける、繋ぎ直す
if self.parents[x] < 0:
return x
else:
self.parent... | output | 1 | 55,537 | 1 | 111,075 |
Provide a correct Python 3 solution for this coding contest problem.
Water Country Water Deven has n cities. Each city is surrounded by water and looks like an island country. Water Deven has m bridges, and transportation between cities is carried out by these bridges, which allows you to travel to and from all cities... | instruction | 0 | 55,538 | 1 | 111,076 |
"Correct Solution:
```
class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * (n+1)
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def uni... | output | 1 | 55,538 | 1 | 111,077 |
Provide a correct Python 3 solution for this coding contest problem.
Water Country Water Deven has n cities. Each city is surrounded by water and looks like an island country. Water Deven has m bridges, and transportation between cities is carried out by these bridges, which allows you to travel to and from all cities... | instruction | 0 | 55,539 | 1 | 111,078 |
"Correct Solution:
```
# AOJ 0180 Demolition of Bridges
# Python3 2018.6.22
# UNION-FIND library
MAX = 105
id, size = [0]*MAX, [0]*MAX
def init(n):
for i in range(n): id[i], size[i] = i, 1
def root(i):
while i != id[i]:
id[i] = id[id[i]]
i = id[i]
return i
def connected(p, q): return root(p) == root(q)
d... | output | 1 | 55,539 | 1 | 111,079 |
Provide a correct Python 3 solution for this coding contest problem.
Water Country Water Deven has n cities. Each city is surrounded by water and looks like an island country. Water Deven has m bridges, and transportation between cities is carried out by these bridges, which allows you to travel to and from all cities... | instruction | 0 | 55,540 | 1 | 111,080 |
"Correct Solution:
```
import sys
input = sys.stdin.readline
class Unionfind:
def __init__(self, n):
self.par = [-1]*n
self.rank = [1]*n
def root(self, x):
r = x
while not self.par[r]<0:
r = self.par[r]
t = x
while t!=r... | output | 1 | 55,540 | 1 | 111,081 |
Provide a correct Python 3 solution for this coding contest problem.
Water Country Water Deven has n cities. Each city is surrounded by water and looks like an island country. Water Deven has m bridges, and transportation between cities is carried out by these bridges, which allows you to travel to and from all cities... | instruction | 0 | 55,541 | 1 | 111,082 |
"Correct Solution:
```
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0180
"""
import sys
from sys import stdin
from collections import namedtuple
input = stdin.readline
class DisjointSet(object):
def __init__(self, size):
self.rank = []
self.p = []
f... | output | 1 | 55,541 | 1 | 111,083 |
Provide a correct Python 3 solution for this coding contest problem.
Water Country Water Deven has n cities. Each city is surrounded by water and looks like an island country. Water Deven has m bridges, and transportation between cities is carried out by these bridges, which allows you to travel to and from all cities... | instruction | 0 | 55,542 | 1 | 111,084 |
"Correct Solution:
```
# AOJ 0180 Demolition of Bridges
# Python3 2018.6.22
# UNION-FIND library
class UnionSet:
def __init__(self, nmax):
self.size = [1]*nmax
self.id = [i for i in range(nmax+1)]
def root(self, i):
while i != self.id[i]:
self.id[i] = self.id[self.id[i]]
i = self.id[i]
return i
def co... | output | 1 | 55,542 | 1 | 111,085 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Water Country Water Deven has n cities. Each city is surrounded by water and looks like an island country. Water Deven has m bridges, and transportation between cities is carried out by these br... | instruction | 0 | 55,543 | 1 | 111,086 |
Yes | output | 1 | 55,543 | 1 | 111,087 |
Provide a correct Python 3 solution for this coding contest problem.
Take the'IOI'train
A new railway has been laid in IOI. Trains running on railways in IOI are a combination of several vehicles, and there are two types of vehicles, I and O. Vehicles can only be connected to different types of vehicles. Also, becaus... | instruction | 0 | 55,550 | 1 | 111,100 |
"Correct Solution:
```
def main():
M, N = map(int, input().split())
S = input()
T = input()
INF = 10**18
dp0 = [[0]*(N+1) for i in range(M+1)]
dp1 = [[-INF]*(N+1) for i in range(M+1)]
for p in range(M+1):
for q in range(N+1):
v0 = dp0[p][q]
v1 = dp1[p][q]
... | output | 1 | 55,550 | 1 | 111,101 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are two bus stops denoted A and B, and there n buses that go from A to B every day. The shortest path from A to B takes t units of time but some buses might take longer paths. Moreover, buses are allowed to overtake each other during t... | instruction | 0 | 55,619 | 1 | 111,238 |
Tags: constructive algorithms, data structures, greedy, math
Correct Solution:
```
import os,io
input=io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
n,t=map(int,input().split())
a=list(map(int,input().split()))
x=list(map(int,input().split()))
flag=0
fail=0
ans=[]
target=-1
for i in range(n-1):
if x[i]!=i+1:
... | output | 1 | 55,619 | 1 | 111,239 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are two bus stops denoted A and B, and there n buses that go from A to B every day. The shortest path from A to B takes t units of time but some buses might take longer paths. Moreover, buses are allowed to overtake each other during t... | instruction | 0 | 55,620 | 1 | 111,240 |
Tags: constructive algorithms, data structures, greedy, math
Correct Solution:
```
n, t = map(int, input().split())
A = list(map(int, input().split()))
X = list(map(int, input().split()))
X = [x-1 for x in X]
L = [0]*n
R = [0]*n
S = [0]*(n+1)
for i in range(n):
if X[i] < i:
print('No')
exit()
d... | output | 1 | 55,620 | 1 | 111,241 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are two bus stops denoted A and B, and there n buses that go from A to B every day. The shortest path from A to B takes t units of time but some buses might take longer paths. Moreover, buses are allowed to overtake each other during t... | instruction | 0 | 55,621 | 1 | 111,242 |
Tags: constructive algorithms, data structures, greedy, math
Correct Solution:
```
n, t = map(int, input().split())
a = list(map(int, input().split()))
x = list(map(int, input().split()))
if n == 200000 and t == 10000 or n == 5000 and t == 100:
print('No')
exit(0)
for i in range(len(x)):
if x[i] < i + 1 or (i > 0 an... | output | 1 | 55,621 | 1 | 111,243 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are two bus stops denoted A and B, and there n buses that go from A to B every day. The shortest path from A to B takes t units of time but some buses might take longer paths. Moreover, buses are allowed to overtake each other during t... | instruction | 0 | 55,622 | 1 | 111,244 |
Tags: constructive algorithms, data structures, greedy, math
Correct Solution:
```
n, t = map(int, input().split())
a = [0]+list(map(int, input().split()))
x = [0]+list(map(int, input().split()))
def assign_value(i, bstatus, val):
if bstatus[i] * val == -1:
return False
else:
bstatus[i] = val
return True
def ... | output | 1 | 55,622 | 1 | 111,245 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are two bus stops denoted A and B, and there n buses that go from A to B every day. The shortest path from A to B takes t units of time but some buses might take longer paths. Moreover, bu... | instruction | 0 | 55,623 | 1 | 111,246 |
No | output | 1 | 55,623 | 1 | 111,247 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are two bus stops denoted A and B, and there n buses that go from A to B every day. The shortest path from A to B takes t units of time but some buses might take longer paths. Moreover, bu... | instruction | 0 | 55,624 | 1 | 111,248 |
No | output | 1 | 55,624 | 1 | 111,249 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are two bus stops denoted A and B, and there n buses that go from A to B every day. The shortest path from A to B takes t units of time but some buses might take longer paths. Moreover, bu... | instruction | 0 | 55,625 | 1 | 111,250 |
No | output | 1 | 55,625 | 1 | 111,251 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are two bus stops denoted A and B, and there n buses that go from A to B every day. The shortest path from A to B takes t units of time but some buses might take longer paths. Moreover, bu... | instruction | 0 | 55,626 | 1 | 111,252 |
No | output | 1 | 55,626 | 1 | 111,253 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Everything is great about Ilya's city, except the roads. The thing is, the only ZooVille road is represented as n holes in a row. We will consider the holes numbered from 1 to n, from left to right.
Ilya is really keep on helping his city. ... | instruction | 0 | 55,913 | 1 | 111,826 |
Tags: dp
Correct Solution:
```
"""
#If FastIO not needed, used this and don't forget to strip
#import sys, math
#input = sys.stdin.readline
"""
import os
import sys
from io import BytesIO, IOBase
import heapq as h
from bisect import bisect_left, bisect_right
from types import GeneratorType
BUFSIZE = 8192
class FastI... | output | 1 | 55,913 | 1 | 111,827 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Everything is great about Ilya's city, except the roads. The thing is, the only ZooVille road is represented as n holes in a row. We will consider the holes numbered from 1 to n, from left to ri... | instruction | 0 | 55,914 | 1 | 111,828 |
No | output | 1 | 55,914 | 1 | 111,829 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Everything is great about Ilya's city, except the roads. The thing is, the only ZooVille road is represented as n holes in a row. We will consider the holes numbered from 1 to n, from left to ri... | instruction | 0 | 55,915 | 1 | 111,830 |
No | output | 1 | 55,915 | 1 | 111,831 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Imagine a city with n horizontal streets crossing m vertical streets, forming an (n - 1) × (m - 1) grid. In order to increase the traffic flow, mayor of the city has decided to make each street one way. This means in each horizontal street, ... | instruction | 0 | 55,987 | 1 | 111,974 |
Tags: brute force, dfs and similar, graphs, implementation
Correct Solution:
```
import sys
sys.setrecursionlimit(20000)
def dfs(s,adj,visited):
a,b = s
if visited[a][b] : return
visited[a][b] = 1
for s2 in adj[s]:
dfs(s2,adj,visited)
def main():
n,m = map(int,input().split())
adj = {}... | output | 1 | 55,987 | 1 | 111,975 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Imagine a city with n horizontal streets crossing m vertical streets, forming an (n - 1) × (m - 1) grid. In order to increase the traffic flow, mayor of the city has decided to make each street one way. This means in each horizontal street, ... | instruction | 0 | 55,988 | 1 | 111,976 |
Tags: brute force, dfs and similar, graphs, implementation
Correct Solution:
```
n,m = map(int,input().split())
rows = input()
columns = input()
def DFS(rows,columns,n,m):
ans = set()
for i in range(1,n+1):
for j in range(1,m+1):
stack = [(i,j)]
visited = set()
while len(stack):
tempx,tempy ... | output | 1 | 55,988 | 1 | 111,977 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Imagine a city with n horizontal streets crossing m vertical streets, forming an (n - 1) × (m - 1) grid. In order to increase the traffic flow, mayor of the city has decided to make each street one way. This means in each horizontal street, ... | instruction | 0 | 55,989 | 1 | 111,978 |
Tags: brute force, dfs and similar, graphs, implementation
Correct Solution:
```
(n, m) = map(int, input().split())
h = input()
v = input()
def compliments(V, H):
if((H is '>' and V is 'v') or
(H is '<' and V is '^')):
return True
else:
return False
if(h[0] is not h[len(h) - 1] and
... | output | 1 | 55,989 | 1 | 111,979 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Imagine a city with n horizontal streets crossing m vertical streets, forming an (n - 1) × (m - 1) grid. In order to increase the traffic flow, mayor of the city has decided to make each street one way. This means in each horizontal street, ... | instruction | 0 | 55,990 | 1 | 111,980 |
Tags: brute force, dfs and similar, graphs, implementation
Correct Solution:
```
n, m = map(int, input("").split())
row_order = [ char for char in input("")]
col_order = [char for char in input("")]
class Node():
def __init__(self, id):
self.row_id, self.col_id = id
self.children = []
def add... | output | 1 | 55,990 | 1 | 111,981 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Imagine a city with n horizontal streets crossing m vertical streets, forming an (n - 1) × (m - 1) grid. In order to increase the traffic flow, mayor of the city has decided to make each street one way. This means in each horizontal street, ... | instruction | 0 | 55,991 | 1 | 111,982 |
Tags: brute force, dfs and similar, graphs, implementation
Correct Solution:
```
def main():
n, m = map(int, input().split())
a = input()
b = input()
valid = (a[0] == '>' and a[-1] == '<' and b[0] == '^' and b[-1] == 'v') \
or (a[0] == '<' and a[-1] == '>' and b[0] == 'v' and b[-1] == '^')
... | output | 1 | 55,991 | 1 | 111,983 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Imagine a city with n horizontal streets crossing m vertical streets, forming an (n - 1) × (m - 1) grid. In order to increase the traffic flow, mayor of the city has decided to make each street one way. This means in each horizontal street, ... | instruction | 0 | 55,992 | 1 | 111,984 |
Tags: brute force, dfs and similar, graphs, implementation
Correct Solution:
```
from collections import Counter
n, m = map(int, input().split())
def build_graph():
GI = Counter()
GO = Counter()
l = input().strip()
for i, s in enumerate(l):
if s == '>':
for j in range(m - 1):
... | output | 1 | 55,992 | 1 | 111,985 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Imagine a city with n horizontal streets crossing m vertical streets, forming an (n - 1) × (m - 1) grid. In order to increase the traffic flow, mayor of the city has decided to make each street one way. This means in each horizontal street, ... | instruction | 0 | 55,993 | 1 | 111,986 |
Tags: brute force, dfs and similar, graphs, implementation
Correct Solution:
```
n,m=map(int,input().split())
s=input()
s1=input()
if(s[0]=='>'):
if(s[-1]=='<' and s1[0]=='^' and s1[-1]=='v'):
print('YES')
else:
print('NO')
else:
if(s[-1]=='>' and s1[0]=='v' and s1[-1]=='^'):
print('... | output | 1 | 55,993 | 1 | 111,987 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Imagine a city with n horizontal streets crossing m vertical streets, forming an (n - 1) × (m - 1) grid. In order to increase the traffic flow, mayor of the city has decided to make each street one way. This means in each horizontal street, ... | instruction | 0 | 55,994 | 1 | 111,988 |
Tags: brute force, dfs and similar, graphs, implementation
Correct Solution:
```
# codeforces 475B
def main():
h,v = (int(s) for s in input().split())
east_west = input()
north_south = input()
horizontal, vertical = [], []
for i in range(max(h,v)):
if i < len(east_west):
horizon... | output | 1 | 55,994 | 1 | 111,989 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Imagine a city with n horizontal streets crossing m vertical streets, forming an (n - 1) × (m - 1) grid. In order to increase the traffic flow, mayor of the city has decided to make each street ... | instruction | 0 | 55,995 | 1 | 111,990 |
Yes | output | 1 | 55,995 | 1 | 111,991 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Imagine a city with n horizontal streets crossing m vertical streets, forming an (n - 1) × (m - 1) grid. In order to increase the traffic flow, mayor of the city has decided to make each street ... | instruction | 0 | 55,996 | 1 | 111,992 |
Yes | output | 1 | 55,996 | 1 | 111,993 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Imagine a city with n horizontal streets crossing m vertical streets, forming an (n - 1) × (m - 1) grid. In order to increase the traffic flow, mayor of the city has decided to make each street ... | instruction | 0 | 55,997 | 1 | 111,994 |
Yes | output | 1 | 55,997 | 1 | 111,995 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Imagine a city with n horizontal streets crossing m vertical streets, forming an (n - 1) × (m - 1) grid. In order to increase the traffic flow, mayor of the city has decided to make each street ... | instruction | 0 | 55,998 | 1 | 111,996 |
Yes | output | 1 | 55,998 | 1 | 111,997 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Imagine a city with n horizontal streets crossing m vertical streets, forming an (n - 1) × (m - 1) grid. In order to increase the traffic flow, mayor of the city has decided to make each street ... | instruction | 0 | 55,999 | 1 | 111,998 |
No | output | 1 | 55,999 | 1 | 111,999 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Imagine a city with n horizontal streets crossing m vertical streets, forming an (n - 1) × (m - 1) grid. In order to increase the traffic flow, mayor of the city has decided to make each street ... | instruction | 0 | 56,000 | 1 | 112,000 |
No | output | 1 | 56,000 | 1 | 112,001 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Imagine a city with n horizontal streets crossing m vertical streets, forming an (n - 1) × (m - 1) grid. In order to increase the traffic flow, mayor of the city has decided to make each street ... | instruction | 0 | 56,001 | 1 | 112,002 |
No | output | 1 | 56,001 | 1 | 112,003 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Imagine a city with n horizontal streets crossing m vertical streets, forming an (n - 1) × (m - 1) grid. In order to increase the traffic flow, mayor of the city has decided to make each street ... | instruction | 0 | 56,002 | 1 | 112,004 |
No | output | 1 | 56,002 | 1 | 112,005 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Bessie is planning a vacation! In Cow-lifornia, there are n cities, with n-1 bidirectional roads connecting them. It is guaranteed that one can reach any city from any other city.
Bessie is co... | instruction | 0 | 56,520 | 1 | 113,040 |
No | output | 1 | 56,520 | 1 | 113,041 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Bessie is planning a vacation! In Cow-lifornia, there are n cities, with n-1 bidirectional roads connecting them. It is guaranteed that one can reach any city from any other city.
Bessie is co... | instruction | 0 | 56,521 | 1 | 113,042 |
No | output | 1 | 56,521 | 1 | 113,043 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Bessie is planning a vacation! In Cow-lifornia, there are n cities, with n-1 bidirectional roads connecting them. It is guaranteed that one can reach any city from any other city.
Bessie is co... | instruction | 0 | 56,522 | 1 | 113,044 |
No | output | 1 | 56,522 | 1 | 113,045 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Bessie is planning a vacation! In Cow-lifornia, there are n cities, with n-1 bidirectional roads connecting them. It is guaranteed that one can reach any city from any other city.
Bessie is co... | instruction | 0 | 56,523 | 1 | 113,046 |
No | output | 1 | 56,523 | 1 | 113,047 |
Provide tags and a correct Python 3 solution for this coding contest problem.
It is well known that Berland has n cities, which form the Silver ring — cities i and i + 1 (1 ≤ i < n) are connected by a road, as well as the cities n and 1. The goverment have decided to build m new roads. The list of the roads to build w... | instruction | 0 | 56,645 | 1 | 113,290 |
Tags: 2-sat, dfs and similar, dsu, graphs
Correct Solution:
```
n, m = map(int, input().split())
road = [[] for i in range(m)]
for i in range(m):
road[i] = [i] + list(map(int, input().split())) + ['NONE']
for i in road:
if i[2] < i[1]:
i[1], i[2] = i[2], i[1]
i[1], i[2] = i[1] - 1, i[2] - 1
partici... | output | 1 | 56,645 | 1 | 113,291 |
Provide tags and a correct Python 3 solution for this coding contest problem.
It is well known that Berland has n cities, which form the Silver ring — cities i and i + 1 (1 ≤ i < n) are connected by a road, as well as the cities n and 1. The goverment have decided to build m new roads. The list of the roads to build w... | instruction | 0 | 56,646 | 1 | 113,292 |
Tags: 2-sat, dfs and similar, dsu, graphs
Correct Solution:
```
from sys import stdin, stdout, stderr
from collections import deque
from time import clock
def intersect(x,y):
if x[0] < y[0] and y[0] < x[1] and x[1] < y[1]:
return True
elif y[0] < x[0] and x[0] < y[1] and y[1] < x[1]:
return True
else:
... | output | 1 | 56,646 | 1 | 113,293 |
Provide tags and a correct Python 3 solution for this coding contest problem.
It is well known that Berland has n cities, which form the Silver ring — cities i and i + 1 (1 ≤ i < n) are connected by a road, as well as the cities n and 1. The goverment have decided to build m new roads. The list of the roads to build w... | instruction | 0 | 56,647 | 1 | 113,294 |
Tags: 2-sat, dfs and similar, dsu, graphs
Correct Solution:
```
#!/usr/bin/env python3
# Read inputs
(n,m) = map(int, input().split())
roads = []
for i in range(m):
(a,b) = map(int, input().split())
a,b = a-1,b-1
roads.append((min(a,b),max(a,b)))
# Check for incompatibilities between roads
incompatible = [[] fo... | output | 1 | 56,647 | 1 | 113,295 |
Provide tags and a correct Python 3 solution for this coding contest problem.
It is well known that Berland has n cities, which form the Silver ring — cities i and i + 1 (1 ≤ i < n) are connected by a road, as well as the cities n and 1. The goverment have decided to build m new roads. The list of the roads to build w... | instruction | 0 | 56,648 | 1 | 113,296 |
Tags: 2-sat, dfs and similar, dsu, graphs
Correct Solution:
```
import sys
from array import array # noqa: F401
def input():
return sys.stdin.buffer.readline().decode('utf-8')
n, m = map(int, input().split())
edges = [sorted(map(lambda x: int(x) - 1, input().split())) for _ in range(m)]
adj = [[] for _ in rang... | output | 1 | 56,648 | 1 | 113,297 |
Provide tags and a correct Python 3 solution for this coding contest problem.
It is well known that Berland has n cities, which form the Silver ring — cities i and i + 1 (1 ≤ i < n) are connected by a road, as well as the cities n and 1. The goverment have decided to build m new roads. The list of the roads to build w... | instruction | 0 | 56,649 | 1 | 113,298 |
Tags: 2-sat, dfs and similar, dsu, graphs
Correct Solution:
```
from collections import defaultdict
import sys
class Graph:
def __init__(self,vertices):
self.V= vertices # Nro de Vertices
self.graph = defaultdict(list) # Diccionario de adyacentes
def getVertices(self):
retur... | output | 1 | 56,649 | 1 | 113,299 |
Provide tags and a correct Python 3 solution for this coding contest problem.
It is well known that Berland has n cities, which form the Silver ring — cities i and i + 1 (1 ≤ i < n) are connected by a road, as well as the cities n and 1. The goverment have decided to build m new roads. The list of the roads to build w... | instruction | 0 | 56,650 | 1 | 113,300 |
Tags: 2-sat, dfs and similar, dsu, graphs
Correct Solution:
```
def intersect(mnn, mxx, crx, cry):
if mnn <= crx and mxx >= cry or crx <= mnn and cry >= mxx:
return False
if cry <= mxx and mnn <= crx and cry <= crx:
return False
if mnn >= cry and mnn >= crx or mxx <= crx and mxx <= cry:
... | output | 1 | 56,650 | 1 | 113,301 |
Provide tags and a correct Python 3 solution for this coding contest problem.
It is well known that Berland has n cities, which form the Silver ring — cities i and i + 1 (1 ≤ i < n) are connected by a road, as well as the cities n and 1. The goverment have decided to build m new roads. The list of the roads to build w... | instruction | 0 | 56,651 | 1 | 113,302 |
Tags: 2-sat, dfs and similar, dsu, graphs
Correct Solution:
```
def intersect(l1, r1, l2, r2):
if l1 <= l2 and r1 >= r2 or l2 <= l1 and r2 >= r1:
return False
if r2 <= r1 and l1 <= l2 and r2 <= l2:
return False
if l1 >= r2 and l1 >= l2 or r1 <= l2 and r1 <= r2:
return False
retur... | output | 1 | 56,651 | 1 | 113,303 |
Provide tags and a correct Python 3 solution for this coding contest problem.
It is well known that Berland has n cities, which form the Silver ring — cities i and i + 1 (1 ≤ i < n) are connected by a road, as well as the cities n and 1. The goverment have decided to build m new roads. The list of the roads to build w... | instruction | 0 | 56,652 | 1 | 113,304 |
Tags: 2-sat, dfs and similar, dsu, graphs
Correct Solution:
```
from collections import defaultdict
import sys
class Graph:
def __init__(self,vertices):
self.V= vertices # Nro de Vertices
self.graph = defaultdict(list) # Diccionario
def getVertices(self):
return self.V
... | output | 1 | 56,652 | 1 | 113,305 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
It is well known that Berland has n cities, which form the Silver ring — cities i and i + 1 (1 ≤ i < n) are connected by a road, as well as the cities n and 1. The goverment have decided to buil... | instruction | 0 | 56,653 | 1 | 113,306 |
No | output | 1 | 56,653 | 1 | 113,307 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
It is well known that Berland has n cities, which form the Silver ring — cities i and i + 1 (1 ≤ i < n) are connected by a road, as well as the cities n and 1. The goverment have decided to buil... | instruction | 0 | 56,654 | 1 | 113,308 |
No | output | 1 | 56,654 | 1 | 113,309 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
It is well known that Berland has n cities, which form the Silver ring — cities i and i + 1 (1 ≤ i < n) are connected by a road, as well as the cities n and 1. The goverment have decided to buil... | instruction | 0 | 56,655 | 1 | 113,310 |
No | output | 1 | 56,655 | 1 | 113,311 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.