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. Vivek has encountered a problem. He has a maze that can be represented as an n × m grid. Each of the grid cells may represent the following: * Empty — '.' * Wall — '#' * Good person — 'G' * Bad person — 'B' The only escape fr...
instruction
0
98,797
15
197,594
Tags: constructive algorithms, dfs and similar, dsu, graphs, greedy, implementation, shortest paths Correct Solution: ``` directions = [(0, 1), (1, 0), (-1, 0), (0, -1)] def solve(matrix, n,m): for i in range(n): for j in range(m): if matrix[i][j] == 'B': for di, dj in direction...
output
1
98,797
15
197,595
Provide tags and a correct Python 2 solution for this coding contest problem. Vivek has encountered a problem. He has a maze that can be represented as an n × m grid. Each of the grid cells may represent the following: * Empty — '.' * Wall — '#' * Good person — 'G' * Bad person — 'B' The only escape fr...
instruction
0
98,798
15
197,596
Tags: constructive algorithms, dfs and similar, dsu, graphs, greedy, implementation, shortest paths Correct Solution: ``` from sys import stdin, stdout from collections import Counter, defaultdict from itertools import permutations, combinations from fractions import gcd import heapq raw_input = stdin.readline pr = std...
output
1
98,798
15
197,597
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vivek has encountered a problem. He has a maze that can be represented as an n × m grid. Each of the grid cells may represent the following: * Empty — '.' * Wall — '#' * Good person — '...
instruction
0
98,799
15
197,598
Yes
output
1
98,799
15
197,599
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vivek has encountered a problem. He has a maze that can be represented as an n × m grid. Each of the grid cells may represent the following: * Empty — '.' * Wall — '#' * Good person — '...
instruction
0
98,800
15
197,600
Yes
output
1
98,800
15
197,601
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vivek has encountered a problem. He has a maze that can be represented as an n × m grid. Each of the grid cells may represent the following: * Empty — '.' * Wall — '#' * Good person — '...
instruction
0
98,801
15
197,602
Yes
output
1
98,801
15
197,603
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vivek has encountered a problem. He has a maze that can be represented as an n × m grid. Each of the grid cells may represent the following: * Empty — '.' * Wall — '#' * Good person — '...
instruction
0
98,802
15
197,604
Yes
output
1
98,802
15
197,605
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vivek has encountered a problem. He has a maze that can be represented as an n × m grid. Each of the grid cells may represent the following: * Empty — '.' * Wall — '#' * Good person — '...
instruction
0
98,803
15
197,606
No
output
1
98,803
15
197,607
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vivek has encountered a problem. He has a maze that can be represented as an n × m grid. Each of the grid cells may represent the following: * Empty — '.' * Wall — '#' * Good person — '...
instruction
0
98,804
15
197,608
No
output
1
98,804
15
197,609
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vivek has encountered a problem. He has a maze that can be represented as an n × m grid. Each of the grid cells may represent the following: * Empty — '.' * Wall — '#' * Good person — '...
instruction
0
98,805
15
197,610
No
output
1
98,805
15
197,611
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vivek has encountered a problem. He has a maze that can be represented as an n × m grid. Each of the grid cells may represent the following: * Empty — '.' * Wall — '#' * Good person — '...
instruction
0
98,806
15
197,612
No
output
1
98,806
15
197,613
Evaluate the correctness of the submitted Python 2 solution to the coding contest problem. Provide a "Yes" or "No" response. Vivek has encountered a problem. He has a maze that can be represented as an n × m grid. Each of the grid cells may represent the following: * Empty — '.' * Wall — '#' * Good person — '...
instruction
0
98,807
15
197,614
No
output
1
98,807
15
197,615
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Ostap Bender recently visited frog farm and was inspired to create his own frog game. Number of frogs are places on a cyclic gameboard, divided into m cells. Cells are numbered from 1 to m, but...
instruction
0
99,083
15
198,166
No
output
1
99,083
15
198,167
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Ostap Bender recently visited frog farm and was inspired to create his own frog game. Number of frogs are places on a cyclic gameboard, divided into m cells. Cells are numbered from 1 to m, but...
instruction
0
99,084
15
198,168
No
output
1
99,084
15
198,169
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Ostap Bender recently visited frog farm and was inspired to create his own frog game. Number of frogs are places on a cyclic gameboard, divided into m cells. Cells are numbered from 1 to m, but...
instruction
0
99,085
15
198,170
No
output
1
99,085
15
198,171
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Ostap Bender recently visited frog farm and was inspired to create his own frog game. Number of frogs are places on a cyclic gameboard, divided into m cells. Cells are numbered from 1 to m, but...
instruction
0
99,086
15
198,172
No
output
1
99,086
15
198,173
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a description of a depot. It is a rectangular checkered field of n × m size. Each cell in a field can be empty (".") or it can be occupied by a wall ("*"). You have one bomb. If you lay the bomb at the cell (x, y), then after...
instruction
0
99,103
15
198,206
Tags: implementation Correct Solution: ``` n, m = tuple(map(int, input().split())) rows = {} cols = {} walls = 0 for i in range(n): line = input() for j in range(m): if line[j] == '*': walls += 1 if i in rows: rows[i].append(j) else: rows[i] = [j] if j in cols: cols[j].append(i) else: ...
output
1
99,103
15
198,207
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a description of a depot. It is a rectangular checkered field of n × m size. Each cell in a field can be empty (".") or it can be occupied by a wall ("*"). You have one bomb. If you lay the bomb at the cell (x, y), then after...
instruction
0
99,104
15
198,208
Tags: implementation Correct Solution: ``` """ Code of Ayush Tiwari Codechef: ayush572000 Codeforces: servermonk """ # import sys # input = sys.stdin.buffer.readline def solution(): n,m=map(int,input().split()) l=[] r=[0]*1001 c=[0]*1001 cnt=0 for i in range(n): x=list(input()) ...
output
1
99,104
15
198,209
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a description of a depot. It is a rectangular checkered field of n × m size. Each cell in a field can be empty (".") or it can be occupied by a wall ("*"). You have one bomb. If you lay the bomb at the cell (x, y), then after...
instruction
0
99,105
15
198,210
Tags: implementation Correct Solution: ``` import sys;input = sys.stdin.readline;print = sys.stdout.write def main(): n, m = map(int, input().split()) arr, have, dpx, dpy, cnt = [0]*n, set(), [0]*n, [0]*m, 0 for i in range(n): arr[i] = input().rstrip() for j in range(m): if arr...
output
1
99,105
15
198,211
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a description of a depot. It is a rectangular checkered field of n × m size. Each cell in a field can be empty (".") or it can be occupied by a wall ("*"). You have one bomb. If you lay the bomb at the cell (x, y), then after...
instruction
0
99,106
15
198,212
Tags: implementation Correct Solution: ``` n,m=[int(x) for x in input().split()] depot=[] r=[] c=[] flag=True for i in range(n): row=input() r.append(row.count('*')) depot.append(row) for j in range(m): column=''.join([x[j] for x in depot]) c.append(column.count('*')) wall=sum(r) for i in range(n): ...
output
1
99,106
15
198,213
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a description of a depot. It is a rectangular checkered field of n × m size. Each cell in a field can be empty (".") or it can be occupied by a wall ("*"). You have one bomb. If you lay the bomb at the cell (x, y), then after...
instruction
0
99,107
15
198,214
Tags: implementation Correct Solution: ``` def bombs(array, rows, cols, walls, wallsInRows, wallsInCols): if walls == 0: print("YES") print(1, 1) return for i in range(0, rows): for j in range(0, cols): s = wallsInRows[i] + wallsInCols[j] if (array[i][j] =...
output
1
99,107
15
198,215
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a description of a depot. It is a rectangular checkered field of n × m size. Each cell in a field can be empty (".") or it can be occupied by a wall ("*"). You have one bomb. If you lay the bomb at the cell (x, y), then after...
instruction
0
99,108
15
198,216
Tags: implementation Correct Solution: ``` n, m = map(int, input().split()) a = [input() for i in range(n)] x = [0] * n y = [0] * m cnt = 0 for i in range(n): for j in range(m): if a[i][j] == '*': x[i] += 1 y[j] += 1 cnt += 1 for i in range(n): for j in range(m): ...
output
1
99,108
15
198,217
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a description of a depot. It is a rectangular checkered field of n × m size. Each cell in a field can be empty (".") or it can be occupied by a wall ("*"). You have one bomb. If you lay the bomb at the cell (x, y), then after...
instruction
0
99,109
15
198,218
Tags: implementation Correct Solution: ``` #!/usr/bin/env python # -*- coding: utf-8 -*- import sys from collections import Counter numrow, numcol = sys.stdin.readline().split(' ') numrow = int(numrow) numcol = int(numcol) #line = sys.stdin.readline() # stores the row and col indices of each * symbol row_index = [] ...
output
1
99,109
15
198,219
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a description of a depot. It is a rectangular checkered field of n × m size. Each cell in a field can be empty (".") or it can be occupied by a wall ("*"). You have one bomb. If you lay the bomb at the cell (x, y), then after...
instruction
0
99,110
15
198,220
Tags: implementation Correct Solution: ``` ##n = int(input()) ##a = list(map(int, input().split())) ##print(" ".join(map(str, res))) [n, m] = list(map(int, input().split())) s = [] for i in range(n): s.append(input()) r = [] c = [] tot = 0 for x in range(n): cnt = 0 for y in range(m): if s[x][y] =...
output
1
99,110
15
198,221
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a description of a depot. It is a rectangular checkered field of n × m size. Each cell in a field can be empty (".") or it can be occupied by a wall ("*"). You have one bomb. If ...
instruction
0
99,111
15
198,222
Yes
output
1
99,111
15
198,223
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a description of a depot. It is a rectangular checkered field of n × m size. Each cell in a field can be empty (".") or it can be occupied by a wall ("*"). You have one bomb. If ...
instruction
0
99,112
15
198,224
Yes
output
1
99,112
15
198,225
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a description of a depot. It is a rectangular checkered field of n × m size. Each cell in a field can be empty (".") or it can be occupied by a wall ("*"). You have one bomb. If ...
instruction
0
99,113
15
198,226
Yes
output
1
99,113
15
198,227
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a description of a depot. It is a rectangular checkered field of n × m size. Each cell in a field can be empty (".") or it can be occupied by a wall ("*"). You have one bomb. If ...
instruction
0
99,114
15
198,228
Yes
output
1
99,114
15
198,229
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a description of a depot. It is a rectangular checkered field of n × m size. Each cell in a field can be empty (".") or it can be occupied by a wall ("*"). You have one bomb. If ...
instruction
0
99,115
15
198,230
No
output
1
99,115
15
198,231
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a description of a depot. It is a rectangular checkered field of n × m size. Each cell in a field can be empty (".") or it can be occupied by a wall ("*"). You have one bomb. If ...
instruction
0
99,116
15
198,232
No
output
1
99,116
15
198,233
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a description of a depot. It is a rectangular checkered field of n × m size. Each cell in a field can be empty (".") or it can be occupied by a wall ("*"). You have one bomb. If ...
instruction
0
99,117
15
198,234
No
output
1
99,117
15
198,235
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a description of a depot. It is a rectangular checkered field of n × m size. Each cell in a field can be empty (".") or it can be occupied by a wall ("*"). You have one bomb. If ...
instruction
0
99,118
15
198,236
No
output
1
99,118
15
198,237
Provide a correct Python 3 solution for this coding contest problem. Takahashi has a maze, which is a grid of H \times W squares with H horizontal rows and W vertical columns. The square at the i-th row from the top and the j-th column is a "wall" square if S_{ij} is `#`, and a "road" square if S_{ij} is `.`. From a...
instruction
0
99,277
15
198,554
"Correct Solution: ``` h,w=map(int,input().split()) g=[[*input()] for _ in range(h)] from collections import * a=0 for sx in range(h): for sy in range(w): if g[sx][sy]=='#': continue d=[[-1]*w for _ in range(h)] d[sx][sy]=0 q=deque([(sx,sy)]) while q: x,y=q.popleft() t=d[x][y]+1 ...
output
1
99,277
15
198,555
Provide a correct Python 3 solution for this coding contest problem. Takahashi has a maze, which is a grid of H \times W squares with H horizontal rows and W vertical columns. The square at the i-th row from the top and the j-th column is a "wall" square if S_{ij} is `#`, and a "road" square if S_{ij} is `.`. From a...
instruction
0
99,278
15
198,556
"Correct Solution: ``` from collections import deque h,w=map(int,input().split()) S=[input() for _ in range(h)] ans=0 inf=float("inf") for i in range(h): for j in range(w): if S[i][j]!="#": dp=[[inf for _ in range(w)]for _ in range(h)] dp[i][j]=0 que=deque([(i,j)]) while que...
output
1
99,278
15
198,557
Provide a correct Python 3 solution for this coding contest problem. Takahashi has a maze, which is a grid of H \times W squares with H horizontal rows and W vertical columns. The square at the i-th row from the top and the j-th column is a "wall" square if S_{ij} is `#`, and a "road" square if S_{ij} is `.`. From a...
instruction
0
99,279
15
198,558
"Correct Solution: ``` # D - Maze Master from collections import deque def bfs(start: int): queue = deque([start]) dist = {start: 0} while queue: x = queue.popleft() for nx in (x + 1, x - 1, x + W, x - W): if maze[nx] == "." and nx not in dist: dist[nx] = dist[x...
output
1
99,279
15
198,559
Provide a correct Python 3 solution for this coding contest problem. Takahashi has a maze, which is a grid of H \times W squares with H horizontal rows and W vertical columns. The square at the i-th row from the top and the j-th column is a "wall" square if S_{ij} is `#`, and a "road" square if S_{ij} is `.`. From a...
instruction
0
99,280
15
198,560
"Correct Solution: ``` from collections import deque h, w = map(int, input().split()) a = ''.join(input() + '#' for _ in range(h)) n = len(a) b = ['#'] * w r = 0 for i in range(n): if a[i] == '.': b[:-w] = a b[i] = 0 q = deque([i]) while(q): i = q.popleft() r = max(r, b[i]) for j i...
output
1
99,280
15
198,561
Provide a correct Python 3 solution for this coding contest problem. Takahashi has a maze, which is a grid of H \times W squares with H horizontal rows and W vertical columns. The square at the i-th row from the top and the j-th column is a "wall" square if S_{ij} is `#`, and a "road" square if S_{ij} is `.`. From a...
instruction
0
99,281
15
198,562
"Correct Solution: ``` H,W = map(int,input().split()) S = [None]*W S = [list(input()) for i in range(H)] dx = [1,-1,0,0] dy = [0,0,1,-1] def max_distance(i,j): not_visit = [[-1]*W for i in range(H)] not_visit[i][j] = 0 stack = [(i,j)] while stack != []: y,x = stack.pop(0) for i in ran...
output
1
99,281
15
198,563
Provide a correct Python 3 solution for this coding contest problem. Takahashi has a maze, which is a grid of H \times W squares with H horizontal rows and W vertical columns. The square at the i-th row from the top and the j-th column is a "wall" square if S_{ij} is `#`, and a "road" square if S_{ij} is `.`. From a...
instruction
0
99,282
15
198,564
"Correct Solution: ``` h, w = map(int, input().split()) s = [input() for _ in range(h)] def bfs(x, y): q = [] dp = {} def qpush(x, y, t): if 0 <= x < w and 0 <= y < h and s[y][x] != '#' and (x, y) not in dp: q.append((x, y)) dp[(x, y)] = t qpush(x, y, 0) while len(q...
output
1
99,282
15
198,565
Provide a correct Python 3 solution for this coding contest problem. Takahashi has a maze, which is a grid of H \times W squares with H horizontal rows and W vertical columns. The square at the i-th row from the top and the j-th column is a "wall" square if S_{ij} is `#`, and a "road" square if S_{ij} is `.`. From a...
instruction
0
99,283
15
198,566
"Correct Solution: ``` from collections import deque h,w = map(int,input().split()) s = [input() for _ in range(h)] ans=0 for i in range(h): for j in range(w): if s[i][j] =='#': continue visited=[[-1]*w for _ in range(h)] visited[i][j] = 0 cnt=0 q = deque([[i,j]]) while q: x,y = q....
output
1
99,283
15
198,567
Provide a correct Python 3 solution for this coding contest problem. Takahashi has a maze, which is a grid of H \times W squares with H horizontal rows and W vertical columns. The square at the i-th row from the top and the j-th column is a "wall" square if S_{ij} is `#`, and a "road" square if S_{ij} is `.`. From a...
instruction
0
99,284
15
198,568
"Correct Solution: ``` from collections import deque d = [(-1,0),(1,0),(0,1),(0,-1)] def bfs(y,x,c): q = deque() q.append((y,x,c)) ma = 0 visit[y][x] = 1 while q: y,x,c = q.popleft() ma = max(ma,c) for dy,dx in d: if 0<=y+dy<h and 0<=x+dx<w: if a...
output
1
99,284
15
198,569
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi has a maze, which is a grid of H \times W squares with H horizontal rows and W vertical columns. The square at the i-th row from the top and the j-th column is a "wall" square if S_{i...
instruction
0
99,285
15
198,570
Yes
output
1
99,285
15
198,571
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi has a maze, which is a grid of H \times W squares with H horizontal rows and W vertical columns. The square at the i-th row from the top and the j-th column is a "wall" square if S_{i...
instruction
0
99,286
15
198,572
Yes
output
1
99,286
15
198,573
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi has a maze, which is a grid of H \times W squares with H horizontal rows and W vertical columns. The square at the i-th row from the top and the j-th column is a "wall" square if S_{i...
instruction
0
99,287
15
198,574
Yes
output
1
99,287
15
198,575
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi has a maze, which is a grid of H \times W squares with H horizontal rows and W vertical columns. The square at the i-th row from the top and the j-th column is a "wall" square if S_{i...
instruction
0
99,288
15
198,576
Yes
output
1
99,288
15
198,577
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi has a maze, which is a grid of H \times W squares with H horizontal rows and W vertical columns. The square at the i-th row from the top and the j-th column is a "wall" square if S_{i...
instruction
0
99,289
15
198,578
No
output
1
99,289
15
198,579
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi has a maze, which is a grid of H \times W squares with H horizontal rows and W vertical columns. The square at the i-th row from the top and the j-th column is a "wall" square if S_{i...
instruction
0
99,290
15
198,580
No
output
1
99,290
15
198,581
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi has a maze, which is a grid of H \times W squares with H horizontal rows and W vertical columns. The square at the i-th row from the top and the j-th column is a "wall" square if S_{i...
instruction
0
99,291
15
198,582
No
output
1
99,291
15
198,583
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi has a maze, which is a grid of H \times W squares with H horizontal rows and W vertical columns. The square at the i-th row from the top and the j-th column is a "wall" square if S_{i...
instruction
0
99,292
15
198,584
No
output
1
99,292
15
198,585
Provide tags and a correct Python 3 solution for this coding contest problem. The Cybernetics Failures (CF) organisation made a prototype of a bomb technician robot. To find the possible problems it was decided to carry out a series of tests. At the beginning of each test the robot prototype will be placed in cell (x0...
instruction
0
99,845
15
199,690
Tags: implementation Correct Solution: ``` x, y, x0, y0 = map(int, input().split()) moves = input() seen = [[False] * y for i in range(x)] currX, currY = x0 - 1, y0 - 1 total = 0 for i in range(len(moves)): #print(currX, currY) #print("Seen:", seen[currX][currY]) #print() if not seen[currX][currY]: ...
output
1
99,845
15
199,691
Provide tags and a correct Python 3 solution for this coding contest problem. The Cybernetics Failures (CF) organisation made a prototype of a bomb technician robot. To find the possible problems it was decided to carry out a series of tests. At the beginning of each test the robot prototype will be placed in cell (x0...
instruction
0
99,846
15
199,692
Tags: implementation Correct Solution: ``` x, y, x0, y0 = map(int, input().split()) s = input() z = set() k = (len(s)+1)*[0] k[0] = 1 u = 0 z.add((x0, y0)) for i in s: u += 1 if i == 'U' and x0 > 1: x0 -= 1 elif i == 'D' and x0 < x: x0 += 1 elif i == 'L' and y0 > 1: y0 -= 1 e...
output
1
99,846
15
199,693
Provide tags and a correct Python 3 solution for this coding contest problem. The Cybernetics Failures (CF) organisation made a prototype of a bomb technician robot. To find the possible problems it was decided to carry out a series of tests. At the beginning of each test the robot prototype will be placed in cell (x0...
instruction
0
99,847
15
199,694
Tags: implementation Correct Solution: ``` x,y,x0,y0=map(int,input().split()) s1=input() r=x*y res="1 " k=1 a = [[0] * y for i in range(x)] a[x0-1][y0-1]=1 for i in range(len(s1)-1): if s1[i]=="U": if x0-1>=1 and k<r: x0=x0-1 if a[x0-1][y0-1]==0: res=res+"1 " ...
output
1
99,847
15
199,695