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.
We have a grid of H rows and W columns of squares. The color of the square at the i-th row from the top and the j-th column from the left (1 \leq i \leq H, 1 \leq j \leq W) is given to you as a character c_{i,j}: the square is white if c_{i,j} is `.`... | instruction | 0 | 19,128 | 7 | 38,256 |
"Correct Solution:
```
H, W, K = map(int, input().split())
C = [input() for _ in range(H)]
ans = 0
for r in range(1<<H):
for c in range(1<<W):
k = 0
for h in range(H):
if (r>>h)&1: continue
for w in range(W):
if (c>>w)&1: continue
if C[h][w]=='... | output | 1 | 19,128 | 7 | 38,257 |
Provide a correct Python 3 solution for this coding contest problem.
We have a grid of H rows and W columns of squares. The color of the square at the i-th row from the top and the j-th column from the left (1 \leq i \leq H, 1 \leq j \leq W) is given to you as a character c_{i,j}: the square is white if c_{i,j} is `.`... | instruction | 0 | 19,129 | 7 | 38,258 |
"Correct Solution:
```
h,*c=open(0)
h,w,k=map(int,h.split())
print(sum(k==sum(y>>w+z//w&y>>z%w&1and'.'>c[z//w][z%w]for z in range(h*w))for y in range(1<<h+w)))
``` | output | 1 | 19,129 | 7 | 38,259 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We have a grid of H rows and W columns of squares. The color of the square at the i-th row from the top and the j-th column from the left (1 \leq i \leq H, 1 \leq j \leq W) is given to you as a ... | instruction | 0 | 19,130 | 7 | 38,260 |
Yes | output | 1 | 19,130 | 7 | 38,261 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We have a grid of H rows and W columns of squares. The color of the square at the i-th row from the top and the j-th column from the left (1 \leq i \leq H, 1 \leq j \leq W) is given to you as a ... | instruction | 0 | 19,131 | 7 | 38,262 |
Yes | output | 1 | 19,131 | 7 | 38,263 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We have a grid of H rows and W columns of squares. The color of the square at the i-th row from the top and the j-th column from the left (1 \leq i \leq H, 1 \leq j \leq W) is given to you as a ... | instruction | 0 | 19,132 | 7 | 38,264 |
Yes | output | 1 | 19,132 | 7 | 38,265 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We have a grid of H rows and W columns of squares. The color of the square at the i-th row from the top and the j-th column from the left (1 \leq i \leq H, 1 \leq j \leq W) is given to you as a ... | instruction | 0 | 19,133 | 7 | 38,266 |
Yes | output | 1 | 19,133 | 7 | 38,267 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We have a grid of H rows and W columns of squares. The color of the square at the i-th row from the top and the j-th column from the left (1 \leq i \leq H, 1 \leq j \leq W) is given to you as a ... | instruction | 0 | 19,134 | 7 | 38,268 |
No | output | 1 | 19,134 | 7 | 38,269 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We have a grid of H rows and W columns of squares. The color of the square at the i-th row from the top and the j-th column from the left (1 \leq i \leq H, 1 \leq j \leq W) is given to you as a ... | instruction | 0 | 19,135 | 7 | 38,270 |
No | output | 1 | 19,135 | 7 | 38,271 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We have a grid of H rows and W columns of squares. The color of the square at the i-th row from the top and the j-th column from the left (1 \leq i \leq H, 1 \leq j \leq W) is given to you as a ... | instruction | 0 | 19,136 | 7 | 38,272 |
No | output | 1 | 19,136 | 7 | 38,273 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We have a grid of H rows and W columns of squares. The color of the square at the i-th row from the top and the j-th column from the left (1 \leq i \leq H, 1 \leq j \leq W) is given to you as a ... | instruction | 0 | 19,137 | 7 | 38,274 |
No | output | 1 | 19,137 | 7 | 38,275 |
Provide a correct Python 3 solution for this coding contest problem.
There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can't move on red tiles, he can move only on black til... | instruction | 0 | 20,208 | 7 | 40,416 |
"Correct Solution:
```
#!/usr/bin/env python
# -*- coding: utf-8 -*-
def dfs(s,Map,H,W):
dxdy = [(1,0),(-1,0),(0,1),(0,-1)]
for i in range(4):
Map[s[0]][s[1]] = '*'
nextPos = (s[0]+dxdy[i][0],s[1]+dxdy[i][1])
if nextPos[0] >= 0 and nextPos[1] >= 0 and nextPos[0] < H and nextPos[1] < W:
... | output | 1 | 20,208 | 7 | 40,417 |
Provide a correct Python 3 solution for this coding contest problem.
There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can't move on red tiles, he can move only on black til... | instruction | 0 | 20,209 | 7 | 40,418 |
"Correct Solution:
```
def f(h,w):
global W,H,S,A
if h<0 or h>=H or w<0 or w>=W or S[h][w]=="#" or A[h][w]==1:
return
A[h][w] = 1
f(h-1,w)
f(h+1,w)
f(h,w-1)
f(h,w+1)
while True:
W,H = map(int,input().split())
if W+H == 0:
break
S = [list(input()) for h in range(H)]
A = [[0 for w in range(W... | output | 1 | 20,209 | 7 | 40,419 |
Provide a correct Python 3 solution for this coding contest problem.
There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can't move on red tiles, he can move only on black til... | instruction | 0 | 20,210 | 7 | 40,420 |
"Correct Solution:
```
import queue
dxy=[(1,0),(0,1),(-1,0),(0,-1)]
def bfs(sx,sy,H,W):#幅優先探索
q=queue.Queue()
visited=[[False]*W for _ in range(H)]
q.put((sx,sy))
visited[sx][sy]=True
ans=1
while not q.empty():
px,py=q.get()
for dx,dy in dxy:
nx=px+dx
ny=p... | output | 1 | 20,210 | 7 | 40,421 |
Provide a correct Python 3 solution for this coding contest problem.
There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can't move on red tiles, he can move only on black til... | instruction | 0 | 20,211 | 7 | 40,422 |
"Correct Solution:
```
while True:
W, H = map(int, input().split())
if W == 0 and H == 0:
break
maze = []
for _ in range(H):
maze.append(list(input()))
visited = [[False] * W for _ in range(H)]
dxy = [(1, 0), (0, 1), (-1, 0), (0, -1)]
ans = 0
def rec(x, y):
glob... | output | 1 | 20,211 | 7 | 40,423 |
Provide a correct Python 3 solution for this coding contest problem.
There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can't move on red tiles, he can move only on black til... | instruction | 0 | 20,212 | 7 | 40,424 |
"Correct Solution:
```
def count_area(h,w):
count = 0
if (h>0) and (s[h-1][w]== "."):
s[h-1][w] = "#"
count += count_area(h-1,w)
if (h<H-1) and (s[h+1][w]== "."):
s[h+1][w] = "#"
count += count_area(h+1,w)
if (w>0) and (s[h][w-1]== "."):
s[h][w-1] = "#"
count += count_area(h,w-1)
if (w<W-1) and (s[h][w... | output | 1 | 20,212 | 7 | 40,425 |
Provide a correct Python 3 solution for this coding contest problem.
There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can't move on red tiles, he can move only on black til... | instruction | 0 | 20,213 | 7 | 40,426 |
"Correct Solution:
```
I=input
def f(x,y,r):
if not(0<=x<len(r[0])and(0<=y<len(r)))or r[y][x]=='#':return 0
r[y][x]='#'
return 1+sum(f(x+dx,y+dy,r)for dx,dy in[[-1,0],[1,0],[0,-1],[0,1]])
while 1:
w,h=map(int,I().split())
if w==0:break
r=[list(input()) for _ in[0]*h]
for a,b in enumerate(r):... | output | 1 | 20,213 | 7 | 40,427 |
Provide a correct Python 3 solution for this coding contest problem.
There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can't move on red tiles, he can move only on black til... | instruction | 0 | 20,214 | 7 | 40,428 |
"Correct Solution:
```
from queue import Queue
def calcReachableTileNumByBFSearch(room, start_pos):
q = Queue()
q.put(start_pos)
count = 1
while not q.empty():
cur_pos = q.get()
D0 = [1, 0, -1, 0]
D1 = [0, -1, 0, 1]
for d in range(4):
nc = [0,0]
... | output | 1 | 20,214 | 7 | 40,429 |
Provide a correct Python 3 solution for this coding contest problem.
There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can't move on red tiles, he can move only on black til... | instruction | 0 | 20,215 | 7 | 40,430 |
"Correct Solution:
```
(lambda f:f(f))(lambda T,A=lambda L,yp,ri=lambda l:R.append([{xi:x}for xi,x in enumerate(l)]):[P.__setitem__("x",L.index("@")),P.__setitem__("y",yp),ri(L)]if "@"in L else ri(L),S=lambda X,Y,s,u:[R[Y][X].__setitem__(X,"@"),s(X-1,Y,s,u)+s(X+1,Y,s,u)+s(X,Y+1,s,u)+s(X,Y-1,s,u)+1][1]if 0<=X<W[0]and 0<... | output | 1 | 20,215 | 7 | 40,431 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But h... | instruction | 0 | 20,216 | 7 | 40,432 |
Yes | output | 1 | 20,216 | 7 | 40,433 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But h... | instruction | 0 | 20,217 | 7 | 40,434 |
Yes | output | 1 | 20,217 | 7 | 40,435 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But h... | instruction | 0 | 20,218 | 7 | 40,436 |
Yes | output | 1 | 20,218 | 7 | 40,437 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But h... | instruction | 0 | 20,219 | 7 | 40,438 |
Yes | output | 1 | 20,219 | 7 | 40,439 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But h... | instruction | 0 | 20,220 | 7 | 40,440 |
No | output | 1 | 20,220 | 7 | 40,441 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But h... | instruction | 0 | 20,221 | 7 | 40,442 |
No | output | 1 | 20,221 | 7 | 40,443 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But h... | instruction | 0 | 20,222 | 7 | 40,444 |
No | output | 1 | 20,222 | 7 | 40,445 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But h... | instruction | 0 | 20,223 | 7 | 40,446 |
No | output | 1 | 20,223 | 7 | 40,447 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Paul is at the orchestra. The string section is arranged in an r × c rectangular grid and is filled with violinists with the exception of n violists. Paul really likes violas, so he would like to take a picture including at least k of them. ... | instruction | 0 | 20,737 | 7 | 41,474 |
Tags: brute force, implementation
Correct Solution:
```
r, c, n, k = list(map(int, input().split()))
alt = []
count = 0
for i in range(n):
a, b = list(map(int, input().split()))
alt.append([a - 1, b - 1])
for x1 in range(r):
for x2 in range(x1 + 1):
for y1 in range(c):
for y2 in range(y1... | output | 1 | 20,737 | 7 | 41,475 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Paul is at the orchestra. The string section is arranged in an r × c rectangular grid and is filled with violinists with the exception of n violists. Paul really likes violas, so he would like to take a picture including at least k of them. ... | instruction | 0 | 20,738 | 7 | 41,476 |
Tags: brute force, implementation
Correct Solution:
```
r, c, n, k = map(int, input().split())
A = [[0] * c for i in range(r)]
for i in range(n):
a, b = map(int, input().split())
A[a - 1][b - 1] = 1
f = 0
g = 0
ans = 0
for i in range(r):
for j in range(c):
for i2 in range(r - i):
for j2... | output | 1 | 20,738 | 7 | 41,477 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Paul is at the orchestra. The string section is arranged in an r × c rectangular grid and is filled with violinists with the exception of n violists. Paul really likes violas, so he would like to take a picture including at least k of them. ... | instruction | 0 | 20,739 | 7 | 41,478 |
Tags: brute force, implementation
Correct Solution:
```
read = lambda: map(int, input().split())
r, c, n, k = read()
a = [[0] * (c + 1) for i in range(r + 1)]
for i in range(n):
x, y = read()
a[x][y] = 1
d = [[0] * (c + 1) for i in range(r + 1)]
for i in range(1, r + 1):
for j in range(1, c + 1):
if... | output | 1 | 20,739 | 7 | 41,479 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Paul is at the orchestra. The string section is arranged in an r × c rectangular grid and is filled with violinists with the exception of n violists. Paul really likes violas, so he would like to take a picture including at least k of them. ... | instruction | 0 | 20,740 | 7 | 41,480 |
Tags: brute force, implementation
Correct Solution:
```
r,c,n,k = map(int, input().split())
G = [[0]*c for i in range(0,r)]
for i in range(0, n):
a,b = map(int, input().split())
a-=1
b-=1
G[a][b] = True
ans = 0
for x in range(0,r):
for y in range(0,c):
for y1 in range(y + 1, c + 1):
... | output | 1 | 20,740 | 7 | 41,481 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Paul is at the orchestra. The string section is arranged in an r × c rectangular grid and is filled with violinists with the exception of n violists. Paul really likes violas, so he would like to take a picture including at least k of them. ... | instruction | 0 | 20,741 | 7 | 41,482 |
Tags: brute force, implementation
Correct Solution:
```
#!/usr/bin/env python3
r, c, n, k = [int(x) for x in input().split()]
min_x, min_y, max_x, max_y = r, c, 1, 1
alts = []
for i in range(0, n):
x, y = [int(i) for i in input().split()]
alts.append((x, y))
photo_count = 0
for x in range(1, r + 1):
for ... | output | 1 | 20,741 | 7 | 41,483 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Paul is at the orchestra. The string section is arranged in an r × c rectangular grid and is filled with violinists with the exception of n violists. Paul really likes violas, so he would like to take a picture including at least k of them. ... | instruction | 0 | 20,742 | 7 | 41,484 |
Tags: brute force, implementation
Correct Solution:
```
def check(x1, y1, x2, y2):
global dp
cnt = 0
for i in range(x2, x1 + 1):
for j in range(y2, y1 + 1):
cnt += dp[i][j]
return cnt
#n = int(input())
r, c, n, k = map(int, input().split())
#s = list(map(int, input().split()))
dp =... | output | 1 | 20,742 | 7 | 41,485 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Paul is at the orchestra. The string section is arranged in an r × c rectangular grid and is filled with violinists with the exception of n violists. Paul really likes violas, so he would like to take a picture including at least k of them. ... | instruction | 0 | 20,743 | 7 | 41,486 |
Tags: brute force, implementation
Correct Solution:
```
r, c, n, k = map(int, input().split())
g = set([tuple(map(int, input().split())) for _ in range(n)])
ret = 0
for i in range(r):
for j in range(c):
for l in range(1, r-i+1):
for w in range(1, c-j+1):
count = 0
... | output | 1 | 20,743 | 7 | 41,487 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Paul is at the orchestra. The string section is arranged in an r × c rectangular grid and is filled with violinists with the exception of n violists. Paul really likes violas, so he would like to take a picture including at least k of them. ... | instruction | 0 | 20,744 | 7 | 41,488 |
Tags: brute force, implementation
Correct Solution:
```
import io
import sys
import time
import random
#~ start = time.clock()
#~ test = '''2 2 1 1
#~ 1 2'''
#~ test = '''3 2 3 3
#~ 1 1
#~ 3 1
#~ 2 2'''
#~ test = '''3 2 3 2
#~ 1 1
#~ 3 1
#~ 2 2'''
#~ sys.stdin = io.StringIO(test)
r,c,n,k = map(int,input().split()) # ... | output | 1 | 20,744 | 7 | 41,489 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Paul is at the orchestra. The string section is arranged in an r × c rectangular grid and is filled with violinists with the exception of n violists. Paul really likes violas, so he would like t... | instruction | 0 | 20,745 | 7 | 41,490 |
Yes | output | 1 | 20,745 | 7 | 41,491 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Paul is at the orchestra. The string section is arranged in an r × c rectangular grid and is filled with violinists with the exception of n violists. Paul really likes violas, so he would like t... | instruction | 0 | 20,746 | 7 | 41,492 |
Yes | output | 1 | 20,746 | 7 | 41,493 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Paul is at the orchestra. The string section is arranged in an r × c rectangular grid and is filled with violinists with the exception of n violists. Paul really likes violas, so he would like t... | instruction | 0 | 20,747 | 7 | 41,494 |
Yes | output | 1 | 20,747 | 7 | 41,495 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Paul is at the orchestra. The string section is arranged in an r × c rectangular grid and is filled with violinists with the exception of n violists. Paul really likes violas, so he would like t... | instruction | 0 | 20,748 | 7 | 41,496 |
Yes | output | 1 | 20,748 | 7 | 41,497 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Paul is at the orchestra. The string section is arranged in an r × c rectangular grid and is filled with violinists with the exception of n violists. Paul really likes violas, so he would like t... | instruction | 0 | 20,749 | 7 | 41,498 |
No | output | 1 | 20,749 | 7 | 41,499 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Paul is at the orchestra. The string section is arranged in an r × c rectangular grid and is filled with violinists with the exception of n violists. Paul really likes violas, so he would like t... | instruction | 0 | 20,750 | 7 | 41,500 |
No | output | 1 | 20,750 | 7 | 41,501 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Paul is at the orchestra. The string section is arranged in an r × c rectangular grid and is filled with violinists with the exception of n violists. Paul really likes violas, so he would like t... | instruction | 0 | 20,751 | 7 | 41,502 |
No | output | 1 | 20,751 | 7 | 41,503 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Paul is at the orchestra. The string section is arranged in an r × c rectangular grid and is filled with violinists with the exception of n violists. Paul really likes violas, so he would like t... | instruction | 0 | 20,752 | 7 | 41,504 |
No | output | 1 | 20,752 | 7 | 41,505 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A group of n dancers rehearses a performance for the closing ceremony. The dancers are arranged in a row, they've studied their dancing moves and can't change positions. For some of them, a white dancing suit is already bought, for some of t... | instruction | 0 | 21,181 | 7 | 42,362 |
Tags: greedy
Correct Solution:
```
N = [int(x) for x in input().strip().split()]
arr = [int(x) for x in input().strip().split()]
i = 0
j = N[0]-1
cost = 0
mini = min(N[1],N[2])
while(i<j):
if(arr[i] == 2 and arr[j] == 2):
cost+=(2*mini)
elif(arr[i] == 2):
if(arr[j] == 0):
cost+=N[1]
... | output | 1 | 21,181 | 7 | 42,363 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A group of n dancers rehearses a performance for the closing ceremony. The dancers are arranged in a row, they've studied their dancing moves and can't change positions. For some of them, a white dancing suit is already bought, for some of t... | instruction | 0 | 21,182 | 7 | 42,364 |
Tags: greedy
Correct Solution:
```
n, a, b = map(int, input().split())
c = list(map(int, input().split()))
flag = True
res = 0
mn = min(a, b)
for i in range((n + 1) // 2):
fst = c[i]
snd = c[n - i - 1]
if fst == 2 and snd == 2:
if i == n // 2:
res += mn
else:
res +... | output | 1 | 21,182 | 7 | 42,365 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A group of n dancers rehearses a performance for the closing ceremony. The dancers are arranged in a row, they've studied their dancing moves and can't change positions. For some of them, a white dancing suit is already bought, for some of t... | instruction | 0 | 21,183 | 7 | 42,366 |
Tags: greedy
Correct Solution:
```
#codeforces_1040A_live
gi = lambda: list(map(int,input().split()))
n,a,b = gi()
l = gi()
ans = 0
for k in range(n//2):
if l[k] == 2 and l[-k-1] == 2:
ans += 2*min(a,b)
elif l[k] == 2 or l[-k-1] == 2:
if l[k] == 2:
ans += [a,b][l[-k-1]]
else:
ans += [a,b][l[k]]
else:
i... | output | 1 | 21,183 | 7 | 42,367 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A group of n dancers rehearses a performance for the closing ceremony. The dancers are arranged in a row, they've studied their dancing moves and can't change positions. For some of them, a white dancing suit is already bought, for some of t... | instruction | 0 | 21,184 | 7 | 42,368 |
Tags: greedy
Correct Solution:
```
line1 = input()
n ,pwhite,pblack = line1.split(' ')
line2 = input()
mylist = line2.split(' ')
intlist = list()
for x in mylist:
intlist.append(int(x))
totalcost = 0
#0 white
cheaper = ((0,pwhite) if (int(pwhite) <= int(pblack)) else (1,pblack))
if (not len(intlist)%2):
pas... | output | 1 | 21,184 | 7 | 42,369 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A group of n dancers rehearses a performance for the closing ceremony. The dancers are arranged in a row, they've studied their dancing moves and can't change positions. For some of them, a white dancing suit is already bought, for some of t... | instruction | 0 | 21,185 | 7 | 42,370 |
Tags: greedy
Correct Solution:
```
n, a, b = map(int, input().split())
c = [int(x) for x in input().split()]
if a < b:
min = a
else:
min = b
middle = n // 2
if n % 2 != 0 and c[middle] == 2:
s = min
else:
s = 0
for i in range(middle):
if c[i] == c[n - i - 1] and c[i] != 2:
pass
else:
... | output | 1 | 21,185 | 7 | 42,371 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A group of n dancers rehearses a performance for the closing ceremony. The dancers are arranged in a row, they've studied their dancing moves and can't change positions. For some of them, a white dancing suit is already bought, for some of t... | instruction | 0 | 21,186 | 7 | 42,372 |
Tags: greedy
Correct Solution:
```
n, a, b = map(int, input().split())
c = input().split()
l = len(c)
summe = 0
if l % 2:
if c[l//2] == '2':
summe += min(a, b)
l = l//2
for x, y in zip(c[:l], reversed(c)):
if (x == '2') and (y == '2'):
summe += 2*min(a, b)
elif (x in '01') and (y in '01'):... | output | 1 | 21,186 | 7 | 42,373 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A group of n dancers rehearses a performance for the closing ceremony. The dancers are arranged in a row, they've studied their dancing moves and can't change positions. For some of them, a white dancing suit is already bought, for some of t... | instruction | 0 | 21,187 | 7 | 42,374 |
Tags: greedy
Correct Solution:
```
n, a, b = map(int, input().split())
c = list(map(int, input().split()))
cost = 0
for i in range(n // 2):
if c[i] != c[n - i - 1] and c[i] != 2 and c[n - i - 1] != 2:
print(-1)
exit()
elif c[i] == c[n - i - 1] and c[i] == 2:
cost += min(a, b) * 2
eli... | output | 1 | 21,187 | 7 | 42,375 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A group of n dancers rehearses a performance for the closing ceremony. The dancers are arranged in a row, they've studied their dancing moves and can't change positions. For some of them, a white dancing suit is already bought, for some of t... | instruction | 0 | 21,188 | 7 | 42,376 |
Tags: greedy
Correct Solution:
```
import math
from operator import itemgetter
from builtins import input
from difflib import SequenceMatcher
def reduce(list):
r = 1
for x in list:
r *= x
return r
import sys
def TwoArrays(a, b, k):
"""
:param a:list
:param b: list
:return: int... | output | 1 | 21,188 | 7 | 42,377 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.