message stringlengths 2 28.7k | message_type stringclasses 2
values | message_id int64 0 1 | conversation_id int64 21 109k | cluster float64 7 7 | __index_level_0__ int64 42 217k |
|---|---|---|---|---|---|
Provide a correct Python 3 solution for this coding contest problem.
Consider a circle whose perimeter is divided by N points into N arcs of equal length, and each of the arcs is painted red or blue. Such a circle is said to generate a string S from every point when the following condition is satisfied:
* We will arb... | instruction | 0 | 71,431 | 7 | 142,862 |
"Correct Solution:
```
p=int(1e9+7)
def calc(n,l,r):
f=[0]* (n+1)
f[0]=1
sum=0
for i in range (1,n+1):
if i>=l:
sum+=f[i-l]
f[i]=sum%p
if (i>=r):
sum-=f[i-r]
ans=0
for i in range (l,r+1):
ans=(ans+f[n-i]*i)%p
return ans
n,m=input().spl... | output | 1 | 71,431 | 7 | 142,863 |
Provide a correct Python 3 solution for this coding contest problem.
Consider a circle whose perimeter is divided by N points into N arcs of equal length, and each of the arcs is painted red or blue. Such a circle is said to generate a string S from every point when the following condition is satisfied:
* We will arb... | instruction | 0 | 71,432 | 7 | 142,864 |
"Correct Solution:
```
n,m = map(int,input().split())
s = input().rstrip()
mod = 10**9+7
if s.count("R") == 0 or s.count("B") == 0:
dp = [[0 for i in range(2)] for j in range(n)]
dp[0][0] = 1
dp[0][1] = 1
for i in range(1,n):
dp[i][0] = (dp[i-1][0]+dp[i-1][1])%mod
dp[i][1] = dp[i-1][0]
print((dp[n-1][... | output | 1 | 71,432 | 7 | 142,865 |
Provide a correct Python 3 solution for this coding contest problem.
Consider a circle whose perimeter is divided by N points into N arcs of equal length, and each of the arcs is painted red or blue. Such a circle is said to generate a string S from every point when the following condition is satisfied:
* We will arb... | instruction | 0 | 71,433 | 7 | 142,866 |
"Correct Solution:
```
def solve(n, m, s):
f = s[0]
MOD = 10 ** 9 + 7
INF = 10 ** 6
p = None
seq = 0
min_seq = INF
for c in s:
if c == p:
seq += 1
else:
if p == f and (min_seq == INF or seq % 2 == 1):
min_seq = min(min_seq, seq)
... | output | 1 | 71,433 | 7 | 142,867 |
Provide a correct Python 3 solution for this coding contest problem.
Consider a circle whose perimeter is divided by N points into N arcs of equal length, and each of the arcs is painted red or blue. Such a circle is said to generate a string S from every point when the following condition is satisfied:
* We will arb... | instruction | 0 | 71,434 | 7 | 142,868 |
"Correct Solution:
```
"""
https://atcoder.jp/contests/agc033/tasks/agc033_e
Sの1文字目をRとしてよい
RB から始まる場合 → 全部交互以外無理(Nが奇数なら0)
RRB から始まる場合 → Rは3連で置けば可能…
R*X + B*Y + R*Z …
とつながっていく
どこからスタートしても、RだけをX回移動したときにBの隣に来なくてはいけない
Rの長さが1なら可能
R*?,B,R*?,…
でつながっていく
最初のRがX個連続の時
片方の端との距離がX-2tでなくてはならない
Xが偶数の時、Rの連続長さはX+1以下の奇数
Xが奇数の時、... | output | 1 | 71,434 | 7 | 142,869 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Consider a circle whose perimeter is divided by N points into N arcs of equal length, and each of the arcs is painted red or blue. Such a circle is said to generate a string S from every point w... | instruction | 0 | 71,435 | 7 | 142,870 |
No | output | 1 | 71,435 | 7 | 142,871 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Consider a circle whose perimeter is divided by N points into N arcs of equal length, and each of the arcs is painted red or blue. Such a circle is said to generate a string S from every point w... | instruction | 0 | 71,436 | 7 | 142,872 |
No | output | 1 | 71,436 | 7 | 142,873 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Consider a circle whose perimeter is divided by N points into N arcs of equal length, and each of the arcs is painted red or blue. Such a circle is said to generate a string S from every point w... | instruction | 0 | 71,437 | 7 | 142,874 |
No | output | 1 | 71,437 | 7 | 142,875 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Consider a circle whose perimeter is divided by N points into N arcs of equal length, and each of the arcs is painted red or blue. Such a circle is said to generate a string S from every point w... | instruction | 0 | 71,438 | 7 | 142,876 |
No | output | 1 | 71,438 | 7 | 142,877 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A Christmas party in city S. had n children. All children came in mittens. The mittens can be of different colors, but each child had the left and the right mitten of the same color. Let's say that the colors of the mittens are numbered with... | instruction | 0 | 72,003 | 7 | 144,006 |
Tags: constructive algorithms, greedy, sortings
Correct Solution:
```
from collections import Counter
def main():
n, m = map(int, input().split())
c = list(map(int, input().split()))
sc = sorted(range(n), key=lambda x: c[x])
mc = Counter(c).most_common(1)[0][1]
print(n if mc <= n - mc else 2*(n... | output | 1 | 72,003 | 7 | 144,007 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A Christmas party in city S. had n children. All children came in mittens. The mittens can be of different colors, but each child had the left and the right mitten of the same color. Let's say that the colors of the mittens are numbered with... | instruction | 0 | 72,004 | 7 | 144,008 |
Tags: constructive algorithms, greedy, sortings
Correct Solution:
```
n, m = [int(i) for i in input().split()]
c1 = [int(i) for i in input().split()]
c1.sort()
ms = 0
i = 0
while i < n - 1:
start = i
while i < n - 1 and c1[i] == c1[i + 1]:
i += 1
ms = max(ms, i - start)
i += 1
ms += 1
c2 = c1[-m... | output | 1 | 72,004 | 7 | 144,009 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A Christmas party in city S. had n children. All children came in mittens. The mittens can be of different colors, but each child had the left and the right mitten of the same color. Let's say that the colors of the mittens are numbered with... | instruction | 0 | 72,005 | 7 | 144,010 |
Tags: constructive algorithms, greedy, sortings
Correct Solution:
```
import math
import sys
import collections
def In():
return map(int, sys.stdin.readline().split())
def mittens():
n, m = In()
l = list(collections.Counter(map(int, input().split())).items())
for i in range(len(l)):
l[i] = [... | output | 1 | 72,005 | 7 | 144,011 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A Christmas party in city S. had n children. All children came in mittens. The mittens can be of different colors, but each child had the left and the right mitten of the same color. Let's say that the colors of the mittens are numbered with... | instruction | 0 | 72,006 | 7 | 144,012 |
Tags: constructive algorithms, greedy, sortings
Correct Solution:
```
#!/usr/bin/python3
def readln(): return tuple(map(int, input().split()))
n, m = readln()
cnt = [0] * (m + 1)
for c in readln():
cnt[c] += 1
ans = [0] * n
j = 0
for _ in range(1, m + 1):
v = max(cnt)
i = cnt.index(v)
while cnt[i]:
... | output | 1 | 72,006 | 7 | 144,013 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A Christmas party in city S. had n children. All children came in mittens. The mittens can be of different colors, but each child had the left and the right mitten of the same color. Let's say that the colors of the mittens are numbered with... | instruction | 0 | 72,007 | 7 | 144,014 |
Tags: constructive algorithms, greedy, sortings
Correct Solution:
```
def takefirst(eml):
return eml[0]
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
b=[]
a.append(0)
max1=0
c=0
for i in range(len(a)-1):
if a[i]!=a[i+1]:
c+=1
max1=max(max1,c)
c=0
else:
... | output | 1 | 72,007 | 7 | 144,015 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A Christmas party in city S. had n children. All children came in mittens. The mittens can be of different colors, but each child had the left and the right mitten of the same color. Let's say that the colors of the mittens are numbered with... | instruction | 0 | 72,008 | 7 | 144,016 |
Tags: constructive algorithms, greedy, sortings
Correct Solution:
```
n, m = map(int, input().split())
arr = sorted(list(map(int, input().split())))
mit, col = 1, 1
for i in range(1, m+1):
t = arr.count(i)
if t > col:
mit = i
col = t
print(n - max(0, 2*col - n))
for i in range(n):
print(arr[(i+col) % n]... | output | 1 | 72,008 | 7 | 144,017 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A Christmas party in city S. had n children. All children came in mittens. The mittens can be of different colors, but each child had the left and the right mitten of the same color. Let's say that the colors of the mittens are numbered with... | instruction | 0 | 72,009 | 7 | 144,018 |
Tags: constructive algorithms, greedy, sortings
Correct Solution:
```
n, m = map(int, input().split())
p = [0] * (m + 1)
for i in map(int, input().split()): p[i] += 1
r, q = [], sorted((p[i], i) for i in range(1, m + 1))
k = q[m - 1][0]
print(n - max(2 * k - n, 0))
for i in q: r.extend([str(i[1])] * i[0])
print('\n'.jo... | output | 1 | 72,009 | 7 | 144,019 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A Christmas party in city S. had n children. All children came in mittens. The mittens can be of different colors, but each child had the left and the right mitten of the same color. Let's say that the colors of the mittens are numbered with... | instruction | 0 | 72,010 | 7 | 144,020 |
Tags: constructive algorithms, greedy, sortings
Correct Solution:
```
n, m = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort()
mit = 1
col = 1
for i in range(1, m+1):
t =arr.count(i)
if t > col:
mit = i
col = t
print(n-max(0, col-(n-col)))
for i in range(n):
print(arr[(i+col) % n]... | output | 1 | 72,010 | 7 | 144,021 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A Christmas party in city S. had n children. All children came in mittens. The mittens can be of different colors, but each child had the left and the right mitten of the same color. Let's say t... | instruction | 0 | 72,011 | 7 | 144,022 |
Yes | output | 1 | 72,011 | 7 | 144,023 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A Christmas party in city S. had n children. All children came in mittens. The mittens can be of different colors, but each child had the left and the right mitten of the same color. Let's say t... | instruction | 0 | 72,012 | 7 | 144,024 |
Yes | output | 1 | 72,012 | 7 | 144,025 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A Christmas party in city S. had n children. All children came in mittens. The mittens can be of different colors, but each child had the left and the right mitten of the same color. Let's say t... | instruction | 0 | 72,013 | 7 | 144,026 |
No | output | 1 | 72,013 | 7 | 144,027 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A Christmas party in city S. had n children. All children came in mittens. The mittens can be of different colors, but each child had the left and the right mitten of the same color. Let's say t... | instruction | 0 | 72,014 | 7 | 144,028 |
No | output | 1 | 72,014 | 7 | 144,029 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A Christmas party in city S. had n children. All children came in mittens. The mittens can be of different colors, but each child had the left and the right mitten of the same color. Let's say t... | instruction | 0 | 72,015 | 7 | 144,030 |
No | output | 1 | 72,015 | 7 | 144,031 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A Christmas party in city S. had n children. All children came in mittens. The mittens can be of different colors, but each child had the left and the right mitten of the same color. Let's say t... | instruction | 0 | 72,016 | 7 | 144,032 |
No | output | 1 | 72,016 | 7 | 144,033 |
Provide a correct Python 3 solution for this coding contest problem.
problem
Mobiles are widely known as moving works of art. The IOI Japan Committee has decided to create mobiles to publicize JOI. JOI public relations mobiles are sticks, strings, and weights. It is constructed as follows using the three types of ele... | instruction | 0 | 72,432 | 7 | 144,864 |
"Correct Solution:
```
# AOJ0520
import sys
def gcd(x, y):
if x < y:
x, y = y, x
while x % y != 0:
x, y = y, x % y
return y
class frac:
def __init__(self, n, d):
self.num = n
self.den = d
def mul(self, yn, yd):
xn, xd = self.num, self.den
x... | output | 1 | 72,432 | 7 | 144,865 |
Provide a correct Python 3 solution for this coding contest problem.
problem
Mobiles are widely known as moving works of art. The IOI Japan Committee has decided to create mobiles to publicize JOI. JOI public relations mobiles are sticks, strings, and weights. It is constructed as follows using the three types of ele... | instruction | 0 | 72,433 | 7 | 144,866 |
"Correct Solution:
```
def gcd(x, y):
while y > 0:
x, y = y, x%y
return x
while True:
N = int(input())
if not N:
break
a = [list(map(int, input().split())) for _ in [0]*N]
root = (set(range(1, N+1)) - set(n for bar in a for n in bar[2:])).pop()
def solve(ratio_r, ratio_l, l... | output | 1 | 72,433 | 7 | 144,867 |
Provide a correct Python 3 solution for this coding contest problem.
problem
Mobiles are widely known as moving works of art. The IOI Japan Committee has decided to create mobiles to publicize JOI. JOI public relations mobiles are sticks, strings, and weights. It is constructed as follows using the three types of ele... | instruction | 0 | 72,434 | 7 | 144,868 |
"Correct Solution:
```
def gcd(a, b):
r = a % b
if r:
return gcd(b, r)
return b
def lcm(a, b):
if a < b:
a, b = b, a
return a * b // gcd(a, b)
def min_weight(m):
p, q, r, b = bars[m - 1]
red = p * (min_weight(r) if r else 1)
blue = q * (min_weight(b) if b else 1)
... | output | 1 | 72,434 | 7 | 144,869 |
Provide a correct Python 3 solution for this coding contest problem.
problem
Mobiles are widely known as moving works of art. The IOI Japan Committee has decided to create mobiles to publicize JOI. JOI public relations mobiles are sticks, strings, and weights. It is constructed as follows using the three types of ele... | instruction | 0 | 72,435 | 7 | 144,870 |
"Correct Solution:
```
'''
Created on 2017/03/09
@author: 03key
'''
def gcd(x,y):
if x<y:
tmp = x
x = y
y = tmp
ans = y
if x%y != 0:
ans = gcd(y,x%y)
return ans
class Mobile:
def __init__(self,leftratio=0,rightratio=0,left=-1,right=-1):
self.weight = 0
... | output | 1 | 72,435 | 7 | 144,871 |
Provide a correct Python 3 solution for this coding contest problem.
problem
Mobiles are widely known as moving works of art. The IOI Japan Committee has decided to create mobiles to publicize JOI. JOI public relations mobiles are sticks, strings, and weights. It is constructed as follows using the three types of ele... | instruction | 0 | 72,436 | 7 | 144,872 |
"Correct Solution:
```
from math import gcd
while True:
try:
n = int(input())
if not n: break
lst = [[]]
weight = [-1 for i in range(n + 1)]
def setWeight(n):
p,q,r,b = lst[n]
if weight[n] != -1:pass
elif r == 0 and b == 0:
weight[n] = (p + q) // gcd(p,q)
elif r == ... | output | 1 | 72,436 | 7 | 144,873 |
Provide a correct Python 3 solution for this coding contest problem.
problem
Mobiles are widely known as moving works of art. The IOI Japan Committee has decided to create mobiles to publicize JOI. JOI public relations mobiles are sticks, strings, and weights. It is constructed as follows using the three types of ele... | instruction | 0 | 72,437 | 7 | 144,874 |
"Correct Solution:
```
# AOJ 0520: Lightest Mobile
# Python3 2018.6.30 bal4u
def lcm(a, b):
return a // gcd(a, b) * b
def gcd(a, b):
while b != 0:
r = a % b
a, b = b, r
return a
def calc(i):
wr = calc(t[i][2]) if t[i][2] > 0 else 1
wb = calc(t[i][3]) if t[i][3] > 0 else 1
w = lcm(t[i][0] * wr, t[i][1] * wb... | output | 1 | 72,437 | 7 | 144,875 |
Provide a correct Python 3 solution for this coding contest problem.
problem
Mobiles are widely known as moving works of art. The IOI Japan Committee has decided to create mobiles to publicize JOI. JOI public relations mobiles are sticks, strings, and weights. It is constructed as follows using the three types of ele... | instruction | 0 | 72,438 | 7 | 144,876 |
"Correct Solution:
```
def solve():
from math import gcd
# Post-order tree traversal
def traversal(bar_id):
if bar_id == 0:
return 1
p, q, r, b = nodes[bar_id]
r_w = traversal(r)
b_w = traversal(b)
cf = gcd(p * r_w, q * b_w)
return r_... | output | 1 | 72,438 | 7 | 144,877 |
Provide a correct Python 3 solution for this coding contest problem.
problem
Mobiles are widely known as moving works of art. The IOI Japan Committee has decided to create mobiles to publicize JOI. JOI public relations mobiles are sticks, strings, and weights. It is constructed as follows using the three types of ele... | instruction | 0 | 72,439 | 7 | 144,878 |
"Correct Solution:
```
from math import gcd
def lcm(i, j):
return i * j // gcd(i, j)
def main():
while True:
n = int(input())
if not n: break
lst = [[]]
weight = [-1 for i in range(n + 1)]
def setWeight(n):
p, q, r, b = lst[n]
if weight[n] != -1: pass
elif r == 0 and b == 0:
... | output | 1 | 72,439 | 7 | 144,879 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Flatland is inhabited by pixels of three colors: red, green and blue. We know that if two pixels of different colors meet in a violent fight, only one of them survives the fight (that is, the total number of pixels decreases by one). Besides... | instruction | 0 | 72,779 | 7 | 145,558 |
Tags: constructive algorithms, math
Correct Solution:
```
a = list(map(int,input().split()))
a.sort()
if int(a[1] % 2 == 0)+int(a[0] % 2 == 0)==1:
print(a[2])
else:
print(int((((a[1]-a[0])+(a[1]+a[0]))/2)))
``` | output | 1 | 72,779 | 7 | 145,559 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Flatland is inhabited by pixels of three colors: red, green and blue. We know that if two pixels of different colors meet in a violent fight, only one of them survives the fight (that is, the total number of pixels decreases by one). Besides... | instruction | 0 | 72,780 | 7 | 145,560 |
Tags: constructive algorithms, math
Correct Solution:
```
import sys
input=sys.stdin.readline
l=input().split()
li=[int(i) for i in l]
maxa=10**18
li.sort()
if((li[2]-li[1])%2==0):
maxa=min(maxa,li[2])
if((li[2]-li[0])%2==0):
maxa=min(maxa,li[2])
if((li[1]-li[0])%2==0):
maxa=min(maxa,li[1])
if(maxa==10**18)... | output | 1 | 72,780 | 7 | 145,561 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Flatland is inhabited by pixels of three colors: red, green and blue. We know that if two pixels of different colors meet in a violent fight, only one of them survives the fight (that is, the total number of pixels decreases by one). Besides... | instruction | 0 | 72,781 | 7 | 145,562 |
Tags: constructive algorithms, math
Correct Solution:
```
def pixel(input):
red, green, blue = input.split()
red = int(red)
green = int(green)
blue = int(blue)
plist = [red,green,blue]
plist.sort()
lowestChet = is_chet(plist[0])
midChet = is_chet(plist[1])
if ((midChet + lowestChe... | output | 1 | 72,781 | 7 | 145,563 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Flatland is inhabited by pixels of three colors: red, green and blue. We know that if two pixels of different colors meet in a violent fight, only one of them survives the fight (that is, the total number of pixels decreases by one). Besides... | instruction | 0 | 72,782 | 7 | 145,564 |
Tags: constructive algorithms, math
Correct Solution:
```
a = list(map(int,input().split()))
def calc(a):
return int((((a[1]-a[0])+(a[1]+a[0]))/2))
a.sort()
if a[1] % 2 == 0 and a[0] % 2 == 0:
print(calc(a))
elif a[1] % 2 == 0 or a[0] % 2 == 0:
print(a[2])
else:
print(calc(a))
``` | output | 1 | 72,782 | 7 | 145,565 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Flatland is inhabited by pixels of three colors: red, green and blue. We know that if two pixels of different colors meet in a violent fight, only one of them survives the fight (that is, the to... | instruction | 0 | 72,783 | 7 | 145,566 |
No | output | 1 | 72,783 | 7 | 145,567 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Flatland is inhabited by pixels of three colors: red, green and blue. We know that if two pixels of different colors meet in a violent fight, only one of them survives the fight (that is, the to... | instruction | 0 | 72,784 | 7 | 145,568 |
No | output | 1 | 72,784 | 7 | 145,569 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Flatland is inhabited by pixels of three colors: red, green and blue. We know that if two pixels of different colors meet in a violent fight, only one of them survives the fight (that is, the to... | instruction | 0 | 72,785 | 7 | 145,570 |
No | output | 1 | 72,785 | 7 | 145,571 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Flatland is inhabited by pixels of three colors: red, green and blue. We know that if two pixels of different colors meet in a violent fight, only one of them survives the fight (that is, the to... | instruction | 0 | 72,786 | 7 | 145,572 |
No | output | 1 | 72,786 | 7 | 145,573 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Berland crossword is a puzzle that is solved on a square grid with n rows and n columns. Initially all the cells are white.
To solve the puzzle one has to color some cells on the border of the grid black in such a way that:
* exactly U ... | instruction | 0 | 73,560 | 7 | 147,120 |
Tags: bitmasks, brute force, greedy, implementation
Correct Solution:
```
import sys
t = int(input())
for i in range(t):
n, u, r, d, l = map(int, sys.stdin.readline().rstrip().split())
l_must = 0
r_must = 0
u_must = 0
d_must = 0
must = 0
if n-u < 2:
if n-u == 0:
must += 2... | output | 1 | 73,560 | 7 | 147,121 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Berland crossword is a puzzle that is solved on a square grid with n rows and n columns. Initially all the cells are white.
To solve the puzzle one has to color some cells on the border of the grid black in such a way that:
* exactly U ... | instruction | 0 | 73,561 | 7 | 147,122 |
Tags: bitmasks, brute force, greedy, implementation
Correct Solution:
```
import os
import sys
from io import BytesIO, IOBase
def mul_input():
return map(int,input().split())
def arr_input():
return list(map(int,input().split()))
def solve():
n,u,r,d,l=mul_input()
u1=u
r1=r
d1=d
l1=l
... | output | 1 | 73,561 | 7 | 147,123 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Berland crossword is a puzzle that is solved on a square grid with n rows and n columns. Initially all the cells are white.
To solve the puzzle one has to color some cells on the border of the grid black in such a way that:
* exactly U ... | instruction | 0 | 73,562 | 7 | 147,124 |
Tags: bitmasks, brute force, greedy, implementation
Correct Solution:
```
def solve(n,u,r,d,l):
u1=u
#Squares to be painted on each side
r1,d1,l1=r,d,l
if(u==n):
r1-=1
l1-=1
if(u==n-1):
if(l1>r1):
l1-=1
else:
r1-=1
... | output | 1 | 73,562 | 7 | 147,125 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Berland crossword is a puzzle that is solved on a square grid with n rows and n columns. Initially all the cells are white.
To solve the puzzle one has to color some cells on the border of the grid black in such a way that:
* exactly U ... | instruction | 0 | 73,563 | 7 | 147,126 |
Tags: bitmasks, brute force, greedy, implementation
Correct Solution:
```
# from __future__ import print_function
# import sys
# def eprint(*args, **kwargs): print(*args, file=sys.stderr, **kwargs)
def solution(n,u,r,d,l):
maxfilled=u+r+d+l
minfilled=u+r+d+l-4
found = False
# for i in range(2**(4*(n-1... | output | 1 | 73,563 | 7 | 147,127 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Berland crossword is a puzzle that is solved on a square grid with n rows and n columns. Initially all the cells are white.
To solve the puzzle one has to color some cells on the border of the grid black in such a way that:
* exactly U ... | instruction | 0 | 73,564 | 7 | 147,128 |
Tags: bitmasks, brute force, greedy, implementation
Correct Solution:
```
tt = int(input())
while tt:
n, U, R, D, L = map(int, input().split())
for mask in range(16):
rU, rR, rD, rL = U, R, D, L
if mask & 1:
rU -= 1
rL -= 1
if mask & 2:
rL -= 1
... | output | 1 | 73,564 | 7 | 147,129 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Berland crossword is a puzzle that is solved on a square grid with n rows and n columns. Initially all the cells are white.
To solve the puzzle one has to color some cells on the border of the grid black in such a way that:
* exactly U ... | instruction | 0 | 73,565 | 7 | 147,130 |
Tags: bitmasks, brute force, greedy, implementation
Correct Solution:
```
import sys
input = sys.stdin.readline
for f in range(int(input())):
n,u,r,d,l=map(int,input().split())
mnv=mnh=0
if u>=n-1:
mnh+=u-n+2
if r>=n-1:
mnv+=r-n+2
if d>=n-1:
mnh+=d-n+2
if l>=n-1:
... | output | 1 | 73,565 | 7 | 147,131 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Berland crossword is a puzzle that is solved on a square grid with n rows and n columns. Initially all the cells are white.
To solve the puzzle one has to color some cells on the border of the grid black in such a way that:
* exactly U ... | instruction | 0 | 73,566 | 7 | 147,132 |
Tags: bitmasks, brute force, greedy, implementation
Correct Solution:
```
t = int(input())
for k in range(t):
n, U, R, D, L = map(int, input().split())
pr = 0
for i in range(16):
m = []
for j in range(4):
dd = (i >> j) & 1
m.append(dd)
ul, ur, dl, dr = m[0], m... | output | 1 | 73,566 | 7 | 147,133 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Berland crossword is a puzzle that is solved on a square grid with n rows and n columns. Initially all the cells are white.
To solve the puzzle one has to color some cells on the border of the grid black in such a way that:
* exactly U ... | instruction | 0 | 73,567 | 7 | 147,134 |
Tags: bitmasks, brute force, greedy, implementation
Correct Solution:
```
def solution():
n, u, r, d, l = map(int, input().split())
if max(u, r, d, l) <= n - 2:
print('YES')
elif max(u, r, d, l) == n - 1:
if u == n - 1 and d == n - 1 and (l + r < 2):
print('NO')
... | output | 1 | 73,567 | 7 | 147,135 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Berland crossword is a puzzle that is solved on a square grid with n rows and n columns. Initially all the cells are white.
To solve the puzzle one has to color some cells on the border of the ... | instruction | 0 | 73,568 | 7 | 147,136 |
Yes | output | 1 | 73,568 | 7 | 147,137 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Berland crossword is a puzzle that is solved on a square grid with n rows and n columns. Initially all the cells are white.
To solve the puzzle one has to color some cells on the border of the ... | instruction | 0 | 73,569 | 7 | 147,138 |
Yes | output | 1 | 73,569 | 7 | 147,139 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Berland crossword is a puzzle that is solved on a square grid with n rows and n columns. Initially all the cells are white.
To solve the puzzle one has to color some cells on the border of the ... | instruction | 0 | 73,570 | 7 | 147,140 |
Yes | output | 1 | 73,570 | 7 | 147,141 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Berland crossword is a puzzle that is solved on a square grid with n rows and n columns. Initially all the cells are white.
To solve the puzzle one has to color some cells on the border of the ... | instruction | 0 | 73,571 | 7 | 147,142 |
Yes | output | 1 | 73,571 | 7 | 147,143 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.