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
107,291
15
214,582
Tags: constructive algorithms, data structures, implementation, two pointers Correct Solution: ``` st = input() a = [] b = [] for i in range(len(st)): if st[i] == 'r': a.append(i+1) else: b.append(i+1) c = a+b[::-1] for i in c: print(i) ```
output
1
107,291
15
214,583
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
107,292
15
214,584
Tags: constructive algorithms, data structures, implementation, two pointers Correct Solution: ``` s=input() r=[] l=[] num=1 for i in s: if i=='r': r.append(num) elif i=='l': l.append(num) num+=1 res=r+l[::-1] for i in res: print(i) ```
output
1
107,292
15
214,585
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
107,293
15
214,586
Tags: constructive algorithms, data structures, implementation, two pointers Correct Solution: ``` from collections import * s, right, left = input(), deque(), deque() for i in range(len(s)): if s[i] == 'l': left.appendleft(str(i + 1)) else: right.append(str(i + 1)) print('\n'.join(right)) pr...
output
1
107,293
15
214,587
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
107,294
15
214,588
Tags: constructive algorithms, data structures, implementation, two pointers Correct Solution: ``` #------------------------template--------------------------# import os import sys from math import * from collections import * # from fractions import * # from heapq import* from bisect import * from io import BytesIO, IO...
output
1
107,294
15
214,589
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
107,295
15
214,590
Tags: constructive algorithms, data structures, implementation, two pointers Correct Solution: ``` # Key: the nth 'l' marks the nth stone from the right directions = input() r_stones = [] l_stones = [] stone = 1 for i in directions: if i == 'r': r_stones.append(stone) if i == 'l': l_stones.ap...
output
1
107,295
15
214,591
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
107,296
15
214,592
Tags: constructive algorithms, data structures, implementation, two pointers Correct Solution: ``` __autor__ = 'Alex239' s = input().rstrip() print("\n".join([str(i + 1) for i in range(len(s)) if s[i] == 'r']), "\n".join([str(i + 1) for i in range(len(s) - 1, -1, -1) if s[i] == 'l']), sep="\n") ```
output
1
107,296
15
214,593
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
107,297
15
214,594
Tags: constructive algorithms, data structures, implementation, two pointers Correct Solution: ``` s=input() l=[] r=[] for i in range(len(s)): if s[i]=='l': l.append(i+1) else: r.append(i+1) for i in r: print(i) for i in reversed(l): print(i) ```
output
1
107,297
15
214,595
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
107,298
15
214,596
Tags: constructive algorithms, data structures, implementation, two pointers Correct Solution: ``` # JAI SHREE RAM import math; from collections import * import sys; from functools import reduce # sys.setrecursionlimit(10**6) def get_ints(): return map(int, input().strip().split()) def get_li...
output
1
107,298
15
214,597
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
107,299
15
214,598
Yes
output
1
107,299
15
214,599
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
107,300
15
214,600
Yes
output
1
107,300
15
214,601
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
107,301
15
214,602
Yes
output
1
107,301
15
214,603
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
107,302
15
214,604
No
output
1
107,302
15
214,605
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
107,303
15
214,606
No
output
1
107,303
15
214,607
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
107,304
15
214,608
No
output
1
107,304
15
214,609
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
107,305
15
214,610
No
output
1
107,305
15
214,611
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Consider infinite grid of unit cells. Some of those cells are planets. Meta-universe M = {p1, p2, ..., pk} is a set of planets. Suppose there is an infinite row or column with following two pr...
instruction
0
107,341
15
214,682
No
output
1
107,341
15
214,683
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Consider infinite grid of unit cells. Some of those cells are planets. Meta-universe M = {p1, p2, ..., pk} is a set of planets. Suppose there is an infinite row or column with following two pr...
instruction
0
107,342
15
214,684
No
output
1
107,342
15
214,685
Provide tags and a correct Python 3 solution for this coding contest problem. Allen dreams of one day owning a enormous fleet of electric cars, the car of the future! He knows that this will give him a big status boost. As Allen is planning out all of the different types of cars he will own and how he will arrange the...
instruction
0
107,606
15
215,212
Tags: constructive algorithms, implementation Correct Solution: ``` from sys import exit n, k = map(int, input().split()) a = [list(map(int, input().split())) for q in range(4)] d = [[-1, 0], [0, 1], [1, 0], [0, -1]] x = y = -1 ans = [] def move(k): global x, y, a x += d[k][0] y += d[k][1] if a[x][y]:...
output
1
107,606
15
215,213
Provide tags and a correct Python 3 solution for this coding contest problem. Allen dreams of one day owning a enormous fleet of electric cars, the car of the future! He knows that this will give him a big status boost. As Allen is planning out all of the different types of cars he will own and how he will arrange the...
instruction
0
107,607
15
215,214
Tags: constructive algorithms, implementation Correct Solution: ``` def main(): n, k = map(int, input().split()) a, b, c, d = (list(map(int, input().split())) for _ in 'abcd') ss, tt, n2, res = [*b, *c[::-1]], [*a, *d[::-1]], n * 2, [] yx = [*[(2, i + 1) for i in range(n)], *[(3, i) for i in range(n, 0,...
output
1
107,607
15
215,215
Provide tags and a correct Python 3 solution for this coding contest problem. Allen dreams of one day owning a enormous fleet of electric cars, the car of the future! He knows that this will give him a big status boost. As Allen is planning out all of the different types of cars he will own and how he will arrange the...
instruction
0
107,608
15
215,216
Tags: constructive algorithms, implementation Correct Solution: ``` k, n = [int(x) for x in input().split()] a = [] for i in range(4): a.append([int(x) - 1 for x in input().split()]) pos = [] for i in range(k): pos.append([1, i]) for i in range(k): pos.append([2, k - i - 1]) lft = n ans = [] for i in range(2 * k...
output
1
107,608
15
215,217
Provide tags and a correct Python 3 solution for this coding contest problem. Allen dreams of one day owning a enormous fleet of electric cars, the car of the future! He knows that this will give him a big status boost. As Allen is planning out all of the different types of cars he will own and how he will arrange the...
instruction
0
107,609
15
215,218
Tags: constructive algorithms, implementation Correct Solution: ``` def all_parked(parked): result = True for p in parked: result = result and p return result class CodeforcesTask995ASolution: def __init__(self): self.result = '' self.n_k = [] self.parking = [] def...
output
1
107,609
15
215,219
Provide tags and a correct Python 3 solution for this coding contest problem. Allen dreams of one day owning a enormous fleet of electric cars, the car of the future! He knows that this will give him a big status boost. As Allen is planning out all of the different types of cars he will own and how he will arrange the...
instruction
0
107,610
15
215,220
Tags: constructive algorithms, implementation Correct Solution: ``` n, k = map(int, input().split()) m = [] for _ in range(4): m.extend(list(map(int, input().split()))) moves = [] ans = 0 zeros = 0 d = {1: 1, 2: 4} def park(): #print("\n parking \n") global ans, moves, m, zeros zeros = 0 for i i...
output
1
107,610
15
215,221
Provide tags and a correct Python 3 solution for this coding contest problem. Allen dreams of one day owning a enormous fleet of electric cars, the car of the future! He knows that this will give him a big status boost. As Allen is planning out all of the different types of cars he will own and how he will arrange the...
instruction
0
107,611
15
215,222
Tags: constructive algorithms, implementation Correct Solution: ``` all_the_moves = [] parked = 0 n, k = map(int, input().split()) park = [] park += [[int(x) for x in input().split()]] park += [[int(x) for x in input().split()]] park += [[int(x) for x in input().split()]] park += [[int(x) for x in input().split()]]...
output
1
107,611
15
215,223
Provide tags and a correct Python 3 solution for this coding contest problem. Allen dreams of one day owning a enormous fleet of electric cars, the car of the future! He knows that this will give him a big status boost. As Allen is planning out all of the different types of cars he will own and how he will arrange the...
instruction
0
107,612
15
215,224
Tags: constructive algorithms, implementation Correct Solution: ``` if __name__ == '__main__': numbers = list(map(int, input().split())) n = numbers[0] k = numbers[1] left = 0 left = k table = [] x = 4 while x > 0: table.append(list(map(int, input().split()))) x = x -1 ...
output
1
107,612
15
215,225
Provide tags and a correct Python 3 solution for this coding contest problem. Allen dreams of one day owning a enormous fleet of electric cars, the car of the future! He knows that this will give him a big status boost. As Allen is planning out all of the different types of cars he will own and how he will arrange the...
instruction
0
107,613
15
215,226
Tags: constructive algorithms, implementation Correct Solution: ``` import os,sys n,k = list(map(int, input().split())) p0 = list(map(int, input().split())) b0 = list(map(int, input().split())) b1 = list(map(int, input().split())) p1 = list(map(int, input().split())) ops = [] for i in range(n): if p0[i] == 0: p0...
output
1
107,613
15
215,227
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. On a large chess board, there are N ants, each numbered from 1 to N. As shown in the figure, the chess board is a rectangle consisting of H Γ— W squares, with the northwest corner as white, and w...
instruction
0
107,800
15
215,600
No
output
1
107,800
15
215,601
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. On a large chess board, there are N ants, each numbered from 1 to N. As shown in the figure, the chess board is a rectangle consisting of H Γ— W squares, with the northwest corner as white, and w...
instruction
0
107,801
15
215,602
No
output
1
107,801
15
215,603
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. On a large chess board, there are N ants, each numbered from 1 to N. As shown in the figure, the chess board is a rectangle consisting of H Γ— W squares, with the northwest corner as white, and w...
instruction
0
107,802
15
215,604
No
output
1
107,802
15
215,605
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. On a large chess board, there are N ants, each numbered from 1 to N. As shown in the figure, the chess board is a rectangle consisting of H Γ— W squares, with the northwest corner as white, and w...
instruction
0
107,803
15
215,606
No
output
1
107,803
15
215,607
Provide tags and a correct Python 3 solution for this coding contest problem. This is an interactive problem. Bob lives in a square grid of size n Γ— n, with rows numbered 1 through n from top to bottom, and columns numbered 1 through n from left to right. Every cell is either allowed or blocked, but you don't know th...
instruction
0
107,858
15
215,716
Tags: constructive algorithms, interactive, matrices Correct Solution: ``` import sys def pos(x1,y1,x2,y2): print('?',y1,x1,y2,x2) sys.stdout.flush() ans=input() if(ans=='YES'): return True else: return False n=int(input()) curx=n cury=n s='' while(curx+cury>n+1): if(p...
output
1
107,858
15
215,717
Provide tags and a correct Python 3 solution for this coding contest problem. This is an interactive problem. Bob lives in a square grid of size n Γ— n, with rows numbered 1 through n from top to bottom, and columns numbered 1 through n from left to right. Every cell is either allowed or blocked, but you don't know th...
instruction
0
107,859
15
215,718
Tags: constructive algorithms, interactive, matrices Correct Solution: ``` from sys import stdout n = int(input()) x0 = 1 y0 = 1 x1 = n y1 = n ans = "" leftans = "" for i in range(n - 1): print("?", x0 + 1, y0, x1, y1) stdout.flush() tmp = input() if tmp == "YES": x0 += 1 ans += "D" ...
output
1
107,859
15
215,719
Provide tags and a correct Python 3 solution for this coding contest problem. This is an interactive problem. Bob lives in a square grid of size n Γ— n, with rows numbered 1 through n from top to bottom, and columns numbered 1 through n from left to right. Every cell is either allowed or blocked, but you don't know th...
instruction
0
107,860
15
215,720
Tags: constructive algorithms, interactive, matrices Correct Solution: ``` #!/usr/bin/python import sys import subprocess def check(a, b, x, y): if y == -1 or b == -1: return True if b < x: return True if a > y: return True if (a < x) and (b > y): return True return F...
output
1
107,860
15
215,721
Provide tags and a correct Python 3 solution for this coding contest problem. This is an interactive problem. Bob lives in a square grid of size n Γ— n, with rows numbered 1 through n from top to bottom, and columns numbered 1 through n from left to right. Every cell is either allowed or blocked, but you don't know th...
instruction
0
107,861
15
215,722
Tags: constructive algorithms, interactive, matrices Correct Solution: ``` from sys import stdout n = int(input()) def query(r1,c1,r2,c2): print("?"+" " + str(r1) + " "+str(c1) +" "+str(r2) +" "+str(c2)) stdout.flush() ans = input() if ans == "YES": return True else: return False ro...
output
1
107,861
15
215,723
Provide tags and a correct Python 3 solution for this coding contest problem. This is an interactive problem. Bob lives in a square grid of size n Γ— n, with rows numbered 1 through n from top to bottom, and columns numbered 1 through n from left to right. Every cell is either allowed or blocked, but you don't know th...
instruction
0
107,862
15
215,724
Tags: constructive algorithms, interactive, matrices Correct Solution: ``` #import sys; sys.stdin = open('input.txt') def cin(obj=list, type=int, sep=' '): return obj(map(type, input().split(sep))) n, = cin() from sys import stdout def query(*args): print('?', *args) stdout.flush() ans = input() ...
output
1
107,862
15
215,725
Provide tags and a correct Python 3 solution for this coding contest problem. This is an interactive problem. Bob lives in a square grid of size n Γ— n, with rows numbered 1 through n from top to bottom, and columns numbered 1 through n from left to right. Every cell is either allowed or blocked, but you don't know th...
instruction
0
107,863
15
215,726
Tags: constructive algorithms, interactive, matrices Correct Solution: ``` from sys import stdout n=int(input()) x=1 y=1 s='! ' s2='' for i in range (n-1): print('? '+str(x+1)+' '+str(y)+' '+str(n)+' '+str(n)) stdout.flush() b=input() if b=='YES': s=s+'D' x+=1 else: s=s+'R' ...
output
1
107,863
15
215,727
Provide tags and a correct Python 3 solution for this coding contest problem. This is an interactive problem. Bob lives in a square grid of size n Γ— n, with rows numbered 1 through n from top to bottom, and columns numbered 1 through n from left to right. Every cell is either allowed or blocked, but you don't know th...
instruction
0
107,864
15
215,728
Tags: constructive algorithms, interactive, matrices Correct Solution: ``` import sys f=sys.stdin out=sys.stdout n=int(f.readline().rstrip('\r\n')) curr=[n,n] s="" y=float('inf') for i in range(n-1): q1=[curr[0]-1,curr[1]] q2=[curr[0],curr[1]-1] if q1[0]>0 and q1[1]>0: out.write("? 1 1 "+str(q1[0])+" "+str(q1[1]...
output
1
107,864
15
215,729
Provide tags and a correct Python 3 solution for this coding contest problem. This is an interactive problem. Bob lives in a square grid of size n Γ— n, with rows numbered 1 through n from top to bottom, and columns numbered 1 through n from left to right. Every cell is either allowed or blocked, but you don't know th...
instruction
0
107,865
15
215,730
Tags: constructive algorithms, interactive, matrices Correct Solution: ``` def ask(x1, y1, x2, y2): print("?", x1, y1, x2, y2) return (input() == "YES") def valid(x, y): return (1 <= x <= n) and (1 <= y <= n) n = int(input()) ans = "" r, d = 0, 0 row, col = 1, 1 for i in range(n - 1): if valid(row + 1, col) an...
output
1
107,865
15
215,731
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. This is an interactive problem. Bob lives in a square grid of size n Γ— n, with rows numbered 1 through n from top to bottom, and columns numbered 1 through n from left to right. Every cell is e...
instruction
0
107,866
15
215,732
Yes
output
1
107,866
15
215,733
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. This is an interactive problem. Bob lives in a square grid of size n Γ— n, with rows numbered 1 through n from top to bottom, and columns numbered 1 through n from left to right. Every cell is e...
instruction
0
107,867
15
215,734
Yes
output
1
107,867
15
215,735
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. This is an interactive problem. Bob lives in a square grid of size n Γ— n, with rows numbered 1 through n from top to bottom, and columns numbered 1 through n from left to right. Every cell is e...
instruction
0
107,868
15
215,736
No
output
1
107,868
15
215,737
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. This is an interactive problem. Bob lives in a square grid of size n Γ— n, with rows numbered 1 through n from top to bottom, and columns numbered 1 through n from left to right. Every cell is e...
instruction
0
107,869
15
215,738
No
output
1
107,869
15
215,739
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. This is an interactive problem. Bob lives in a square grid of size n Γ— n, with rows numbered 1 through n from top to bottom, and columns numbered 1 through n from left to right. Every cell is e...
instruction
0
107,870
15
215,740
No
output
1
107,870
15
215,741
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. This is an interactive problem. Bob lives in a square grid of size n Γ— n, with rows numbered 1 through n from top to bottom, and columns numbered 1 through n from left to right. Every cell is e...
instruction
0
107,871
15
215,742
No
output
1
107,871
15
215,743
Provide tags and a correct Python 3 solution for this coding contest problem. All of us love treasures, right? That's why young Vasya is heading for a Treasure Island. Treasure Island may be represented as a rectangular table n Γ— m which is surrounded by the ocean. Let us number rows of the field with consecutive int...
instruction
0
107,930
15
215,860
Tags: dfs and similar, dp, flows, hashing Correct Solution: ``` from heapq import heappush, heappop from collections import deque,defaultdict,Counter import itertools from itertools import permutations import sys import bisect import string import math import time ts=time.time() sys.setrecursionlimit(10**6) def SI(): ...
output
1
107,930
15
215,861
Provide tags and a correct Python 3 solution for this coding contest problem. All of us love treasures, right? That's why young Vasya is heading for a Treasure Island. Treasure Island may be represented as a rectangular table n Γ— m which is surrounded by the ocean. Let us number rows of the field with consecutive int...
instruction
0
107,931
15
215,862
Tags: dfs and similar, dp, flows, hashing Correct Solution: ``` import sys import collections as cc input = sys.stdin.readline n,m=map(int,input().split()) ar=[list(input().strip()) for i in range(n)] q=cc.deque() q.append([0,0]) while q: x,y=q.pop() if x+1<n and ar[x+1][y]==".": ar[x+1][y]=1 q....
output
1
107,931
15
215,863
Provide tags and a correct Python 3 solution for this coding contest problem. All of us love treasures, right? That's why young Vasya is heading for a Treasure Island. Treasure Island may be represented as a rectangular table n Γ— m which is surrounded by the ocean. Let us number rows of the field with consecutive int...
instruction
0
107,932
15
215,864
Tags: dfs and similar, dp, flows, hashing Correct Solution: ``` import sys input = sys.stdin.readline n,m=map(int,input().split()) MAP=[list(input().strip()) for i in range(n)] from collections import deque Q=deque() Q.append([0,0]) while Q: x,y=Q.pop() if x+1<n and MAP[x+1][y]==".": MAP[x+1][y]=...
output
1
107,932
15
215,865
Provide tags and a correct Python 3 solution for this coding contest problem. All of us love treasures, right? That's why young Vasya is heading for a Treasure Island. Treasure Island may be represented as a rectangular table n Γ— m which is surrounded by the ocean. Let us number rows of the field with consecutive int...
instruction
0
107,933
15
215,866
Tags: dfs and similar, dp, flows, hashing Correct Solution: ``` # ------------------- fast io -------------------- import os import sys from io import BytesIO, IOBase BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = BytesIO() ...
output
1
107,933
15
215,867
Provide tags and a correct Python 3 solution for this coding contest problem. All of us love treasures, right? That's why young Vasya is heading for a Treasure Island. Treasure Island may be represented as a rectangular table n Γ— m which is surrounded by the ocean. Let us number rows of the field with consecutive int...
instruction
0
107,934
15
215,868
Tags: dfs and similar, dp, flows, hashing Correct Solution: ``` from collections import * import sys def main(): r, c = map(int, sys.stdin.readline().strip().split()) grid = [list(sys.stdin.readline().strip()) for _ in range(r)] n = sum(u.count('#') for u in grid) if n == 0: if r == 1: ...
output
1
107,934
15
215,869
Provide tags and a correct Python 3 solution for this coding contest problem. All of us love treasures, right? That's why young Vasya is heading for a Treasure Island. Treasure Island may be represented as a rectangular table n Γ— m which is surrounded by the ocean. Let us number rows of the field with consecutive int...
instruction
0
107,935
15
215,870
Tags: dfs and similar, dp, flows, hashing Correct Solution: ``` import sys readLn = sys.stdin.readline if __name__ == '__main__': n, m = map(int, readLn().split()) ds = [[-1 if c == '#' else 0 for c in readLn()] for _ in range(n)] ds[0][0] = 1 for i in range(0, n): for j in range(0, m): ...
output
1
107,935
15
215,871
Provide tags and a correct Python 3 solution for this coding contest problem. All of us love treasures, right? That's why young Vasya is heading for a Treasure Island. Treasure Island may be represented as a rectangular table n Γ— m which is surrounded by the ocean. Let us number rows of the field with consecutive int...
instruction
0
107,936
15
215,872
Tags: dfs and similar, dp, flows, hashing Correct Solution: ``` import sys input = sys.stdin.readline t = 1 for _ in range(t): n, m = (int(x) for x in input().split()) mat = [input() for x in range(n)] dp = [[0 for x in range(m+1)] for y in range(n+1)] for i in range(n-1, -1, -1): for j in ran...
output
1
107,936
15
215,873