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 a correct Python 3 solution for this coding contest problem.
There is a pond with a rectangular shape. The pond is divided into a grid with H rows and W columns of squares. We will denote the square at the i-th row from the top and j-th column from the left by (i,\ j).
Some of the squares in the pond contains... | instruction | 0 | 9,741 | 15 | 19,482 |
"Correct Solution:
```
"""
.o...o..o.
....o.....
....oo.oo.
..oooo..o.
....oo....
..o..o....
o..o....So
o....T....
....o.....
........oo
グラフを作る
⇛ SからTにたどり着く個数を全探索
⇛ たどり着く直前の座標を保持
⇛ 直前のバリエーション
解説AC
⇛ 行内、列内は自由に動ける
⇛ 行/列のどこかにいる状態でもたせる
⇛ 点の上は行⇔列の切り替えが出来るので、cap==1とする
⇛ 結局MaxCutをしているのと一緒!!
"""
from collections import deque... | output | 1 | 9,741 | 15 | 19,483 |
Provide a correct Python 3 solution for this coding contest problem.
There is a pond with a rectangular shape. The pond is divided into a grid with H rows and W columns of squares. We will denote the square at the i-th row from the top and j-th column from the left by (i,\ j).
Some of the squares in the pond contains... | instruction | 0 | 9,742 | 15 | 19,484 |
"Correct Solution:
```
import collections
class Dinic:
def __init__(self, vnum):
self.edge = [[] for i in range(vnum)]
self.n = vnum
self.inf = float('inf')
def addedge(self, st, en, c):
self.edge[st].append([en, c, len(self.edge[en])])
self.edge[en].append([st, 0, len(se... | output | 1 | 9,742 | 15 | 19,485 |
Provide a correct Python 3 solution for this coding contest problem.
There is a pond with a rectangular shape. The pond is divided into a grid with H rows and W columns of squares. We will denote the square at the i-th row from the top and j-th column from the left by (i,\ j).
Some of the squares in the pond contains... | instruction | 0 | 9,743 | 15 | 19,486 |
"Correct Solution:
```
# 最大流
NUMERIC_LIMITS = 10 ** 18
import queue
class maxFlow:
class edge:
def __init__(s, frm, to, cap, flow):
s.frm, s.to = frm, to
s.cap, s.flow = cap, flow
def __init__(s, n):
s._n = n
s.g = [[] for _ in range(n)]
s.pos = []
def add_edge(s, frm, to, cap):
... | output | 1 | 9,743 | 15 | 19,487 |
Provide a correct Python 3 solution for this coding contest problem.
There is a pond with a rectangular shape. The pond is divided into a grid with H rows and W columns of squares. We will denote the square at the i-th row from the top and j-th column from the left by (i,\ j).
Some of the squares in the pond contains... | instruction | 0 | 9,744 | 15 | 19,488 |
"Correct Solution:
```
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from collections import deque
H,W = map(int,readline().split())
A = [line.rstrip().decode('utf-8') for line in readlines()]
class Dinic:
def __init__(self, N, source, sink):
... | output | 1 | 9,744 | 15 | 19,489 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Alice got a new doll these days. It can even walk!
Alice has built a maze for the doll and wants to test it. The maze is a grid with n rows and m columns. There are k obstacles, the i-th of them is on the cell (x_i, y_i), which means the ce... | instruction | 0 | 10,037 | 15 | 20,074 |
Tags: brute force, data structures, greedy, implementation
Correct Solution:
```
import sys
from collections import deque
a, b, k = map(int,input().split())
obsa = [[] for _ in range(a)]
obsb = [[] for _ in range(b)]
for _ in range(k):
x, y = map(int,input().split())
# x, y = _,7
obsa[x-1].append(y-1)
o... | output | 1 | 10,037 | 15 | 20,075 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Alice got a new doll these days. It can even walk!
Alice has built a maze for the doll and wants to test it. The maze is a grid with n rows and m columns. There are k obstacles, the i-th of them is on the cell (x_i, y_i), which means the ce... | instruction | 0 | 10,038 | 15 | 20,076 |
Tags: brute force, data structures, greedy, implementation
Correct Solution:
```
import sys
def I():
return sys.stdin.readline().rstrip()
n, m, k = map( int, I().split() )
r, c = dict(), dict()
for _ in range( k ):
x, y = map( int, I().split() )
if x not in r:
r[ x ] = []
r[ x ].append( y )
... | output | 1 | 10,038 | 15 | 20,077 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Alice got a new doll these days. It can even walk!
Alice has built a maze for the doll and wants to test it. The maze is a grid with n rows and m columns. There are k obstacles, the i-th of them is on the cell (x_i, y_i), which means the ce... | instruction | 0 | 10,039 | 15 | 20,078 |
Tags: brute force, data structures, greedy, implementation
Correct Solution:
```
import sys
from collections import deque
a, b, k = map(int,sys.stdin.readline().split())
obsa = [[] for _ in range(a)]
obsb = [[] for _ in range(b)]
for _ in range(k):
x, y = map(int,sys.stdin.readline().split())
# x, y = _,7
o... | output | 1 | 10,039 | 15 | 20,079 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Alice got a new doll these days. It can even walk!
Alice has built a maze for the doll and wants to test it. The maze is a grid with n rows and m columns. There are k obstacles, the i-th of them is on the cell (x_i, y_i), which means the ce... | instruction | 0 | 10,040 | 15 | 20,080 |
Tags: brute force, data structures, greedy, implementation
Correct Solution:
```
def tr(n, m, inp):
xa = n
xi = yi = 1
ya = m
while True:
while (xi, ya) in inp:
for x in range(xi, xa + 1):
inp.remove((x, ya))
ya -= 1
if ya < yi:
... | output | 1 | 10,040 | 15 | 20,081 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Alice got a new doll these days. It can even walk!
Alice has built a maze for the doll and wants to test it. The maze is a grid with n rows and m columns. There are k obstacles, the i-th of them is on the cell (x_i, y_i), which means the ce... | instruction | 0 | 10,041 | 15 | 20,082 |
Tags: brute force, data structures, greedy, implementation
Correct Solution:
```
"""
Author : thekushalghosh
Team : CodeDiggers
"""
import sys,math
input = sys.stdin.readline
############ ---- USER DEFINED INPUT FUNCTIONS ---- ############
def inp():
return(int(input()))
def inlt():
return(list(map(... | output | 1 | 10,041 | 15 | 20,083 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Alice got a new doll these days. It can even walk!
Alice has built a maze for the doll and wants to test it. The maze is a grid with n rows and m columns. There are k obstacles, the i-th of them is on the cell (x_i, y_i), which means the ce... | instruction | 0 | 10,042 | 15 | 20,084 |
Tags: brute force, data structures, greedy, implementation
Correct Solution:
```
from sys import stdout
printn = lambda x: stdout.write(x)
inn = lambda : int(input())
inl = lambda: list(map(int, input().split()))
inm = lambda: map(int, input().split())
DBG = True and False
BIG = 999999999
R = 10**9 + 7
def ... | output | 1 | 10,042 | 15 | 20,085 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Alice got a new doll these days. It can even walk!
Alice has built a maze for the doll and wants to test it. The maze is a grid with n rows and m columns. There are k obstacles, the i-th of them is on the cell (x_i, y_i), which means the ce... | instruction | 0 | 10,043 | 15 | 20,086 |
Tags: brute force, data structures, greedy, implementation
Correct Solution:
```
import sys
from bisect import bisect
input = sys.stdin.readline
def r1():
return int(input())
def rm():
return map(int, input().split())
n, m, k = rm()
rw, cl = {}, {}
for i in range(k):
x, y = rm()
if x not in rw:
... | output | 1 | 10,043 | 15 | 20,087 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Alice got a new doll these days. It can even walk!
Alice has built a maze for the doll and wants to test it. The maze is a grid with n rows and m columns. There are k obstacles, the i-th of them is on the cell (x_i, y_i), which means the ce... | instruction | 0 | 10,044 | 15 | 20,088 |
Tags: brute force, data structures, greedy, implementation
Correct Solution:
```
import sys
#sys.stdin = open('in', 'r')
#n = int(input())
n,m,k = map(int, input().split())
dr = {}
dc = {}
for i in range(n):
dr[i] = []
for i in range(m):
dc[i] = []
for i in range(k):
r,c = map(int, input().split())
dr[r... | output | 1 | 10,044 | 15 | 20,089 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Alice got a new doll these days. It can even walk!
Alice has built a maze for the doll and wants to test it. The maze is a grid with n rows and m columns. There are k obstacles, the i-th of the... | instruction | 0 | 10,045 | 15 | 20,090 |
Yes | output | 1 | 10,045 | 15 | 20,091 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Alice got a new doll these days. It can even walk!
Alice has built a maze for the doll and wants to test it. The maze is a grid with n rows and m columns. There are k obstacles, the i-th of the... | instruction | 0 | 10,046 | 15 | 20,092 |
Yes | output | 1 | 10,046 | 15 | 20,093 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Alice got a new doll these days. It can even walk!
Alice has built a maze for the doll and wants to test it. The maze is a grid with n rows and m columns. There are k obstacles, the i-th of the... | instruction | 0 | 10,047 | 15 | 20,094 |
No | output | 1 | 10,047 | 15 | 20,095 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Alice got a new doll these days. It can even walk!
Alice has built a maze for the doll and wants to test it. The maze is a grid with n rows and m columns. There are k obstacles, the i-th of the... | instruction | 0 | 10,048 | 15 | 20,096 |
No | output | 1 | 10,048 | 15 | 20,097 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Alice got a new doll these days. It can even walk!
Alice has built a maze for the doll and wants to test it. The maze is a grid with n rows and m columns. There are k obstacles, the i-th of the... | instruction | 0 | 10,049 | 15 | 20,098 |
No | output | 1 | 10,049 | 15 | 20,099 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Alice got a new doll these days. It can even walk!
Alice has built a maze for the doll and wants to test it. The maze is a grid with n rows and m columns. There are k obstacles, the i-th of the... | instruction | 0 | 10,050 | 15 | 20,100 |
No | output | 1 | 10,050 | 15 | 20,101 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Mr. Chanek just won the national chess tournament and got a huge chessboard of size N × M. Bored with playing conventional chess, Mr. Chanek now defines a function F(X, Y), which denotes the min... | instruction | 0 | 10,140 | 15 | 20,280 |
No | output | 1 | 10,140 | 15 | 20,281 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Mr. Chanek just won the national chess tournament and got a huge chessboard of size N × M. Bored with playing conventional chess, Mr. Chanek now defines a function F(X, Y), which denotes the min... | instruction | 0 | 10,141 | 15 | 20,282 |
No | output | 1 | 10,141 | 15 | 20,283 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Mr. Chanek just won the national chess tournament and got a huge chessboard of size N × M. Bored with playing conventional chess, Mr. Chanek now defines a function F(X, Y), which denotes the min... | instruction | 0 | 10,142 | 15 | 20,284 |
No | output | 1 | 10,142 | 15 | 20,285 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A boy Petya loves chess very much. He even came up with a chess piece of his own, a semiknight. The semiknight can move in any of these four directions: 2 squares forward and 2 squares to the right, 2 squares forward and 2 squares to the lef... | instruction | 0 | 10,310 | 15 | 20,620 |
Tags: greedy, math
Correct Solution:
```
MOVS = [(2,-2),(-2,2),(-2,-2),(2,2)]
def check(a):
return 0<=a<8
set1 = set()
set2 = set()
dic1 = dict()
dic2 = dict()
def cango1(matrix,pos,lap):
for dx,dy in MOVS:
nx,ny = dx+pos[0],dy+pos[1]
if not check (nx) or not check(ny):
continue
... | output | 1 | 10,310 | 15 | 20,621 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A boy Petya loves chess very much. He even came up with a chess piece of his own, a semiknight. The semiknight can move in any of these four directions: 2 squares forward and 2 squares to the right, 2 squares forward and 2 squares to the lef... | instruction | 0 | 10,311 | 15 | 20,622 |
Tags: greedy, math
Correct Solution:
```
n = int(input())
for t in range(n):
if t: input()
board = [[c for c in input()] for i in range(8)]
k1, k2 = ((i, j) for i in range(8) for j in range(8) if board[i][j] == 'K')
if (k1[0] - k2[0]) % 4 == 0 and (k1[1] - k2[1]) % 4 == 0:
print('YES')
else:... | output | 1 | 10,311 | 15 | 20,623 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A boy Petya loves chess very much. He even came up with a chess piece of his own, a semiknight. The semiknight can move in any of these four directions: 2 squares forward and 2 squares to the right, 2 squares forward and 2 squares to the lef... | instruction | 0 | 10,312 | 15 | 20,624 |
Tags: greedy, math
Correct Solution:
```
def check():
board = []
for cont in range(0,8):
board.append(input())
l = True
for cont in range(0,8):
for cont2 in range(0,8):
if board[cont][cont2] == 'K':
if l:
xk1 = cont2
yk1... | output | 1 | 10,312 | 15 | 20,625 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A boy Petya loves chess very much. He even came up with a chess piece of his own, a semiknight. The semiknight can move in any of these four directions: 2 squares forward and 2 squares to the right, 2 squares forward and 2 squares to the lef... | instruction | 0 | 10,313 | 15 | 20,626 |
Tags: greedy, math
Correct Solution:
```
import sys
import collections
class GetOutOfLoop(Exception):
pass
if __name__ == "__main__":
n_cases = int(sys.stdin.readline())
for case in range(n_cases):
board = [list(sys.stdin.readline().rstrip()) for i in range(8)]
knight_init_loc = [None, ... | output | 1 | 10,313 | 15 | 20,627 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A boy Petya loves chess very much. He even came up with a chess piece of his own, a semiknight. The semiknight can move in any of these four directions: 2 squares forward and 2 squares to the right, 2 squares forward and 2 squares to the lef... | instruction | 0 | 10,314 | 15 | 20,628 |
Tags: greedy, math
Correct Solution:
```
for i in range(int(input())):
if i :
input()
ans = []
for i in range(8):
s = input()
for j in range(8):
if s[j] == 'K':
ans.append((i, j))
print(['NO' , 'YES'][abs(ans[0][0] - ans[1][0]) % 4 == 0 and abs(ans[0][... | output | 1 | 10,314 | 15 | 20,629 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A boy Petya loves chess very much. He even came up with a chess piece of his own, a semiknight. The semiknight can move in any of these four directions: 2 squares forward and 2 squares to the right, 2 squares forward and 2 squares to the lef... | instruction | 0 | 10,315 | 15 | 20,630 |
Tags: greedy, math
Correct Solution:
```
t = int(input())
for _ in range(t):
if _:
input()
knights = []
for i in range(8):
s = input().strip()
for j in range(8):
if s[j] == 'K':
knights.append((i,j))
n1 = knights[0]
n2 = knights[1]
"""
if n... | output | 1 | 10,315 | 15 | 20,631 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A boy Petya loves chess very much. He even came up with a chess piece of his own, a semiknight. The semiknight can move in any of these four directions: 2 squares forward and 2 squares to the right, 2 squares forward and 2 squares to the lef... | instruction | 0 | 10,316 | 15 | 20,632 |
Tags: greedy, math
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 = BytesIO()
self.writable =... | output | 1 | 10,316 | 15 | 20,633 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A boy Petya loves chess very much. He even came up with a chess piece of his own, a semiknight. The semiknight can move in any of these four directions: 2 squares forward and 2 squares to the right, 2 squares forward and 2 squares to the lef... | instruction | 0 | 10,317 | 15 | 20,634 |
Tags: greedy, math
Correct Solution:
```
def check(x, y):
return 0 <= x < 8 and 0 <= y < 8
def dfs1(x, y, T=0):
global first, used
if not(check(x, y)) or used[x][y]:
return
used[x][y] = True
first.add((x, y, T))
for pair in (2, 2), (2, -2), (-2, 2), (-2, -2):
dfs1(x + pair[0], y... | output | 1 | 10,317 | 15 | 20,635 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A boy Petya loves chess very much. He even came up with a chess piece of his own, a semiknight. The semiknight can move in any of these four directions: 2 squares forward and 2 squares to the ri... | instruction | 0 | 10,318 | 15 | 20,636 |
Yes | output | 1 | 10,318 | 15 | 20,637 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A boy Petya loves chess very much. He even came up with a chess piece of his own, a semiknight. The semiknight can move in any of these four directions: 2 squares forward and 2 squares to the ri... | instruction | 0 | 10,319 | 15 | 20,638 |
Yes | output | 1 | 10,319 | 15 | 20,639 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A boy Petya loves chess very much. He even came up with a chess piece of his own, a semiknight. The semiknight can move in any of these four directions: 2 squares forward and 2 squares to the ri... | instruction | 0 | 10,320 | 15 | 20,640 |
Yes | output | 1 | 10,320 | 15 | 20,641 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A boy Petya loves chess very much. He even came up with a chess piece of his own, a semiknight. The semiknight can move in any of these four directions: 2 squares forward and 2 squares to the ri... | instruction | 0 | 10,321 | 15 | 20,642 |
Yes | output | 1 | 10,321 | 15 | 20,643 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A boy Petya loves chess very much. He even came up with a chess piece of his own, a semiknight. The semiknight can move in any of these four directions: 2 squares forward and 2 squares to the ri... | instruction | 0 | 10,322 | 15 | 20,644 |
No | output | 1 | 10,322 | 15 | 20,645 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A boy Petya loves chess very much. He even came up with a chess piece of his own, a semiknight. The semiknight can move in any of these four directions: 2 squares forward and 2 squares to the ri... | instruction | 0 | 10,323 | 15 | 20,646 |
No | output | 1 | 10,323 | 15 | 20,647 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A boy Petya loves chess very much. He even came up with a chess piece of his own, a semiknight. The semiknight can move in any of these four directions: 2 squares forward and 2 squares to the ri... | instruction | 0 | 10,324 | 15 | 20,648 |
No | output | 1 | 10,324 | 15 | 20,649 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A boy Petya loves chess very much. He even came up with a chess piece of his own, a semiknight. The semiknight can move in any of these four directions: 2 squares forward and 2 squares to the ri... | instruction | 0 | 10,325 | 15 | 20,650 |
No | output | 1 | 10,325 | 15 | 20,651 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasya owns a cornfield which can be defined with two integers n and d. The cornfield can be represented as rectangle with vertices having Cartesian coordinates (0, d), (d, 0), (n, n - d) and (n - d, n).
<image> An example of a cornfield wit... | instruction | 0 | 10,798 | 15 | 21,596 |
Tags: geometry
Correct Solution:
```
n, d = map(int, input().split())
count = int(input())
for i in range(count):
x, y = map(int, input().split())
if (y>=x-d) and (y>=-x+d) and (y<=x+d) and (y<=-x+n*2-d):
print('YES')
else:
print('NO')
``` | output | 1 | 10,798 | 15 | 21,597 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasya owns a cornfield which can be defined with two integers n and d. The cornfield can be represented as rectangle with vertices having Cartesian coordinates (0, d), (d, 0), (n, n - d) and (n - d, n).
<image> An example of a cornfield wit... | instruction | 0 | 10,799 | 15 | 21,598 |
Tags: geometry
Correct Solution:
```
n, d = map(int, input().split())
m = int(input())
for _ in range(m) :
x, y = map(int, input().split())
if (x + y) >= d and (x + y) <= n + n - d and (x - y) >= -d and (x - y) <= d :
print("YES")
else :
print("NO")
``` | output | 1 | 10,799 | 15 | 21,599 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasya owns a cornfield which can be defined with two integers n and d. The cornfield can be represented as rectangle with vertices having Cartesian coordinates (0, d), (d, 0), (n, n - d) and (n - d, n).
<image> An example of a cornfield wit... | instruction | 0 | 10,800 | 15 | 21,600 |
Tags: geometry
Correct Solution:
```
n, d = [int(i) for i in input().split()]
m = int(input())
for i in range(m):
x, y = [int(i) for i in input().split()]
if y <= n - abs(x - n + d) and y >= abs(x - d):
print('YES')
else:
print('NO')
``` | output | 1 | 10,800 | 15 | 21,601 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasya owns a cornfield which can be defined with two integers n and d. The cornfield can be represented as rectangle with vertices having Cartesian coordinates (0, d), (d, 0), (n, n - d) and (n - d, n).
<image> An example of a cornfield wit... | instruction | 0 | 10,801 | 15 | 21,602 |
Tags: geometry
Correct Solution:
```
def inF(d,n,x,y):
mg = 0.7071067811865475
x1 = (x-y)*mg
y1 = (x+y)*mg
if x1>=-d*mg and x1<=d*mg:
if y1>=d*mg and y1<=(2*n-d)*mg:
return True
return False
n,d = list(map(int,input().split()))
m=int(input())
x=[]
y=[]
for i in r... | output | 1 | 10,801 | 15 | 21,603 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasya owns a cornfield which can be defined with two integers n and d. The cornfield can be represented as rectangle with vertices having Cartesian coordinates (0, d), (d, 0), (n, n - d) and (n - d, n).
<image> An example of a cornfield wit... | instruction | 0 | 10,802 | 15 | 21,604 |
Tags: geometry
Correct Solution:
```
n, d = map(int, input().split())
q = int(input())
for i in range(q):
x, y = map(int, input().split())
if x >= d - y and y <= 2 * n - d - x and abs(x - y) <= d:
print("YES")
else:
print("NO")
``` | output | 1 | 10,802 | 15 | 21,605 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasya owns a cornfield which can be defined with two integers n and d. The cornfield can be represented as rectangle with vertices having Cartesian coordinates (0, d), (d, 0), (n, n - d) and (n - d, n).
<image> An example of a cornfield wit... | instruction | 0 | 10,803 | 15 | 21,606 |
Tags: geometry
Correct Solution:
```
#------------------------------what is this I don't know....just makes my mess faster--------------------------------------
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd... | output | 1 | 10,803 | 15 | 21,607 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasya owns a cornfield which can be defined with two integers n and d. The cornfield can be represented as rectangle with vertices having Cartesian coordinates (0, d), (d, 0), (n, n - d) and (n - d, n).
<image> An example of a cornfield wit... | instruction | 0 | 10,804 | 15 | 21,608 |
Tags: geometry
Correct Solution:
```
n, d = list(map(int, input().split()))
m = int(input())
def lfunc(x1, y1, x2, y2, x):
if x2!=x1:
k = (y2 - y1)/(x2-x1)
else:
k = 0
b = y1 - k * x1
return k*x+b
k = 0
for i in range(m):
x, y = list(map(int, input().split()))
if y<=lfunc(0,... | output | 1 | 10,804 | 15 | 21,609 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasya owns a cornfield which can be defined with two integers n and d. The cornfield can be represented as rectangle with vertices having Cartesian coordinates (0, d), (d, 0), (n, n - d) and (n - d, n).
<image> An example of a cornfield wit... | instruction | 0 | 10,805 | 15 | 21,610 |
Tags: geometry
Correct Solution:
```
n,d = map(int,input().split())
m = int(input())
ans = []
for i in range(m):
x1,y1 = map(int,input().split())
t1 = x1+y1
t2 = x1-y1
if t1>=d and t1<=(2*n-d) and t2>=(-d) and t2<=d:
ans.append('YES')
else:
ans.append('NO')
for i in ans:
print(i)... | output | 1 | 10,805 | 15 | 21,611 |
Provide tags and a correct Python 3 solution for this coding contest problem.
On a chessboard with a width of n and a height of n, rows are numbered from bottom to top from 1 to n, columns are numbered from left to right from 1 to n. Therefore, for each cell of the chessboard, you can assign the coordinates (r,c), whe... | instruction | 0 | 10,815 | 15 | 21,630 |
Tags: implementation, math
Correct Solution:
```
n = int(input())
xy = input().split(" ")
x = int(xy[0])
y = int(xy[1])
wx = 1
wy = 1
bx = n
by = n
if x < y:
white = (x-1) + (y-x)
black = (n-y) + (y-x)
else:
white = (y-1) + (x-y)
black = (n-x) + (x-y)
if white <= black:
print('White')
else:
p... | output | 1 | 10,815 | 15 | 21,631 |
Provide tags and a correct Python 3 solution for this coding contest problem.
On a chessboard with a width of n and a height of n, rows are numbered from bottom to top from 1 to n, columns are numbered from left to right from 1 to n. Therefore, for each cell of the chessboard, you can assign the coordinates (r,c), whe... | instruction | 0 | 10,816 | 15 | 21,632 |
Tags: implementation, math
Correct Solution:
```
def go():
n = int(input())
x, y = [int(i) for i in input().split(' ')]
a = 1 + 1
b = n + n
c = x + y
distance_w = c - a
distance_b = b - c
if distance_w == distance_b:
return 'White'
if distance_w < distance_b:
return '... | output | 1 | 10,816 | 15 | 21,633 |
Provide tags and a correct Python 3 solution for this coding contest problem.
On a chessboard with a width of n and a height of n, rows are numbered from bottom to top from 1 to n, columns are numbered from left to right from 1 to n. Therefore, for each cell of the chessboard, you can assign the coordinates (r,c), whe... | instruction | 0 | 10,817 | 15 | 21,634 |
Tags: implementation, math
Correct Solution:
```
gcd = lambda a, b: gcd(b, a % b) if b else a
def main():
n = int(input())
x, y = map(int, input().split())
if max(n - x, n - y) < max(x - 1, y - 1):
print("Black")
else:
print("White")
main()
``` | output | 1 | 10,817 | 15 | 21,635 |
Provide tags and a correct Python 3 solution for this coding contest problem.
On a chessboard with a width of n and a height of n, rows are numbered from bottom to top from 1 to n, columns are numbered from left to right from 1 to n. Therefore, for each cell of the chessboard, you can assign the coordinates (r,c), whe... | instruction | 0 | 10,818 | 15 | 21,636 |
Tags: implementation, math
Correct Solution:
```
n = int(input())
[x,y] = [int(x) for x in input().split()]
xw = yw = 1
xb = yb = n
maxi = max(x,y)
mini = min(x,y)
sw = mini-xw + maxi-mini
sb = xb-maxi + maxi-mini
if sw <= sb:
print('White')
else:
print('Black')
``` | output | 1 | 10,818 | 15 | 21,637 |
Provide tags and a correct Python 3 solution for this coding contest problem.
On a chessboard with a width of n and a height of n, rows are numbered from bottom to top from 1 to n, columns are numbered from left to right from 1 to n. Therefore, for each cell of the chessboard, you can assign the coordinates (r,c), whe... | instruction | 0 | 10,819 | 15 | 21,638 |
Tags: implementation, math
Correct Solution:
```
n=int(input())
a,b=map(int,input().split())
a,b=min(a,b),max(a,b)
x=a-1+b-a
y=n-b+b-a
if(x<=y):
print("White")
else:
print("Black")
``` | output | 1 | 10,819 | 15 | 21,639 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.