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 a correct Python 3 solution for this coding contest problem. We have a rectangular grid of squares with H horizontal rows and W vertical columns. Let (i,j) denote the square at the i-th row from the top and the j-th column from the left. On this grid, there is a piece, which is initially placed at square (s_r,...
instruction
0
59,470
15
118,940
"Correct Solution: ``` d='URLD' h,w,n=map(int,input().split()) b=[h,w,w,h] r,c=map(int,input().split()) o=[h-r+1,c,w-c+1,r] s=input() t=[dict(zip(d,d[::-1]))[i] for i in input()] a=0 for i,j in enumerate(d): x=o[i] for k in range(n): x+=(s[k]==j) if x>b[i]:a=1 if x>1:x-=(t[k]==j) print('YNEOS'[a::2]) ``...
output
1
59,470
15
118,941
Provide a correct Python 3 solution for this coding contest problem. We have a rectangular grid of squares with H horizontal rows and W vertical columns. Let (i,j) denote the square at the i-th row from the top and the j-th column from the left. On this grid, there is a piece, which is initially placed at square (s_r,...
instruction
0
59,471
15
118,942
"Correct Solution: ``` H,W,N = map(int, input().split()) st = [int(i) for i in input().split()] S = input() T = input() def simu(dim1): now = [st[0],st[1]] if dim1 == 'U': dim2,L,step,dim = 'D',H,1,0 if dim1 == 'D': dim2,L,step,dim = 'U',H,-1,0 if dim1 == 'L': dim2,L,step,dim ...
output
1
59,471
15
118,943
Provide a correct Python 3 solution for this coding contest problem. We have a rectangular grid of squares with H horizontal rows and W vertical columns. Let (i,j) denote the square at the i-th row from the top and the j-th column from the left. On this grid, there is a piece, which is initially placed at square (s_r,...
instruction
0
59,472
15
118,944
"Correct Solution: ``` #!/usr/bin/env python3 H, W, N = map(int, input().split()) sr, sc = map(lambda x: int(x) - 1, input().split()) S = input() T = input() l, r = 0, W u, d = 0, H for i in range(N)[::-1]: if T[i] == 'L': r = min(W, r + 1) if T[i] == 'R': l = max(0, l - 1) if T[i] == 'U': d = min(H, d + 1)...
output
1
59,472
15
118,945
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. We have a rectangular grid of squares with H horizontal rows and W vertical columns. Let (i,j) denote the square at the i-th row from the top and the j-th column from the left. On this grid, the...
instruction
0
59,473
15
118,946
Yes
output
1
59,473
15
118,947
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. We have a rectangular grid of squares with H horizontal rows and W vertical columns. Let (i,j) denote the square at the i-th row from the top and the j-th column from the left. On this grid, the...
instruction
0
59,474
15
118,948
Yes
output
1
59,474
15
118,949
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. We have a rectangular grid of squares with H horizontal rows and W vertical columns. Let (i,j) denote the square at the i-th row from the top and the j-th column from the left. On this grid, the...
instruction
0
59,475
15
118,950
Yes
output
1
59,475
15
118,951
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. We have a rectangular grid of squares with H horizontal rows and W vertical columns. Let (i,j) denote the square at the i-th row from the top and the j-th column from the left. On this grid, the...
instruction
0
59,476
15
118,952
Yes
output
1
59,476
15
118,953
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. We have a rectangular grid of squares with H horizontal rows and W vertical columns. Let (i,j) denote the square at the i-th row from the top and the j-th column from the left. On this grid, the...
instruction
0
59,477
15
118,954
No
output
1
59,477
15
118,955
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. We have a rectangular grid of squares with H horizontal rows and W vertical columns. Let (i,j) denote the square at the i-th row from the top and the j-th column from the left. On this grid, the...
instruction
0
59,478
15
118,956
No
output
1
59,478
15
118,957
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. We have a rectangular grid of squares with H horizontal rows and W vertical columns. Let (i,j) denote the square at the i-th row from the top and the j-th column from the left. On this grid, the...
instruction
0
59,479
15
118,958
No
output
1
59,479
15
118,959
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. We have a rectangular grid of squares with H horizontal rows and W vertical columns. Let (i,j) denote the square at the i-th row from the top and the j-th column from the left. On this grid, the...
instruction
0
59,480
15
118,960
No
output
1
59,480
15
118,961
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Kolya has a turtle and a field of size 2 × n. The field rows are numbered from 1 to 2 from top to bottom, while the columns are numbered from 1 to n from left to right. Suppose in each cell of ...
instruction
0
59,810
15
119,620
No
output
1
59,810
15
119,621
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Kolya has a turtle and a field of size 2 × n. The field rows are numbered from 1 to 2 from top to bottom, while the columns are numbered from 1 to n from left to right. Suppose in each cell of ...
instruction
0
59,811
15
119,622
No
output
1
59,811
15
119,623
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Kolya has a turtle and a field of size 2 × n. The field rows are numbered from 1 to 2 from top to bottom, while the columns are numbered from 1 to n from left to right. Suppose in each cell of ...
instruction
0
59,812
15
119,624
No
output
1
59,812
15
119,625
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Kolya has a turtle and a field of size 2 × n. The field rows are numbered from 1 to 2 from top to bottom, while the columns are numbered from 1 to n from left to right. Suppose in each cell of ...
instruction
0
59,813
15
119,626
No
output
1
59,813
15
119,627
Provide tags and a correct Python 3 solution for this coding contest problem. To improve the boomerang throwing skills of the animals, Zookeeper has set up an n × n grid with some targets, where each row and each column has at most 2 targets each. The rows are numbered from 1 to n from top to bottom, and the columns a...
instruction
0
59,916
15
119,832
Tags: constructive algorithms, greedy, implementation Correct Solution: ``` import sys input = sys.stdin.readline ############ ---- Input Functions ---- ############ def inp(): return(int(input())) def inlt(): return(list(map(int,input().split()))) def insr(): s = input() return(list(s[:len(s) - 1])) d...
output
1
59,916
15
119,833
Provide tags and a correct Python 3 solution for this coding contest problem. To improve the boomerang throwing skills of the animals, Zookeeper has set up an n × n grid with some targets, where each row and each column has at most 2 targets each. The rows are numbered from 1 to n from top to bottom, and the columns a...
instruction
0
59,917
15
119,834
Tags: constructive algorithms, greedy, implementation Correct Solution: ``` n=int(input()) s=[int(x) for x in input().split()] L1=[] L2=[] L3=[] L4=[] row=n-1 ans=[] flag=0 for i in range(len(s)-1,-1,-1): if(s[i]==1): ans.append([row+1,i+1]) L1.append(row) L3.append(i) elif(s[i]==2): ...
output
1
59,917
15
119,835
Provide tags and a correct Python 3 solution for this coding contest problem. To improve the boomerang throwing skills of the animals, Zookeeper has set up an n × n grid with some targets, where each row and each column has at most 2 targets each. The rows are numbered from 1 to n from top to bottom, and the columns a...
instruction
0
59,918
15
119,836
Tags: constructive algorithms, greedy, implementation Correct Solution: ``` n = int(input()) x = [] y = [] ans = [] A = list(map(int, input().split())) for i in range(n): if A[i] == 1: if y: ans += [[y.pop(), i + 1]] elif x: ...
output
1
59,918
15
119,837
Provide tags and a correct Python 3 solution for this coding contest problem. To improve the boomerang throwing skills of the animals, Zookeeper has set up an n × n grid with some targets, where each row and each column has at most 2 targets each. The rows are numbered from 1 to n from top to bottom, and the columns a...
instruction
0
59,919
15
119,838
Tags: constructive algorithms, greedy, implementation Correct Solution: ``` n = int(input()) a = [int(i) for i in input().split()] targ = [int(0) for i in range(n)] di = [int(-1) for i in range(n)] one = list() two = list() ok = 1 for i in range(n-1, -1, -1): if a[i] == 1: one.append(i) targ[i] = 1 ...
output
1
59,919
15
119,839
Provide tags and a correct Python 3 solution for this coding contest problem. To improve the boomerang throwing skills of the animals, Zookeeper has set up an n × n grid with some targets, where each row and each column has at most 2 targets each. The rows are numbered from 1 to n from top to bottom, and the columns a...
instruction
0
59,920
15
119,840
Tags: constructive algorithms, greedy, implementation Correct Solution: ``` from collections import deque, defaultdict def solve(): n = int(input()) a = list(map(int, input().split())) tar = [] ful2 = [] ful3 = [] r = 1 for i in range(n): if a[i]==3: if len(ful3)!=0: ...
output
1
59,920
15
119,841
Provide tags and a correct Python 3 solution for this coding contest problem. To improve the boomerang throwing skills of the animals, Zookeeper has set up an n × n grid with some targets, where each row and each column has at most 2 targets each. The rows are numbered from 1 to n from top to bottom, and the columns a...
instruction
0
59,921
15
119,842
Tags: constructive algorithms, greedy, implementation Correct Solution: ``` def die(): print(-1) exit(0) ones = [] ans = [] H = 1 lastThree = (-1,-1) n = int(input()) arr = list(map(int,input().split(" "))) for i in range(n-1, -1, -1): if arr[i] == 0: continue elif arr[i] == 1: one...
output
1
59,921
15
119,843
Provide tags and a correct Python 3 solution for this coding contest problem. To improve the boomerang throwing skills of the animals, Zookeeper has set up an n × n grid with some targets, where each row and each column has at most 2 targets each. The rows are numbered from 1 to n from top to bottom, and the columns a...
instruction
0
59,922
15
119,844
Tags: constructive algorithms, greedy, implementation Correct Solution: ``` import os, sys from io import BytesIO, IOBase from math import log2, ceil, sqrt, gcd from _collections import deque import heapq as hp from bisect import bisect_left, bisect_right from math import cos, sin BUFSIZE = 8192 class FastIO(IOBase)...
output
1
59,922
15
119,845
Provide tags and a correct Python 3 solution for this coding contest problem. To improve the boomerang throwing skills of the animals, Zookeeper has set up an n × n grid with some targets, where each row and each column has at most 2 targets each. The rows are numbered from 1 to n from top to bottom, and the columns a...
instruction
0
59,923
15
119,846
Tags: constructive algorithms, greedy, implementation Correct Solution: ``` from bisect import * from collections import * from math import * from heapq import * from typing import List from itertools import * from operator import * from functools import * #-------------------------------------------------------------...
output
1
59,923
15
119,847
Provide tags and a correct Python 3 solution for this coding contest problem. Utkarsh is forced to play yet another one of Ashish's games. The game progresses turn by turn and as usual, Ashish moves first. Consider the 2D plane. There is a token which is initially at (0,0). In one move a player must increase either t...
instruction
0
59,932
15
119,864
Tags: games, geometry, math Correct Solution: ``` t = int(input()) for _ in range(t): d,k = map(int,input().split()) val = int((d) // ((2**0.5)*k)) p = q = val * k i = 0 while (p**2 + q**2) <= d**2: if p != q: q += k else: p += k i += 1 if i % 2 ==...
output
1
59,932
15
119,865
Provide tags and a correct Python 3 solution for this coding contest problem. Utkarsh is forced to play yet another one of Ashish's games. The game progresses turn by turn and as usual, Ashish moves first. Consider the 2D plane. There is a token which is initially at (0,0). In one move a player must increase either t...
instruction
0
59,933
15
119,866
Tags: games, geometry, math Correct Solution: ``` import sys import math import bisect from sys import stdin, stdout from math import gcd, floor, sqrt, log, ceil from collections import defaultdict as dd from collections import Counter as cc from bisect import bisect_left as bl from bisect import bisect_right as br ''...
output
1
59,933
15
119,867
Provide tags and a correct Python 3 solution for this coding contest problem. Utkarsh is forced to play yet another one of Ashish's games. The game progresses turn by turn and as usual, Ashish moves first. Consider the 2D plane. There is a token which is initially at (0,0). In one move a player must increase either t...
instruction
0
59,934
15
119,868
Tags: games, geometry, math Correct Solution: ``` from __future__ import print_function # for PyPy2 from collections import Counter, OrderedDict from itertools import permutations as perm from collections import deque from sys import stdin from bisect import * from heapq import * import math g = lambda : stdin.read...
output
1
59,934
15
119,869
Provide tags and a correct Python 3 solution for this coding contest problem. Utkarsh is forced to play yet another one of Ashish's games. The game progresses turn by turn and as usual, Ashish moves first. Consider the 2D plane. There is a token which is initially at (0,0). In one move a player must increase either t...
instruction
0
59,935
15
119,870
Tags: games, geometry, math Correct Solution: ``` l=lambda:map(int,input().split()) p=lambda:int(input()) ss=lambda:input() from math import log10 as c for _ in range(p()): d,k=l() if k>=1: ans=d//k y=(d//k)*k i=y j=k while i>=0 and j<=y: if i*i+j*j>d*d: ...
output
1
59,935
15
119,871
Provide tags and a correct Python 3 solution for this coding contest problem. Utkarsh is forced to play yet another one of Ashish's games. The game progresses turn by turn and as usual, Ashish moves first. Consider the 2D plane. There is a token which is initially at (0,0). In one move a player must increase either t...
instruction
0
59,936
15
119,872
Tags: games, geometry, math Correct Solution: ``` import math import sys input = sys.stdin.readline t = int(input()) while t: t-=1 d,k = [int(x) for x in input().split()] max_point = int(math.sqrt((d**2)/(2*(k**2)))) point1 = k*max_point point2 = k*(max_point+1) if (point1**2+point2**2)<=d**2: ...
output
1
59,936
15
119,873
Provide tags and a correct Python 3 solution for this coding contest problem. Utkarsh is forced to play yet another one of Ashish's games. The game progresses turn by turn and as usual, Ashish moves first. Consider the 2D plane. There is a token which is initially at (0,0). In one move a player must increase either t...
instruction
0
59,937
15
119,874
Tags: games, geometry, math Correct Solution: ``` t = int(input()) for _ in range(t): d, k = map(int, input().split()) d2 = d * d z = 0 while 2 * z * z < d2: z += k z -= k nl = (z + k) ** 2 + z ** 2 print('Ashish') if nl <= d2 else print('Utkarsh') ```
output
1
59,937
15
119,875
Provide tags and a correct Python 3 solution for this coding contest problem. Utkarsh is forced to play yet another one of Ashish's games. The game progresses turn by turn and as usual, Ashish moves first. Consider the 2D plane. There is a token which is initially at (0,0). In one move a player must increase either t...
instruction
0
59,938
15
119,876
Tags: games, geometry, math Correct Solution: ``` import math t = int(input()) while t!=0: d,k = map(int,input().split()) p = d//(math.sqrt(2)*k) xcor = p*k ycor = p*k if (xcor+k)*(xcor+k) + ycor*ycor <= d*d : xcor+=k if xcor==ycor: print("Utkarsh") else: print("...
output
1
59,938
15
119,877
Provide tags and a correct Python 3 solution for this coding contest problem. Utkarsh is forced to play yet another one of Ashish's games. The game progresses turn by turn and as usual, Ashish moves first. Consider the 2D plane. There is a token which is initially at (0,0). In one move a player must increase either t...
instruction
0
59,939
15
119,878
Tags: games, geometry, math Correct Solution: ``` """ Author - Satwik Tiwari . 21th NOV , 2020 - Saturday """ #=============================================================================================== #importing some useful libraries. from __future__ import division, print_function from fractions impor...
output
1
59,939
15
119,879
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Utkarsh is forced to play yet another one of Ashish's games. The game progresses turn by turn and as usual, Ashish moves first. Consider the 2D plane. There is a token which is initially at (0,...
instruction
0
59,943
15
119,886
Yes
output
1
59,943
15
119,887
Provide tags and a correct Python 3 solution for this coding contest problem. You are running through a rectangular field. This field can be represented as a matrix with 3 rows and m columns. (i, j) denotes a cell belonging to i-th row and j-th column. You start in (2, 1) and have to end your path in (2, m). From the...
instruction
0
60,364
15
120,728
Tags: dp, matrices, sortings Correct Solution: ``` from operator import itemgetter import sys input = sys.stdin.buffer.readline def _mul(A, B, MOD): C = [[0] * len(B[0]) for i in range(len(A))] for i in range(len(A)): for k in range(len(B)): for j in range(len(B[0])): C[i][...
output
1
60,364
15
120,729
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are running through a rectangular field. This field can be represented as a matrix with 3 rows and m columns. (i, j) denotes a cell belonging to i-th row and j-th column. You start in (2, 1...
instruction
0
60,365
15
120,730
No
output
1
60,365
15
120,731
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are running through a rectangular field. This field can be represented as a matrix with 3 rows and m columns. (i, j) denotes a cell belonging to i-th row and j-th column. You start in (2, 1...
instruction
0
60,366
15
120,732
No
output
1
60,366
15
120,733
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are running through a rectangular field. This field can be represented as a matrix with 3 rows and m columns. (i, j) denotes a cell belonging to i-th row and j-th column. You start in (2, 1...
instruction
0
60,367
15
120,734
No
output
1
60,367
15
120,735
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are running through a rectangular field. This field can be represented as a matrix with 3 rows and m columns. (i, j) denotes a cell belonging to i-th row and j-th column. You start in (2, 1...
instruction
0
60,368
15
120,736
No
output
1
60,368
15
120,737
Provide tags and a correct Python 3 solution for this coding contest problem. There are n points on an infinite plane. The i-th point has coordinates (x_i, y_i) such that x_i > 0 and y_i > 0. The coordinates are not necessarily integer. In one move you perform the following operations: * choose two points a and b...
instruction
0
60,929
15
121,858
Tags: constructive algorithms, dfs and similar, geometry, graphs, sortings, trees Correct Solution: ``` def divisors(M): d=[] i=1 while M>=i**2: if M%i==0: d.append(i) if i**2!=M: d.append(M//i) i=i+1 return d def popcount(x): x = x - ((x >> 1...
output
1
60,929
15
121,859
Provide tags and a correct Python 3 solution for this coding contest problem. There are n points on an infinite plane. The i-th point has coordinates (x_i, y_i) such that x_i > 0 and y_i > 0. The coordinates are not necessarily integer. In one move you perform the following operations: * choose two points a and b...
instruction
0
60,930
15
121,860
Tags: constructive algorithms, dfs and similar, geometry, graphs, sortings, trees Correct Solution: ``` import io import os from collections import defaultdict from math import gcd from types import GeneratorType # From https://github.com/cheran-senthil/PyRival/blob/master/pyrival/misc/bootstrap.py def bootstrap(f, s...
output
1
60,930
15
121,861
Provide tags and a correct Python 3 solution for this coding contest problem. There are n points on an infinite plane. The i-th point has coordinates (x_i, y_i) such that x_i > 0 and y_i > 0. The coordinates are not necessarily integer. In one move you perform the following operations: * choose two points a and b...
instruction
0
60,931
15
121,862
Tags: constructive algorithms, dfs and similar, geometry, graphs, sortings, trees Correct Solution: ``` import sys from sys import stdin import math from collections import deque n = int(stdin.readline()) dic = {} lis = [] for i in range(n): a,b,c,d = map(int,stdin.readline().split()) #xpl A,B,C,D = a...
output
1
60,931
15
121,863
Provide tags and a correct Python 3 solution for this coding contest problem. There are n points on an infinite plane. The i-th point has coordinates (x_i, y_i) such that x_i > 0 and y_i > 0. The coordinates are not necessarily integer. In one move you perform the following operations: * choose two points a and b...
instruction
0
60,932
15
121,864
Tags: constructive algorithms, dfs and similar, geometry, graphs, sortings, trees Correct Solution: ``` import sys from sys import stdin import math from collections import deque n = int(stdin.readline()) dic = {} lis = [] for i in range(n): a,b,c,d = map(int,stdin.readline().split()) A,B,C,D = a+b,b,c,d si...
output
1
60,932
15
121,865
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n points on an infinite plane. The i-th point has coordinates (x_i, y_i) such that x_i > 0 and y_i > 0. The coordinates are not necessarily integer. In one move you perform the follow...
instruction
0
60,933
15
121,866
No
output
1
60,933
15
121,867
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n points on an infinite plane. The i-th point has coordinates (x_i, y_i) such that x_i > 0 and y_i > 0. The coordinates are not necessarily integer. In one move you perform the follow...
instruction
0
60,934
15
121,868
No
output
1
60,934
15
121,869
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n points on an infinite plane. The i-th point has coordinates (x_i, y_i) such that x_i > 0 and y_i > 0. The coordinates are not necessarily integer. In one move you perform the follow...
instruction
0
60,935
15
121,870
No
output
1
60,935
15
121,871
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n points on an infinite plane. The i-th point has coordinates (x_i, y_i) such that x_i > 0 and y_i > 0. The coordinates are not necessarily integer. In one move you perform the follow...
instruction
0
60,936
15
121,872
No
output
1
60,936
15
121,873
Provide tags and a correct Python 3 solution for this coding contest problem. You've got a robot, its task is destroying bombs on a square plane. Specifically, the square plane contains n bombs, the i-th bomb is at point with coordinates (xi, yi). We know that no two bombs are at the same point and that no bomb is at ...
instruction
0
61,756
15
123,512
Tags: greedy, implementation, sortings Correct Solution: ``` import sys input = lambda: sys.stdin.readline().strip("\r\n") n = int(input()) ans = [] for x, y in sorted([list(map(int, input().split())) for _ in range(n)], key=lambda x: abs(x[0]) + abs(x[1])): if x > 0: ans.append('1 %d R' % x) if x < 0...
output
1
61,756
15
123,513
Provide tags and a correct Python 3 solution for this coding contest problem. You've got a robot, its task is destroying bombs on a square plane. Specifically, the square plane contains n bombs, the i-th bomb is at point with coordinates (xi, yi). We know that no two bombs are at the same point and that no bomb is at ...
instruction
0
61,757
15
123,514
Tags: greedy, implementation, sortings Correct Solution: ``` #!/usr/bin/env python3 import io import os import sys input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline def printd(*args, **kwargs): #print(*args, **kwargs, file=sys.stderr) print(*args, **kwargs) pass def get_str(): return input(...
output
1
61,757
15
123,515
Provide tags and a correct Python 3 solution for this coding contest problem. You've got a robot, its task is destroying bombs on a square plane. Specifically, the square plane contains n bombs, the i-th bomb is at point with coordinates (xi, yi). We know that no two bombs are at the same point and that no bomb is at ...
instruction
0
61,758
15
123,516
Tags: greedy, implementation, sortings Correct Solution: ``` import os import sys from io import BytesIO, IOBase def main(): pass # region fastio BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = BytesIO() self....
output
1
61,758
15
123,517
Provide tags and a correct Python 3 solution for this coding contest problem. You've got a robot, its task is destroying bombs on a square plane. Specifically, the square plane contains n bombs, the i-th bomb is at point with coordinates (xi, yi). We know that no two bombs are at the same point and that no bomb is at ...
instruction
0
61,759
15
123,518
Tags: greedy, implementation, sortings Correct Solution: ``` #!/usr/bin/python3 def readln(): return tuple(map(int, input().split())) n, = readln() ans = [] for x, y in sorted([readln() for _ in range(n)], key=lambda x: abs(x[0]) + abs(x[1])): if x > 0: ans.append('1 %d R' % x) if x < 0: ans.a...
output
1
61,759
15
123,519
Provide tags and a correct Python 3 solution for this coding contest problem. You've got a robot, its task is destroying bombs on a square plane. Specifically, the square plane contains n bombs, the i-th bomb is at point with coordinates (xi, yi). We know that no two bombs are at the same point and that no bomb is at ...
instruction
0
61,760
15
123,520
Tags: greedy, implementation, sortings Correct Solution: ``` from sys import stdin, stdout n = int(stdin.readline()) pos = [] for i in range(n): x, y = map( int,stdin.readline().split() ) pos.append([x,y]) pos = sorted( pos,key=lambda pos: abs(pos[0])+abs(pos[1]) ) # print(pos) moves = [] for p in pos: x,...
output
1
61,760
15
123,521