message stringlengths 2 48.6k | message_type stringclasses 2
values | message_id int64 0 1 | conversation_id int64 318 108k | cluster float64 8 8 | __index_level_0__ int64 636 217k |
|---|---|---|---|---|---|
Provide tags and a correct Python 3 solution for this coding contest problem.
In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of them. The sections are enumerated from 1 to m al... | instruction | 0 | 99,196 | 8 | 198,392 |
Tags: binary search
Correct Solution:
```
import sys
from bisect import bisect_left
from math import ceil
input=sys.stdin.readline
n,m,cl,ce,v=map(int,input().split())
l=list(map(int,input().split()))
e=list(map(int,input().split()))
q=int(input())
for _ in range(q):
x1,y1,x2,y2=map(int,input().split())
if x1==x2:
... | output | 1 | 99,196 | 8 | 198,393 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of them. The sections are enumerated from 1 to m al... | instruction | 0 | 99,197 | 8 | 198,394 |
Tags: binary search
Correct Solution:
```
def takeClosest(myList, myNumber):
"""
Assumes myList is sorted. Returns closest value to myNumber.
If two numbers are equally close, return the smallest number.
"""
if len(myList) == 0:
return 9e10
pos = bisect_left(myList, myNumber)
if pos... | output | 1 | 99,197 | 8 | 198,395 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of them. The sections are enumerated from 1 to m al... | instruction | 0 | 99,198 | 8 | 198,396 |
Tags: binary search
Correct Solution:
```
import bisect as bs
import sys
inp = sys.stdin.readlines()
n, m, ladders, elevators, v = [int(x) for x in inp[0].strip().split()]
ladders = [int(x) for x in inp[1].strip().split()]
elevators = [int(x) for x in inp[2].strip().split()]
q = int(inp[3].strip())
qs = []
for i in r... | output | 1 | 99,198 | 8 | 198,397 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of them. The sections are enumerated from 1 to m al... | instruction | 0 | 99,199 | 8 | 198,398 |
Tags: binary search
Correct Solution:
```
import sys
def minp():
return sys.stdin.readline().strip()
def mint():
return int(minp())
def mints():
return map(int,minp().split())
n,m,cl,ce,v = mints()
l = list(mints())
e = list(mints())
def dist(x1, y1, x2, y2, t, yv):
if t == 0:
return abs(y1-yv)+abs(yv-y2)+ab... | output | 1 | 99,199 | 8 | 198,399 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of t... | instruction | 0 | 99,200 | 8 | 198,400 |
Yes | output | 1 | 99,200 | 8 | 198,401 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of t... | instruction | 0 | 99,201 | 8 | 198,402 |
Yes | output | 1 | 99,201 | 8 | 198,403 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of t... | instruction | 0 | 99,202 | 8 | 198,404 |
Yes | output | 1 | 99,202 | 8 | 198,405 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of t... | instruction | 0 | 99,203 | 8 | 198,406 |
No | output | 1 | 99,203 | 8 | 198,407 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of t... | instruction | 0 | 99,204 | 8 | 198,408 |
No | output | 1 | 99,204 | 8 | 198,409 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of t... | instruction | 0 | 99,205 | 8 | 198,410 |
No | output | 1 | 99,205 | 8 | 198,411 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of t... | instruction | 0 | 99,206 | 8 | 198,412 |
No | output | 1 | 99,206 | 8 | 198,413 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Suppose you are stuck on a desert island. The only way to save yourself is to craft a wooden raft and go to the sea. Fortunately, you have a hand-made saw and a forest nearby. Moreover, you've a... | instruction | 0 | 99,572 | 8 | 199,144 |
No | output | 1 | 99,572 | 8 | 199,145 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Suppose you are stuck on a desert island. The only way to save yourself is to craft a wooden raft and go to the sea. Fortunately, you have a hand-made saw and a forest nearby. Moreover, you've a... | instruction | 0 | 99,573 | 8 | 199,146 |
No | output | 1 | 99,573 | 8 | 199,147 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Suppose you are stuck on a desert island. The only way to save yourself is to craft a wooden raft and go to the sea. Fortunately, you have a hand-made saw and a forest nearby. Moreover, you've a... | instruction | 0 | 99,574 | 8 | 199,148 |
No | output | 1 | 99,574 | 8 | 199,149 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Recently a new building with a new layout was constructed in Monocarp's hometown. According to this new layout, the building consists of three types of apartments: three-room, five-room, and seven-room apartments. It's also known that each r... | instruction | 0 | 99,630 | 8 | 199,260 |
Tags: brute force, constructive algorithms, math
Correct Solution:
```
for t in range(int(input())):
n=int(input())
a=[]
if n%3==0 or n%5==0 or n%7==0:
if n%3==0:
a=[n//3,0,0]
elif n%5==0:
a=[0,n//5,0]
else:
a=[0,0,n//7]
else:
if (n-7)%... | output | 1 | 99,630 | 8 | 199,261 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Recently a new building with a new layout was constructed in Monocarp's hometown. According to this new layout, the building consists of three types of apartments: three-room, five-room, and seven-room apartments. It's also known that each r... | instruction | 0 | 99,631 | 8 | 199,262 |
Tags: brute force, constructive algorithms, math
Correct Solution:
```
#include <CodeforcesSolutions.h>
#include <ONLINE_JUDGE <solution.cf(contestID = "1430",questionID = "A",method = "GET")>.h>
"""
Author : thekushalghosh
Team : CodeDiggers
I prefer Python language over the C++ language :p :D
... | output | 1 | 99,631 | 8 | 199,263 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Recently a new building with a new layout was constructed in Monocarp's hometown. According to this new layout, the building consists of three types of apartments: three-room, five-room, and seven-room apartments. It's also known that each r... | instruction | 0 | 99,632 | 8 | 199,264 |
Tags: brute force, constructive algorithms, math
Correct Solution:
```
t = int(input())
for _ in range(t):
#n = list(map(int, input().split()))
n = int(input())
flag = 0
for three in range(0,n):
for five in range(0,n):
if ( n - (three*3 + five*5) )%7 == 0 and ( n - (three*3 + five*5)... | output | 1 | 99,632 | 8 | 199,265 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Recently a new building with a new layout was constructed in Monocarp's hometown. According to this new layout, the building consists of three types of apartments: three-room, five-room, and seven-room apartments. It's also known that each r... | instruction | 0 | 99,633 | 8 | 199,266 |
Tags: brute force, constructive algorithms, math
Correct Solution:
```
from collections import defaultdict
test=int(input())
for _ in range(test):
n=int(input())
n1=0
n2=0
n3=0
if(n==1 or n==2 or n==4):
print("-1")
else:
while(n>0):
if(n%3==0):
n1=n1+(... | output | 1 | 99,633 | 8 | 199,267 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Recently a new building with a new layout was constructed in Monocarp's hometown. According to this new layout, the building consists of three types of apartments: three-room, five-room, and seven-room apartments. It's also known that each r... | instruction | 0 | 99,634 | 8 | 199,268 |
Tags: brute force, constructive algorithms, math
Correct Solution:
```
def search(k):
if k == 1 or k == 2 or k == 4:
return [-1]
if k % 3 == 0:
return k // 3, 0, 0
elif k % 3 == 1:
return (k - 7) // 3, 0, 1
else:
return (k - 5) // 3, 1, 0
for _ in range(int(input())):
... | output | 1 | 99,634 | 8 | 199,269 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Recently a new building with a new layout was constructed in Monocarp's hometown. According to this new layout, the building consists of three types of apartments: three-room, five-room, and seven-room apartments. It's also known that each r... | instruction | 0 | 99,635 | 8 | 199,270 |
Tags: brute force, constructive algorithms, math
Correct Solution:
```
import sys
import math
def II():
return int(sys.stdin.readline())
def LI():
return list(map(int, sys.stdin.readline().split()))
def MI():
return map(int, sys.stdin.readline().split())
def SI():
return sys.stdin.readline().strip()
t = II()
... | output | 1 | 99,635 | 8 | 199,271 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Recently a new building with a new layout was constructed in Monocarp's hometown. According to this new layout, the building consists of three types of apartments: three-room, five-room, and seven-room apartments. It's also known that each r... | instruction | 0 | 99,636 | 8 | 199,272 |
Tags: brute force, constructive algorithms, math
Correct Solution:
```
a=[]
for i in range(1000):
a.append([-1])
a[2]=[1,0,0]
a[4]=[0,1,0]
a[6]=[0,0,1]
for i in range(993):
if a[i]!=[-1]:
a[i+3]=[a[i][0]+1]+a[i][1:]
a[i+5]=[a[i][0]]+[a[i][1]+1]+[a[i][2]]
a[i+7]=a[i][:2]+[a[i][2]+1]
for i... | output | 1 | 99,636 | 8 | 199,273 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Recently a new building with a new layout was constructed in Monocarp's hometown. According to this new layout, the building consists of three types of apartments: three-room, five-room, and seven-room apartments. It's also known that each r... | instruction | 0 | 99,637 | 8 | 199,274 |
Tags: brute force, constructive algorithms, math
Correct Solution:
```
t = int(input())
for i in range(t):
n = int(input())
ans = [0, 0, 0]
if n == 1 or n == 2 or n == 4:
print(-1)
continue
if n > 20:
ans[1] += (n-20)//5
n -= ans[1]*5
flag = 0
# print(n)
# print("AA", ans)
for i in range(5):
for j... | output | 1 | 99,637 | 8 | 199,275 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Recently a new building with a new layout was constructed in Monocarp's hometown. According to this new layout, the building consists of three types of apartments: three-room, five-room, and sev... | instruction | 0 | 99,638 | 8 | 199,276 |
Yes | output | 1 | 99,638 | 8 | 199,277 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Recently a new building with a new layout was constructed in Monocarp's hometown. According to this new layout, the building consists of three types of apartments: three-room, five-room, and sev... | instruction | 0 | 99,639 | 8 | 199,278 |
Yes | output | 1 | 99,639 | 8 | 199,279 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Recently a new building with a new layout was constructed in Monocarp's hometown. According to this new layout, the building consists of three types of apartments: three-room, five-room, and sev... | instruction | 0 | 99,640 | 8 | 199,280 |
Yes | output | 1 | 99,640 | 8 | 199,281 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Recently a new building with a new layout was constructed in Monocarp's hometown. According to this new layout, the building consists of three types of apartments: three-room, five-room, and sev... | instruction | 0 | 99,641 | 8 | 199,282 |
Yes | output | 1 | 99,641 | 8 | 199,283 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Recently a new building with a new layout was constructed in Monocarp's hometown. According to this new layout, the building consists of three types of apartments: three-room, five-room, and sev... | instruction | 0 | 99,642 | 8 | 199,284 |
No | output | 1 | 99,642 | 8 | 199,285 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Recently a new building with a new layout was constructed in Monocarp's hometown. According to this new layout, the building consists of three types of apartments: three-room, five-room, and sev... | instruction | 0 | 99,643 | 8 | 199,286 |
No | output | 1 | 99,643 | 8 | 199,287 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Recently a new building with a new layout was constructed in Monocarp's hometown. According to this new layout, the building consists of three types of apartments: three-room, five-room, and sev... | instruction | 0 | 99,644 | 8 | 199,288 |
No | output | 1 | 99,644 | 8 | 199,289 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Recently a new building with a new layout was constructed in Monocarp's hometown. According to this new layout, the building consists of three types of apartments: three-room, five-room, and sev... | instruction | 0 | 99,645 | 8 | 199,290 |
No | output | 1 | 99,645 | 8 | 199,291 |
Provide a correct Python 3 solution for this coding contest problem.
There are n cups of different sizes and three trays (bon festivals) A, B, and C, and these cups are placed on top of each of the three trays in a pile. However, in any tray, the smallest cup in the tray is on the bottom, the second smallest cup is on... | instruction | 0 | 100,256 | 8 | 200,512 |
"Correct Solution:
```
from collections import deque
def main():
while True:
n, m = [int(i) for i in input().split()]
if n == 0 and m == 0:
return
_, *a = [int(i) for i in input().split()]
_, *b = [int(i) for i in input().split()]
_, *c = [int(i) for i in input(... | output | 1 | 100,256 | 8 | 200,513 |
Provide a correct Python 3 solution for this coding contest problem.
There are n cups of different sizes and three trays (bon festivals) A, B, and C, and these cups are placed on top of each of the three trays in a pile. However, in any tray, the smallest cup in the tray is on the bottom, the second smallest cup is on... | instruction | 0 | 100,257 | 8 | 200,514 |
"Correct Solution:
```
from collections import deque
def main():
while True:
n, m = [int(i) for i in input().split()]
if n == 0 and m == 0:
return
_, *a = [int(i) for i in input().split()]
_, *b = [int(i) for i in input().split()]
_, *c = [int(i) for i in input(... | output | 1 | 100,257 | 8 | 200,515 |
Provide a correct Python 3 solution for this coding contest problem.
There are n cups of different sizes and three trays (bon festivals) A, B, and C, and these cups are placed on top of each of the three trays in a pile. However, in any tray, the smallest cup in the tray is on the bottom, the second smallest cup is on... | instruction | 0 | 100,258 | 8 | 200,516 |
"Correct Solution:
```
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0503
from collections import deque
def main():
N, M = map(int, input().split()) # N: コップの数 M: 最大回数
if N==0:
exit()
data = [0]*N
map(int, input().split())
for b in list(map(int, input().split()))[1:]:
... | output | 1 | 100,258 | 8 | 200,517 |
Provide a correct Python 3 solution for this coding contest problem.
There are n cups of different sizes and three trays (bon festivals) A, B, and C, and these cups are placed on top of each of the three trays in a pile. However, in any tray, the smallest cup in the tray is on the bottom, the second smallest cup is on... | instruction | 0 | 100,259 | 8 | 200,518 |
"Correct Solution:
```
def solve():
from sys import stdin
f_i = stdin
def rec(i):
if i == 0:
return 0
tray = cups[n - i]
if tray == 'A':
return rec(i - 1)
elif tray == 'B':
return 2 * 3 ** (i - 1) - 1 - rec(i - 1)
else... | output | 1 | 100,259 | 8 | 200,519 |
Provide a correct Python 3 solution for this coding contest problem.
There are n cups of different sizes and three trays (bon festivals) A, B, and C, and these cups are placed on top of each of the three trays in a pile. However, in any tray, the smallest cup in the tray is on the bottom, the second smallest cup is on... | instruction | 0 | 100,260 | 8 | 200,520 |
"Correct Solution:
```
def move(a,b):
aa = a[:]
bb = b[:]
bb.append(aa.pop(-1))
return aa,bb
def move_is_True(a,b):
if len(a) == 0:
return False
elif len(b) == 0 or a[-1]>b[-1]:
return True
return False
def search(abc_first, n):
counts = [10**10]
abcs = [(abc_first,... | output | 1 | 100,260 | 8 | 200,521 |
Provide a correct Python 3 solution for this coding contest problem.
There are n cups of different sizes and three trays (bon festivals) A, B, and C, and these cups are placed on top of each of the three trays in a pile. However, in any tray, the smallest cup in the tray is on the bottom, the second smallest cup is on... | instruction | 0 | 100,261 | 8 | 200,522 |
"Correct Solution:
```
while True:
try:
n,m = map(int,input().split())
l = [0 for i in range(n)]
for i in range(3):
s = list(map(int,input().split()))
for j in s[1:]:
l[j - 1] = i
ans = 100000000
for pos in [0,2]:
count = 0
for i in range(n):
if abs(l[i] - ... | output | 1 | 100,261 | 8 | 200,523 |
Provide a correct Python 3 solution for this coding contest problem.
There are n cups of different sizes and three trays (bon festivals) A, B, and C, and these cups are placed on top of each of the three trays in a pile. However, in any tray, the smallest cup in the tray is on the bottom, the second smallest cup is on... | instruction | 0 | 100,262 | 8 | 200,524 |
"Correct Solution:
```
from sys import stdin
from collections import deque
def l2t(g):
return tuple(map(tuple,g))
class BFS():
def __init__(self, graph, m, n):
# 盤面
self.graph = graph
self.m = m
self.n = n
# 始点からの距離
self.dist = {}
# キュー
self.... | output | 1 | 100,262 | 8 | 200,525 |
Provide a correct Python 3 solution for this coding contest problem.
There are n cups of different sizes and three trays (bon festivals) A, B, and C, and these cups are placed on top of each of the three trays in a pile. However, in any tray, the smallest cup in the tray is on the bottom, the second smallest cup is on... | instruction | 0 | 100,263 | 8 | 200,526 |
"Correct Solution:
```
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0503
def main():
from collections import deque
while True:
N, M = map(int, input().split())
if N == 0 and M == 0:
return
cop = [list(map(int, input().split())) for _ in range(3)]
cop = ... | output | 1 | 100,263 | 8 | 200,527 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n cups of different sizes and three trays (bon festivals) A, B, and C, and these cups are placed on top of each of the three trays in a pile. However, in any tray, the smallest cup in ... | instruction | 0 | 100,264 | 8 | 200,528 |
Yes | output | 1 | 100,264 | 8 | 200,529 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n cups of different sizes and three trays (bon festivals) A, B, and C, and these cups are placed on top of each of the three trays in a pile. However, in any tray, the smallest cup in ... | instruction | 0 | 100,265 | 8 | 200,530 |
Yes | output | 1 | 100,265 | 8 | 200,531 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n cups of different sizes and three trays (bon festivals) A, B, and C, and these cups are placed on top of each of the three trays in a pile. However, in any tray, the smallest cup in ... | instruction | 0 | 100,266 | 8 | 200,532 |
Yes | output | 1 | 100,266 | 8 | 200,533 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n cups of different sizes and three trays (bon festivals) A, B, and C, and these cups are placed on top of each of the three trays in a pile. However, in any tray, the smallest cup in ... | instruction | 0 | 100,267 | 8 | 200,534 |
Yes | output | 1 | 100,267 | 8 | 200,535 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n cups of different sizes and three trays (bon festivals) A, B, and C, and these cups are placed on top of each of the three trays in a pile. However, in any tray, the smallest cup in ... | instruction | 0 | 100,268 | 8 | 200,536 |
No | output | 1 | 100,268 | 8 | 200,537 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n cups of different sizes and three trays (bon festivals) A, B, and C, and these cups are placed on top of each of the three trays in a pile. However, in any tray, the smallest cup in ... | instruction | 0 | 100,269 | 8 | 200,538 |
No | output | 1 | 100,269 | 8 | 200,539 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n cups of different sizes and three trays (bon festivals) A, B, and C, and these cups are placed on top of each of the three trays in a pile. However, in any tray, the smallest cup in ... | instruction | 0 | 100,270 | 8 | 200,540 |
No | output | 1 | 100,270 | 8 | 200,541 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n cups of different sizes and three trays (bon festivals) A, B, and C, and these cups are placed on top of each of the three trays in a pile. However, in any tray, the smallest cup in ... | instruction | 0 | 100,271 | 8 | 200,542 |
No | output | 1 | 100,271 | 8 | 200,543 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Bertown is a city with n buildings in a straight line.
The city's security service discovered that some buildings were mined. A map was compiled, which is a string of length n, where the i-th character is "1" if there is a mine under the bu... | instruction | 0 | 100,510 | 8 | 201,020 |
Tags: dp, greedy, math, sortings
Correct Solution:
```
t = int(input())
for i in range(t):
a, p = map(int, input().split())
binarr = list(input())
gaps = []
acts = 0
if binarr[0] == '1':
acts += 1
cost = 0
current = 0
for bit in binarr:
if bit == '0':
current... | output | 1 | 100,510 | 8 | 201,021 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Bertown is a city with n buildings in a straight line.
The city's security service discovered that some buildings were mined. A map was compiled, which is a string of length n, where the i-th character is "1" if there is a mine under the bu... | instruction | 0 | 100,511 | 8 | 201,022 |
Tags: dp, greedy, math, sortings
Correct Solution:
```
import sys
#from collections import deque
#from functools import *
#from fractions import Fraction as f
from copy import *
from bisect import *
#from heapq import *
from math import gcd,ceil,sqrt
from itertools import permutations as prm,product
def eprint(*args... | output | 1 | 100,511 | 8 | 201,023 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Bertown is a city with n buildings in a straight line.
The city's security service discovered that some buildings were mined. A map was compiled, which is a string of length n, where the i-th character is "1" if there is a mine under the bu... | instruction | 0 | 100,512 | 8 | 201,024 |
Tags: dp, greedy, math, sortings
Correct Solution:
```
from math import *
from operator import *
t = int(input())
for _ in range(t):
a, b = map(int, input().split())
s = input()
l = list()
p, q = 0, 0
s = '0' + s + '0'
for i in range(len(s)):
if s[i] == '1' and s[i-1] == '0':
... | output | 1 | 100,512 | 8 | 201,025 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Bertown is a city with n buildings in a straight line.
The city's security service discovered that some buildings were mined. A map was compiled, which is a string of length n, where the i-th character is "1" if there is a mine under the bu... | instruction | 0 | 100,513 | 8 | 201,026 |
Tags: dp, greedy, math, sortings
Correct Solution:
```
def get_min_cost(mines, a, b):
mines = mines.strip('0')
if len(mines) == 0:
return 0
max_zeros_len = a // b
ones_run_count = 0
short_zeros_count = 0
short_zeros_sum_length = 0
for i, ch in enumerate(mines):
if ch == '1':... | output | 1 | 100,513 | 8 | 201,027 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.