message
stringlengths
2
65.1k
message_type
stringclasses
2 values
message_id
int64
0
1
conversation_id
int64
0
108k
cluster
float64
14
14
__index_level_0__
int64
0
217k
Provide tags and a correct Python 3 solution for this coding contest problem. Pashmak decided to give Parmida a pair of flowers from the garden. There are n flowers in the garden and the i-th of them has a beauty number bi. Parmida is a very strange girl so she doesn't want to have the two most beautiful flowers neces...
instruction
0
93,039
14
186,078
Tags: combinatorics, implementation, sortings Correct Solution: ``` def pashmak(a): ma=max(a) mi=min(a) c1=a.count(ma) c2=a.count(mi) if ma==mi: return ma-mi,c1*(c1-1)//2 return ma-mi,c1*c2 t=int(input()) a=list(map(int,input().split(" "))) alpha,beta=pashmak(a) print(alpha,beta) ...
output
1
93,039
14
186,079
Provide tags and a correct Python 3 solution for this coding contest problem. Pashmak decided to give Parmida a pair of flowers from the garden. There are n flowers in the garden and the i-th of them has a beauty number bi. Parmida is a very strange girl so she doesn't want to have the two most beautiful flowers neces...
instruction
0
93,040
14
186,080
Tags: combinatorics, implementation, sortings Correct Solution: ``` def count_flowers(flowers): flowers.sort() if flowers[0] == flowers[-1]: l = len(flowers) return 0, int(l*(l-1)/2) left_part = right_part = 1 while flowers[left_part] == flowers[0]: left_part += 1 while flowe...
output
1
93,040
14
186,081
Provide tags and a correct Python 3 solution for this coding contest problem. Pashmak decided to give Parmida a pair of flowers from the garden. There are n flowers in the garden and the i-th of them has a beauty number bi. Parmida is a very strange girl so she doesn't want to have the two most beautiful flowers neces...
instruction
0
93,041
14
186,082
Tags: combinatorics, implementation, sortings Correct Solution: ``` from sys import stdin ##################################################################### def iinput(): return int(stdin.readline()) def minput(): return map(int, stdin.readline().split()) def linput(): return list(map(int, stdin.readline().split()))...
output
1
93,041
14
186,083
Provide tags and a correct Python 3 solution for this coding contest problem. Pashmak decided to give Parmida a pair of flowers from the garden. There are n flowers in the garden and the i-th of them has a beauty number bi. Parmida is a very strange girl so she doesn't want to have the two most beautiful flowers neces...
instruction
0
93,042
14
186,084
Tags: combinatorics, implementation, sortings Correct Solution: ``` from math import factorial n=int(input()) l= input() l=[int(i) for i in l.split()] if max(l)!=min(l): y=max(l) - min(l) r = l.count(max(l)) *l.count(min(l)) print(y,r) else: y=max(l) - min(l) i = ((l.count(max(l))-1) * l.count(ma...
output
1
93,042
14
186,085
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Pashmak decided to give Parmida a pair of flowers from the garden. There are n flowers in the garden and the i-th of them has a beauty number bi. Parmida is a very strange girl so she doesn't wa...
instruction
0
93,043
14
186,086
Yes
output
1
93,043
14
186,087
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Pashmak decided to give Parmida a pair of flowers from the garden. There are n flowers in the garden and the i-th of them has a beauty number bi. Parmida is a very strange girl so she doesn't wa...
instruction
0
93,044
14
186,088
Yes
output
1
93,044
14
186,089
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Pashmak decided to give Parmida a pair of flowers from the garden. There are n flowers in the garden and the i-th of them has a beauty number bi. Parmida is a very strange girl so she doesn't wa...
instruction
0
93,045
14
186,090
Yes
output
1
93,045
14
186,091
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Pashmak decided to give Parmida a pair of flowers from the garden. There are n flowers in the garden and the i-th of them has a beauty number bi. Parmida is a very strange girl so she doesn't wa...
instruction
0
93,046
14
186,092
Yes
output
1
93,046
14
186,093
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Pashmak decided to give Parmida a pair of flowers from the garden. There are n flowers in the garden and the i-th of them has a beauty number bi. Parmida is a very strange girl so she doesn't wa...
instruction
0
93,047
14
186,094
No
output
1
93,047
14
186,095
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Pashmak decided to give Parmida a pair of flowers from the garden. There are n flowers in the garden and the i-th of them has a beauty number bi. Parmida is a very strange girl so she doesn't wa...
instruction
0
93,048
14
186,096
No
output
1
93,048
14
186,097
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Pashmak decided to give Parmida a pair of flowers from the garden. There are n flowers in the garden and the i-th of them has a beauty number bi. Parmida is a very strange girl so she doesn't wa...
instruction
0
93,049
14
186,098
No
output
1
93,049
14
186,099
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Pashmak decided to give Parmida a pair of flowers from the garden. There are n flowers in the garden and the i-th of them has a beauty number bi. Parmida is a very strange girl so she doesn't wa...
instruction
0
93,050
14
186,100
No
output
1
93,050
14
186,101
Provide tags and a correct Python 3 solution for this coding contest problem. If you have ever interacted with a cat, you have probably noticed that they are quite particular about how to pet them. Here is an approximate map of a normal cat. <image> However, some cats won't tolerate this nonsense from the humans. He...
instruction
0
93,218
14
186,436
Tags: brute force, interactive Correct Solution: ``` print('grumpy' if input('9\n')in['go die in a hole','are you serious?','terrible','worse','no way',"don't even"] else 'normal') # Made By Mostafa_Khaled ```
output
1
93,218
14
186,437
Provide tags and a correct Python 3 solution for this coding contest problem. If you have ever interacted with a cat, you have probably noticed that they are quite particular about how to pet them. Here is an approximate map of a normal cat. <image> However, some cats won't tolerate this nonsense from the humans. He...
instruction
0
93,219
14
186,438
Tags: brute force, interactive Correct Solution: ``` for i in range(10): print(i) t = input().strip() if t == "no": continue if t in {"don't even", "are you serious", "worse", "terrible", "go die in a hole", "no way"}: print("grumpy") else: print("normal") break ```
output
1
93,219
14
186,439
Provide tags and a correct Python 3 solution for this coding contest problem. If you have ever interacted with a cat, you have probably noticed that they are quite particular about how to pet them. Here is an approximate map of a normal cat. <image> However, some cats won't tolerate this nonsense from the humans. He...
instruction
0
93,220
14
186,440
Tags: brute force, interactive Correct Solution: ``` no = 0 for i in range (10): print(i) inp = input() if inp == "no": no += 1 if no == 4: exit(print("normal")) continue if inp == "cool" or inp == "don't think so" or inp == "not bad" or inp == "don't touch me" or in...
output
1
93,220
14
186,441
Provide tags and a correct Python 3 solution for this coding contest problem. If you have ever interacted with a cat, you have probably noticed that they are quite particular about how to pet them. Here is an approximate map of a normal cat. <image> However, some cats won't tolerate this nonsense from the humans. He...
instruction
0
93,221
14
186,442
Tags: brute force, interactive Correct Solution: ``` print(9) s = input() sk = ["go die in a hole", "are you serious?", "terrible", "worse", "no way", "don't even"] print("grumpy" if s in sk else "normal") ```
output
1
93,221
14
186,443
Provide tags and a correct Python 3 solution for this coding contest problem. There are n computers in the company network. They are numbered from 1 to n. For each pair of two computers 1 ≤ i < j ≤ n you know the value a_{i,j}: the difficulty of sending data between computers i and j. All values a_{i,j} for i<j are d...
instruction
0
93,682
14
187,364
Tags: combinatorics, dp, dsu, fft, graphs, trees Correct Solution: ``` # import itertools as it # import functools as ft import math teststring = """4 0 3 4 6 3 0 2 1 4 2 0 5 6 1 5 0 """ online = __file__ != "/home/jhli/py/Grakn/Problem_G2.py" true, false = True, False if True: def spitout(): for c in te...
output
1
93,682
14
187,365
Provide tags and a correct Python 3 solution for this coding contest problem. At the beginning of the new semester there is new schedule in the Berland State University. According to this schedule, n groups have lessons at the room 31. For each group the starting time of the lesson and the finishing time of the lesson...
instruction
0
93,807
14
187,614
Tags: implementation Correct Solution: ``` def get_input(): sections = [] n = int(input()) for i in range(n): l, r = map(int, input().split()) sections.append((l, r)) return n, sections def counting_sections_for_numbers(n, sections, count_of_numbers): count_section_for_numbers = [...
output
1
93,807
14
187,615
Provide tags and a correct Python 3 solution for this coding contest problem. At the beginning of the new semester there is new schedule in the Berland State University. According to this schedule, n groups have lessons at the room 31. For each group the starting time of the lesson and the finishing time of the lesson...
instruction
0
93,808
14
187,616
Tags: implementation Correct Solution: ``` class Event: def __init__(self, span_id, point, open=False, close=False): self.span_id, self.point = span_id, point self.open, self.close = open, close self.sort_key = 2 * point + (1 if open else 0) self.count = 0 class Span: def __init...
output
1
93,808
14
187,617
Provide tags and a correct Python 3 solution for this coding contest problem. At the beginning of the new semester there is new schedule in the Berland State University. According to this schedule, n groups have lessons at the room 31. For each group the starting time of the lesson and the finishing time of the lesson...
instruction
0
93,809
14
187,618
Tags: implementation Correct Solution: ``` from operator import add import sys from array import array # noqa: F401 from typing import TypeVar, Generic, Callable, List T = TypeVar('T') class SegmentTree(Generic[T]): __slots__ = ["size", "tree", "identity", "op", "update_op"] def __init__(self, size: int, id...
output
1
93,809
14
187,619
Provide tags and a correct Python 3 solution for this coding contest problem. At the beginning of the new semester there is new schedule in the Berland State University. According to this schedule, n groups have lessons at the room 31. For each group the starting time of the lesson and the finishing time of the lesson...
instruction
0
93,810
14
187,620
Tags: implementation Correct Solution: ``` n=int(input()) a=sorted([list(map(int,input().split()))+[i+1] for i in range(n)]) b=[] d=[] c=0 for j in range(n-1): if a[j][1]>a[j+1][0]: d.append(False) c+=1 else: d.append(True) if c==0: b=list(range(1,n+1)) elif c==1: for i in range(...
output
1
93,810
14
187,621
Provide tags and a correct Python 3 solution for this coding contest problem. At the beginning of the new semester there is new schedule in the Berland State University. According to this schedule, n groups have lessons at the room 31. For each group the starting time of the lesson and the finishing time of the lesson...
instruction
0
93,811
14
187,622
Tags: implementation Correct Solution: ``` a=int(input()) ans=[] for i in range(a): x,y=map(int,input().split()) ans.append([x,y,i+1]) ans.sort() fin=[] for i in range(len(ans)): start=-1 end=0 flag=0 for j in range(len(ans)): if(j==i): continue; else: if(...
output
1
93,811
14
187,623
Provide tags and a correct Python 3 solution for this coding contest problem. At the beginning of the new semester there is new schedule in the Berland State University. According to this schedule, n groups have lessons at the room 31. For each group the starting time of the lesson and the finishing time of the lesson...
instruction
0
93,812
14
187,624
Tags: implementation Correct Solution: ``` n = int(input()) A = [] for j in range(1, n+1): tmp = [int(i) for i in input().split()] A.append(tmp + [j]) A = sorted(A) # sort by starting time ans=[] for i in range(1,n+1): flag = True mov_right = 0 for j in range(n): if i == A[j][2]: # current i...
output
1
93,812
14
187,625
Provide tags and a correct Python 3 solution for this coding contest problem. At the beginning of the new semester there is new schedule in the Berland State University. According to this schedule, n groups have lessons at the room 31. For each group the starting time of the lesson and the finishing time of the lesson...
instruction
0
93,813
14
187,626
Tags: implementation Correct Solution: ``` groups = [] overlapping = {} append = groups.append for notused in range(int(input())): append(list(map(int, input().split(" ")))) for i in range(len(groups)-1): if groups[-1][0] > groups[i][0] and groups[-1][0] < groups[i][1] or groups[-1][1] > groups[i][0] and groups[-1]...
output
1
93,813
14
187,627
Provide tags and a correct Python 3 solution for this coding contest problem. At the beginning of the new semester there is new schedule in the Berland State University. According to this schedule, n groups have lessons at the room 31. For each group the starting time of the lesson and the finishing time of the lesson...
instruction
0
93,814
14
187,628
Tags: implementation Correct Solution: ``` n = int(input()) c=0 l=[] for i in range(1,n+1): a , b = map(int,input().split()) l.append([a,b,i]) l.sort() #print(l) right=0 ans=[] for i in range(1,n+1): k=1 right=0 for j in range(n): if i==l[j][2]: continue if l[j][0]< right...
output
1
93,814
14
187,629
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. At the beginning of the new semester there is new schedule in the Berland State University. According to this schedule, n groups have lessons at the room 31. For each group the starting time of ...
instruction
0
93,816
14
187,632
No
output
1
93,816
14
187,633
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. At the beginning of the new semester there is new schedule in the Berland State University. According to this schedule, n groups have lessons at the room 31. For each group the starting time of ...
instruction
0
93,818
14
187,636
No
output
1
93,818
14
187,637
Provide tags and a correct Python 3 solution for this coding contest problem. Arseny likes to organize parties and invite people to it. However, not only friends come to his parties, but friends of his friends, friends of friends of his friends and so on. That's why some of Arseny's guests can be unknown to him. He de...
instruction
0
94,102
14
188,204
Tags: bitmasks, brute force, dp, graphs Correct Solution: ``` from collections import defaultdict def count(x): c=0 while x > 0: c+=1 x &= (x-1) return c n,m=map(int,input().split()) g=defaultdict(list) for _ in range(m): u, v = map(int,input().split()) u-=1;v-=1 g[u].append(v) ...
output
1
94,102
14
188,205
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Arseny likes to organize parties and invite people to it. However, not only friends come to his parties, but friends of his friends, friends of friends of his friends and so on. That's why some ...
instruction
0
94,103
14
188,206
No
output
1
94,103
14
188,207
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Arseny likes to organize parties and invite people to it. However, not only friends come to his parties, but friends of his friends, friends of friends of his friends and so on. That's why some ...
instruction
0
94,104
14
188,208
No
output
1
94,104
14
188,209
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Arseny likes to organize parties and invite people to it. However, not only friends come to his parties, but friends of his friends, friends of friends of his friends and so on. That's why some ...
instruction
0
94,105
14
188,210
No
output
1
94,105
14
188,211
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Arseny likes to organize parties and invite people to it. However, not only friends come to his parties, but friends of his friends, friends of friends of his friends and so on. That's why some ...
instruction
0
94,106
14
188,212
No
output
1
94,106
14
188,213
Provide tags and a correct Python 3 solution for this coding contest problem. Sereja and his friends went to a picnic. The guys had n soda bottles just for it. Sereja forgot the bottle opener as usual, so the guys had to come up with another way to open bottles. Sereja knows that the i-th bottle is from brand ai, bes...
instruction
0
94,695
14
189,390
Tags: brute force Correct Solution: ``` n = int(input()) a = [] b=[] freq={} for i in range(n): ai,bi = [int(x) for x in input().split()] a.append(ai) b.append(bi) if bi not in freq: freq[bi] = 0 freq[bi] +=1 #No of bottles than can be used to open bi ans= n for i in range(n): #a[i]#can be used to open bottle...
output
1
94,695
14
189,391
Provide tags and a correct Python 3 solution for this coding contest problem. Sereja and his friends went to a picnic. The guys had n soda bottles just for it. Sereja forgot the bottle opener as usual, so the guys had to come up with another way to open bottles. Sereja knows that the i-th bottle is from brand ai, bes...
instruction
0
94,696
14
189,392
Tags: brute force Correct Solution: ``` n=int(input()) arr=[] rra=[] for i in range (n): z=list(map(int,input().split())) rra.append(z[0]) arr.append(z[1]) count=0 for i in range(n) : temp=arr[i] indexx=i arr.remove(temp) if rra[i] in arr : arr.insert(indexx,temp) else : ...
output
1
94,696
14
189,393
Provide tags and a correct Python 3 solution for this coding contest problem. Sereja and his friends went to a picnic. The guys had n soda bottles just for it. Sereja forgot the bottle opener as usual, so the guys had to come up with another way to open bottles. Sereja knows that the i-th bottle is from brand ai, bes...
instruction
0
94,697
14
189,394
Tags: brute force Correct Solution: ``` import sys,math from collections import deque,defaultdict import operator as op from functools import reduce from itertools import permutations #sys.setrecursionlimit(10**6) I=sys.stdin.readline #alpha="abcdefghijklmnopqrstuvwxyz" """ x_move=[-1,0,1,0,-1,1,1,-1] y_move=[0,1,...
output
1
94,697
14
189,395
Provide tags and a correct Python 3 solution for this coding contest problem. Sereja and his friends went to a picnic. The guys had n soda bottles just for it. Sereja forgot the bottle opener as usual, so the guys had to come up with another way to open bottles. Sereja knows that the i-th bottle is from brand ai, bes...
instruction
0
94,698
14
189,396
Tags: brute force Correct Solution: ``` n = int(input()) a, b = [], [] for i in range(n): l, m = input().split() a.append(int(l)) b.append(int(m)) count = 0 for i in range(n): for j in range(n): if b[j] == a[i] and i != j: count += 1 break print(n - count) ```
output
1
94,698
14
189,397
Provide tags and a correct Python 3 solution for this coding contest problem. Sereja and his friends went to a picnic. The guys had n soda bottles just for it. Sereja forgot the bottle opener as usual, so the guys had to come up with another way to open bottles. Sereja knows that the i-th bottle is from brand ai, bes...
instruction
0
94,699
14
189,398
Tags: brute force Correct Solution: ``` #A. Sereja and Bottles n = int(input()) a = [] b = [] for _ in range(n): x,y = map(int,input().split()) a.append(x) b.append(y) total = n for i in range(n): for j in range(n): if i!=j and a[i]==b[j]: total -= 1 break print(total) ``...
output
1
94,699
14
189,399
Provide tags and a correct Python 3 solution for this coding contest problem. Sereja and his friends went to a picnic. The guys had n soda bottles just for it. Sereja forgot the bottle opener as usual, so the guys had to come up with another way to open bottles. Sereja knows that the i-th bottle is from brand ai, bes...
instruction
0
94,700
14
189,400
Tags: brute force Correct Solution: ``` n=int(input()) l=[list(map(int,input().split())) for i in range(n)] c=0 for i in range(n): temp=0 for j in range(n): if l[i][0]==l[j][1] and i!=j:temp+=1 if temp==0:c+=1 print(c) ```
output
1
94,700
14
189,401
Provide tags and a correct Python 3 solution for this coding contest problem. Sereja and his friends went to a picnic. The guys had n soda bottles just for it. Sereja forgot the bottle opener as usual, so the guys had to come up with another way to open bottles. Sereja knows that the i-th bottle is from brand ai, bes...
instruction
0
94,701
14
189,402
Tags: brute force Correct Solution: ``` import sys from functools import reduce from collections import Counter import time import datetime from math import sqrt,gcd # def time_t(): # print("Current date and time: " , datetime.datetime.now()) # print("Current year: ", datetime.date.today().strftime("%Y")) # ...
output
1
94,701
14
189,403
Provide tags and a correct Python 3 solution for this coding contest problem. Sereja and his friends went to a picnic. The guys had n soda bottles just for it. Sereja forgot the bottle opener as usual, so the guys had to come up with another way to open bottles. Sereja knows that the i-th bottle is from brand ai, bes...
instruction
0
94,702
14
189,404
Tags: brute force Correct Solution: ``` import re in1 = int(input()) count = 0 bto = [] bco = [] conA = [] conB = [] for _ in range(in1): inX = [int(x) for x in re.split("\\s", input())] if inX[0] != inX[1]: bto.append(inX[0]) bco.append(inX[1]) else: if inX[0] not in conA: ...
output
1
94,702
14
189,405
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Sereja and his friends went to a picnic. The guys had n soda bottles just for it. Sereja forgot the bottle opener as usual, so the guys had to come up with another way to open bottles. Sereja k...
instruction
0
94,703
14
189,406
Yes
output
1
94,703
14
189,407
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Sereja and his friends went to a picnic. The guys had n soda bottles just for it. Sereja forgot the bottle opener as usual, so the guys had to come up with another way to open bottles. Sereja k...
instruction
0
94,704
14
189,408
Yes
output
1
94,704
14
189,409
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Sereja and his friends went to a picnic. The guys had n soda bottles just for it. Sereja forgot the bottle opener as usual, so the guys had to come up with another way to open bottles. Sereja k...
instruction
0
94,705
14
189,410
Yes
output
1
94,705
14
189,411
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Sereja and his friends went to a picnic. The guys had n soda bottles just for it. Sereja forgot the bottle opener as usual, so the guys had to come up with another way to open bottles. Sereja k...
instruction
0
94,707
14
189,414
No
output
1
94,707
14
189,415
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Little Artem is fond of dancing. Most of all dances Artem likes rueda — Cuban dance that is danced by pairs of boys and girls forming a circle and dancing together. More detailed, there are n p...
instruction
0
94,854
14
189,708
No
output
1
94,854
14
189,709
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Little Artem is fond of dancing. Most of all dances Artem likes rueda — Cuban dance that is danced by pairs of boys and girls forming a circle and dancing together. More detailed, there are n p...
instruction
0
94,856
14
189,712
No
output
1
94,856
14
189,713
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Little Artem is fond of dancing. Most of all dances Artem likes rueda — Cuban dance that is danced by pairs of boys and girls forming a circle and dancing together. More detailed, there are n p...
instruction
0
94,857
14
189,714
No
output
1
94,857
14
189,715
Provide tags and a correct Python 3 solution for this coding contest problem. There are n walruses standing in a queue in an airport. They are numbered starting from the queue's tail: the 1-st walrus stands at the end of the queue and the n-th walrus stands at the beginning of the queue. The i-th walrus has the age eq...
instruction
0
94,991
14
189,982
Tags: binary search, data structures Correct Solution: ``` def displeasure(wal_arr): wal_arr = sorted(wal_arr) highest_ind = -1 ret_arr = [-1] * len(wal_arr) for wal in wal_arr: if wal[1] < highest_ind: ret_arr[wal[1]] = highest_ind - wal[1] - 1 highest_ind = max(highest_in...
output
1
94,991
14
189,983
Provide tags and a correct Python 3 solution for this coding contest problem. There are n walruses standing in a queue in an airport. They are numbered starting from the queue's tail: the 1-st walrus stands at the end of the queue and the n-th walrus stands at the beginning of the queue. The i-th walrus has the age eq...
instruction
0
94,992
14
189,984
Tags: binary search, data structures Correct Solution: ``` n = int(input()) A = list(map(int,input().split())) B = [0]*len(A) # список ответов C = [[0]*3 for i in range(len(A))] # хранить мин элементы, индекс текущего и предыдущего минимума B[-1] = -1 C[-1][0] = A[-1] C[-1][1] = len(A)-1 C[-1][2] = len(A) # за ...
output
1
94,992
14
189,985
Provide tags and a correct Python 3 solution for this coding contest problem. There are n walruses standing in a queue in an airport. They are numbered starting from the queue's tail: the 1-st walrus stands at the end of the queue and the n-th walrus stands at the beginning of the queue. The i-th walrus has the age eq...
instruction
0
94,993
14
189,986
Tags: binary search, data structures Correct Solution: ``` n = int(input()) a = list(map(int,input().split(' '))) ans = [0]*(n) def bsearch(i,l,h): pos = -1 while(h>=l): mid = (l+h)//2 if a[mid]<a[i]: pos = mid l = mid+1 else: h = mid-1 if pos!=-1:...
output
1
94,993
14
189,987