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.
Dima overslept the alarm clock, which was supposed to raise him to school.
Dima wonders if he will have time to come to the first lesson. To do this, he needs to know the minimum time it will take him to get from home to school.
The city w... | instruction | 0 | 90,382 | 15 | 180,764 |
Tags: brute force, dfs and similar, graphs, greedy, implementation, shortest paths
Correct Solution:
```
#!/usr/bin/env python3
import io
import os
from collections import deque
# input = sys.stdin.readline # to read input quickly
from math import inf
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
# ava... | output | 1 | 90,382 | 15 | 180,765 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Dima overslept the alarm clock, which was supposed to raise him to school.
Dima wonders if he will have time to come to the first lesson. To do this, he needs to know the minimum time it will take him to get from home to school.
The city w... | instruction | 0 | 90,383 | 15 | 180,766 |
Tags: brute force, dfs and similar, graphs, greedy, implementation, shortest paths
Correct Solution:
```
#!/usr/bin/env python3
import io
import os
from collections import deque
# input = sys.stdin.readline # to read input quickly
from math import inf
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
# ava... | output | 1 | 90,383 | 15 | 180,767 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Dima overslept the alarm clock, which was supposed to raise him to school.
Dima wonders if he will have time to come to the first lesson. To do this, he needs to know the minimum time it will take him to get from home to school.
The city w... | instruction | 0 | 90,384 | 15 | 180,768 |
Tags: brute force, dfs and similar, graphs, greedy, implementation, shortest paths
Correct Solution:
```
#!/usr/bin/env python3
import io
import os
from collections import deque
# input = sys.stdin.readline # to read input quickly
from math import inf
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
# ava... | output | 1 | 90,384 | 15 | 180,769 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Dima overslept the alarm clock, which was supposed to raise him to school.
Dima wonders if he will have time to come to the first lesson. To do this, he needs to know the minimum time it will take him to get from home to school.
The city w... | instruction | 0 | 90,385 | 15 | 180,770 |
Tags: brute force, dfs and similar, graphs, greedy, implementation, shortest paths
Correct Solution:
```
import io,os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
from collections import deque
m,n,w = map(int,input().split())
grid = []
for i in range(m):
temp = list(map(int,input().split()))
gri... | output | 1 | 90,385 | 15 | 180,771 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Dima overslept the alarm clock, which was supposed to raise him to school.
Dima wonders if he will have time to come to the first lesson. To do this, he needs to know the minimum time it will take him to get from home to school.
The city w... | instruction | 0 | 90,386 | 15 | 180,772 |
Tags: brute force, dfs and similar, graphs, greedy, implementation, shortest paths
Correct Solution:
```
#!/usr/bin/env python3
import io
import os
from collections import deque
# input = sys.stdin.readline # to read input quickly
from math import inf
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
# ava... | output | 1 | 90,386 | 15 | 180,773 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Dima overslept the alarm clock, which was supposed to raise him to school.
Dima wonders if he will have time to come to the first lesson. To do this, he needs to know the minimum time it will take him to get from home to school.
The city w... | instruction | 0 | 90,387 | 15 | 180,774 |
Tags: brute force, dfs and similar, graphs, greedy, implementation, shortest paths
Correct Solution:
```
from collections import deque
from math import inf
import io
import os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
(n,m,w) = [int(x) for x in input().split()]
M = [int(x) for i in range(n) for x in... | output | 1 | 90,387 | 15 | 180,775 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Dima overslept the alarm clock, which was supposed to raise him to school.
Dima wonders if he will have time to come to the first lesson. To do this, he needs to know the minimum time it will t... | instruction | 0 | 90,388 | 15 | 180,776 |
Yes | output | 1 | 90,388 | 15 | 180,777 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Dima overslept the alarm clock, which was supposed to raise him to school.
Dima wonders if he will have time to come to the first lesson. To do this, he needs to know the minimum time it will t... | instruction | 0 | 90,389 | 15 | 180,778 |
Yes | output | 1 | 90,389 | 15 | 180,779 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Dima overslept the alarm clock, which was supposed to raise him to school.
Dima wonders if he will have time to come to the first lesson. To do this, he needs to know the minimum time it will t... | instruction | 0 | 90,390 | 15 | 180,780 |
Yes | output | 1 | 90,390 | 15 | 180,781 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Dima overslept the alarm clock, which was supposed to raise him to school.
Dima wonders if he will have time to come to the first lesson. To do this, he needs to know the minimum time it will t... | instruction | 0 | 90,391 | 15 | 180,782 |
Yes | output | 1 | 90,391 | 15 | 180,783 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Dima overslept the alarm clock, which was supposed to raise him to school.
Dima wonders if he will have time to come to the first lesson. To do this, he needs to know the minimum time it will t... | instruction | 0 | 90,392 | 15 | 180,784 |
No | output | 1 | 90,392 | 15 | 180,785 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Dima overslept the alarm clock, which was supposed to raise him to school.
Dima wonders if he will have time to come to the first lesson. To do this, he needs to know the minimum time it will t... | instruction | 0 | 90,393 | 15 | 180,786 |
No | output | 1 | 90,393 | 15 | 180,787 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Dima overslept the alarm clock, which was supposed to raise him to school.
Dima wonders if he will have time to come to the first lesson. To do this, he needs to know the minimum time it will t... | instruction | 0 | 90,394 | 15 | 180,788 |
No | output | 1 | 90,394 | 15 | 180,789 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Dima overslept the alarm clock, which was supposed to raise him to school.
Dima wonders if he will have time to come to the first lesson. To do this, he needs to know the minimum time it will t... | instruction | 0 | 90,395 | 15 | 180,790 |
No | output | 1 | 90,395 | 15 | 180,791 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Bessie the cow and her best friend Elsie each received a sliding puzzle on Pi Day. Their puzzles consist of a 2 Γ 2 grid and three tiles labeled 'A', 'B', and 'C'. The three tiles sit on top of the grid, leaving one grid cell empty. To make ... | instruction | 0 | 90,548 | 15 | 181,096 |
Tags: brute force, constructive algorithms, implementation
Correct Solution:
```
a = input()
b = input()
c = input()
d = input()
s = list(a + b[1] + b[0])
t = list(c + d[1] + d[0])
s.remove('X')
t.remove('X')
for i in range(5):
t = t[1:] + [t[0]]
if s == t:
print("YES")
break
else:
print("... | output | 1 | 90,548 | 15 | 181,097 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Bessie the cow and her best friend Elsie each received a sliding puzzle on Pi Day. Their puzzles consist of a 2 Γ 2 grid and three tiles labeled 'A', 'B', and 'C'. The three tiles sit on top of the grid, leaving one grid cell empty. To make ... | instruction | 0 | 90,549 | 15 | 181,098 |
Tags: brute force, constructive algorithms, implementation
Correct Solution:
```
count = 12
ans = False
first = [list(input())]
first.append(list(input()))
second = [list(input())]
second.append(list(input()))
for i in range(count):
if first == second:
ans = True
break
if first[0][0] == 'X':
... | output | 1 | 90,549 | 15 | 181,099 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Bessie the cow and her best friend Elsie each received a sliding puzzle on Pi Day. Their puzzles consist of a 2 Γ 2 grid and three tiles labeled 'A', 'B', and 'C'. The three tiles sit on top of the grid, leaving one grid cell empty. To make ... | instruction | 0 | 90,550 | 15 | 181,100 |
Tags: brute force, constructive algorithms, implementation
Correct Solution:
```
a = input()
a = a + input()[::-1]
a = a.replace('X','')
b = input()
b = b + input()[::-1]
b = b.replace('X','')
b = b * 2
if b.find(a) == -1:
print('NO')
else:
print('YES')
``` | output | 1 | 90,550 | 15 | 181,101 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Bessie the cow and her best friend Elsie each received a sliding puzzle on Pi Day. Their puzzles consist of a 2 Γ 2 grid and three tiles labeled 'A', 'B', and 'C'. The three tiles sit on top of the grid, leaving one grid cell empty. To make ... | instruction | 0 | 90,551 | 15 | 181,102 |
Tags: brute force, constructive algorithms, implementation
Correct Solution:
```
#!/usr/bin/python3
def main():
a = input() + "".join(reversed(input()))
b = input() + "".join(reversed(input()))
a = a[:a.find("X")] + a[a.find("X") + 1:]
b = b[:b.find("X")] + b[b.find("X") + 1:]
for i in range(3):
... | output | 1 | 90,551 | 15 | 181,103 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Bessie the cow and her best friend Elsie each received a sliding puzzle on Pi Day. Their puzzles consist of a 2 Γ 2 grid and three tiles labeled 'A', 'B', and 'C'. The three tiles sit on top of the grid, leaving one grid cell empty. To make ... | instruction | 0 | 90,552 | 15 | 181,104 |
Tags: brute force, constructive algorithms, implementation
Correct Solution:
```
def find_order(A, B):
d = dict()
i = 0
if A[0] != 'X':
d[i] = A[0]
i += 1
if A[1] != 'X':
d[i] = A[1]
i += 1
if B[1] != 'X':
d[i] = B[1]
i += 1
if B[0] != 'X':
... | output | 1 | 90,552 | 15 | 181,105 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Bessie the cow and her best friend Elsie each received a sliding puzzle on Pi Day. Their puzzles consist of a 2 Γ 2 grid and three tiles labeled 'A', 'B', and 'C'. The three tiles sit on top of the grid, leaving one grid cell empty. To make ... | instruction | 0 | 90,553 | 15 | 181,106 |
Tags: brute force, constructive algorithms, implementation
Correct Solution:
```
s1 = ""
s2 = ""
a = input()
b = input()
c = input()
d = input()
s1 = list(a + b[1] + b[0])
s2 = list(c + d[1] + d[0])
t = s1.index('X')
if t != 3:
s1 = s1[:t] + s1[t+1:]
else:
s1 = s1[:3]
t = s2.index('X')
if t != 3:
s2 = s2[:t... | output | 1 | 90,553 | 15 | 181,107 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Bessie the cow and her best friend Elsie each received a sliding puzzle on Pi Day. Their puzzles consist of a 2 Γ 2 grid and three tiles labeled 'A', 'B', and 'C'. The three tiles sit on top of the grid, leaving one grid cell empty. To make ... | instruction | 0 | 90,554 | 15 | 181,108 |
Tags: brute force, constructive algorithms, implementation
Correct Solution:
```
f = lambda: 'ABC' in 2 * (input()+input()[::-1]).replace('X', '')
print('NO' if f()^f() else 'YES')
``` | output | 1 | 90,554 | 15 | 181,109 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Bessie the cow and her best friend Elsie each received a sliding puzzle on Pi Day. Their puzzles consist of a 2 Γ 2 grid and three tiles labeled 'A', 'B', and 'C'. The three tiles sit on top of the grid, leaving one grid cell empty. To make ... | instruction | 0 | 90,555 | 15 | 181,110 |
Tags: brute force, constructive algorithms, implementation
Correct Solution:
```
s1 = input() + input()[::-1]
s2 = input() + input()[::-1]
s1 = s1[:s1.find('X')] + s1[s1.find('X') + 1:]
s2 = s2[:s2.find('X')] + s2[s2.find('X') + 1:]
flag = False
for i in range(3):
if s1 == s2:
flag = True
break
... | output | 1 | 90,555 | 15 | 181,111 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Bessie the cow and her best friend Elsie each received a sliding puzzle on Pi Day. Their puzzles consist of a 2 Γ 2 grid and three tiles labeled 'A', 'B', and 'C'. The three tiles sit on top of ... | instruction | 0 | 90,556 | 15 | 181,112 |
Yes | output | 1 | 90,556 | 15 | 181,113 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Bessie the cow and her best friend Elsie each received a sliding puzzle on Pi Day. Their puzzles consist of a 2 Γ 2 grid and three tiles labeled 'A', 'B', and 'C'. The three tiles sit on top of ... | instruction | 0 | 90,557 | 15 | 181,114 |
Yes | output | 1 | 90,557 | 15 | 181,115 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Bessie the cow and her best friend Elsie each received a sliding puzzle on Pi Day. Their puzzles consist of a 2 Γ 2 grid and three tiles labeled 'A', 'B', and 'C'. The three tiles sit on top of ... | instruction | 0 | 90,558 | 15 | 181,116 |
Yes | output | 1 | 90,558 | 15 | 181,117 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Bessie the cow and her best friend Elsie each received a sliding puzzle on Pi Day. Their puzzles consist of a 2 Γ 2 grid and three tiles labeled 'A', 'B', and 'C'. The three tiles sit on top of ... | instruction | 0 | 90,559 | 15 | 181,118 |
Yes | output | 1 | 90,559 | 15 | 181,119 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Bessie the cow and her best friend Elsie each received a sliding puzzle on Pi Day. Their puzzles consist of a 2 Γ 2 grid and three tiles labeled 'A', 'B', and 'C'. The three tiles sit on top of ... | instruction | 0 | 90,560 | 15 | 181,120 |
No | output | 1 | 90,560 | 15 | 181,121 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Bessie the cow and her best friend Elsie each received a sliding puzzle on Pi Day. Their puzzles consist of a 2 Γ 2 grid and three tiles labeled 'A', 'B', and 'C'. The three tiles sit on top of ... | instruction | 0 | 90,561 | 15 | 181,122 |
No | output | 1 | 90,561 | 15 | 181,123 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Bessie the cow and her best friend Elsie each received a sliding puzzle on Pi Day. Their puzzles consist of a 2 Γ 2 grid and three tiles labeled 'A', 'B', and 'C'. The three tiles sit on top of ... | instruction | 0 | 90,562 | 15 | 181,124 |
No | output | 1 | 90,562 | 15 | 181,125 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Bessie the cow and her best friend Elsie each received a sliding puzzle on Pi Day. Their puzzles consist of a 2 Γ 2 grid and three tiles labeled 'A', 'B', and 'C'. The three tiles sit on top of ... | instruction | 0 | 90,563 | 15 | 181,126 |
No | output | 1 | 90,563 | 15 | 181,127 |
Provide a correct Python 3 solution for this coding contest problem.
Twin adventurers Rin and Len are searching for treasure in the Mirror Cave. The cave has two pairs of rooms, the Hall of Mirrors, and an expensive treasure lies behind the door of the room.
For convenience, each of the two rooms is considered to hav... | instruction | 0 | 90,921 | 15 | 181,842 |
"Correct Solution:
```
from collections import deque
def bfs(W, H):
G = '%'
edges = '#' * (W + 2)
dxy = [(0, 1), (0, -1), (1, 0), (-1, 0)]
mapL, mapR = [edges], [edges]
for i in range(H):
l, r = input().split()
mapL.append('#' + l + '#')
mapR.append('#' + r + '#')
if... | output | 1 | 90,921 | 15 | 181,843 |
Provide a correct Python 3 solution for this coding contest problem.
Twin adventurers Rin and Len are searching for treasure in the Mirror Cave. The cave has two pairs of rooms, the Hall of Mirrors, and an expensive treasure lies behind the door of the room.
For convenience, each of the two rooms is considered to hav... | instruction | 0 | 90,922 | 15 | 181,844 |
"Correct Solution:
```
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bi... | output | 1 | 90,922 | 15 | 181,845 |
Provide a correct Python 3 solution for this coding contest problem.
Twin adventurers Rin and Len are searching for treasure in the Mirror Cave. The cave has two pairs of rooms, the Hall of Mirrors, and an expensive treasure lies behind the door of the room.
For convenience, each of the two rooms is considered to hav... | instruction | 0 | 90,923 | 15 | 181,846 |
"Correct Solution:
```
from collections import deque, defaultdict
def main():
directs = ((-1, 0, 1, 0), (1, 0, -1, 0), (0, 1, 0, 1), (0, -1, 0, -1))
while True:
w, h = map(int, input().split())
if w == 0:
break
mp_l = ["#" * (w + 2)]
mp_r = ["#" * (w + 2)]
for _ in range(h):
l, r... | output | 1 | 90,923 | 15 | 181,847 |
Provide a correct Python 3 solution for this coding contest problem.
Twin adventurers Rin and Len are searching for treasure in the Mirror Cave. The cave has two pairs of rooms, the Hall of Mirrors, and an expensive treasure lies behind the door of the room.
For convenience, each of the two rooms is considered to hav... | instruction | 0 | 90,924 | 15 | 181,848 |
"Correct Solution:
```
from collections import deque,defaultdict
d = [(1,0),(-1,0),(0,1),(0,-1)]
def bfs(sly,slx,sry,srx):
bfs_map = defaultdict(lambda : 1)
bfs_map[(sly,slx,sry,srx)] = 0
q = deque()
q.append((sly,slx,sry,srx))
while q:
ly,lx,ry,rx = q.popleft()
for dy,dx in d:
... | output | 1 | 90,924 | 15 | 181,849 |
Provide a correct Python 3 solution for this coding contest problem.
Twin adventurers Rin and Len are searching for treasure in the Mirror Cave. The cave has two pairs of rooms, the Hall of Mirrors, and an expensive treasure lies behind the door of the room.
For convenience, each of the two rooms is considered to hav... | instruction | 0 | 90,925 | 15 | 181,850 |
"Correct Solution:
```
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
def LI(): return [int... | output | 1 | 90,925 | 15 | 181,851 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Twin adventurers Rin and Len are searching for treasure in the Mirror Cave. The cave has two pairs of rooms, the Hall of Mirrors, and an expensive treasure lies behind the door of the room.
For... | instruction | 0 | 90,926 | 15 | 181,852 |
No | output | 1 | 90,926 | 15 | 181,853 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Twin adventurers Rin and Len are searching for treasure in the Mirror Cave. The cave has two pairs of rooms, the Hall of Mirrors, and an expensive treasure lies behind the door of the room.
For... | instruction | 0 | 90,927 | 15 | 181,854 |
No | output | 1 | 90,927 | 15 | 181,855 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Twin adventurers Rin and Len are searching for treasure in the Mirror Cave. The cave has two pairs of rooms, the Hall of Mirrors, and an expensive treasure lies behind the door of the room.
For... | instruction | 0 | 90,928 | 15 | 181,856 |
No | output | 1 | 90,928 | 15 | 181,857 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Twin adventurers Rin and Len are searching for treasure in the Mirror Cave. The cave has two pairs of rooms, the Hall of Mirrors, and an expensive treasure lies behind the door of the room.
For... | instruction | 0 | 90,929 | 15 | 181,858 |
No | output | 1 | 90,929 | 15 | 181,859 |
Provide a correct Python 3 solution for this coding contest problem.
Sunake is in the form of a polygonal line consisting of n vertices (without self-intersection). First, Sunake-kun's i-th vertex is at (xi, yi). You can move continuously by translating or rotating, but you cannot deform (change the length of the poly... | instruction | 0 | 90,930 | 15 | 181,860 |
"Correct Solution:
```
import sys
readline = sys.stdin.readline
write = sys.stdout.write
def dot3(p0, p1, p2):
x0, y0 = p0; x1, y1 = p1; x2, y2 = p2
return (x1 - x0) * (x2 - x0) + (y1 - y0) * (y2 - y0)
def cross3(p0, p1, p2):
x0, y0 = p0; x1, y1 = p1; x2, y2 = p2
return (x1 - x0) * (y2 - y0) - (y1 - y0)... | output | 1 | 90,930 | 15 | 181,861 |
Provide a correct Python 3 solution for this coding contest problem.
Mr. A and Mr. B live in an N Γ M rectangular grid area. Each square is either a road, a wall, or a house. Since this area is famous for the frequent occurrence of molestation damage due to the complicated and intricate roads, the boundary between thi... | instruction | 0 | 91,702 | 15 | 183,404 |
"Correct Solution:
```
# coding: utf-8
n,m=map(int,input().split())
def mae(v,i,j):
if v==0 and 0<=i-1<n+2 and 0<=j<m+2:
return (i-1,j)
elif v==1 and 0<=i<n+2 and 0<=j+1<m+2:
return (i,j+1)
elif v==2 and 0<=i+1<n+2 and 0<=j<m+2:
return (i+1,j)
elif v==3 and 0<=i<n+2 and 0<=j-1<m+... | output | 1 | 91,702 | 15 | 183,405 |
Provide a correct Python 3 solution for this coding contest problem.
Mr. A and Mr. B live in an N Γ M rectangular grid area. Each square is either a road, a wall, or a house. Since this area is famous for the frequent occurrence of molestation damage due to the complicated and intricate roads, the boundary between thi... | instruction | 0 | 91,703 | 15 | 183,406 |
"Correct Solution:
```
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
def LI(): return [int... | output | 1 | 91,703 | 15 | 183,407 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a table consisting of n rows and m columns. Each cell of the table contains a number, 0 or 1. In one move we can choose some row of the table and cyclically shift its values either one cell to the left, or one cell to the right... | instruction | 0 | 92,033 | 15 | 184,066 |
Tags: brute force, two pointers
Correct Solution:
```
n, m = map(int, input().split())
memo = [[int(2e9) for j in range(m)] for i in range(n)]
for i in range(n):
s = input()
if s.find('1') == -1:
print(-1)
exit()
memo[i][0] = s[::-1].find('1') + 1
memo[i][m-1] = s.find('1') + 1
... | output | 1 | 92,033 | 15 | 184,067 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a table consisting of n rows and m columns. Each cell of the table contains a number, 0 or 1. In one move we can choose some row of the table and cyclically shift its values either one cell to the left, or one cell to the right... | instruction | 0 | 92,034 | 15 | 184,068 |
Tags: brute force, two pointers
Correct Solution:
```
n, m = map(int, input().split())
f = [[int(1e9) for j in range(m)] for i in range(n)]
for i in range(n):
s = input()
if s.find('1') == -1:
print(-1)
exit()
f[i][0] = s[::-1].find('1') + 1
f[i][m - 1] = s.find('1') + 1
for j in range(m):
f[i][j] = 0 if s[j... | output | 1 | 92,034 | 15 | 184,069 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a table consisting of n rows and m columns. Each cell of the table contains a number, 0 or 1. In one move we can choose some row of the table and cyclically shift its values either one cell to the left, or one cell to the right... | instruction | 0 | 92,035 | 15 | 184,070 |
Tags: brute force, two pointers
Correct Solution:
```
def binS(a, x, n):
l, r = -1, n
while(l + 1 < r):
m = (l + r)//2
if(a[m] >= x):
r = m
else:
l = m
return min(abs(a[r] - x), abs(a[r - 1] - x))
def main():
n, m = [int(i) for i in input().split()]
q ... | output | 1 | 92,035 | 15 | 184,071 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a table consisting of n rows and m columns. Each cell of the table contains a number, 0 or 1. In one move we can choose some row of the table and cyclically shift its values either one cell to the left, or one cell to the right... | instruction | 0 | 92,036 | 15 | 184,072 |
Tags: brute force, two pointers
Correct Solution:
```
'''
Auther: ghoshashis545 Ashis Ghosh
College: jalpaiguri Govt Enggineering College
'''
from os import path
import sys
from heapq import heappush,heappop
from functools import cmp_to_key as ctk
from collections import deque,defaultdict as dd
from bisect im... | output | 1 | 92,036 | 15 | 184,073 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a table consisting of n rows and m columns. Each cell of the table contains a number, 0 or 1. In one move we can choose some row of the table and cyclically shift its values either one cell to the left, or one cell to the right... | instruction | 0 | 92,037 | 15 | 184,074 |
Tags: brute force, two pointers
Correct Solution:
```
def calc_shift_cost(row):
starts = [i for i, x in enumerate(row) if x]
for start in starts:
d = 2
pos = start + 1
if pos == len(row):
pos = 0
while row[pos] != 1:
if row[pos]:
row[pos] =... | output | 1 | 92,037 | 15 | 184,075 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a table consisting of n rows and m columns. Each cell of the table contains a number, 0 or 1. In one move we can choose some row of the table and cyclically shift its values either one cell to the left, or one cell to the right... | instruction | 0 | 92,038 | 15 | 184,076 |
Tags: brute force, two pointers
Correct Solution:
```
x=int(input().split(' ')[0])
y=[]
for i in range(x):
y.append(input())
for x in y:
if '1' not in x:
print("-1")
exit()
# y=['101010','000100','100000']
# y=['1011','1100','0010','0001']
# yy=[ (s.index('1'),s.rindex('1')) for s in y ]
# l=len(y[0])
#######... | output | 1 | 92,038 | 15 | 184,077 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a table consisting of n rows and m columns. Each cell of the table contains a number, 0 or 1. In one move we can choose some row of the table and cyclically shift its values either one cell to the left, or one cell to the right... | instruction | 0 | 92,039 | 15 | 184,078 |
Tags: brute force, two pointers
Correct Solution:
```
import sys
n, m = map(int, input().split())
mp = ['' for i in range(n)]
f = [[0 for j in range(m)] for i in range(n)]
for i in range(n):
mp[i] = input()
if mp[i].find('1') == -1:
print(-1)
sys.exit()
tmp = mp[i][::-1].find('1') + 1
for j in range(m):
if mp... | output | 1 | 92,039 | 15 | 184,079 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a table consisting of n rows and m columns. Each cell of the table contains a number, 0 or 1. In one move we can choose some row of the table and cyclically shift its values either one cell to the left, or one cell to the right... | instruction | 0 | 92,040 | 15 | 184,080 |
Tags: brute force, two pointers
Correct Solution:
```
"""
Author - Satwik Tiwari .
20th Oct , 2020 - Tuesday
"""
#===============================================================================================
#importing some useful libraries.
from __future__ import division, print_function
from fractions i... | output | 1 | 92,040 | 15 | 184,081 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.