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.
Ivan places knights on infinite chessboard. Initially there are n knights. If there is free cell which is under attack of at least 4 knights then he places new knight in this cell. Ivan repeats this until there are no such free cells. One ca... | instruction | 0 | 45,409 | 15 | 90,818 |
Tags: constructive algorithms
Correct Solution:
```
n = int(input())
anss = [(0, 0)]
for i in range(1, n):
anss.append((0, i))
anss.append((i, 0))
anss.append((0, -i))
anss.append((-i, 0))
for i in range(n):
print(str(anss[i][0]) + ' ' + str(anss[i][1]))
``` | output | 1 | 45,409 | 15 | 90,819 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Ivan places knights on infinite chessboard. Initially there are n knights. If there is free cell which is under attack of at least 4 knights then he places new knight in this cell. Ivan repeats ... | instruction | 0 | 45,410 | 15 | 90,820 |
No | output | 1 | 45,410 | 15 | 90,821 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Ivan places knights on infinite chessboard. Initially there are n knights. If there is free cell which is under attack of at least 4 knights then he places new knight in this cell. Ivan repeats ... | instruction | 0 | 45,411 | 15 | 90,822 |
No | output | 1 | 45,411 | 15 | 90,823 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Ivan places knights on infinite chessboard. Initially there are n knights. If there is free cell which is under attack of at least 4 knights then he places new knight in this cell. Ivan repeats ... | instruction | 0 | 45,412 | 15 | 90,824 |
No | output | 1 | 45,412 | 15 | 90,825 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Ivan places knights on infinite chessboard. Initially there are n knights. If there is free cell which is under attack of at least 4 knights then he places new knight in this cell. Ivan repeats ... | instruction | 0 | 45,413 | 15 | 90,826 |
No | output | 1 | 45,413 | 15 | 90,827 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Calculate the number of ways to place n rooks on n × n chessboard so that both following conditions are met:
* each empty cell is under attack;
* exactly k pairs of rooks attack each other.
An empty cell is under attack if there is... | instruction | 0 | 45,535 | 15 | 91,070 |
Tags: combinatorics, fft, math
Correct Solution:
```
from sys import stdin
from sys import stdout
# Valor dado para modular y evitar valores demasiado grandes
m = 998244353
# En factorial se almacenan los factoriales de todos los valores posibles de n (desde 1 hasta 200000) modulados.
factorial = [1]
for i in range(1... | output | 1 | 45,535 | 15 | 91,071 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Calculate the number of ways to place n rooks on n × n chessboard so that both following conditions are met:
* each empty cell is under attack;
* exactly k pairs of rooks attack each other.
An empty cell is under attack if there is... | instruction | 0 | 45,536 | 15 | 91,072 |
Tags: combinatorics, fft, math
Correct Solution:
```
class Combination:
def __init__(self, n_max, mod=10**9+7):
self.mod = mod
f = 1
self.fac = fac = [f]
for i in range(1, n_max+1):
f = f * i % mod
fac.append(f)
f = pow(f, mod-2, mod)
self.faci... | output | 1 | 45,536 | 15 | 91,073 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Calculate the number of ways to place n rooks on n × n chessboard so that both following conditions are met:
* each empty cell is under attack;
* exactly k pairs of rooks attack each other.
An empty cell is under attack if there is... | instruction | 0 | 45,537 | 15 | 91,074 |
Tags: combinatorics, fft, math
Correct Solution:
```
import sys
input = sys.stdin.buffer.readline
def print(val):
sys.stdout.write(str(val) + '\n')
def inverse(n,primemod):
return pow(n,primemod-2,primemod)
def choose(n,k,mod,factorials,inverses):
return (factorials[n]*inverses[k]*inverses[n-k])% mod
def... | output | 1 | 45,537 | 15 | 91,075 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Calculate the number of ways to place n rooks on n × n chessboard so that both following conditions are met:
* each empty cell is under attack;
* exactly k pairs of rooks attack each other.
An empty cell is under attack if there is... | instruction | 0 | 45,538 | 15 | 91,076 |
Tags: combinatorics, fft, math
Correct Solution:
```
"""import sys
input = sys.stdin.buffer.readline
def print(val):
sys.stdout.write(str(val) + '\n')"""
def inverse(n,primemod):
return pow(n,primemod-2,primemod)
def choose(n,k,mod):
return (factorials[n]*inverses[k]*inverses[n-k])% mod
def factorial_cre... | output | 1 | 45,538 | 15 | 91,077 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Calculate the number of ways to place n rooks on n × n chessboard so that both following conditions are met:
* each empty cell is under attack;
* exactly k pairs of rooks attack each other.
An empty cell is under attack if there is... | instruction | 0 | 45,539 | 15 | 91,078 |
Tags: combinatorics, fft, math
Correct Solution:
```
nn = 200200
P = 998244353
fa = [1] * (nn+1)
fainv = [1] * (nn+1)
for i in range(nn):
fa[i+1] = fa[i] * (i+1) % P
fainv[-1] = pow(fa[-1], P-2, P)
for i in range(nn)[::-1]:
fainv[i] = fainv[i+1] * (i+1) % P
C = lambda a, b: fa[a] * fainv[b] % P * fainv[a-b] %... | output | 1 | 45,539 | 15 | 91,079 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Calculate the number of ways to place n rooks on n × n chessboard so that both following conditions are met:
* each empty cell is under attack;
* exactly k pairs of rooks attack each other.
An empty cell is under attack if there is... | instruction | 0 | 45,540 | 15 | 91,080 |
Tags: combinatorics, fft, math
Correct Solution:
```
mod=998244353
n,k=map(int,input().split())
fact=[1]
for i in range(1,n+1):
fact.append((fact[-1]*i)%mod)
revfact=[1]
for i in range(1,n+1):
revfact.append(pow(fact[i],mod-2,mod))
if k>=n:
print(0)
elif k==0:
print(fact[n])
else:
ans=0
for i in range(n-k+1... | output | 1 | 45,540 | 15 | 91,081 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Calculate the number of ways to place n rooks on n × n chessboard so that both following conditions are met:
* each empty cell is under attack;
* exactly k pairs of rooks attack each other.
An empty cell is under attack if there is... | instruction | 0 | 45,541 | 15 | 91,082 |
Tags: combinatorics, fft, math
Correct Solution:
```
import sys
input=sys.stdin.readline
mod = 998244353
def cmb(n, r):
if ( r<0 or r>n ):
return 0
r = min(r, n-r)
return g1[n] * g2[r] * g2[n-r] % mod
NNN = 2*10**5
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]
for i in range( 2, NNN + 1 ):
g1.a... | output | 1 | 45,541 | 15 | 91,083 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Calculate the number of ways to place n rooks on n × n chessboard so that both following conditions are met:
* each empty cell is under attack;
* exactly k pairs of rooks attack each other.
An empty cell is under attack if there is... | instruction | 0 | 45,542 | 15 | 91,084 |
Tags: combinatorics, fft, math
Correct Solution:
```
MOD = 998244353
n, k = map(int, input().split())
x = n - k
num = 1
den = 1
s = 0
#print(x)
for i in range(x):
v = pow(x-i, n, MOD) * num * pow(den, MOD-2, MOD)
#print(num, den, (x-i)**n, den, v )
s = (s + ((-1)**i) * v) % MOD
num = (num * (x-i)) % MOD
den = (d... | output | 1 | 45,542 | 15 | 91,085 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Calculate the number of ways to place n rooks on n × n chessboard so that both following conditions are met:
* each empty cell is under attack;
* exactly k pairs of rooks attack each other... | instruction | 0 | 45,543 | 15 | 91,086 |
Yes | output | 1 | 45,543 | 15 | 91,087 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Calculate the number of ways to place n rooks on n × n chessboard so that both following conditions are met:
* each empty cell is under attack;
* exactly k pairs of rooks attack each other... | instruction | 0 | 45,544 | 15 | 91,088 |
Yes | output | 1 | 45,544 | 15 | 91,089 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Calculate the number of ways to place n rooks on n × n chessboard so that both following conditions are met:
* each empty cell is under attack;
* exactly k pairs of rooks attack each other... | instruction | 0 | 45,545 | 15 | 91,090 |
Yes | output | 1 | 45,545 | 15 | 91,091 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Calculate the number of ways to place n rooks on n × n chessboard so that both following conditions are met:
* each empty cell is under attack;
* exactly k pairs of rooks attack each other... | instruction | 0 | 45,546 | 15 | 91,092 |
Yes | output | 1 | 45,546 | 15 | 91,093 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Calculate the number of ways to place n rooks on n × n chessboard so that both following conditions are met:
* each empty cell is under attack;
* exactly k pairs of rooks attack each other... | instruction | 0 | 45,547 | 15 | 91,094 |
No | output | 1 | 45,547 | 15 | 91,095 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Calculate the number of ways to place n rooks on n × n chessboard so that both following conditions are met:
* each empty cell is under attack;
* exactly k pairs of rooks attack each other... | instruction | 0 | 45,548 | 15 | 91,096 |
No | output | 1 | 45,548 | 15 | 91,097 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Calculate the number of ways to place n rooks on n × n chessboard so that both following conditions are met:
* each empty cell is under attack;
* exactly k pairs of rooks attack each other... | instruction | 0 | 45,549 | 15 | 91,098 |
No | output | 1 | 45,549 | 15 | 91,099 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Calculate the number of ways to place n rooks on n × n chessboard so that both following conditions are met:
* each empty cell is under attack;
* exactly k pairs of rooks attack each other... | instruction | 0 | 45,550 | 15 | 91,100 |
No | output | 1 | 45,550 | 15 | 91,101 |
Provide a correct Python 3 solution for this coding contest problem.
problem
Cryptography is all the rage at xryuseix's school. Xryuseix, who lives in a grid of cities, has come up with a new cryptography to decide where to meet.
The ciphertext consists of the $ N $ character string $ S $, and the $ S_i $ character ... | instruction | 0 | 46,141 | 15 | 92,282 |
"Correct Solution:
```
# -*- coding: utf-8 -*-
from string import ascii_letters
from collections import defaultdict
import sys
#input = sys.stdin.readline
def inpl(): return list(map(int, input().split()))
M = {s:i//13 for i, s in enumerate(ascii_letters)}
D = defaultdict(int)
ans = ""
input()
for s in input():
D... | output | 1 | 46,141 | 15 | 92,283 |
Provide a correct Python 3 solution for this coding contest problem.
problem
Cryptography is all the rage at xryuseix's school. Xryuseix, who lives in a grid of cities, has come up with a new cryptography to decide where to meet.
The ciphertext consists of the $ N $ character string $ S $, and the $ S_i $ character ... | instruction | 0 | 46,142 | 15 | 92,284 |
"Correct Solution:
```
N = int(input())
word = list(input())
X1 = ['A','B','C','D','E','F','G','H','I','J','K','L','M']
X2 = ['N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
Y1 = ['a','b','c','d','e','f','g','h','i','j','k','l','m']
Y2 = ['n','o','p','q','r','s','t','u','v','w','x','y','z']
x = 0
y = 0
answer = ""... | output | 1 | 46,142 | 15 | 92,285 |
Provide a correct Python 3 solution for this coding contest problem.
problem
Cryptography is all the rage at xryuseix's school. Xryuseix, who lives in a grid of cities, has come up with a new cryptography to decide where to meet.
The ciphertext consists of the $ N $ character string $ S $, and the $ S_i $ character ... | instruction | 0 | 46,143 | 15 | 92,286 |
"Correct Solution:
```
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.st... | output | 1 | 46,143 | 15 | 92,287 |
Provide a correct Python 3 solution for this coding contest problem.
problem
Cryptography is all the rage at xryuseix's school. Xryuseix, who lives in a grid of cities, has come up with a new cryptography to decide where to meet.
The ciphertext consists of the $ N $ character string $ S $, and the $ S_i $ character ... | instruction | 0 | 46,144 | 15 | 92,288 |
"Correct Solution:
```
n = int(input())
S = input()
C = [chr(i) for i in range(97, 97+13)]
D = [chr(i) for i in range(97+13, 97+26)]
A = [chr(i) for i in range(65, 65+13)]
B = [chr(i) for i in range(65+13, 65+26)]
X = [0] * 2
for s in S:
if s in A:
X[0] += 1
elif s in B:
X[0] -= 1
elif s i... | output | 1 | 46,144 | 15 | 92,289 |
Provide a correct Python 3 solution for this coding contest problem.
problem
Cryptography is all the rage at xryuseix's school. Xryuseix, who lives in a grid of cities, has come up with a new cryptography to decide where to meet.
The ciphertext consists of the $ N $ character string $ S $, and the $ S_i $ character ... | instruction | 0 | 46,145 | 15 | 92,290 |
"Correct Solution:
```
N = int(input())
S = input()
n = s = e = w = 0
for c in S:
if 'A' <= c <= 'M':
n += 1
elif 'N' <= c <= 'Z':
s += 1
elif 'a' <= c <= 'm':
e += 1
else:
w += 1
my = min(n,s)
n -= my
s -= my
mx = min(e,w)
e -= mx
w -= mx
ans = 'A'*n + 'N'*s + 'a'*e + 'n'*w
print(len(ans))
p... | output | 1 | 46,145 | 15 | 92,291 |
Provide a correct Python 3 solution for this coding contest problem.
problem
Cryptography is all the rage at xryuseix's school. Xryuseix, who lives in a grid of cities, has come up with a new cryptography to decide where to meet.
The ciphertext consists of the $ N $ character string $ S $, and the $ S_i $ character ... | instruction | 0 | 46,146 | 15 | 92,292 |
"Correct Solution:
```
N = int(input())
S = input()
A = Z = a = z = 0
for c in S:
c = ord(c)
if c <= 77:
A += 1
elif c <= 90:
Z += 1
elif c <= 109:
a += 1
else:
z += 1
ans = "A"*(A-Z)+"Z"*(Z-A)+"a"*(a-z)+"z"*(z-a)
print(len(ans))
print(ans)
``` | output | 1 | 46,146 | 15 | 92,293 |
Provide a correct Python 3 solution for this coding contest problem.
problem
Cryptography is all the rage at xryuseix's school. Xryuseix, who lives in a grid of cities, has come up with a new cryptography to decide where to meet.
The ciphertext consists of the $ N $ character string $ S $, and the $ S_i $ character ... | instruction | 0 | 46,147 | 15 | 92,294 |
"Correct Solution:
```
n = int(input())
ns = 0
ew = 0
meirei = list(input())
for i in range(n) :
if 65 <= ord(meirei[i]) <= 77 :
ns += 1
elif 78 <= ord(meirei[i]) <= 90 :
ns -= 1
elif 97 <= ord(meirei[i]) <= 109 :
ew += 1
else :
ew -= 1
print(abs(ns) + abs(ew))
if ns > 0 ... | output | 1 | 46,147 | 15 | 92,295 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
As Kevin is in BigMan's house, suddenly a trap sends him onto a grid with n rows and m columns.
BigMan's trap is configured by two arrays: an array a_1,a_2,…,a_n and an array b_1,b_2,…,b_m.
In... | instruction | 0 | 46,448 | 15 | 92,896 |
No | output | 1 | 46,448 | 15 | 92,897 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
As Kevin is in BigMan's house, suddenly a trap sends him onto a grid with n rows and m columns.
BigMan's trap is configured by two arrays: an array a_1,a_2,…,a_n and an array b_1,b_2,…,b_m.
In... | instruction | 0 | 46,449 | 15 | 92,898 |
No | output | 1 | 46,449 | 15 | 92,899 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
As Kevin is in BigMan's house, suddenly a trap sends him onto a grid with n rows and m columns.
BigMan's trap is configured by two arrays: an array a_1,a_2,…,a_n and an array b_1,b_2,…,b_m.
In... | instruction | 0 | 46,450 | 15 | 92,900 |
No | output | 1 | 46,450 | 15 | 92,901 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Mr. Bender has a digital table of size n × n, each cell can be switched on or off. He wants the field to have at least c switched on squares. When this condition is fulfilled, Mr Bender will be happy.
We'll consider the table rows numbered ... | instruction | 0 | 46,562 | 15 | 93,124 |
Tags: binary search, implementation, math
Correct Solution:
```
def compute(n,x,y,c):
x1=min(x-1,n-x)
x2=n-x1-1
y1=min(y-1,n-y)
y2=n-y1-1
i1=x1+y1+1
i2=min(y1+x2,y2+x1)+1
i3=max(y1+x2,y2+x1)+1
o1=min(x1,y1)
o2=min(max(x1,y1),min(y2,x2))
o3=max(max(x1,y1),min... | output | 1 | 46,562 | 15 | 93,125 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Mr. Bender has a digital table of size n × n, each cell can be switched on or off. He wants the field to have at least c switched on squares. When this condition is fulfilled, Mr Bender will be happy.
We'll consider the table rows numbered ... | instruction | 0 | 46,563 | 15 | 93,126 |
Tags: binary search, implementation, math
Correct Solution:
```
import sys
ii = lambda: sys.stdin.readline().strip()
idata = lambda: [int(x) for x in ii().split()]
sdata = lambda: list(ii())
def solve():
n, x, y, c = idata()
r = n ** 2
l = -1
while l + 1 < r:
middle = (l + r) // 2
ans =... | output | 1 | 46,563 | 15 | 93,127 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Consider a long corridor which can be divided into n square cells of size 1 × 1. These cells are numbered from 1 to n from left to right.
There are two people in this corridor, a hooligan and a security guard. Initially, the hooligan is in ... | instruction | 0 | 47,221 | 15 | 94,442 |
Tags: binary search, sortings
Correct Solution:
```
for _ in range(int(input())):
n, m, a, b = map(int, input().split())
s = [int(i) for i in input().split()]
s.sort()
s.append(0)
if a > b:
a = n - a + 1
b = n - b + 1
num_of_possible_firecrackers = b - a - 1
seconds_to_guar... | output | 1 | 47,221 | 15 | 94,443 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Consider a long corridor which can be divided into n square cells of size 1 × 1. These cells are numbered from 1 to n from left to right.
There are two people in this corridor, a hooligan and a security guard. Initially, the hooligan is in ... | instruction | 0 | 47,222 | 15 | 94,444 |
Tags: binary search, sortings
Correct Solution:
```
# by the authority of GOD author: manhar singh sachdev #
import os,sys
from io import BytesIO, IOBase
def check(n,a,b,s,mid):
if abs(a-b) <= mid:
return False
ti = 0
for i in range(mid):
ti = max(ti,s[i]+mid-i)
if a > b:
d... | output | 1 | 47,222 | 15 | 94,445 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Consider a long corridor which can be divided into n square cells of size 1 × 1. These cells are numbered from 1 to n from left to right.
There are two people in this corridor, a hooligan and a security guard. Initially, the hooligan is in ... | instruction | 0 | 47,223 | 15 | 94,446 |
Tags: binary search, sortings
Correct Solution:
```
import sys
input = sys.stdin.readline
for _ in range(int(input())):
n,m,a,b=[int(x) for x in input().split()]
arr=[int(x) for x in input().split()]
arr.sort()
t=abs(b-a)-1
if a>b:
x=n-a+1
else:
x=a
now=min(t-1,m-1)
curr=... | output | 1 | 47,223 | 15 | 94,447 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Consider a long corridor which can be divided into n square cells of size 1 × 1. These cells are numbered from 1 to n from left to right.
There are two people in this corridor, a hooligan and a security guard. Initially, the hooligan is in ... | instruction | 0 | 47,224 | 15 | 94,448 |
Tags: binary search, sortings
Correct Solution:
```
import sys
input=sys.stdin.buffer.readline #FOR READING PURE INTEGER INPUTS (space separation ok)
def multiLineArrayPrint(arr):
print('\n'.join([str(x) for x in arr]))
t=int(input())
allAns=[]
for _ in range(t):
n,m,a,b=[int(x) for x in input().split()]
s... | output | 1 | 47,224 | 15 | 94,449 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Consider a long corridor which can be divided into n square cells of size 1 × 1. These cells are numbered from 1 to n from left to right.
There are two people in this corridor, a hooligan and a security guard. Initially, the hooligan is in ... | instruction | 0 | 47,225 | 15 | 94,450 |
Tags: binary search, sortings
Correct Solution:
```
'''
3
7 2 3 6
1 4
7 2 3 6
5 1
7 2 3 6
4 4
'''
n=int(input())
for i in range(0,n):
o=input().rstrip().split(' ')
p=input().rstrip().split(' ')
p.sort(key=int,reverse=True)
N=int(o[0])
A=int(o[2])
B=int(o[3])
if A==B:
print(0)
... | output | 1 | 47,225 | 15 | 94,451 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Consider a long corridor which can be divided into n square cells of size 1 × 1. These cells are numbered from 1 to n from left to right.
There are two people in this corridor, a hooligan and a security guard. Initially, the hooligan is in ... | instruction | 0 | 47,226 | 15 | 94,452 |
Tags: binary search, sortings
Correct Solution:
```
import sys
import math
T=int(sys.stdin.readline().strip())
while (T>0):
T-=1
n,m,a,b=sys.stdin.readline().strip().split(" ")
l=sys.stdin.readline().strip()
l=l.split(" ")
l=sorted(list(map(lambda x:int(x), l)),reverse=True)
if int(a)<int(b):
k=int(b)-1
els... | output | 1 | 47,226 | 15 | 94,453 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Consider a long corridor which can be divided into n square cells of size 1 × 1. These cells are numbered from 1 to n from left to right.
There are two people in this corridor, a hooligan and a security guard. Initially, the hooligan is in ... | instruction | 0 | 47,227 | 15 | 94,454 |
Tags: binary search, sortings
Correct Solution:
```
for _ in range(int(input())):
n, m, a, b = map(int, input().split())
cnt = abs(a - b) - 1
total = 0
if a < b:
total += b - 2
else:
total += n - b - 1
u = total - cnt
s = list(map(int, input().split()))
s = sorted(s)
... | output | 1 | 47,227 | 15 | 94,455 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Consider a long corridor which can be divided into n square cells of size 1 × 1. These cells are numbered from 1 to n from left to right.
There are two people in this corridor, a hooligan and a security guard. Initially, the hooligan is in ... | instruction | 0 | 47,228 | 15 | 94,456 |
Tags: binary search, sortings
Correct Solution:
```
#coding:utf8
cnt_case = int(input())
for i in range(cnt_case):
n, m, a, b = [int(_v) for _v in input().split(" ")]
m_list = sorted([int(_v) for _v in input().split(" ")], reverse=True)
cnt = len(m_list)
if a == b:
print(0)
if a > b:
... | output | 1 | 47,228 | 15 | 94,457 |
Provide tags and a correct Python 3 solution for this coding contest problem.
One way to create task is to learn from game. You should pick a game and focus on part of the mechanic of that game, then it might be a good task.
Let's have a try. Puzzle and Dragon was a popular game in Japan, we focus on the puzzle part ... | instruction | 0 | 47,428 | 15 | 94,856 |
Tags: constructive algorithms, implementation
Correct Solution:
```
"""
Codeforces Contest 270 Problem E
Author : chaotic_iak
Language: Python 3.3.4
"""
class Board(object):
def __init__(self, init):
self.grid = init
moves = []
def current(self):
return self.moves[-1]
d... | output | 1 | 47,428 | 15 | 94,857 |
Provide tags and a correct Python 3 solution for this coding contest problem.
One way to create task is to learn from game. You should pick a game and focus on part of the mechanic of that game, then it might be a good task.
Let's have a try. Puzzle and Dragon was a popular game in Japan, we focus on the puzzle part ... | instruction | 0 | 47,429 | 15 | 94,858 |
Tags: constructive algorithms, implementation
Correct Solution:
```
class Board(object):
def __init__(self, init):
self.grid = init
moves = []
def current(self):
return self.moves[-1]
def print_moves(self):
print(len(self.moves)-1)
for i,j in self.moves:
... | output | 1 | 47,429 | 15 | 94,859 |
Provide a correct Python 3 solution for this coding contest problem.
There is a grid with H horizontal rows and W vertical columns. Let (i, j) denote the square at the i-th row from the top and the j-th column from the left.
For each i and j (1 \leq i \leq H, 1 \leq j \leq W), Square (i, j) is described by a characte... | instruction | 0 | 47,752 | 15 | 95,504 |
"Correct Solution:
```
from sys import stdin
h,w = map(int,stdin.readline().split())
arr = [list(stdin.readline()) for _ in range(h)]
dp = [[0]*w for _ in range(h)]
dp[0][0] = 1
mod = 10**9+7
for i in range(h):
for j in range(w):
if arr[i][j] == '.':
dp[i][j] += (0 if i==0 else dp[i-1][j])+(0 if... | output | 1 | 47,752 | 15 | 95,505 |
Provide a correct Python 3 solution for this coding contest problem.
There is a grid with H horizontal rows and W vertical columns. Let (i, j) denote the square at the i-th row from the top and the j-th column from the left.
For each i and j (1 \leq i \leq H, 1 \leq j \leq W), Square (i, j) is described by a characte... | instruction | 0 | 47,753 | 15 | 95,506 |
"Correct Solution:
```
h, w = map(int, input().split())
a = [None for _ in range(h)]
for i in range(h):
a[i] = [s == '.' for s in input()]
MOD = 10 ** 9 + 7
dp = [[0 for j in range(w + 1)] for i in range(h + 1)]
dp[1][1] = 1
for i in range(h):
for j in range(w):
if a[i][j]:
dp[i + 1][j + 1]... | output | 1 | 47,753 | 15 | 95,507 |
Provide a correct Python 3 solution for this coding contest problem.
There is a grid with H horizontal rows and W vertical columns. Let (i, j) denote the square at the i-th row from the top and the j-th column from the left.
For each i and j (1 \leq i \leq H, 1 \leq j \leq W), Square (i, j) is described by a characte... | instruction | 0 | 47,754 | 15 | 95,508 |
"Correct Solution:
```
mod = int(1e9 + 7)
h, w = map(int, input().split())
MAP = ['#' * w] + ['#' + input() for _ in range(h)]
dp = [[0] * (w + 1) for _ in range(h + 1)]
dp[0][1] = 1
for i in range(1, h + 1):
for j in range(1, w + 1):
if MAP[i][j] == '.':
dp[i][j] = (dp[i - 1][j] + dp[i][j - 1])... | output | 1 | 47,754 | 15 | 95,509 |
Provide a correct Python 3 solution for this coding contest problem.
There is a grid with H horizontal rows and W vertical columns. Let (i, j) denote the square at the i-th row from the top and the j-th column from the left.
For each i and j (1 \leq i \leq H, 1 \leq j \leq W), Square (i, j) is described by a characte... | instruction | 0 | 47,755 | 15 | 95,510 |
"Correct Solution:
```
MOD = 1000000007
h, w = map(int, input().split())
mp = [input() for _ in range(h)]
dp = [[0] * (w + 1) for _ in range(h + 1)]
dp[1][1] = 1
for y in range(1, h + 1):
for x in range(1, w + 1):
if mp[y - 1][x - 1] == "#":continue
dp[y][x] += dp[y - 1][x] + dp[y][x - 1]
dp[y][x] %= MOD
... | output | 1 | 47,755 | 15 | 95,511 |
Provide a correct Python 3 solution for this coding contest problem.
There is a grid with H horizontal rows and W vertical columns. Let (i, j) denote the square at the i-th row from the top and the j-th column from the left.
For each i and j (1 \leq i \leq H, 1 \leq j \leq W), Square (i, j) is described by a characte... | instruction | 0 | 47,756 | 15 | 95,512 |
"Correct Solution:
```
h, w = map(int, input().split())
a = [list(input()) for _ in range(h)]
dp = [[0] * w for _ in range(h)]
dp[0][0] = 1
for i in range(h):
for j in range(w):
if (j != w - 1) and (a[i][j + 1] == '.'):
dp[i][j + 1] += dp[i][j]
if (i != h - 1) and (a[i + 1][j] == '... | output | 1 | 47,756 | 15 | 95,513 |
Provide a correct Python 3 solution for this coding contest problem.
There is a grid with H horizontal rows and W vertical columns. Let (i, j) denote the square at the i-th row from the top and the j-th column from the left.
For each i and j (1 \leq i \leq H, 1 \leq j \leq W), Square (i, j) is described by a characte... | instruction | 0 | 47,757 | 15 | 95,514 |
"Correct Solution:
```
import sys
input = sys.stdin.readline
H, W = map(int, input().split())
Ms = [input().strip("\n") for _ in range(H)]
C = 10 ** 9 + 7
dp = [0] * (W + 1)
dp[0] = 1
for row in Ms:
for i in range(len(row)):
i1 = i + 1
if row[i] == '#':
dp[i1] = 0
else:
... | output | 1 | 47,757 | 15 | 95,515 |
Provide a correct Python 3 solution for this coding contest problem.
There is a grid with H horizontal rows and W vertical columns. Let (i, j) denote the square at the i-th row from the top and the j-th column from the left.
For each i and j (1 \leq i \leq H, 1 \leq j \leq W), Square (i, j) is described by a characte... | instruction | 0 | 47,758 | 15 | 95,516 |
"Correct Solution:
```
H, W = map(int, input().split())
a = [input() for _ in range(H)]
WARU = 10**9+7
dp = [[0]*(W+1) for _ in range(H+1)]
dp[0][0] = 1
for i in range(H):
for j in range(W):
if a[i][j] == "#":
continue
dp[i][j] %= WARU
dp[i+1][j] += dp[i][j]
... | output | 1 | 47,758 | 15 | 95,517 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.