message
stringlengths
2
433k
message_type
stringclasses
2 values
message_id
int64
0
1
conversation_id
int64
113
108k
cluster
float64
12
12
__index_level_0__
int64
226
217k
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. For a permutation P[1... N] of integers from 1 to N, function f is defined as follows: <image> Let g(i) be the minimum positive integer j such that f(i, j) = i. We can show such j always exist...
instruction
0
4,778
12
9,556
Yes
output
1
4,778
12
9,557
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. For a permutation P[1... N] of integers from 1 to N, function f is defined as follows: <image> Let g(i) be the minimum positive integer j such that f(i, j) = i. We can show such j always exist...
instruction
0
4,779
12
9,558
No
output
1
4,779
12
9,559
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. For a permutation P[1... N] of integers from 1 to N, function f is defined as follows: <image> Let g(i) be the minimum positive integer j such that f(i, j) = i. We can show such j always exist...
instruction
0
4,780
12
9,560
No
output
1
4,780
12
9,561
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. For a permutation P[1... N] of integers from 1 to N, function f is defined as follows: <image> Let g(i) be the minimum positive integer j such that f(i, j) = i. We can show such j always exist...
instruction
0
4,781
12
9,562
No
output
1
4,781
12
9,563
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. For a permutation P[1... N] of integers from 1 to N, function f is defined as follows: <image> Let g(i) be the minimum positive integer j such that f(i, j) = i. We can show such j always exist...
instruction
0
4,782
12
9,564
No
output
1
4,782
12
9,565
Provide tags and a correct Python 3 solution for this coding contest problem. Petr likes to come up with problems about randomly generated data. This time problem is about random permutation. He decided to generate a random permutation this way: he takes identity permutation of numbers from 1 to n and then 3n times ta...
instruction
0
4,792
12
9,584
Tags: combinatorics, math Correct Solution: ``` n=int(input()) a=list(map(int,input().split())) if sum(a[i]==i+1 for i in range(n))>=n//1000:print("Petr") else:print("Um_nik") ```
output
1
4,792
12
9,585
Provide tags and a correct Python 3 solution for this coding contest problem. Petr likes to come up with problems about randomly generated data. This time problem is about random permutation. He decided to generate a random permutation this way: he takes identity permutation of numbers from 1 to n and then 3n times ta...
instruction
0
4,793
12
9,586
Tags: combinatorics, math Correct Solution: ``` input() a=list(map(int,input().split())) n=len(a) u=n for i in range(n): j=i k=0 while a[j]>0: k+=1 t=j j=a[j]-1 a[t]=0 if k>0: u+=1-k%2 s='Petr' if u%2>0: s='Um_nik' print(s) ```
output
1
4,793
12
9,587
Provide tags and a correct Python 3 solution for this coding contest problem. Petr likes to come up with problems about randomly generated data. This time problem is about random permutation. He decided to generate a random permutation this way: he takes identity permutation of numbers from 1 to n and then 3n times ta...
instruction
0
4,794
12
9,588
Tags: combinatorics, math Correct Solution: ``` #!/usr/bin/env python3 n = int(input().strip()) ais = list(map(int, input().strip().split())) visited = [False for _ in range(n)] parity = 0 for i in range(n): if not visited[i]: parity += 1 j = i while not visited[j]: visited[j] = True j = ais[j] - 1 if ...
output
1
4,794
12
9,589
Provide tags and a correct Python 3 solution for this coding contest problem. Petr likes to come up with problems about randomly generated data. This time problem is about random permutation. He decided to generate a random permutation this way: he takes identity permutation of numbers from 1 to n and then 3n times ta...
instruction
0
4,795
12
9,590
Tags: combinatorics, math Correct Solution: ``` n = int( input() ) a = list( map( lambda x: int( x )-1, input().split( ' ' ) ) ) ret = True for i in range( n ): if a[i]==-1: continue x, ret = i, not ret while a[x]!=i: a[x], x = -1, a[x] a[x] = -1 if ret: print( "Petr" ) else: print( "Um_nik" )...
output
1
4,795
12
9,591
Provide tags and a correct Python 3 solution for this coding contest problem. Petr likes to come up with problems about randomly generated data. This time problem is about random permutation. He decided to generate a random permutation this way: he takes identity permutation of numbers from 1 to n and then 3n times ta...
instruction
0
4,796
12
9,592
Tags: combinatorics, math Correct Solution: ``` n = int(input()) u = list(map(int, input().split())) for i in range(n): u[i] -= 1 ans = 0 for i in range(n): if u[i] == -1: continue ans = 1 - ans x = i while x >= 0: y = u[x] u[x] = -1 x = y if ans: print('Um_nik') ...
output
1
4,796
12
9,593
Provide tags and a correct Python 3 solution for this coding contest problem. Petr likes to come up with problems about randomly generated data. This time problem is about random permutation. He decided to generate a random permutation this way: he takes identity permutation of numbers from 1 to n and then 3n times ta...
instruction
0
4,797
12
9,594
Tags: combinatorics, math Correct Solution: ``` n=int(input()) a=[0] + list(map(int,input().split())) d={} for i in range(1,n+1): d[a[i]]=i ans=0 for i in range(1,n+1): if a[i]!=i: ind1=d[a[i]] ind2=d[i] va1=a[i] val2=i a[ind1],a[ind2]=a[ind2],a[ind1] d[i]=i ...
output
1
4,797
12
9,595
Provide tags and a correct Python 3 solution for this coding contest problem. Petr likes to come up with problems about randomly generated data. This time problem is about random permutation. He decided to generate a random permutation this way: he takes identity permutation of numbers from 1 to n and then 3n times ta...
instruction
0
4,798
12
9,596
Tags: combinatorics, math Correct Solution: ``` import sys n = int(sys.stdin.readline().rstrip()) nums = list(map(int, sys.stdin.readline().split())) swaps = 0 visited = set() for index in range(n): if index in visited: continue else: visited.add(index) length = 0 value = nums[...
output
1
4,798
12
9,597
Provide tags and a correct Python 3 solution for this coding contest problem. Petr likes to come up with problems about randomly generated data. This time problem is about random permutation. He decided to generate a random permutation this way: he takes identity permutation of numbers from 1 to n and then 3n times ta...
instruction
0
4,799
12
9,598
Tags: combinatorics, math Correct Solution: ``` class BIT: __all__ = ['add', 'sumrange', 'lower_left'] def __init__(self, maxsize=10**7): assert (maxsize > 0) self._n = maxsize+1 self._bitdata = [0]*(maxsize+1) def add(self, i, x): '''Add x to A[i] (A[i] += x) ''' ...
output
1
4,799
12
9,599
Provide tags and a correct Python 2 solution for this coding contest problem. Petr likes to come up with problems about randomly generated data. This time problem is about random permutation. He decided to generate a random permutation this way: he takes identity permutation of numbers from 1 to n and then 3n times ta...
instruction
0
4,800
12
9,600
Tags: combinatorics, math Correct Solution: ``` from sys import stdin, stdout from collections import Counter, defaultdict from itertools import permutations, combinations raw_input = stdin.readline pr = stdout.write def in_num(): return int(raw_input()) def in_arr(): return map(int,raw_input().split()) d...
output
1
4,800
12
9,601
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Petr likes to come up with problems about randomly generated data. This time problem is about random permutation. He decided to generate a random permutation this way: he takes identity permutat...
instruction
0
4,801
12
9,602
Yes
output
1
4,801
12
9,603
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Petr likes to come up with problems about randomly generated data. This time problem is about random permutation. He decided to generate a random permutation this way: he takes identity permutat...
instruction
0
4,802
12
9,604
Yes
output
1
4,802
12
9,605
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Petr likes to come up with problems about randomly generated data. This time problem is about random permutation. He decided to generate a random permutation this way: he takes identity permutat...
instruction
0
4,803
12
9,606
Yes
output
1
4,803
12
9,607
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Petr likes to come up with problems about randomly generated data. This time problem is about random permutation. He decided to generate a random permutation this way: he takes identity permutat...
instruction
0
4,804
12
9,608
Yes
output
1
4,804
12
9,609
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Petr likes to come up with problems about randomly generated data. This time problem is about random permutation. He decided to generate a random permutation this way: he takes identity permutat...
instruction
0
4,805
12
9,610
No
output
1
4,805
12
9,611
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Petr likes to come up with problems about randomly generated data. This time problem is about random permutation. He decided to generate a random permutation this way: he takes identity permutat...
instruction
0
4,806
12
9,612
No
output
1
4,806
12
9,613
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Petr likes to come up with problems about randomly generated data. This time problem is about random permutation. He decided to generate a random permutation this way: he takes identity permutat...
instruction
0
4,807
12
9,614
No
output
1
4,807
12
9,615
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Petr likes to come up with problems about randomly generated data. This time problem is about random permutation. He decided to generate a random permutation this way: he takes identity permutat...
instruction
0
4,808
12
9,616
No
output
1
4,808
12
9,617
Provide tags and a correct Python 3 solution for this coding contest problem. A girl named Sonya is studying in the scientific lyceum of the Kingdom of Kremland. The teacher of computer science (Sonya's favorite subject!) invented a task for her. Given an array a of length n, consisting only of the numbers 0 and 1, a...
instruction
0
5,096
12
10,192
Tags: combinatorics, dp, matrices, probabilities Correct Solution: ``` N, T = map(int, input().split()) A = [int(a) for a in input().split()] if sum(A) > N//2: A = [1-a for a in A][::-1] K = sum(A) S = sum(A[-K:]) M = K + 1 P = 10**9+7 inv = pow(N*(N-1)//2, P-2, P) X = [[0]*M for _ in range(M)] for i in range(M): ...
output
1
5,096
12
10,193
Provide tags and a correct Python 3 solution for this coding contest problem. A girl named Sonya is studying in the scientific lyceum of the Kingdom of Kremland. The teacher of computer science (Sonya's favorite subject!) invented a task for her. Given an array a of length n, consisting only of the numbers 0 and 1, a...
instruction
0
5,097
12
10,194
Tags: combinatorics, dp, matrices, probabilities Correct Solution: ``` import sys; input=sys.stdin.readline # print(input()) N, T = map(int, input().split()) A = [int(a) for a in input().split()] if sum(A) > N//2: A = [1-a for a in A][::-1] K = sum(A) S = sum(A[-K:]) M = K + 1 P = 10**9+7 inv = pow(N*(N-1)//2, P-2,...
output
1
5,097
12
10,195
Provide tags and a correct Python 3 solution for this coding contest problem. A girl named Sonya is studying in the scientific lyceum of the Kingdom of Kremland. The teacher of computer science (Sonya's favorite subject!) invented a task for her. Given an array a of length n, consisting only of the numbers 0 and 1, a...
instruction
0
5,098
12
10,196
Tags: combinatorics, dp, matrices, probabilities Correct Solution: ``` #!/usr/bin/env python # -*- coding: utf-8 -*- """Codeforces Round #553 (Div. 2) Problem F. Sonya and Informatics :author: Kitchen Tong :mail: kctong529@gmail.com Please feel free to contact me if you have any question regarding the im...
output
1
5,098
12
10,197
Provide tags and a correct Python 3 solution for this coding contest problem. A girl named Sonya is studying in the scientific lyceum of the Kingdom of Kremland. The teacher of computer science (Sonya's favorite subject!) invented a task for her. Given an array a of length n, consisting only of the numbers 0 and 1, a...
instruction
0
5,099
12
10,198
Tags: combinatorics, dp, matrices, probabilities Correct Solution: ``` M = 10 ** 9 + 7 n, k = map(int, input().split()) a = list(map(int, input().split())) z, o = a.count(0), a.count(1) d = pow(n * (n - 1) // 2, M - 2, M) if z > o: o, z = z, o a = [1 - x for x in a][::-1] res = [[0] * (z + 1) for i in range...
output
1
5,099
12
10,199
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A girl named Sonya is studying in the scientific lyceum of the Kingdom of Kremland. The teacher of computer science (Sonya's favorite subject!) invented a task for her. Given an array a of leng...
instruction
0
5,100
12
10,200
No
output
1
5,100
12
10,201
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A girl named Sonya is studying in the scientific lyceum of the Kingdom of Kremland. The teacher of computer science (Sonya's favorite subject!) invented a task for her. Given an array a of leng...
instruction
0
5,101
12
10,202
No
output
1
5,101
12
10,203
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A girl named Sonya is studying in the scientific lyceum of the Kingdom of Kremland. The teacher of computer science (Sonya's favorite subject!) invented a task for her. Given an array a of leng...
instruction
0
5,102
12
10,204
No
output
1
5,102
12
10,205
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a sequence b_1, b_2, …, b_n. Find the lexicographically minimal permutation a_1, a_2, …, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible. Input Each test contains one or more test cases. The f...
instruction
0
5,177
12
10,354
Tags: greedy Correct Solution: ``` from sys import stdin, gettrace if not gettrace(): def input(): return next(stdin)[:-1] def main(): def solve(): n = int(input()) bb = [int(a) for a in input().split()] avail = [False] + [True] * 2 * n for b in bb: avail[...
output
1
5,177
12
10,355
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a sequence b_1, b_2, …, b_n. Find the lexicographically minimal permutation a_1, a_2, …, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible. Input Each test contains one or more test cases. The f...
instruction
0
5,178
12
10,356
Tags: greedy Correct Solution: ``` for _ in range(int(input())): n=int(input()) a=list(map(int,input().split()));d={} for i in range(n): d[a[i]]=1 ans=[];f=0 for i in range(n): if a[i]<2*n: for j in range(a[i],(2*n)+2): if not d.get(j) and j<=2*n: ...
output
1
5,178
12
10,357
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a sequence b_1, b_2, …, b_n. Find the lexicographically minimal permutation a_1, a_2, …, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible. Input Each test contains one or more test cases. The f...
instruction
0
5,179
12
10,358
Tags: greedy Correct Solution: ``` t=int(input()) for i in range(0,t): n=int(input()) b=[] c=[] a=list(map(int,input().split())) k1=1 k2=n*2 if(k1 in a and k2 not in a): for j in range(1,2*n+1): if(j not in a): b.append(j) for j in range(0,n): ...
output
1
5,179
12
10,359
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a sequence b_1, b_2, …, b_n. Find the lexicographically minimal permutation a_1, a_2, …, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible. Input Each test contains one or more test cases. The f...
instruction
0
5,180
12
10,360
Tags: greedy Correct Solution: ``` from functools import reduce import os import sys from math import * from collections import * from fractions import * from bisect import * from heapq import* from io import BytesIO, IOBase input = lambda: sys.stdin.readline().rstrip("\r\n") def value():return tuple(map(int,input().s...
output
1
5,180
12
10,361
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a sequence b_1, b_2, …, b_n. Find the lexicographically minimal permutation a_1, a_2, …, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible. Input Each test contains one or more test cases. The f...
instruction
0
5,181
12
10,362
Tags: greedy Correct Solution: ``` from collections import defaultdict as dfd for _ in range(int(input())): N = int(input()) A = list(map(int,input().split())) C = dfd(int) for i in range(1,(2*N)+1): C[i] = 0 for i in range(len(A)): C[A[i]] = 1 B = [] # print(C) for i in ...
output
1
5,181
12
10,363
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a sequence b_1, b_2, …, b_n. Find the lexicographically minimal permutation a_1, a_2, …, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible. Input Each test contains one or more test cases. The f...
instruction
0
5,182
12
10,364
Tags: greedy Correct Solution: ``` t = int(input()) for _ in range(t): n = int(input()) b = list(map(int, input().split())) if max(b) >= n*2 or 1 not in b: print(-1) else: a = [0]*(2*n) ok = True for i in range(n): a[i*2] = b[i] whil...
output
1
5,182
12
10,365
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a sequence b_1, b_2, …, b_n. Find the lexicographically minimal permutation a_1, a_2, …, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible. Input Each test contains one or more test cases. The f...
instruction
0
5,183
12
10,366
Tags: greedy Correct Solution: ``` for T in range(int(input())): n = int(input()) x = list(map(int, input().split(" "))) b = [0] for i in x: b.append(i) vis = [False for cnt_used in range(2*n + 1)] a = [0 for cnt_a in range(2*n + 1)] set_elem_b = True for i in range(1, n+1): ...
output
1
5,183
12
10,367
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a sequence b_1, b_2, …, b_n. Find the lexicographically minimal permutation a_1, a_2, …, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible. Input Each test contains one or more test cases. The f...
instruction
0
5,184
12
10,368
Tags: greedy Correct Solution: ``` for _ in range(int(input())): n=int(input()) b=list(map(int,input().split())) d={} for i in range(1,2*n+1): d[i]=1 for i in b: d[i]=0 a=[] for i in b: a.append(i) z=i for j in range(z+1,2*n+1): if d[j]: ...
output
1
5,184
12
10,369
Provide tags and a correct Python 2 solution for this coding contest problem. You are given a sequence b_1, b_2, …, b_n. Find the lexicographically minimal permutation a_1, a_2, …, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible. Input Each test contains one or more test cases. The f...
instruction
0
5,185
12
10,370
Tags: greedy Correct Solution: ``` from sys import stdin, stdout from collections import Counter, defaultdict from itertools import permutations, combinations raw_input = stdin.readline pr = stdout.write mod=10**9+7 def ni(): return int(raw_input()) def li(): return map(int,raw_input().split()) def pn(n): ...
output
1
5,185
12
10,371
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a sequence b_1, b_2, …, b_n. Find the lexicographically minimal permutation a_1, a_2, …, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible. Input E...
instruction
0
5,186
12
10,372
Yes
output
1
5,186
12
10,373
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a sequence b_1, b_2, …, b_n. Find the lexicographically minimal permutation a_1, a_2, …, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible. Input E...
instruction
0
5,187
12
10,374
Yes
output
1
5,187
12
10,375
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a sequence b_1, b_2, …, b_n. Find the lexicographically minimal permutation a_1, a_2, …, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible. Input E...
instruction
0
5,188
12
10,376
Yes
output
1
5,188
12
10,377
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a sequence b_1, b_2, …, b_n. Find the lexicographically minimal permutation a_1, a_2, …, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible. Input E...
instruction
0
5,189
12
10,378
Yes
output
1
5,189
12
10,379
Evaluate the correctness of the submitted Python 2 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a sequence b_1, b_2, …, b_n. Find the lexicographically minimal permutation a_1, a_2, …, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible. Input E...
instruction
0
5,190
12
10,380
No
output
1
5,190
12
10,381
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a sequence b_1, b_2, …, b_n. Find the lexicographically minimal permutation a_1, a_2, …, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible. Input E...
instruction
0
5,191
12
10,382
No
output
1
5,191
12
10,383
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a sequence b_1, b_2, …, b_n. Find the lexicographically minimal permutation a_1, a_2, …, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible. Input E...
instruction
0
5,192
12
10,384
No
output
1
5,192
12
10,385
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a sequence b_1, b_2, …, b_n. Find the lexicographically minimal permutation a_1, a_2, …, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible. Input E...
instruction
0
5,193
12
10,386
No
output
1
5,193
12
10,387
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a sequence b_1, b_2, …, b_n. Find the lexicographically minimal permutation a_1, a_2, …, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible. Input E...
instruction
0
5,194
12
10,388
No
output
1
5,194
12
10,389
Provide tags and a correct Python 3 solution for this coding contest problem. Let's denote the median of a sequence s with odd length as the value in the middle of s if we sort s in non-decreasing order. For example, let s = [1, 2, 5, 7, 2, 3, 12]. After sorting, we get sequence [1, 2, 2, \underline{3}, 5, 7, 12], and...
instruction
0
5,236
12
10,472
Tags: constructive algorithms, greedy, math Correct Solution: ``` import sys for _ in range(int(sys.stdin.readline().strip())): n,k,m=tuple(map(int,sys.stdin.readline().strip().split(" "))) ml=set(map(int,sys.stdin.readline().strip().split(" "))) havitada=[] for i in range(1,n+1): if i not in ml: havitada.appe...
output
1
5,236
12
10,473
Provide tags and a correct Python 3 solution for this coding contest problem. Let's denote the median of a sequence s with odd length as the value in the middle of s if we sort s in non-decreasing order. For example, let s = [1, 2, 5, 7, 2, 3, 12]. After sorting, we get sequence [1, 2, 2, \underline{3}, 5, 7, 12], and...
instruction
0
5,237
12
10,474
Tags: constructive algorithms, greedy, math Correct Solution: ``` import sys def load_sys(): return sys.stdin.readlines() def load_local(): with open('input.txt','r') as f: input = f.readlines() return input def km(n,k,m,B): if (n-m)%(k-1) != 0: return 'NO' R = [0]*m L = [0]...
output
1
5,237
12
10,475
Provide tags and a correct Python 3 solution for this coding contest problem. Let's denote the median of a sequence s with odd length as the value in the middle of s if we sort s in non-decreasing order. For example, let s = [1, 2, 5, 7, 2, 3, 12]. After sorting, we get sequence [1, 2, 2, \underline{3}, 5, 7, 12], and...
instruction
0
5,238
12
10,476
Tags: constructive algorithms, greedy, math Correct Solution: ``` T = int(input()) for _ in range(T): n, k, m = map(int, input().split()) b = [int(i) for i in input().split()] ff = False for p, i in enumerate(b): if i - p - 1 >= k>>1 and n - i - len(b) + p + 1 >= k>>1: ff = True ...
output
1
5,238
12
10,477