message stringlengths 2 19.9k | message_type stringclasses 2
values | message_id int64 0 1 | conversation_id int64 322 108k | cluster float64 15 15 | __index_level_0__ int64 644 217k |
|---|---|---|---|---|---|
Provide tags and a correct Python 3 solution for this coding contest problem.
Bashar was practicing for the national programming contest. Because of sitting too much in front of the computer without doing physical movements and eating a lot Bashar became much fatter. Bashar is going to quit programming after the natio... | instruction | 0 | 98,009 | 15 | 196,018 |
Tags: constructive algorithms, graphs, implementation
Correct Solution:
```
# -*- coding: utf-8 -*-
import math
import collections
import bisect
import heapq
import time
import random
import itertools
import sys
from typing import List
"""
created by shhuan at 2020/3/23 11:04
"""
def solve(N, M, K):
if K > 4 *... | output | 1 | 98,009 | 15 | 196,019 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a matrix with n rows (numbered from 1 to n) and m columns (numbered from 1 to m). A number a_{i, j} is written in the cell belonging to the i-th row and the j-th column, each number is either 0 or 1.
A chip is initially in the... | instruction | 0 | 98,050 | 15 | 196,100 |
Tags: greedy, math
Correct Solution:
```
import sys
input = sys.stdin.readline
import math
############ ---- Input Functions ---- ############
def inp():
return(int(input()))
def inlt():
return(list(map(int,input().split())))
def insr():
s = input().strip()
return(list(s[:len(s)]))
def invr():
retu... | output | 1 | 98,050 | 15 | 196,101 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a matrix with n rows (numbered from 1 to n) and m columns (numbered from 1 to m). A number a_{i, j} is written in the cell belonging to the i-th row and the j-th column, each number is either 0 or 1.
A chip is initially in the... | instruction | 0 | 98,051 | 15 | 196,102 |
Tags: greedy, math
Correct Solution:
```
t = int(input())
for _ in range(t):
nm = list(map(int, input().split()))
n, m = nm
mat = []
for i in range(n):
mat.append(list(map(int, input().split()))[::-1])
res = 0
diags = []
for i in range(2 * max(n, m) - 1):
diag = []
f... | output | 1 | 98,051 | 15 | 196,103 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a matrix with n rows (numbered from 1 to n) and m columns (numbered from 1 to m). A number a_{i, j} is written in the cell belonging to the i-th row and the j-th column, each number is either 0 or 1.
A chip is initially in the... | instruction | 0 | 98,052 | 15 | 196,104 |
Tags: greedy, math
Correct Solution:
```
for _ in range(int(input())):
n,m=map(int,input().split())
l=[]
for i in range(n):
l.append(list(map(int,input().split())))
a1=[0]*(m+n-1)
a2=[0]*(m+n-1)
for i in range(n):
for j in range(m):
a2[i+j]+=1
for i in range(n):
... | output | 1 | 98,052 | 15 | 196,105 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a matrix with n rows (numbered from 1 to n) and m columns (numbered from 1 to m). A number a_{i, j} is written in the cell belonging to the i-th row and the j-th column, each number is either 0 or 1.
A chip is initially in the... | instruction | 0 | 98,053 | 15 | 196,106 |
Tags: greedy, math
Correct Solution:
```
for t in range(int(input())):
n, m = [int(x) for x in input().split()]
data = [(0, 0)] * (m + n - 1)
for i in range(n):
a = [int(x) for x in input().split()]
for j in range(m):
data[i + j] = (data[i + j][0] + 1, data[i + j][1] + a[j])
... | output | 1 | 98,053 | 15 | 196,107 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a matrix with n rows (numbered from 1 to n) and m columns (numbered from 1 to m). A number a_{i, j} is written in the cell belonging to the i-th row and the j-th column, each number is either 0 or 1.
A chip is initially in the... | instruction | 0 | 98,054 | 15 | 196,108 |
Tags: greedy, math
Correct Solution:
```
from sys import stdin
input = stdin.buffer.readline
for _ in range(int(input())):
n, m = map(int, input().split())
a = [[int(i) for i in input().split()] for j in range(n)]
s, l = [0] * (n + m - 2), [0] * (n + m - 2)
for i in range(n):
for j in range(m):
if i + j == n... | output | 1 | 98,054 | 15 | 196,109 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a matrix with n rows (numbered from 1 to n) and m columns (numbered from 1 to m). A number a_{i, j} is written in the cell belonging to the i-th row and the j-th column, each number is either 0 or 1.
A chip is initially in the... | instruction | 0 | 98,055 | 15 | 196,110 |
Tags: greedy, math
Correct Solution:
```
from sys import stdin
from collections import defaultdict as dd
from collections import deque as dq
import itertools as it
from math import sqrt, log, log2
from fractions import Fraction
t = int(input())
for _ in range(t):
n, m = map(int, input().split())
matrix = []
... | output | 1 | 98,055 | 15 | 196,111 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a matrix with n rows (numbered from 1 to n) and m columns (numbered from 1 to m). A number a_{i, j} is written in the cell belonging to the i-th row and the j-th column, each number is either 0 or 1.
A chip is initially in the... | instruction | 0 | 98,056 | 15 | 196,112 |
Tags: greedy, math
Correct Solution:
```
import sys
input=lambda: sys.stdin.readline().rstrip()
t=int(input())
for _ in range(t):
n,m=map(int,input().split())
Z=[0]*(n+m-1)
O=[0]*(n+m-1)
for i in range(n):
A=[int(j) for j in input().split()]
for j,a in enumerate(A):
if a==0:
Z[i+j]+=1
... | output | 1 | 98,056 | 15 | 196,113 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a matrix with n rows (numbered from 1 to n) and m columns (numbered from 1 to m). A number a_{i, j} is written in the cell belonging to the i-th row and the j-th column, each number is either 0 or 1.
A chip is initially in the... | instruction | 0 | 98,057 | 15 | 196,114 |
Tags: greedy, math
Correct Solution:
```
from sys import *
input = stdin.readline
for _ in range(int(input())):
n,m = map(int,input().split())
a = []
for _ in range(n):
b = list(map(int,input().split()))
a.append(b)
sn = 0
if(a[0][0] != a[n-1][m-1]):
sn += 1
... | output | 1 | 98,057 | 15 | 196,115 |
Provide tags and a correct Python 2 solution for this coding contest problem.
You are given a matrix with n rows (numbered from 1 to n) and m columns (numbered from 1 to m). A number a_{i, j} is written in the cell belonging to the i-th row and the j-th column, each number is either 0 or 1.
A chip is initially in the... | instruction | 0 | 98,058 | 15 | 196,116 |
Tags: greedy, math
Correct Solution:
```
from sys import stdin, stdout
from collections import Counter, defaultdict
from itertools import permutations, combinations
raw_input = stdin.readline
pr = stdout.write
mod=10**9+7
def ni():
return int(raw_input())
def li():
return map(int,raw_input().split())
def p... | output | 1 | 98,058 | 15 | 196,117 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a matrix with n rows (numbered from 1 to n) and m columns (numbered from 1 to m). A number a_{i, j} is written in the cell belonging to the i-th row and the j-th column, each numbe... | instruction | 0 | 98,059 | 15 | 196,118 |
Yes | output | 1 | 98,059 | 15 | 196,119 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a matrix with n rows (numbered from 1 to n) and m columns (numbered from 1 to m). A number a_{i, j} is written in the cell belonging to the i-th row and the j-th column, each numbe... | instruction | 0 | 98,060 | 15 | 196,120 |
Yes | output | 1 | 98,060 | 15 | 196,121 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a matrix with n rows (numbered from 1 to n) and m columns (numbered from 1 to m). A number a_{i, j} is written in the cell belonging to the i-th row and the j-th column, each numbe... | instruction | 0 | 98,061 | 15 | 196,122 |
Yes | output | 1 | 98,061 | 15 | 196,123 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a matrix with n rows (numbered from 1 to n) and m columns (numbered from 1 to m). A number a_{i, j} is written in the cell belonging to the i-th row and the j-th column, each numbe... | instruction | 0 | 98,062 | 15 | 196,124 |
Yes | output | 1 | 98,062 | 15 | 196,125 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a matrix with n rows (numbered from 1 to n) and m columns (numbered from 1 to m). A number a_{i, j} is written in the cell belonging to the i-th row and the j-th column, each numbe... | instruction | 0 | 98,063 | 15 | 196,126 |
No | output | 1 | 98,063 | 15 | 196,127 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a matrix with n rows (numbered from 1 to n) and m columns (numbered from 1 to m). A number a_{i, j} is written in the cell belonging to the i-th row and the j-th column, each numbe... | instruction | 0 | 98,064 | 15 | 196,128 |
No | output | 1 | 98,064 | 15 | 196,129 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a matrix with n rows (numbered from 1 to n) and m columns (numbered from 1 to m). A number a_{i, j} is written in the cell belonging to the i-th row and the j-th column, each numbe... | instruction | 0 | 98,065 | 15 | 196,130 |
No | output | 1 | 98,065 | 15 | 196,131 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a matrix with n rows (numbered from 1 to n) and m columns (numbered from 1 to m). A number a_{i, j} is written in the cell belonging to the i-th row and the j-th column, each numbe... | instruction | 0 | 98,066 | 15 | 196,132 |
No | output | 1 | 98,066 | 15 | 196,133 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There is an infinite 2-dimensional grid. The robot stands in cell (0, 0) and wants to reach cell (x, y). Here is a list of possible commands the robot can execute:
* move north from cell (i, j) to (i, j + 1);
* move east from cell (i, ... | instruction | 0 | 98,099 | 15 | 196,198 |
Tags: math
Correct Solution:
```
for _ in range(0,int(input())):
x,y=map(int,input().split())
print(2*x if x==y else max(x,y)*2-1)
``` | output | 1 | 98,099 | 15 | 196,199 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There is an infinite 2-dimensional grid. The robot stands in cell (0, 0) and wants to reach cell (x, y). Here is a list of possible commands the robot can execute:
* move north from cell (i, j) to (i, j + 1);
* move east from cell (i, ... | instruction | 0 | 98,100 | 15 | 196,200 |
Tags: math
Correct Solution:
```
import sys
# import math
# import re
# from heapq import *
# from collections import defaultdict as dd
# from collections import OrderedDict as odict
# from collections import Counter as cc
# from collections import deque
sys.setrecursionlimit(10**5)#thsis is must
# mod = 10**9+7; md = ... | output | 1 | 98,100 | 15 | 196,201 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There is an infinite 2-dimensional grid. The robot stands in cell (0, 0) and wants to reach cell (x, y). Here is a list of possible commands the robot can execute:
* move north from cell (i, j) to (i, j + 1);
* move east from cell (i, ... | instruction | 0 | 98,101 | 15 | 196,202 |
Tags: math
Correct Solution:
```
t = int(input())
l= []
for i in range(t):
a, b = map(int, input().split())
s = 0
max_ = max(a, b)
min_ = min(a, b)
s += min_ * 2
if max_ - min_ == 0:
l.append(s)
else:
l.append(s + (max_ - min_) * 2 - 1)
for i in l:
print(i)
``` | output | 1 | 98,101 | 15 | 196,203 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There is an infinite 2-dimensional grid. The robot stands in cell (0, 0) and wants to reach cell (x, y). Here is a list of possible commands the robot can execute:
* move north from cell (i, j) to (i, j + 1);
* move east from cell (i, ... | instruction | 0 | 98,102 | 15 | 196,204 |
Tags: math
Correct Solution:
```
for _ in range(int(input())):
x, y = map(int, input().split())
print(x+y+max(abs(x-y)-1, 0))
``` | output | 1 | 98,102 | 15 | 196,205 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There is an infinite 2-dimensional grid. The robot stands in cell (0, 0) and wants to reach cell (x, y). Here is a list of possible commands the robot can execute:
* move north from cell (i, j) to (i, j + 1);
* move east from cell (i, ... | instruction | 0 | 98,103 | 15 | 196,206 |
Tags: math
Correct Solution:
```
def call():
x,y=map(int,input().split())
t=max(x,y)
if(x==y):
reS=t*2
else:
reS=t*2-1
print(reS)
for _ in range(int(input())):
call()
``` | output | 1 | 98,103 | 15 | 196,207 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There is an infinite 2-dimensional grid. The robot stands in cell (0, 0) and wants to reach cell (x, y). Here is a list of possible commands the robot can execute:
* move north from cell (i, j) to (i, j + 1);
* move east from cell (i, ... | instruction | 0 | 98,104 | 15 | 196,208 |
Tags: math
Correct Solution:
```
t = int(input())
for _ in range(t):
x, y = [int(s) for s in input().split() ]
lastMove = ''
moveCount = 0
actualX = 0
actualY = 0
firstMove = 'x' if x > y else 'y'
while actualX!=x or actualY!=y:
if firstMove == 'y':
if (actualX < x and l... | output | 1 | 98,104 | 15 | 196,209 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There is an infinite 2-dimensional grid. The robot stands in cell (0, 0) and wants to reach cell (x, y). Here is a list of possible commands the robot can execute:
* move north from cell (i, j) to (i, j + 1);
* move east from cell (i, ... | instruction | 0 | 98,105 | 15 | 196,210 |
Tags: math
Correct Solution:
```
t = int(input())
for _ in range(t):
x, y = (abs(int(number)) for number in input().split(" "))
if x > y:
result = 2 * y + 2 * (x - y) - 1
elif y > x:
result = 2 * x + 2 * (y - x) - 1
else:
result = 2 * x
print(result)
``` | output | 1 | 98,105 | 15 | 196,211 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There is an infinite 2-dimensional grid. The robot stands in cell (0, 0) and wants to reach cell (x, y). Here is a list of possible commands the robot can execute:
* move north from cell (i, j) to (i, j + 1);
* move east from cell (i, ... | instruction | 0 | 98,106 | 15 | 196,212 |
Tags: math
Correct Solution:
```
import sys
input=sys.stdin.readline
from collections import defaultdict as dc
from collections import Counter
from bisect import bisect_right, bisect_left
import math
from operator import itemgetter
from heapq import heapify, heappop, heappush
for _ in range(int(input())):
n,m=map(i... | output | 1 | 98,106 | 15 | 196,213 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is an infinite 2-dimensional grid. The robot stands in cell (0, 0) and wants to reach cell (x, y). Here is a list of possible commands the robot can execute:
* move north from cell (i, ... | instruction | 0 | 98,107 | 15 | 196,214 |
Yes | output | 1 | 98,107 | 15 | 196,215 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is an infinite 2-dimensional grid. The robot stands in cell (0, 0) and wants to reach cell (x, y). Here is a list of possible commands the robot can execute:
* move north from cell (i, ... | instruction | 0 | 98,108 | 15 | 196,216 |
Yes | output | 1 | 98,108 | 15 | 196,217 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is an infinite 2-dimensional grid. The robot stands in cell (0, 0) and wants to reach cell (x, y). Here is a list of possible commands the robot can execute:
* move north from cell (i, ... | instruction | 0 | 98,109 | 15 | 196,218 |
Yes | output | 1 | 98,109 | 15 | 196,219 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is an infinite 2-dimensional grid. The robot stands in cell (0, 0) and wants to reach cell (x, y). Here is a list of possible commands the robot can execute:
* move north from cell (i, ... | instruction | 0 | 98,110 | 15 | 196,220 |
Yes | output | 1 | 98,110 | 15 | 196,221 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is an infinite 2-dimensional grid. The robot stands in cell (0, 0) and wants to reach cell (x, y). Here is a list of possible commands the robot can execute:
* move north from cell (i, ... | instruction | 0 | 98,111 | 15 | 196,222 |
No | output | 1 | 98,111 | 15 | 196,223 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is an infinite 2-dimensional grid. The robot stands in cell (0, 0) and wants to reach cell (x, y). Here is a list of possible commands the robot can execute:
* move north from cell (i, ... | instruction | 0 | 98,112 | 15 | 196,224 |
No | output | 1 | 98,112 | 15 | 196,225 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is an infinite 2-dimensional grid. The robot stands in cell (0, 0) and wants to reach cell (x, y). Here is a list of possible commands the robot can execute:
* move north from cell (i, ... | instruction | 0 | 98,113 | 15 | 196,226 |
No | output | 1 | 98,113 | 15 | 196,227 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is an infinite 2-dimensional grid. The robot stands in cell (0, 0) and wants to reach cell (x, y). Here is a list of possible commands the robot can execute:
* move north from cell (i, ... | instruction | 0 | 98,114 | 15 | 196,228 |
No | output | 1 | 98,114 | 15 | 196,229 |
Provide tags and a correct Python 3 solution for this coding contest problem.
It's a beautiful April day and Wallace is playing football with his friends. But his friends do not know that Wallace actually stayed home with Gromit and sent them his robotic self instead. Robo-Wallace has several advantages over the other... | instruction | 0 | 98,161 | 15 | 196,322 |
Tags: binary search, geometry
Correct Solution:
```
from math import hypot
y1, y2, yw, xb, yb, r = map(int, input().split())
yw -= r
y1, y2 = yw * 2 - y2, yw * 2 - y1
def xww(y):
return (y - yw) * xb / (y - yb)
def dd(y):
xw = xww(y)
return (y - y1) / hypot(1, (yw - y) / xw)
def binary_search():
a, b = y1 + ... | output | 1 | 98,161 | 15 | 196,323 |
Provide tags and a correct Python 3 solution for this coding contest problem.
On a number axis directed from the left rightwards, n marbles with coordinates x1, x2, ..., xn are situated. Let's assume that the sizes of the marbles are infinitely small, that is in this task each of them is assumed to be a material point... | instruction | 0 | 98,203 | 15 | 196,406 |
Tags: dp, sortings
Correct Solution:
```
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 = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode
s... | output | 1 | 98,203 | 15 | 196,407 |
Provide tags and a correct Python 3 solution for this coding contest problem.
On a number axis directed from the left rightwards, n marbles with coordinates x1, x2, ..., xn are situated. Let's assume that the sizes of the marbles are infinitely small, that is in this task each of them is assumed to be a material point... | instruction | 0 | 98,204 | 15 | 196,408 |
Tags: dp, sortings
Correct Solution:
```
n=int(input() )
a=sorted([list(map(int, input().split())) for _ in range(n)])
a.append( [ a[-1][0]+1, 0] )
res=[10**15]*(n+1)
res[0]=a[0][1]
ind=a[0][0]
for i in range(n+1):
acc=0
for j in range(i+1,n+1):
res[j]=min(res[j], res[i]+acc+a[j][1])
acc=acc+a[j... | output | 1 | 98,204 | 15 | 196,409 |
Provide tags and a correct Python 3 solution for this coding contest problem.
On a number axis directed from the left rightwards, n marbles with coordinates x1, x2, ..., xn are situated. Let's assume that the sizes of the marbles are infinitely small, that is in this task each of them is assumed to be a material point... | instruction | 0 | 98,205 | 15 | 196,410 |
Tags: dp, sortings
Correct Solution:
```
from typing import Tuple, List
def compute(n: int, m: List[Tuple[int, int]]) -> int:
m = sorted(m)
state = [0] * (n + 1)
state[n - 1] = m[n - 1][1]
for i in range(n - 2, -1, -1):
min_cost = state[i + 1]
acc = 0
for j in range(i + 2, n + ... | output | 1 | 98,205 | 15 | 196,411 |
Provide tags and a correct Python 3 solution for this coding contest problem.
On a number axis directed from the left rightwards, n marbles with coordinates x1, x2, ..., xn are situated. Let's assume that the sizes of the marbles are infinitely small, that is in this task each of them is assumed to be a material point... | instruction | 0 | 98,206 | 15 | 196,412 |
Tags: dp, sortings
Correct Solution:
```
import math
R = lambda: map(int, input().split())
n = int(input())
arr = sorted(list(R()) for i in range(n))
dp = [[math.inf, math.inf] for i in range(n + 1)]
dp[0][0] = arr[0][1]
for i in range(1, n):
dp[i][0] = min(dp[i - 1]) + arr[i][1]
sm = arr[i][0]
for j in ran... | output | 1 | 98,206 | 15 | 196,413 |
Provide tags and a correct Python 3 solution for this coding contest problem.
On a number axis directed from the left rightwards, n marbles with coordinates x1, x2, ..., xn are situated. Let's assume that the sizes of the marbles are infinitely small, that is in this task each of them is assumed to be a material point... | instruction | 0 | 98,207 | 15 | 196,414 |
Tags: dp, sortings
Correct Solution:
```
n = int(input())
arr = []
for i in range(n):
p, c = map(int, input().split())
arr += [[p, c]]
arr.sort()
dp = [[10**100, 10**100] for i in range(n)]
dp[0][0] = 10**100
dp[0][1] = arr[0][1]
for i in range(1, n):
dp[i][1] = min(dp[i-1]) + arr[i][1]
tot = arr[i][0]
count ... | output | 1 | 98,207 | 15 | 196,415 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
On a number axis directed from the left rightwards, n marbles with coordinates x1, x2, ..., xn are situated. Let's assume that the sizes of the marbles are infinitely small, that is in this task... | instruction | 0 | 98,209 | 15 | 196,418 |
No | output | 1 | 98,209 | 15 | 196,419 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
On a number axis directed from the left rightwards, n marbles with coordinates x1, x2, ..., xn are situated. Let's assume that the sizes of the marbles are infinitely small, that is in this task... | instruction | 0 | 98,210 | 15 | 196,420 |
No | output | 1 | 98,210 | 15 | 196,421 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
On a number axis directed from the left rightwards, n marbles with coordinates x1, x2, ..., xn are situated. Let's assume that the sizes of the marbles are infinitely small, that is in this task... | instruction | 0 | 98,211 | 15 | 196,422 |
No | output | 1 | 98,211 | 15 | 196,423 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vivek has encountered a problem. He has a maze that can be represented as an n × m grid. Each of the grid cells may represent the following:
* Empty — '.'
* Wall — '#'
* Good person — 'G'
* Bad person — 'B'
The only escape fr... | instruction | 0 | 98,790 | 15 | 197,580 |
Tags: constructive algorithms, dfs and similar, dsu, graphs, greedy, implementation, shortest paths
Correct Solution:
```
import sys
import math
sys.setrecursionlimit(1000000) #设置最大递归深度
int1 = lambda x: int(x) - 1 #返回x-1
p2D = lambda x: print(*x, sep="\n") #输出多个元素,以换行符分割
p2S = lambda x: print(*x, sep=" ") #输出多个元素,以空格... | output | 1 | 98,790 | 15 | 197,581 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vivek has encountered a problem. He has a maze that can be represented as an n × m grid. Each of the grid cells may represent the following:
* Empty — '.'
* Wall — '#'
* Good person — 'G'
* Bad person — 'B'
The only escape fr... | instruction | 0 | 98,791 | 15 | 197,582 |
Tags: constructive algorithms, dfs and similar, dsu, graphs, greedy, implementation, shortest paths
Correct Solution:
```
import sys
input = sys.stdin.readline
t=int(input())
ans=[]
for _ in range(t):
h,w=map(int,input().split())
grid=[list(input()) for _ in range(h)]
good=set()
bad=set()
delta=[(-1,0),(1,0),(0,1)... | output | 1 | 98,791 | 15 | 197,583 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vivek has encountered a problem. He has a maze that can be represented as an n × m grid. Each of the grid cells may represent the following:
* Empty — '.'
* Wall — '#'
* Good person — 'G'
* Bad person — 'B'
The only escape fr... | instruction | 0 | 98,792 | 15 | 197,584 |
Tags: constructive algorithms, dfs and similar, dsu, graphs, greedy, implementation, shortest paths
Correct Solution:
```
def solve(n, m, maze):
for i in range(n):
for j in range(m):
if maze[i][j] != "B":
continue
if i > 0:
if maze[i - 1][j] == "G":
... | output | 1 | 98,792 | 15 | 197,585 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vivek has encountered a problem. He has a maze that can be represented as an n × m grid. Each of the grid cells may represent the following:
* Empty — '.'
* Wall — '#'
* Good person — 'G'
* Bad person — 'B'
The only escape fr... | instruction | 0 | 98,793 | 15 | 197,586 |
Tags: constructive algorithms, dfs and similar, dsu, graphs, greedy, implementation, shortest paths
Correct Solution:
```
from sys import stdin
from collections import deque
def fun():
n, m = map(int, stdin.readline().split())
lst = [list(stdin.readline()) for _ in range(n)]
good = []
for x in range(n... | output | 1 | 98,793 | 15 | 197,587 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vivek has encountered a problem. He has a maze that can be represented as an n × m grid. Each of the grid cells may represent the following:
* Empty — '.'
* Wall — '#'
* Good person — 'G'
* Bad person — 'B'
The only escape fr... | instruction | 0 | 98,794 | 15 | 197,588 |
Tags: constructive algorithms, dfs and similar, dsu, graphs, greedy, implementation, shortest paths
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()
se... | output | 1 | 98,794 | 15 | 197,589 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vivek has encountered a problem. He has a maze that can be represented as an n × m grid. Each of the grid cells may represent the following:
* Empty — '.'
* Wall — '#'
* Good person — 'G'
* Bad person — 'B'
The only escape fr... | instruction | 0 | 98,795 | 15 | 197,590 |
Tags: constructive algorithms, dfs and similar, dsu, graphs, greedy, implementation, shortest paths
Correct Solution:
```
T = int(input().strip())
for t in range(T):
n, m = list(map(int, input().split()))
field = [[1] * (m + 2) for _ in range(n+2)]
bads = []
goods = []
for row in range(n):
c... | output | 1 | 98,795 | 15 | 197,591 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vivek has encountered a problem. He has a maze that can be represented as an n × m grid. Each of the grid cells may represent the following:
* Empty — '.'
* Wall — '#'
* Good person — 'G'
* Bad person — 'B'
The only escape fr... | instruction | 0 | 98,796 | 15 | 197,592 |
Tags: constructive algorithms, dfs and similar, dsu, graphs, greedy, implementation, shortest paths
Correct Solution:
```
from collections import deque
t = int(input())
for _ in range(t):
n, m = map(int, input().split())
g = [["#"]*(m+2)]
for i in range(n):
g.append(["#"] + list(input()) + ["#"])
... | output | 1 | 98,796 | 15 | 197,593 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.