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.
Squirrel Liss lived in a forest peacefully, but unexpected trouble happens. Stones fall from a mountain. Initially Squirrel Liss occupies an interval [0, 1]. Next, n stones will fall and Liss will escape from the stones. The stones are numbe... | instruction | 0 | 50,781 | 15 | 101,562 |
Tags: constructive algorithms, data structures, implementation, two pointers
Correct Solution:
```
s = input()
n = len(s)
left = []
right = []
for i in range(n):
if s[i] == "l":
left.append(i+1)
else:
right.append(i+1)
for x in right+left[::-1]:
print(x)
``` | output | 1 | 50,781 | 15 | 101,563 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Squirrel Liss lived in a forest peacefully, but unexpected trouble happens. Stones fall from a mountain. Initially Squirrel Liss occupies an interval [0, 1]. Next, n stones will fall and Liss will escape from the stones. The stones are numbe... | instruction | 0 | 50,782 | 15 | 101,564 |
Tags: constructive algorithms, data structures, implementation, two pointers
Correct Solution:
```
from sys import stdin
class node:
def __init__(self,n):
self.prev=None
self.next = None
self.key = n
def sin():
return stdin.readline()
s = input()
a=[]
b=[]
for i in range(1,len(s)+... | output | 1 | 50,782 | 15 | 101,565 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Squirrel Liss lived in a forest peacefully, but unexpected trouble happens. Stones fall from a mountain. Initially Squirrel Liss occupies an interval [0, 1]. Next, n stones will fall and Liss will escape from the stones. The stones are numbe... | instruction | 0 | 50,783 | 15 | 101,566 |
Tags: constructive algorithms, data structures, implementation, two pointers
Correct Solution:
```
class LN:
data = None
left = None
right = None
def __init__(self, data, left, right):
self.data = data
self.left = left
self.right = right
inst = input()
root = LN(1, None, None)... | output | 1 | 50,783 | 15 | 101,567 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Squirrel Liss lived in a forest peacefully, but unexpected trouble happens. Stones fall from a mountain. Initially Squirrel Liss occupies an interval [0, 1]. Next, n stones will fall and Liss wi... | instruction | 0 | 50,784 | 15 | 101,568 |
Yes | output | 1 | 50,784 | 15 | 101,569 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Squirrel Liss lived in a forest peacefully, but unexpected trouble happens. Stones fall from a mountain. Initially Squirrel Liss occupies an interval [0, 1]. Next, n stones will fall and Liss wi... | instruction | 0 | 50,785 | 15 | 101,570 |
Yes | output | 1 | 50,785 | 15 | 101,571 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Squirrel Liss lived in a forest peacefully, but unexpected trouble happens. Stones fall from a mountain. Initially Squirrel Liss occupies an interval [0, 1]. Next, n stones will fall and Liss wi... | instruction | 0 | 50,786 | 15 | 101,572 |
Yes | output | 1 | 50,786 | 15 | 101,573 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Squirrel Liss lived in a forest peacefully, but unexpected trouble happens. Stones fall from a mountain. Initially Squirrel Liss occupies an interval [0, 1]. Next, n stones will fall and Liss wi... | instruction | 0 | 50,787 | 15 | 101,574 |
Yes | output | 1 | 50,787 | 15 | 101,575 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Squirrel Liss lived in a forest peacefully, but unexpected trouble happens. Stones fall from a mountain. Initially Squirrel Liss occupies an interval [0, 1]. Next, n stones will fall and Liss wi... | instruction | 0 | 50,788 | 15 | 101,576 |
No | output | 1 | 50,788 | 15 | 101,577 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Squirrel Liss lived in a forest peacefully, but unexpected trouble happens. Stones fall from a mountain. Initially Squirrel Liss occupies an interval [0, 1]. Next, n stones will fall and Liss wi... | instruction | 0 | 50,789 | 15 | 101,578 |
No | output | 1 | 50,789 | 15 | 101,579 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Squirrel Liss lived in a forest peacefully, but unexpected trouble happens. Stones fall from a mountain. Initially Squirrel Liss occupies an interval [0, 1]. Next, n stones will fall and Liss wi... | instruction | 0 | 50,790 | 15 | 101,580 |
No | output | 1 | 50,790 | 15 | 101,581 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Squirrel Liss lived in a forest peacefully, but unexpected trouble happens. Stones fall from a mountain. Initially Squirrel Liss occupies an interval [0, 1]. Next, n stones will fall and Liss wi... | instruction | 0 | 50,791 | 15 | 101,582 |
No | output | 1 | 50,791 | 15 | 101,583 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There was a big bank robbery in Tablecity. In order to catch the thief, the President called none other than Albert – Tablecity’s Chief of Police. Albert does not know where the thief is located, but he does know how he moves.
Tablecity can... | instruction | 0 | 50,899 | 15 | 101,798 |
Tags: constructive algorithms, implementation
Correct Solution:
```
print('2000')
a = 1
b = 1000
for i in range(1000):
print(a, 1, a, 2)
a += 1
for i in range(1000):
print(b, 1, b, 2)
b -= 1
``` | output | 1 | 50,899 | 15 | 101,799 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There was a big bank robbery in Tablecity. In order to catch the thief, the President called none other than Albert – Tablecity’s Chief of Police. Albert does not know where the thief is located, but he does know how he moves.
Tablecity can... | instruction | 0 | 50,900 | 15 | 101,800 |
Tags: constructive algorithms, implementation
Correct Solution:
```
print(2000)
for j in range(1000):
print(j+1,1,j+1,2)
for j in range(1001,1,-1):
print(j-1,1,j-1,2)
``` | output | 1 | 50,900 | 15 | 101,801 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There was a big bank robbery in Tablecity. In order to catch the thief, the President called none other than Albert – Tablecity’s Chief of Police. Albert does not know where the thief is located, but he does know how he moves.
Tablecity can... | instruction | 0 | 50,901 | 15 | 101,802 |
Tags: constructive algorithms, implementation
Correct Solution:
```
print(2001)
for i in range(1 , 1001):
print(f"{i} 1 {i} 2")
print(f"1 1 1 2")
for i in range(1 , 1001):
print(f"{i} 1 {i} 2")
``` | output | 1 | 50,901 | 15 | 101,803 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There was a big bank robbery in Tablecity. In order to catch the thief, the President called none other than Albert – Tablecity’s Chief of Police. Albert does not know where the thief is located, but he does know how he moves.
Tablecity can... | instruction | 0 | 50,902 | 15 | 101,804 |
Tags: constructive algorithms, implementation
Correct Solution:
```
print(1998)
[print(i, 1, i, 2) for k in '12' for i in range(1, 1000)]
``` | output | 1 | 50,902 | 15 | 101,805 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There was a big bank robbery in Tablecity. In order to catch the thief, the President called none other than Albert – Tablecity’s Chief of Police. Albert does not know where the thief is located, but he does know how he moves.
Tablecity can... | instruction | 0 | 50,903 | 15 | 101,806 |
Tags: constructive algorithms, implementation
Correct Solution:
```
print(1999)
for i in range(1,1001):print(i,1,i,2)
for i in range(2,1001):print(i,1,i,2)
``` | output | 1 | 50,903 | 15 | 101,807 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There was a big bank robbery in Tablecity. In order to catch the thief, the President called none other than Albert – Tablecity’s Chief of Police. Albert does not know where the thief is located, but he does know how he moves.
Tablecity can... | instruction | 0 | 50,904 | 15 | 101,808 |
Tags: constructive algorithms, implementation
Correct Solution:
```
print(1998); f = lambda: [print(i, 1, i, 2) for i in range(1, 1000)]
f(); f()
``` | output | 1 | 50,904 | 15 | 101,809 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There was a big bank robbery in Tablecity. In order to catch the thief, the President called none other than Albert – Tablecity’s Chief of Police. Albert does not know where the thief is located, but he does know how he moves.
Tablecity can... | instruction | 0 | 50,905 | 15 | 101,810 |
Tags: constructive algorithms, implementation
Correct Solution:
```
print(2000)
n = 1000
for i in range(1, n + 1):
print(i, 1, i, 2)
for i in range(n, 0, -1):
print(i, 1, i, 2)
``` | output | 1 | 50,905 | 15 | 101,811 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There was a big bank robbery in Tablecity. In order to catch the thief, the President called none other than Albert – Tablecity’s Chief of Police. Albert does not know where the thief is located, but he does know how he moves.
Tablecity can... | instruction | 0 | 50,906 | 15 | 101,812 |
Tags: constructive algorithms, implementation
Correct Solution:
```
print ("2000")
for i in range(1000,0,-1):
print("{0} 1 {1} 2".format(i,i))
for i in range(1,1001):
print("{0} 1 {1} 2".format(i,i))
``` | output | 1 | 50,906 | 15 | 101,813 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There was a big bank robbery in Tablecity. In order to catch the thief, the President called none other than Albert – Tablecity’s Chief of Police. Albert does not know where the thief is located... | instruction | 0 | 50,907 | 15 | 101,814 |
Yes | output | 1 | 50,907 | 15 | 101,815 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There was a big bank robbery in Tablecity. In order to catch the thief, the President called none other than Albert – Tablecity’s Chief of Police. Albert does not know where the thief is located... | instruction | 0 | 50,908 | 15 | 101,816 |
Yes | output | 1 | 50,908 | 15 | 101,817 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There was a big bank robbery in Tablecity. In order to catch the thief, the President called none other than Albert – Tablecity’s Chief of Police. Albert does not know where the thief is located... | instruction | 0 | 50,909 | 15 | 101,818 |
Yes | output | 1 | 50,909 | 15 | 101,819 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There was a big bank robbery in Tablecity. In order to catch the thief, the President called none other than Albert – Tablecity’s Chief of Police. Albert does not know where the thief is located... | instruction | 0 | 50,910 | 15 | 101,820 |
Yes | output | 1 | 50,910 | 15 | 101,821 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There was a big bank robbery in Tablecity. In order to catch the thief, the President called none other than Albert – Tablecity’s Chief of Police. Albert does not know where the thief is located... | instruction | 0 | 50,911 | 15 | 101,822 |
No | output | 1 | 50,911 | 15 | 101,823 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There was a big bank robbery in Tablecity. In order to catch the thief, the President called none other than Albert – Tablecity’s Chief of Police. Albert does not know where the thief is located... | instruction | 0 | 50,912 | 15 | 101,824 |
No | output | 1 | 50,912 | 15 | 101,825 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There was a big bank robbery in Tablecity. In order to catch the thief, the President called none other than Albert – Tablecity’s Chief of Police. Albert does not know where the thief is located... | instruction | 0 | 50,913 | 15 | 101,826 |
No | output | 1 | 50,913 | 15 | 101,827 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There was a big bank robbery in Tablecity. In order to catch the thief, the President called none other than Albert – Tablecity’s Chief of Police. Albert does not know where the thief is located... | instruction | 0 | 50,914 | 15 | 101,828 |
No | output | 1 | 50,914 | 15 | 101,829 |
Provide tags and a correct Python 3 solution for this coding contest problem.
DZY loves chessboard, and he enjoys playing with it.
He has a chessboard of n rows and m columns. Some cells of the chessboard are bad, others are good. For every good cell, DZY wants to put a chessman on it. Each chessman is either white o... | instruction | 0 | 51,676 | 15 | 103,352 |
Tags: dfs and similar, implementation
Correct Solution:
```
n,m= map(int,input().split())
arr=[]
for i in range(n):
x=list(input())
arr.append(x)
counter=0
for i in range(n):
for j in range(m):
if(arr[i][j]=="."):
if((i+j)%2==0):
arr[i][j]="B"
else:
arr[i][j]="W"
for i in range(n):
print("".join(... | output | 1 | 51,676 | 15 | 103,353 |
Provide tags and a correct Python 3 solution for this coding contest problem.
DZY loves chessboard, and he enjoys playing with it.
He has a chessboard of n rows and m columns. Some cells of the chessboard are bad, others are good. For every good cell, DZY wants to put a chessman on it. Each chessman is either white o... | instruction | 0 | 51,677 | 15 | 103,354 |
Tags: dfs and similar, implementation
Correct Solution:
```
def chess():
n,m=map(int,input().split())
liss=[]
for i in range(n):
liss.append(list(map(str,input())))
st=''
for i in range(n):
for j in range(len(liss[0])):
if(liss[i][j]=='.'):
if(abs(i-j)%2==... | output | 1 | 51,677 | 15 | 103,355 |
Provide tags and a correct Python 3 solution for this coding contest problem.
DZY loves chessboard, and he enjoys playing with it.
He has a chessboard of n rows and m columns. Some cells of the chessboard are bad, others are good. For every good cell, DZY wants to put a chessman on it. Each chessman is either white o... | instruction | 0 | 51,678 | 15 | 103,356 |
Tags: dfs and similar, implementation
Correct Solution:
```
#input
n,m=map(int,input().split())
chessboard=[]
for i in range(n):
row=list(input())
chessboard.append(row)
#variables
#main
for i in range(n):
for j in range(m):
if chessboard[i][j]=='.':
if (j+i)%2==0:
chessboard[i][j]='B'
else:
chess... | output | 1 | 51,678 | 15 | 103,357 |
Provide tags and a correct Python 3 solution for this coding contest problem.
DZY loves chessboard, and he enjoys playing with it.
He has a chessboard of n rows and m columns. Some cells of the chessboard are bad, others are good. For every good cell, DZY wants to put a chessman on it. Each chessman is either white o... | instruction | 0 | 51,679 | 15 | 103,358 |
Tags: dfs and similar, implementation
Correct Solution:
```
n,m = map(int,input().split())
for i in range(0,n):
s = input()
ans = ""
for j in range(0,m):
if s[j] == '.':
if (i+j)&1==1:
ans += "W"
else:
... | output | 1 | 51,679 | 15 | 103,359 |
Provide tags and a correct Python 3 solution for this coding contest problem.
DZY loves chessboard, and he enjoys playing with it.
He has a chessboard of n rows and m columns. Some cells of the chessboard are bad, others are good. For every good cell, DZY wants to put a chessman on it. Each chessman is either white o... | instruction | 0 | 51,680 | 15 | 103,360 |
Tags: dfs and similar, implementation
Correct Solution:
```
n, m = map(int, input().split())
for i in range(0, n):
s = input()
ans = ""
for j in range(0, m):
if s[j] == '.':
if (i + j) & 1 == 1:
ans = ans + "B"
else:
ans = ans + "W"
els... | output | 1 | 51,680 | 15 | 103,361 |
Provide tags and a correct Python 3 solution for this coding contest problem.
DZY loves chessboard, and he enjoys playing with it.
He has a chessboard of n rows and m columns. Some cells of the chessboard are bad, others are good. For every good cell, DZY wants to put a chessman on it. Each chessman is either white o... | instruction | 0 | 51,681 | 15 | 103,362 |
Tags: dfs and similar, implementation
Correct Solution:
```
n, m = [int(x) for x in input().split()]
a = []
for i in range(0, n):
a.append(input())
f = 1
for i in range(0, n):
for j in range(0, m):
if a[i][j] == "-":
print(a[i][j], end = "")
if a[i][j] == ".":
if f == 1:
... | output | 1 | 51,681 | 15 | 103,363 |
Provide tags and a correct Python 3 solution for this coding contest problem.
DZY loves chessboard, and he enjoys playing with it.
He has a chessboard of n rows and m columns. Some cells of the chessboard are bad, others are good. For every good cell, DZY wants to put a chessman on it. Each chessman is either white o... | instruction | 0 | 51,682 | 15 | 103,364 |
Tags: dfs and similar, implementation
Correct Solution:
```
#445A
n,m=map(int,input().split())
for i in range(n):
L=input()
for j in range(m):
if L[j]==".":
if (i+j)%2==1:
print("W",end="")
else:
print("B",end="")
else:
print("-... | output | 1 | 51,682 | 15 | 103,365 |
Provide tags and a correct Python 3 solution for this coding contest problem.
DZY loves chessboard, and he enjoys playing with it.
He has a chessboard of n rows and m columns. Some cells of the chessboard are bad, others are good. For every good cell, DZY wants to put a chessman on it. Each chessman is either white o... | instruction | 0 | 51,683 | 15 | 103,366 |
Tags: dfs and similar, implementation
Correct Solution:
```
# -*- coding: utf-8 -*-
"""
Created on Wed Jul 1 09:37:24 2020
@author: Harshal
"""
m,n=map(int,input().split())
arr=[]
for i in range(m):
arr.append(list(input()))
for i in range(m):
for j in range(n):
if arr[i][j]=='.':
if (... | output | 1 | 51,683 | 15 | 103,367 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
DZY loves chessboard, and he enjoys playing with it.
He has a chessboard of n rows and m columns. Some cells of the chessboard are bad, others are good. For every good cell, DZY wants to put a ... | instruction | 0 | 51,684 | 15 | 103,368 |
Yes | output | 1 | 51,684 | 15 | 103,369 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
DZY loves chessboard, and he enjoys playing with it.
He has a chessboard of n rows and m columns. Some cells of the chessboard are bad, others are good. For every good cell, DZY wants to put a ... | instruction | 0 | 51,685 | 15 | 103,370 |
Yes | output | 1 | 51,685 | 15 | 103,371 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
DZY loves chessboard, and he enjoys playing with it.
He has a chessboard of n rows and m columns. Some cells of the chessboard are bad, others are good. For every good cell, DZY wants to put a ... | instruction | 0 | 51,686 | 15 | 103,372 |
Yes | output | 1 | 51,686 | 15 | 103,373 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
DZY loves chessboard, and he enjoys playing with it.
He has a chessboard of n rows and m columns. Some cells of the chessboard are bad, others are good. For every good cell, DZY wants to put a ... | instruction | 0 | 51,687 | 15 | 103,374 |
Yes | output | 1 | 51,687 | 15 | 103,375 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
DZY loves chessboard, and he enjoys playing with it.
He has a chessboard of n rows and m columns. Some cells of the chessboard are bad, others are good. For every good cell, DZY wants to put a ... | instruction | 0 | 51,688 | 15 | 103,376 |
No | output | 1 | 51,688 | 15 | 103,377 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
DZY loves chessboard, and he enjoys playing with it.
He has a chessboard of n rows and m columns. Some cells of the chessboard are bad, others are good. For every good cell, DZY wants to put a ... | instruction | 0 | 51,689 | 15 | 103,378 |
No | output | 1 | 51,689 | 15 | 103,379 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
DZY loves chessboard, and he enjoys playing with it.
He has a chessboard of n rows and m columns. Some cells of the chessboard are bad, others are good. For every good cell, DZY wants to put a ... | instruction | 0 | 51,690 | 15 | 103,380 |
No | output | 1 | 51,690 | 15 | 103,381 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
DZY loves chessboard, and he enjoys playing with it.
He has a chessboard of n rows and m columns. Some cells of the chessboard are bad, others are good. For every good cell, DZY wants to put a ... | instruction | 0 | 51,691 | 15 | 103,382 |
No | output | 1 | 51,691 | 15 | 103,383 |
Provide a correct Python 3 solution for this coding contest problem.
We have a grid with H rows and W columns. The square at the i-th row and the j-th column will be called Square (i,j).
The integers from 1 through H×W are written throughout the grid, and the integer written in Square (i,j) is A_{i,j}.
You, a magica... | instruction | 0 | 52,012 | 15 | 104,024 |
"Correct Solution:
```
H, W, D = map(int, input().split())
X, Y, ans = [-1] * H * W, [-1] * H * W, [0] * H * W
for h in range(H):
A = list(map(int, input().split()))
for w in range(W):
X[A[w] - 1], Y[A[w] - 1] = h, w
for d in range(D):
while d + D < H * W:
ans[d + D] = ans[d] + abs(X[d] - ... | output | 1 | 52,012 | 15 | 104,025 |
Provide a correct Python 3 solution for this coding contest problem.
We have a grid with H rows and W columns. The square at the i-th row and the j-th column will be called Square (i,j).
The integers from 1 through H×W are written throughout the grid, and the integer written in Square (i,j) is A_{i,j}.
You, a magica... | instruction | 0 | 52,013 | 15 | 104,026 |
"Correct Solution:
```
# ABC089 D - Practical Skill Test
h,w,d=map(int,input().split())
a=[list(map(int,input().split())) for i in range(h)]
x=[0]*(h*w+1)
y=[0]*(h*w+1)
ans=[0]*(h*w+1)
for i in range(h):
for j in range(w):
x[a[i][j]]=i
y[a[i][j]]=j
for i in range(d+1,h*w+1):
ans[i]=ans[i-d]+abs(... | output | 1 | 52,013 | 15 | 104,027 |
Provide a correct Python 3 solution for this coding contest problem.
We have a grid with H rows and W columns. The square at the i-th row and the j-th column will be called Square (i,j).
The integers from 1 through H×W are written throughout the grid, and the integer written in Square (i,j) is A_{i,j}.
You, a magica... | instruction | 0 | 52,014 | 15 | 104,028 |
"Correct Solution:
```
import sys
readline = sys.stdin.buffer.readline
H, W, D = map(int, readline().split())
px = [0] * (H*W+1)
py = [0] * (H*W+1)
d = [0] * (H*W+1)
for y in range(H):
line = list(map(int, readline().split()))
for x, A in enumerate(line):
px[A] = x
py[A] = y
for i in range(D+... | output | 1 | 52,014 | 15 | 104,029 |
Provide a correct Python 3 solution for this coding contest problem.
We have a grid with H rows and W columns. The square at the i-th row and the j-th column will be called Square (i,j).
The integers from 1 through H×W are written throughout the grid, and the integer written in Square (i,j) is A_{i,j}.
You, a magica... | instruction | 0 | 52,015 | 15 | 104,030 |
"Correct Solution:
```
def main():
H,W,D=map(int,input().split())
A=[]
for h in range(H):
for w,a in enumerate(map(int,input().split())):
A+=[[a,h,w]]
A.sort(key=lambda x:x[0])
B=[0]*(H*W)
for i in range(D):
while i+D<W*H:
B[i+D]=B[i]+abs(A[i][1]-A[i+D][1])+abs(A[i][2]-A[i+D][2])
... | output | 1 | 52,015 | 15 | 104,031 |
Provide a correct Python 3 solution for this coding contest problem.
We have a grid with H rows and W columns. The square at the i-th row and the j-th column will be called Square (i,j).
The integers from 1 through H×W are written throughout the grid, and the integer written in Square (i,j) is A_{i,j}.
You, a magica... | instruction | 0 | 52,016 | 15 | 104,032 |
"Correct Solution:
```
h,w,d=map(int,input().split())
b=[0]*(h*w)
for i in range(h):
for j,s in enumerate(input().split()):b[int(s)-1]=(i,j)
a=[0]*(h*w+d)
for i in range(d,h*w):a[i]=a[i-d]+abs(b[i][0]-b[i-d][0])+abs(b[i][1]-b[i-d][1])
for i in range(int(input())):
l,r=map(int,input().split())
print(a[r-1]-a[l-1])... | output | 1 | 52,016 | 15 | 104,033 |
Provide a correct Python 3 solution for this coding contest problem.
We have a grid with H rows and W columns. The square at the i-th row and the j-th column will be called Square (i,j).
The integers from 1 through H×W are written throughout the grid, and the integer written in Square (i,j) is A_{i,j}.
You, a magica... | instruction | 0 | 52,017 | 15 | 104,034 |
"Correct Solution:
```
H, W, D = map(int, input().split())
x = [0] * (H * W + 1)
for i in range(H):
a = list(map(int, input().split()))
for j in range(W):
x[a[j]] = [i, j]
#print(x)
d = [0] * (H * W + 1)
for i in range(1, H * W + 1):
if i > D:
d[i] = d[i - D] + abs(x[i][0] - x[i - D][0]) + abs(x[i][1... | output | 1 | 52,017 | 15 | 104,035 |
Provide a correct Python 3 solution for this coding contest problem.
We have a grid with H rows and W columns. The square at the i-th row and the j-th column will be called Square (i,j).
The integers from 1 through H×W are written throughout the grid, and the integer written in Square (i,j) is A_{i,j}.
You, a magica... | instruction | 0 | 52,018 | 15 | 104,036 |
"Correct Solution:
```
H,W,D=map(int,input().split())
def main():
A=list()
for h in range(H):
for w,a in enumerate(map(int,input().split())):
A.append([a,h,w])
A=sorted(A, key=lambda x:x[0])
B=[0]*(H*W)
for i in range(D):
while i+D<W*H:
B[i+D]=B[i]+abs(A[i][1]-A[i+D][1])+abs(A[i][2]-A[i... | output | 1 | 52,018 | 15 | 104,037 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.