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
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Recently you have bought a snow walking robot and brought it home. Suppose your home is a cell (0, 0) on an infinite grid. You also have the sequence of instructions of this robot. It is writte...
instruction
0
55,712
15
111,424
No
output
1
55,712
15
111,425
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Recently you have bought a snow walking robot and brought it home. Suppose your home is a cell (0, 0) on an infinite grid. You also have the sequence of instructions of this robot. It is writte...
instruction
0
55,713
15
111,426
No
output
1
55,713
15
111,427
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Recently you have bought a snow walking robot and brought it home. Suppose your home is a cell (0, 0) on an infinite grid. You also have the sequence of instructions of this robot. It is writte...
instruction
0
55,714
15
111,428
No
output
1
55,714
15
111,429
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Recently you have bought a snow walking robot and brought it home. Suppose your home is a cell (0, 0) on an infinite grid. You also have the sequence of instructions of this robot. It is writte...
instruction
0
55,715
15
111,430
No
output
1
55,715
15
111,431
Provide a correct Python 3 solution for this coding contest problem. It was the last day of the summer camp you strayed into the labyrinth on the way to Komaba Campus, the University of Tokyo. The contest has just begun. Your teammates must impatiently wait for you. So you have to escape from this labyrinth as soon as...
instruction
0
56,370
15
112,740
"Correct Solution: ``` from collections import deque import sys def main(): readline = sys.stdin.readline write = sys.stdout.write W, H = map(int, readline().split()) MP = [readline() for i in range(H)] A = [[-1]*W for i in range(H)] B = [[-1]*W for i in range(H)] C = [[0]*W for i in range(H...
output
1
56,370
15
112,741
Provide tags and a correct Python 3 solution for this coding contest problem. Alice and Bob are playing chess on a huge chessboard with dimensions n Γ— n. Alice has a single piece left β€” a queen, located at (a_x, a_y), while Bob has only the king standing at (b_x, b_y). Alice thinks that as her queen is dominating the ...
instruction
0
56,407
15
112,814
Tags: dfs and similar, graphs, implementation Correct Solution: ``` n=int(input()) ax, ay = map(int,input().split()) bx, by = map(int,input().split()) cx, cy = map(int,input().split()) if ((bx<ax and cx<ax) or (bx>ax and cx>ax)) and ((by<ay and cy<ay) or (by>ay and cy>ay)): print('YES') else: print('NO') ```
output
1
56,407
15
112,815
Provide tags and a correct Python 3 solution for this coding contest problem. Alice and Bob are playing chess on a huge chessboard with dimensions n Γ— n. Alice has a single piece left β€” a queen, located at (a_x, a_y), while Bob has only the king standing at (b_x, b_y). Alice thinks that as her queen is dominating the ...
instruction
0
56,408
15
112,816
Tags: dfs and similar, graphs, implementation Correct Solution: ``` import sys from collections import defaultdict mod = 1000000007 def get_array(): return list(map(int, sys.stdin.readline().split())) def get_ints(): return map(int, sys.stdin.readline().split()) def input(): return sys.stdin.readline() def print_array(...
output
1
56,408
15
112,817
Provide tags and a correct Python 3 solution for this coding contest problem. Alice and Bob are playing chess on a huge chessboard with dimensions n Γ— n. Alice has a single piece left β€” a queen, located at (a_x, a_y), while Bob has only the king standing at (b_x, b_y). Alice thinks that as her queen is dominating the ...
instruction
0
56,409
15
112,818
Tags: dfs and similar, graphs, implementation Correct Solution: ``` n = int(input()) ax,ay = map(int,input().split()) bx,by = map(int,input().split()) cx,cy = map(int,input().split()) if (bx>=ax and cx<=ax) or (bx<=ax and cx>=ax) or (by>=ay and cy<=ay) or (by<=ay and cy>=ay):print('NO') else:print('YES') ```
output
1
56,409
15
112,819
Provide tags and a correct Python 3 solution for this coding contest problem. Alice and Bob are playing chess on a huge chessboard with dimensions n Γ— n. Alice has a single piece left β€” a queen, located at (a_x, a_y), while Bob has only the king standing at (b_x, b_y). Alice thinks that as her queen is dominating the ...
instruction
0
56,410
15
112,820
Tags: dfs and similar, graphs, implementation Correct Solution: ``` n = int(input()) ax, ay = map(int, input().split()) bx, by = map(int, input().split()) cx, cy = map(int, input().split()) if ((bx < ax)==(cx < ax)) and ((by < ay)==(cy < ay)): print("YES") else: print('NO') ```
output
1
56,410
15
112,821
Provide tags and a correct Python 3 solution for this coding contest problem. Alice and Bob are playing chess on a huge chessboard with dimensions n Γ— n. Alice has a single piece left β€” a queen, located at (a_x, a_y), while Bob has only the king standing at (b_x, b_y). Alice thinks that as her queen is dominating the ...
instruction
0
56,411
15
112,822
Tags: dfs and similar, graphs, implementation Correct Solution: ``` sign = lambda x: (1, -1)[x<0] def solve(n, ax, ay, bx, by, cx, cy): axdif = sign(bx-ax) aydif = sign(by-ay) cxdif = sign(cx-ax) cydif = sign(cy-ay) return 'YES' if axdif == cxdif and aydif == cydif else 'NO' n = int(input()) ax, ay = map(lambd...
output
1
56,411
15
112,823
Provide tags and a correct Python 3 solution for this coding contest problem. Alice and Bob are playing chess on a huge chessboard with dimensions n Γ— n. Alice has a single piece left β€” a queen, located at (a_x, a_y), while Bob has only the king standing at (b_x, b_y). Alice thinks that as her queen is dominating the ...
instruction
0
56,412
15
112,824
Tags: dfs and similar, graphs, implementation Correct Solution: ``` n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) c = list(map(int, input().split())) def four(x, y): xf = a[0] yf = a[1] if x > xf and y > yf: return 1 if x < xf and y > yf: retur...
output
1
56,412
15
112,825
Provide tags and a correct Python 3 solution for this coding contest problem. Alice and Bob are playing chess on a huge chessboard with dimensions n Γ— n. Alice has a single piece left β€” a queen, located at (a_x, a_y), while Bob has only the king standing at (b_x, b_y). Alice thinks that as her queen is dominating the ...
instruction
0
56,413
15
112,826
Tags: dfs and similar, graphs, implementation Correct Solution: ``` import queue n = int(input()) [qx,qy] = map(int, input().split()) [kx,ky] = map(int, input().split()) [tx,ty] = map(int, input().split()) kdx = kx - qx kdy = ky - qy tdx = tx - qx tdy = ty - qy if tdx * kdx > 0 and tdy * kdy > 0: print("YES") els...
output
1
56,413
15
112,827
Provide tags and a correct Python 3 solution for this coding contest problem. Alice and Bob are playing chess on a huge chessboard with dimensions n Γ— n. Alice has a single piece left β€” a queen, located at (a_x, a_y), while Bob has only the king standing at (b_x, b_y). Alice thinks that as her queen is dominating the ...
instruction
0
56,414
15
112,828
Tags: dfs and similar, graphs, implementation Correct Solution: ``` n = int(input()) ax, ay = [int(x) for x in input().split()] bx, by = [int(x) for x in input().split()] cx, cy = [int(x) for x in input().split()] dxb = ax - bx dxc = ax - cx dyb = ay - by dyc = ay - cy dxba = int(dxb / abs(dxb)) dxca = int(dxc / abs...
output
1
56,414
15
112,829
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Alice and Bob are playing chess on a huge chessboard with dimensions n Γ— n. Alice has a single piece left β€” a queen, located at (a_x, a_y), while Bob has only the king standing at (b_x, b_y). Al...
instruction
0
56,415
15
112,830
Yes
output
1
56,415
15
112,831
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Alice and Bob are playing chess on a huge chessboard with dimensions n Γ— n. Alice has a single piece left β€” a queen, located at (a_x, a_y), while Bob has only the king standing at (b_x, b_y). Al...
instruction
0
56,416
15
112,832
Yes
output
1
56,416
15
112,833
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Alice and Bob are playing chess on a huge chessboard with dimensions n Γ— n. Alice has a single piece left β€” a queen, located at (a_x, a_y), while Bob has only the king standing at (b_x, b_y). Al...
instruction
0
56,417
15
112,834
Yes
output
1
56,417
15
112,835
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Alice and Bob are playing chess on a huge chessboard with dimensions n Γ— n. Alice has a single piece left β€” a queen, located at (a_x, a_y), while Bob has only the king standing at (b_x, b_y). Al...
instruction
0
56,418
15
112,836
Yes
output
1
56,418
15
112,837
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Alice and Bob are playing chess on a huge chessboard with dimensions n Γ— n. Alice has a single piece left β€” a queen, located at (a_x, a_y), while Bob has only the king standing at (b_x, b_y). Al...
instruction
0
56,419
15
112,838
No
output
1
56,419
15
112,839
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Alice and Bob are playing chess on a huge chessboard with dimensions n Γ— n. Alice has a single piece left β€” a queen, located at (a_x, a_y), while Bob has only the king standing at (b_x, b_y). Al...
instruction
0
56,420
15
112,840
No
output
1
56,420
15
112,841
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Alice and Bob are playing chess on a huge chessboard with dimensions n Γ— n. Alice has a single piece left β€” a queen, located at (a_x, a_y), while Bob has only the king standing at (b_x, b_y). Al...
instruction
0
56,421
15
112,842
No
output
1
56,421
15
112,843
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Alice and Bob are playing chess on a huge chessboard with dimensions n Γ— n. Alice has a single piece left β€” a queen, located at (a_x, a_y), while Bob has only the king standing at (b_x, b_y). Al...
instruction
0
56,422
15
112,844
No
output
1
56,422
15
112,845
Provide tags and a correct Python 3 solution for this coding contest problem. Scrooge McDuck keeps his most treasured savings in a home safe with a combination lock. Each time he wants to put there the treasures that he's earned fair and square, he has to open the lock. <image> The combination lock is represented by...
instruction
0
56,711
15
113,422
Tags: implementation Correct Solution: ``` input(); cnt = 0 for i, j in (zip(input(), input())): i, j = int(i), int(j) cnt+=(abs(i-j), 10+min(i, j)-max(i, j))[abs(i-j)>5] print(cnt) #-------------------------------code_marshal-------------------------------- ```
output
1
56,711
15
113,423
Provide tags and a correct Python 3 solution for this coding contest problem. Scrooge McDuck keeps his most treasured savings in a home safe with a combination lock. Each time he wants to put there the treasures that he's earned fair and square, he has to open the lock. <image> The combination lock is represented by...
instruction
0
56,712
15
113,424
Tags: implementation Correct Solution: ``` n=int(input()) ex=input() out=input() mo=0 for i in range(n): s=abs(int(ex[i])-int(out[i])) if(s>5): s=10-s mo+=s print(mo) ```
output
1
56,712
15
113,425
Provide tags and a correct Python 3 solution for this coding contest problem. Scrooge McDuck keeps his most treasured savings in a home safe with a combination lock. Each time he wants to put there the treasures that he's earned fair and square, he has to open the lock. <image> The combination lock is represented by...
instruction
0
56,713
15
113,426
Tags: implementation Correct Solution: ``` n=int(input()) m1=input() m2=input() x=0 for i in range(len(m1)): p=abs(int(m1[i])-int(m2[i])) q=10-int(m1[i])+int(m2[i]) s=10-int(m2[i])+int(m1[i]) x=x+min(p,q,s) print(x) ```
output
1
56,713
15
113,427
Provide tags and a correct Python 3 solution for this coding contest problem. Scrooge McDuck keeps his most treasured savings in a home safe with a combination lock. Each time he wants to put there the treasures that he's earned fair and square, he has to open the lock. <image> The combination lock is represented by...
instruction
0
56,714
15
113,428
Tags: implementation Correct Solution: ``` # f = open('input') n = int(input()) num1 = [int(x) for x in str(input().strip())] num2 = [int(x) for x in str(input().strip())] # print(num1) # print(num2) print(sum([min(abs(num1[x] - num2[x]), (min(num1[x], num2[x]) + 10 - max(num1[x],num2[x]))) for x in range(n)])) ```
output
1
56,714
15
113,429
Provide tags and a correct Python 3 solution for this coding contest problem. Scrooge McDuck keeps his most treasured savings in a home safe with a combination lock. Each time he wants to put there the treasures that he's earned fair and square, he has to open the lock. <image> The combination lock is represented by...
instruction
0
56,715
15
113,430
Tags: implementation Correct Solution: ``` n=int(input()) a=input() b=input() turns=0 for i in range(n): if (int(a[i])-int(b[i]))>0: turns=turns+min( int(a[i]) - int(b[i]), 10 - (int(a[i]) - int(b[i])) ) else: turns=turns+min( int(b[i])-int(a[i]), 10 + int(a[i]) - int(b[i]) ) print(turns) ```
output
1
56,715
15
113,431
Provide tags and a correct Python 3 solution for this coding contest problem. Scrooge McDuck keeps his most treasured savings in a home safe with a combination lock. Each time he wants to put there the treasures that he's earned fair and square, he has to open the lock. <image> The combination lock is represented by...
instruction
0
56,716
15
113,432
Tags: implementation Correct Solution: ``` n = int(input()) disc_1 = input() disc_2 = input() s = 0 for i in range(n): s += min(abs(int(disc_1[i])-int(disc_2[i])), 10-abs(int(disc_1[i])-int(disc_2[i]))) print(s) ```
output
1
56,716
15
113,433
Provide tags and a correct Python 3 solution for this coding contest problem. Scrooge McDuck keeps his most treasured savings in a home safe with a combination lock. Each time he wants to put there the treasures that he's earned fair and square, he has to open the lock. <image> The combination lock is represented by...
instruction
0
56,717
15
113,434
Tags: implementation Correct Solution: ``` n = int(input()) a = input() b = input() rotation = 0 for i in range(len(a)): if abs(int(a[i]) - int(b[i])) <= 5: rotation = rotation + abs(int(a[i]) - int(b[i])) else: rotation = rotation + (9 - max(int(a[i]), int(b[i])) + 1 + min(int(a[i]), int(b[i]))...
output
1
56,717
15
113,435
Provide tags and a correct Python 3 solution for this coding contest problem. Scrooge McDuck keeps his most treasured savings in a home safe with a combination lock. Each time he wants to put there the treasures that he's earned fair and square, he has to open the lock. <image> The combination lock is represented by...
instruction
0
56,718
15
113,436
Tags: implementation Correct Solution: ``` e = int(input()) a = input() b = input() res = 0 i = 0 while i != e: res += min(abs(max(int(a[i]),int(b[i]))-min(int(a[i]),int(b[i]))), abs(10-max(int(a[i]),int(b[i]))+min(int(a[i]),int(b[i])))) i += 1 print(res) ```
output
1
56,718
15
113,437
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Scrooge McDuck keeps his most treasured savings in a home safe with a combination lock. Each time he wants to put there the treasures that he's earned fair and square, he has to open the lock. ...
instruction
0
56,724
15
113,448
No
output
1
56,724
15
113,449
Provide tags and a correct Python 3 solution for this coding contest problem. Theater stage is a rectangular field of size n Γ— m. The director gave you the stage's plan which actors will follow. For each cell it is stated in the plan if there would be an actor in this cell or not. You are to place a spotlight on the ...
instruction
0
56,784
15
113,568
Tags: dp, implementation Correct Solution: ``` n,m = list(map(int,input().split())) ss = [list(map(int,input().split())) for _ in range(n)] ll = [] ll.append([ss[i][j] for i in range(n) for j in range(m)]) #(t-d)(l-r) ll.append([ss[i][j] for i in range(n) for j in range(m-1,-1,-1)]) #(t-d)(r-l) ll.append(...
output
1
56,784
15
113,569
Provide tags and a correct Python 3 solution for this coding contest problem. Theater stage is a rectangular field of size n Γ— m. The director gave you the stage's plan which actors will follow. For each cell it is stated in the plan if there would be an actor in this cell or not. You are to place a spotlight on the ...
instruction
0
56,785
15
113,570
Tags: dp, implementation Correct Solution: ``` num_input = input() num_input = num_input.split(" ") n = int(num_input[0]) m = int(num_input[1]) arr = [] for i in range(0, n): arr.append(input().split(" ")) t_arr = list(map(list, zip(*arr))) res = 0 for i in range(0, n): num_1 = arr[i].count("1") if num...
output
1
56,785
15
113,571
Provide tags and a correct Python 3 solution for this coding contest problem. Theater stage is a rectangular field of size n Γ— m. The director gave you the stage's plan which actors will follow. For each cell it is stated in the plan if there would be an actor in this cell or not. You are to place a spotlight on the ...
instruction
0
56,786
15
113,572
Tags: dp, implementation Correct Solution: ``` n,m = list(map(int,input().split())) arr = [] for i in range(n): arr.append(list(map(int,input().split()))) c = 0 for i in range(n): was = 0 for g in range(m): if not was: was = arr[i][g] else: c+=arr[i][g]==0 was = 0...
output
1
56,786
15
113,573
Provide tags and a correct Python 3 solution for this coding contest problem. Theater stage is a rectangular field of size n Γ— m. The director gave you the stage's plan which actors will follow. For each cell it is stated in the plan if there would be an actor in this cell or not. You are to place a spotlight on the ...
instruction
0
56,787
15
113,574
Tags: dp, implementation Correct Solution: ``` class CodeforcesTask729BSolution: def __init__(self): self.result = '' self.n_m = [] self.plan = [] def read_input(self): self.n_m = [int(x) for x in input().split(" ")] for x in range(self.n_m[0]): self.plan.app...
output
1
56,787
15
113,575
Provide tags and a correct Python 3 solution for this coding contest problem. Theater stage is a rectangular field of size n Γ— m. The director gave you the stage's plan which actors will follow. For each cell it is stated in the plan if there would be an actor in this cell or not. You are to place a spotlight on the ...
instruction
0
56,788
15
113,576
Tags: dp, implementation Correct Solution: ``` n,m = list(map(int,input().split())) mat = [list(map(int,input().split())) for i in range(n)] ans = [[0]*m for i in range(n)] # left to right traversal on row and right to left on row for i in range(n): f = 0 for j in range(m): if mat[i][j]==0: ans[i][j]+=f if ma...
output
1
56,788
15
113,577
Provide tags and a correct Python 3 solution for this coding contest problem. Theater stage is a rectangular field of size n Γ— m. The director gave you the stage's plan which actors will follow. For each cell it is stated in the plan if there would be an actor in this cell or not. You are to place a spotlight on the ...
instruction
0
56,789
15
113,578
Tags: dp, implementation Correct Solution: ``` n, m = map(int, input().split()) a = [] t_a = [] ans = 0 for i in range(n): x = list(map(int, input().split())) a.append(x) t_a = list(map(list, zip(*a))) #print(a) #print(t_a) for i in range(n): c = a[i].count(1) if (c > 1): l = a[i].index(1) ...
output
1
56,789
15
113,579
Provide tags and a correct Python 3 solution for this coding contest problem. Theater stage is a rectangular field of size n Γ— m. The director gave you the stage's plan which actors will follow. For each cell it is stated in the plan if there would be an actor in this cell or not. You are to place a spotlight on the ...
instruction
0
56,790
15
113,580
Tags: dp, implementation Correct Solution: ``` n,m=map(int,input().split()) ans=0 a=[] for i in range(n): a.append(list(map(int,input().split()))) for i in range(n): for j in range(m): if a[i][j]: ans+=a[i][j:].count(0) break for j in range(m-1,-1,-1): if a[i][j]: ...
output
1
56,790
15
113,581
Provide tags and a correct Python 3 solution for this coding contest problem. Theater stage is a rectangular field of size n Γ— m. The director gave you the stage's plan which actors will follow. For each cell it is stated in the plan if there would be an actor in this cell or not. You are to place a spotlight on the ...
instruction
0
56,791
15
113,582
Tags: dp, implementation Correct Solution: ``` # # Created by Polusummator on 25.10.2020 # --------- Little PyPy Squad --------- # Verdict: TLE # n, m = [int(i) for i in input().split()] A = [0] * n ones = 0 for i in range(n): a = [int(i) for i in input().split()] A[i] = a ones += a.count(1) ans = 0 for i...
output
1
56,791
15
113,583
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Theater stage is a rectangular field of size n Γ— m. The director gave you the stage's plan which actors will follow. For each cell it is stated in the plan if there would be an actor in this cel...
instruction
0
56,792
15
113,584
Yes
output
1
56,792
15
113,585
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Theater stage is a rectangular field of size n Γ— m. The director gave you the stage's plan which actors will follow. For each cell it is stated in the plan if there would be an actor in this cel...
instruction
0
56,793
15
113,586
Yes
output
1
56,793
15
113,587
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Theater stage is a rectangular field of size n Γ— m. The director gave you the stage's plan which actors will follow. For each cell it is stated in the plan if there would be an actor in this cel...
instruction
0
56,794
15
113,588
Yes
output
1
56,794
15
113,589
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Theater stage is a rectangular field of size n Γ— m. The director gave you the stage's plan which actors will follow. For each cell it is stated in the plan if there would be an actor in this cel...
instruction
0
56,795
15
113,590
Yes
output
1
56,795
15
113,591
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Theater stage is a rectangular field of size n Γ— m. The director gave you the stage's plan which actors will follow. For each cell it is stated in the plan if there would be an actor in this cel...
instruction
0
56,796
15
113,592
No
output
1
56,796
15
113,593
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Theater stage is a rectangular field of size n Γ— m. The director gave you the stage's plan which actors will follow. For each cell it is stated in the plan if there would be an actor in this cel...
instruction
0
56,797
15
113,594
No
output
1
56,797
15
113,595
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Theater stage is a rectangular field of size n Γ— m. The director gave you the stage's plan which actors will follow. For each cell it is stated in the plan if there would be an actor in this cel...
instruction
0
56,798
15
113,596
No
output
1
56,798
15
113,597
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Theater stage is a rectangular field of size n Γ— m. The director gave you the stage's plan which actors will follow. For each cell it is stated in the plan if there would be an actor in this cel...
instruction
0
56,799
15
113,598
No
output
1
56,799
15
113,599
Provide tags and a correct Python 3 solution for this coding contest problem. The black king is standing on a chess field consisting of 109 rows and 109 columns. We will consider the rows of the field numbered with integers from 1 to 109 from top to bottom. The columns are similarly numbered with integers from 1 to 10...
instruction
0
57,380
15
114,760
Tags: dfs and similar, graphs, hashing, shortest paths Correct Solution: ``` from collections import deque x0,y0,x1,y1 = list(map(int, input().split())) n = int(input()) allowed = {} for i in range(n): r,a,b = list(map(int, input().split())) for j in range(a,b+1): allowed[(r,j)] = True visited = {} q ...
output
1
57,380
15
114,761
Provide tags and a correct Python 3 solution for this coding contest problem. The black king is standing on a chess field consisting of 109 rows and 109 columns. We will consider the rows of the field numbered with integers from 1 to 109 from top to bottom. The columns are similarly numbered with integers from 1 to 10...
instruction
0
57,381
15
114,762
Tags: dfs and similar, graphs, hashing, shortest paths Correct Solution: ``` from collections import deque x0,y0,x1,y1=list(map(int, input().split())) n=int(input()) allowed={} for i in range(n): r,a,b=list(map(int,input().split())) for j in range(a,b+1): allowed[(r,j)]=True visited={} q=deque() q.appe...
output
1
57,381
15
114,763
Provide tags and a correct Python 3 solution for this coding contest problem. The black king is standing on a chess field consisting of 109 rows and 109 columns. We will consider the rows of the field numbered with integers from 1 to 109 from top to bottom. The columns are similarly numbered with integers from 1 to 10...
instruction
0
57,382
15
114,764
Tags: dfs and similar, graphs, hashing, shortest paths Correct Solution: ``` def bfs(a,b): global segment q = [(a,b)] while q: a, b = q.pop(0) x = [0,0,-1,1,-1,1,-1,1] y = [1,-1,0,0,-1,1,1,-1] for i in range(8): a_new, b_new = a+x[i], b+y[i] if (a_new,b_new) in segment and segment[(a_...
output
1
57,382
15
114,765
Provide tags and a correct Python 3 solution for this coding contest problem. The black king is standing on a chess field consisting of 109 rows and 109 columns. We will consider the rows of the field numbered with integers from 1 to 109 from top to bottom. The columns are similarly numbered with integers from 1 to 10...
instruction
0
57,383
15
114,766
Tags: dfs and similar, graphs, hashing, shortest paths Correct Solution: ``` def connect_point(graph, r, j, deg) : if (r - 1, j) in graph and deg < graph[r - 1, j][0]: graph[r - 1, j][0] = deg graph[r, j].append((r - 1, j)) if (r + 1, j) in graph and deg < graph[r + 1, j][0]: graph[r + 1...
output
1
57,383
15
114,767