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.
Maksim walks on a Cartesian plane. Initially, he stands at the point (0, 0) and in one move he can go to any of four adjacent points (left, right, up, down). For example, if Maksim is currently at the point (0, 0), he can go to any of the fo... | instruction | 0 | 67,271 | 15 | 134,542 |
Tags: dp
Correct Solution:
```
from sys import stdin
n=int(stdin.readline().strip())
s=[]
s1=[]
for i in range(n):
a,b=map(int,stdin.readline().strip().split())
s.append((a,b))
s1.append((b,a))
s.sort()
s1.sort(reverse=True)
mt=dict()
for i in s:
if i[0]<=i[1]:
if i[1] in mt:
mt[i[1]... | output | 1 | 67,271 | 15 | 134,543 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Maksim walks on a Cartesian plane. Initially, he stands at the point (0, 0) and in one move he can go to any of four adjacent points (left, right, up, down). For example, if Maksim is currently at the point (0, 0), he can go to any of the fo... | instruction | 0 | 67,272 | 15 | 134,544 |
Tags: dp
Correct Solution:
```
import itertools as it
def dist(a, b):
return abs(a[0] - b[0]) + abs(a[1] - b[1])
def spir_dist(x):
a, b = x
if a >= b:
return b
else:
return 2 * b - a
n = int(input())
A = [[0, 0]]
for _ in range(n):
x, y = map(int, input(... | output | 1 | 67,272 | 15 | 134,545 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Maksim walks on a Cartesian plane. Initially, he stands at the point (0, 0) and in one move he can go to any of four adjacent points (left, right, up, down). For example, if Maksim is currently at the point (0, 0), he can go to any of the fo... | instruction | 0 | 67,273 | 15 | 134,546 |
Tags: dp
Correct Solution:
```
def dista(a, b):
return abs(lista[a][0]-lista[b][0]) + abs(lista[a][1]-lista[b][1])
lista = []
ne = 0
n = int(input())
dist = [0] * (n+1)
lista.append((0, 0))
for _ in range(n):
x, y = map(int, input().split())
lista.append((x, y))
lista = sorted(lista, key= lambda x: min(x))
lista =... | output | 1 | 67,273 | 15 | 134,547 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Maksim walks on a Cartesian plane. Initially, he stands at the point (0, 0) and in one move he can go to any of four adjacent points (left, right, up, down). For example, if Maksim is currently at the point (0, 0), he can go to any of the fo... | instruction | 0 | 67,274 | 15 | 134,548 |
Tags: dp
Correct Solution:
```
def get_input_list():
return list(map(int, input().split()))
def sort_(p):
np = []
for i in p:
np.append([i[0],-i[1]])
np.sort()
return np
def distance(A,B):
return abs(B[0] - A[0]) + abs(B[1] - A[1])
n = int(input())
p_ = []
for _ in range(n):
p_.append(get_input_list())
d = {... | output | 1 | 67,274 | 15 | 134,549 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Maksim walks on a Cartesian plane. Initially, he stands at the point (0, 0) and in one move he can go to any of four adjacent points (left, right, up, down). For example, if Maksim is currently ... | instruction | 0 | 67,275 | 15 | 134,550 |
Yes | output | 1 | 67,275 | 15 | 134,551 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Maksim walks on a Cartesian plane. Initially, he stands at the point (0, 0) and in one move he can go to any of four adjacent points (left, right, up, down). For example, if Maksim is currently ... | instruction | 0 | 67,276 | 15 | 134,552 |
Yes | output | 1 | 67,276 | 15 | 134,553 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Maksim walks on a Cartesian plane. Initially, he stands at the point (0, 0) and in one move he can go to any of four adjacent points (left, right, up, down). For example, if Maksim is currently ... | instruction | 0 | 67,277 | 15 | 134,554 |
Yes | output | 1 | 67,277 | 15 | 134,555 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Maksim walks on a Cartesian plane. Initially, he stands at the point (0, 0) and in one move he can go to any of four adjacent points (left, right, up, down). For example, if Maksim is currently ... | instruction | 0 | 67,278 | 15 | 134,556 |
Yes | output | 1 | 67,278 | 15 | 134,557 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Maksim walks on a Cartesian plane. Initially, he stands at the point (0, 0) and in one move he can go to any of four adjacent points (left, right, up, down). For example, if Maksim is currently ... | instruction | 0 | 67,279 | 15 | 134,558 |
No | output | 1 | 67,279 | 15 | 134,559 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Maksim walks on a Cartesian plane. Initially, he stands at the point (0, 0) and in one move he can go to any of four adjacent points (left, right, up, down). For example, if Maksim is currently ... | instruction | 0 | 67,280 | 15 | 134,560 |
No | output | 1 | 67,280 | 15 | 134,561 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Maksim walks on a Cartesian plane. Initially, he stands at the point (0, 0) and in one move he can go to any of four adjacent points (left, right, up, down). For example, if Maksim is currently ... | instruction | 0 | 67,281 | 15 | 134,562 |
No | output | 1 | 67,281 | 15 | 134,563 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Maksim walks on a Cartesian plane. Initially, he stands at the point (0, 0) and in one move he can go to any of four adjacent points (left, right, up, down). For example, if Maksim is currently ... | instruction | 0 | 67,282 | 15 | 134,564 |
No | output | 1 | 67,282 | 15 | 134,565 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are playing the game "Arranging The Sheep". The goal of this game is to make the sheep line up. The level in the game is described by a string of length n, consisting of the characters '.' (empty space) and '*' (sheep). In one move, you ... | instruction | 0 | 67,531 | 15 | 135,062 |
Tags: greedy, math
Correct Solution:
```
answers = []
def solve(n, s):
store = []
for i, ele in enumerate(s):
if ele == '*':
store.append(i)
length = len(store)
if length == 0:
answers.append(0)
return
median = None
if length % 2 == 0:
median = (store[length//2] + store[length/... | output | 1 | 67,531 | 15 | 135,063 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are playing the game "Arranging The Sheep". The goal of this game is to make the sheep line up. The level in the game is described by a string of length n, consisting of the characters '.' (empty space) and '*' (sheep). In one move, you ... | instruction | 0 | 67,532 | 15 | 135,064 |
Tags: greedy, math
Correct Solution:
```
import sys
import collections
import math
inf = sys.maxsize
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def get_array(): return list(map(int, sys.stdin.readline().strip().split()))
def input(): return sys.stdin.readline().strip()
mod =... | output | 1 | 67,532 | 15 | 135,065 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are playing the game "Arranging The Sheep". The goal of this game is to make the sheep line up. The level in the game is described by a string of length n, consisting of the characters '.' (empty space) and '*' (sheep). In one move, you ... | instruction | 0 | 67,533 | 15 | 135,066 |
Tags: greedy, math
Correct Solution:
```
t = int(input())
for _ in range(t):
n = int(input())
arr = [1 if i == '*' else 0 for i in input()]
ships = sum(arr)
left = 0
right = n - 1
ans = 0
i = 1
while (right - left > 0) and (ships >= 2):
ships -= 2
while arr[left] != ... | output | 1 | 67,533 | 15 | 135,067 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are playing the game "Arranging The Sheep". The goal of this game is to make the sheep line up. The level in the game is described by a string of length n, consisting of the characters '.' (empty space) and '*' (sheep). In one move, you ... | instruction | 0 | 67,534 | 15 | 135,068 |
Tags: greedy, math
Correct Solution:
```
"""
"""
import sys
from sys import stdin
tt = int(stdin.readline())
ANS = []
for loop in range(tt):
n = int(stdin.readline())
a = list(stdin.readline()[:-1])
m1 = None
m2 = None
alls = 0
for i in range(n):
if a[i] == "*":
alls ... | output | 1 | 67,534 | 15 | 135,069 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are playing the game "Arranging The Sheep". The goal of this game is to make the sheep line up. The level in the game is described by a string of length n, consisting of the characters '.' (empty space) and '*' (sheep). In one move, you ... | instruction | 0 | 67,535 | 15 | 135,070 |
Tags: greedy, math
Correct Solution:
```
import sys
input = sys.stdin.readline
def calc(x):
ANS=0
for i in range(len(B)):
ANS+=abs(B[i]-(x+i))
return ANS
t=int(input())
for tests in range(t):
n=int(input())
A=list(input().strip())
B=[]
for i in range(n):
if A[i]=="*":
... | output | 1 | 67,535 | 15 | 135,071 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are playing the game "Arranging The Sheep". The goal of this game is to make the sheep line up. The level in the game is described by a string of length n, consisting of the characters '.' (empty space) and '*' (sheep). In one move, you ... | instruction | 0 | 67,536 | 15 | 135,072 |
Tags: greedy, math
Correct Solution:
```
import math
test = int(input())
for t in range(test):
# n, k = map(int, input().split())
n = int(input())
# x = list(map(int, input().split()))
s = input()
x = []
for i in range(n):
if s[i]=="*":
x.append(i+1)
a = len(x)//2
y ... | output | 1 | 67,536 | 15 | 135,073 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are playing the game "Arranging The Sheep". The goal of this game is to make the sheep line up. The level in the game is described by a string of length n, consisting of the characters '.' (empty space) and '*' (sheep). In one move, you ... | instruction | 0 | 67,537 | 15 | 135,074 |
Tags: greedy, math
Correct Solution:
```
def solve():
# put code here
n=int(input())
s=input()
l=0
r=n-1
while l<n and s[l]=='.':
l+=1
while r>=0 and s[r]=='.':
r-=1
if l>=r:
print(0)
return
sr = s.count('*')
sl=0
ans=0
for k in ... | output | 1 | 67,537 | 15 | 135,075 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are playing the game "Arranging The Sheep". The goal of this game is to make the sheep line up. The level in the game is described by a string of length n, consisting of the characters '.' (empty space) and '*' (sheep). In one move, you ... | instruction | 0 | 67,538 | 15 | 135,076 |
Tags: greedy, math
Correct Solution:
```
"""
// Author : snape_here - Susanta Mukherjee
"""
from __future__ import division, print_function
import os,sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
from __builtin__ import xrange as range
from future_builtins import ascii, filter, hex,... | output | 1 | 67,538 | 15 | 135,077 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are playing the game "Arranging The Sheep". The goal of this game is to make the sheep line up. The level in the game is described by a string of length n, consisting of the characters '.' (... | instruction | 0 | 67,539 | 15 | 135,078 |
Yes | output | 1 | 67,539 | 15 | 135,079 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are playing the game "Arranging The Sheep". The goal of this game is to make the sheep line up. The level in the game is described by a string of length n, consisting of the characters '.' (... | instruction | 0 | 67,540 | 15 | 135,080 |
Yes | output | 1 | 67,540 | 15 | 135,081 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are playing the game "Arranging The Sheep". The goal of this game is to make the sheep line up. The level in the game is described by a string of length n, consisting of the characters '.' (... | instruction | 0 | 67,541 | 15 | 135,082 |
Yes | output | 1 | 67,541 | 15 | 135,083 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are playing the game "Arranging The Sheep". The goal of this game is to make the sheep line up. The level in the game is described by a string of length n, consisting of the characters '.' (... | instruction | 0 | 67,542 | 15 | 135,084 |
Yes | output | 1 | 67,542 | 15 | 135,085 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are playing the game "Arranging The Sheep". The goal of this game is to make the sheep line up. The level in the game is described by a string of length n, consisting of the characters '.' (... | instruction | 0 | 67,543 | 15 | 135,086 |
No | output | 1 | 67,543 | 15 | 135,087 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are playing the game "Arranging The Sheep". The goal of this game is to make the sheep line up. The level in the game is described by a string of length n, consisting of the characters '.' (... | instruction | 0 | 67,544 | 15 | 135,088 |
No | output | 1 | 67,544 | 15 | 135,089 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are playing the game "Arranging The Sheep". The goal of this game is to make the sheep line up. The level in the game is described by a string of length n, consisting of the characters '.' (... | instruction | 0 | 67,545 | 15 | 135,090 |
No | output | 1 | 67,545 | 15 | 135,091 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are playing the game "Arranging The Sheep". The goal of this game is to make the sheep line up. The level in the game is described by a string of length n, consisting of the characters '.' (... | instruction | 0 | 67,546 | 15 | 135,092 |
No | output | 1 | 67,546 | 15 | 135,093 |
Provide a correct Python 3 solution for this coding contest problem.
Takahashi and Aoki will play a game using a grid with H rows and W columns of square cells. There are N obstacles on this grid; the i-th obstacle is at (X_i,Y_i). Here, we represent the cell at the i-th row and j-th column (1 \leq i \leq H, 1 \leq j ... | instruction | 0 | 67,958 | 15 | 135,916 |
"Correct Solution:
```
H, W, N = map( int, input().split())
X = [ tuple( map( int, input().split())) for _ in range(N)]
X.sort()
d = 0
ans = H
for i in range(N):
if X[i][1]+d == X[i][0]:
d += 1
if X[i][1] + d < X[i][0]:
ans = X[i][0]-1
break
print(ans)
``` | output | 1 | 67,958 | 15 | 135,917 |
Provide a correct Python 3 solution for this coding contest problem.
Takahashi and Aoki will play a game using a grid with H rows and W columns of square cells. There are N obstacles on this grid; the i-th obstacle is at (X_i,Y_i). Here, we represent the cell at the i-th row and j-th column (1 \leq i \leq H, 1 \leq j ... | instruction | 0 | 67,959 | 15 | 135,918 |
"Correct Solution:
```
import sys
H,W,N = map(int,input().split())
ans = H
XY = []
now = 0
for i in range(N):
X,Y = map(int,input().split())
XY.append([X,Y])
XY.sort()
for i in range(N):
X = XY[i][0]
Y = XY[i][1]
if Y < X - now:
print (X-1)
sys.exit()
elif Y == X - n... | output | 1 | 67,959 | 15 | 135,919 |
Provide a correct Python 3 solution for this coding contest problem.
Takahashi and Aoki will play a game using a grid with H rows and W columns of square cells. There are N obstacles on this grid; the i-th obstacle is at (X_i,Y_i). Here, we represent the cell at the i-th row and j-th column (1 \leq i \leq H, 1 \leq j ... | instruction | 0 | 67,960 | 15 | 135,920 |
"Correct Solution:
```
import bisect
import os
import sys
if os.getenv("LOCAL"):
sys.stdin = open("_in.txt", "r")
sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353
H, W, N = list(map(int, sys.stdin.buffer.readline().split()))
XY = [list(map(int, sys.stdin.buff... | output | 1 | 67,960 | 15 | 135,921 |
Provide a correct Python 3 solution for this coding contest problem.
Takahashi and Aoki will play a game using a grid with H rows and W columns of square cells. There are N obstacles on this grid; the i-th obstacle is at (X_i,Y_i). Here, we represent the cell at the i-th row and j-th column (1 \leq i \leq H, 1 \leq j ... | instruction | 0 | 67,961 | 15 | 135,922 |
"Correct Solution:
```
X,Y,N = list(map(int,input().split()))
l = []
for i in range(N):
x,y = list(map(int,input().split()))
l.append([x,y])
l.sort()
cnt = 0
ans = 0
for i in l:
if i[0] > i[1]+cnt:
ans = i[0]
break
elif i[0] == i[1]+cnt:
cnt += 1
if ans != 0:
print(ans-1)
else:
print(X)
``... | output | 1 | 67,961 | 15 | 135,923 |
Provide a correct Python 3 solution for this coding contest problem.
Takahashi and Aoki will play a game using a grid with H rows and W columns of square cells. There are N obstacles on this grid; the i-th obstacle is at (X_i,Y_i). Here, we represent the cell at the i-th row and j-th column (1 \leq i \leq H, 1 \leq j ... | instruction | 0 | 67,962 | 15 | 135,924 |
"Correct Solution:
```
import sys
input = sys.stdin.readline
H, W, N = map(int, input().split())
A = [[] for _ in range(H+1)]
for _ in range(N):
X, Y = map(int, input().split())
A[X].append(Y)
ans = H
Ymax = 1
for n in range(1, H):
cango = True
for y in A[n+1]:
if y <= Ymax:
ans = ... | output | 1 | 67,962 | 15 | 135,925 |
Provide a correct Python 3 solution for this coding contest problem.
Takahashi and Aoki will play a game using a grid with H rows and W columns of square cells. There are N obstacles on this grid; the i-th obstacle is at (X_i,Y_i). Here, we represent the cell at the i-th row and j-th column (1 \leq i \leq H, 1 \leq j ... | instruction | 0 | 67,963 | 15 | 135,926 |
"Correct Solution:
```
H, W, N = map(int, input().split())
L = [list(map(int, input().split())) for i in range(N)]
dic = {}
for l in L:
try:
dic[l[0]].append(l[1])
except:
dic[l[0]] = [l[1]]
def get(H, N):
area = 1.
for i in range(1, H):
try:
for block in sorted(dic[i+1]):
if 1 <= bloc... | output | 1 | 67,963 | 15 | 135,927 |
Provide a correct Python 3 solution for this coding contest problem.
Takahashi and Aoki will play a game using a grid with H rows and W columns of square cells. There are N obstacles on this grid; the i-th obstacle is at (X_i,Y_i). Here, we represent the cell at the i-th row and j-th column (1 \leq i \leq H, 1 \leq j ... | instruction | 0 | 67,964 | 15 | 135,928 |
"Correct Solution:
```
H, W, N = map(int, input().split())
posObss = [{H} for y in range(W)]
for _ in range(N):
X, Y = map(int, input().split())
posObss[Y - 1].add(X - 1)
ans = H
xNow = 0
for y in range(W):
xLim = min([x for x in posObss[y] if x > xNow])
ans = min(ans, xLim)
if y == W - 1: break
... | output | 1 | 67,964 | 15 | 135,929 |
Provide a correct Python 3 solution for this coding contest problem.
Takahashi and Aoki will play a game using a grid with H rows and W columns of square cells. There are N obstacles on this grid; the i-th obstacle is at (X_i,Y_i). Here, we represent the cell at the i-th row and j-th column (1 \leq i \leq H, 1 \leq j ... | instruction | 0 | 67,965 | 15 | 135,930 |
"Correct Solution:
```
#設定
import sys
input = sys.stdin.buffer.readline
#ライブラリインポート
from collections import defaultdict
INF = float("inf")
#入力受け取り
def getlist():
return list(map(int, input().split()))
#処理内容
def main():
H, W, N = getlist()
L = []
for i in range(N):
x, y = getlist()
L.append((x, y))
L = sorte... | output | 1 | 67,965 | 15 | 135,931 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Takahashi and Aoki will play a game using a grid with H rows and W columns of square cells. There are N obstacles on this grid; the i-th obstacle is at (X_i,Y_i). Here, we represent the cell at ... | instruction | 0 | 67,966 | 15 | 135,932 |
Yes | output | 1 | 67,966 | 15 | 135,933 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Takahashi and Aoki will play a game using a grid with H rows and W columns of square cells. There are N obstacles on this grid; the i-th obstacle is at (X_i,Y_i). Here, we represent the cell at ... | instruction | 0 | 67,967 | 15 | 135,934 |
Yes | output | 1 | 67,967 | 15 | 135,935 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Takahashi and Aoki will play a game using a grid with H rows and W columns of square cells. There are N obstacles on this grid; the i-th obstacle is at (X_i,Y_i). Here, we represent the cell at ... | instruction | 0 | 67,968 | 15 | 135,936 |
Yes | output | 1 | 67,968 | 15 | 135,937 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Takahashi and Aoki will play a game using a grid with H rows and W columns of square cells. There are N obstacles on this grid; the i-th obstacle is at (X_i,Y_i). Here, we represent the cell at ... | instruction | 0 | 67,969 | 15 | 135,938 |
Yes | output | 1 | 67,969 | 15 | 135,939 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Takahashi and Aoki will play a game using a grid with H rows and W columns of square cells. There are N obstacles on this grid; the i-th obstacle is at (X_i,Y_i). Here, we represent the cell at ... | instruction | 0 | 67,970 | 15 | 135,940 |
No | output | 1 | 67,970 | 15 | 135,941 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Takahashi and Aoki will play a game using a grid with H rows and W columns of square cells. There are N obstacles on this grid; the i-th obstacle is at (X_i,Y_i). Here, we represent the cell at ... | instruction | 0 | 67,971 | 15 | 135,942 |
No | output | 1 | 67,971 | 15 | 135,943 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Takahashi and Aoki will play a game using a grid with H rows and W columns of square cells. There are N obstacles on this grid; the i-th obstacle is at (X_i,Y_i). Here, we represent the cell at ... | instruction | 0 | 67,972 | 15 | 135,944 |
No | output | 1 | 67,972 | 15 | 135,945 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Takahashi and Aoki will play a game using a grid with H rows and W columns of square cells. There are N obstacles on this grid; the i-th obstacle is at (X_i,Y_i). Here, we represent the cell at ... | instruction | 0 | 67,973 | 15 | 135,946 |
No | output | 1 | 67,973 | 15 | 135,947 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Alice and Bob are playing a game on a line with n cells. There are n cells labeled from 1 through n. For each i from 1 to n-1, cells i and i+1 are adjacent.
Alice initially has a token on some cell on the line, and Bob tries to guess where ... | instruction | 0 | 68,193 | 15 | 136,386 |
Tags: graphs
Correct Solution:
```
N, K = map(int, input().split())
X = list(map(lambda x: int(x) - 1, input().split()))
inf = 10**9+7
Fi = [inf]*N
La = [-1]*N
for i, x in enumerate(X):
Fi[x] = min(Fi[x], i)
for i, x in enumerate(X[::-1]):
La[x] = max(La[x], K-1-i)
ans = sum(1 if l < 0 else 0 for l in La)
for i... | output | 1 | 68,193 | 15 | 136,387 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Alice and Bob are playing a game on a line with n cells. There are n cells labeled from 1 through n. For each i from 1 to n-1, cells i and i+1 are adjacent.
Alice initially has a token on some cell on the line, and Bob tries to guess where ... | instruction | 0 | 68,194 | 15 | 136,388 |
Tags: graphs
Correct Solution:
```
def main():
n, k = map(int, input().split())
x = list(map(int, input().split()))
minus1 = [False] * (k+1)
plus1 = [False] * (k+1)
dminus1 = {}
dplus1 = {}
for i, val in enumerate(x):
if val < n and val+1 in dminus1:
for ind in dminus1[v... | output | 1 | 68,194 | 15 | 136,389 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Alice and Bob are playing a game on a line with n cells. There are n cells labeled from 1 through n. For each i from 1 to n-1, cells i and i+1 are adjacent.
Alice initially has a token on some cell on the line, and Bob tries to guess where ... | instruction | 0 | 68,195 | 15 | 136,390 |
Tags: graphs
Correct Solution:
```
n, k = map(int, input().split())
q = list(map(int, input().split()))
seen = [False]*(n+2)
cnt = (n-2)*3+2*2
impossible = set()
for x in q:
seen[x] = True
impossible.add((x,x))
if seen[x-1]: impossible.add((x, x-1))
if seen[x+1]: impossible.add((x, x+1))
print(cnt-len(i... | output | 1 | 68,195 | 15 | 136,391 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Alice and Bob are playing a game on a line with n cells. There are n cells labeled from 1 through n. For each i from 1 to n-1, cells i and i+1 are adjacent.
Alice initially has a token on some cell on the line, and Bob tries to guess where ... | instruction | 0 | 68,196 | 15 | 136,392 |
Tags: graphs
Correct Solution:
```
import math
import bisect
import heapq
from collections import defaultdict
def egcd(a, b):
if a == 0:
return (b, 0, 1)
else:
g, x, y = egcd(b % a, a)
return (g, y - (b // a) * x, x)
def mulinv(b, n):
g, x, _ = egcd(b, n)
if g == 1:
r... | output | 1 | 68,196 | 15 | 136,393 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Alice and Bob are playing a game on a line with n cells. There are n cells labeled from 1 through n. For each i from 1 to n-1, cells i and i+1 are adjacent.
Alice initially has a token on some cell on the line, and Bob tries to guess where ... | instruction | 0 | 68,197 | 15 | 136,394 |
Tags: graphs
Correct Solution:
```
from collections import defaultdict, deque
from heapq import heappush, heappop
from math import inf
ri = lambda : map(int, input().split())
def solve():
n, k = ri()
fst = [inf] * n
lst = [-inf] * n
A = list(ri())
for i in range(k):
x = A[i]
x -= 1... | output | 1 | 68,197 | 15 | 136,395 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Alice and Bob are playing a game on a line with n cells. There are n cells labeled from 1 through n. For each i from 1 to n-1, cells i and i+1 are adjacent.
Alice initially has a token on some cell on the line, and Bob tries to guess where ... | instruction | 0 | 68,198 | 15 | 136,396 |
Tags: graphs
Correct Solution:
```
from math import *
from collections import *
from bisect import *
import sys
input=sys.stdin.readline
t=1
while(t):
t-=1
n,k=map(int,input().split())
a=list(map(int,input().split()))
vis=set()
for i in a:
vis.add((i,i))
if((i-1,i-1) in vis):
... | output | 1 | 68,198 | 15 | 136,397 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.