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. You are given two sequences a_1, a_2, ..., a_n and b_1, b_2, ..., b_n. Each element of both sequences is either 0, 1 or 2. The number of elements 0, 1, 2 in the sequence a is x_1, y_1, z_1 respe...
instruction
0
105,465
12
210,930
No
output
1
105,465
12
210,931
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given two sequences a_1, a_2, ..., a_n and b_1, b_2, ..., b_n. Each element of both sequences is either 0, 1 or 2. The number of elements 0, 1, 2 in the sequence a is x_1, y_1, z_1 respe...
instruction
0
105,466
12
210,932
No
output
1
105,466
12
210,933
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given two sequences a_1, a_2, ..., a_n and b_1, b_2, ..., b_n. Each element of both sequences is either 0, 1 or 2. The number of elements 0, 1, 2 in the sequence a is x_1, y_1, z_1 respe...
instruction
0
105,467
12
210,934
No
output
1
105,467
12
210,935
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given two sequences a_1, a_2, ..., a_n and b_1, b_2, ..., b_n. Each element of both sequences is either 0, 1 or 2. The number of elements 0, 1, 2 in the sequence a is x_1, y_1, z_1 respe...
instruction
0
105,468
12
210,936
No
output
1
105,468
12
210,937
Provide tags and a correct Python 3 solution for this coding contest problem. You are given two integer arrays a and b of length n. You can reverse at most one subarray (continuous subsegment) of the array a. Your task is to reverse such a subarray that the sum βˆ‘_{i=1}^n a_i β‹… b_i is maximized. Input The first li...
instruction
0
105,494
12
210,988
Tags: brute force, dp, implementation, math, two pointers Correct Solution: ``` n=int(input()) array1=list(map(int,input().split())) array2=list(map(int,input().split())) totalSum=sum([array2[i]*array1[i] for i in range(n)]) maxSum=totalSum """ for i in range(n): for j in range(i,i+2): start=i end=...
output
1
105,494
12
210,989
Provide tags and a correct Python 3 solution for this coding contest problem. You are given two integer arrays a and b of length n. You can reverse at most one subarray (continuous subsegment) of the array a. Your task is to reverse such a subarray that the sum βˆ‘_{i=1}^n a_i β‹… b_i is maximized. Input The first li...
instruction
0
105,495
12
210,990
Tags: brute force, dp, implementation, math, two pointers Correct Solution: ``` # https://codeforces.com/contest/1519/submission/114616034 # import io,os # input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) s = sum(a[i]...
output
1
105,495
12
210,991
Provide tags and a correct Python 3 solution for this coding contest problem. You are given two integer arrays a and b of length n. You can reverse at most one subarray (continuous subsegment) of the array a. Your task is to reverse such a subarray that the sum βˆ‘_{i=1}^n a_i β‹… b_i is maximized. Input The first li...
instruction
0
105,496
12
210,992
Tags: brute force, dp, implementation, math, two pointers Correct Solution: ``` from collections import defaultdict from itertools import accumulate import sys input = sys.stdin.readline ''' for CASES in range(int(input())): n, m = map(int, input().split()) n = int(input()) A = list(map(int, input().split())) S = input...
output
1
105,496
12
210,993
Provide tags and a correct Python 3 solution for this coding contest problem. You are given two integer arrays a and b of length n. You can reverse at most one subarray (continuous subsegment) of the array a. Your task is to reverse such a subarray that the sum βˆ‘_{i=1}^n a_i β‹… b_i is maximized. Input The first li...
instruction
0
105,497
12
210,994
Tags: brute force, dp, implementation, math, two pointers Correct Solution: ``` n = int(input()) a = list(map(int,input().split())) b = list(map(int,input().split())) ans = 0 for i in range(n): ans+= (b[i]*a[i]) maxi = ans for i in range(n): l = i - 1 r = i + 1 temp_ans = ans while l >= 0 and...
output
1
105,497
12
210,995
Provide tags and a correct Python 3 solution for this coding contest problem. You are given two integer arrays a and b of length n. You can reverse at most one subarray (continuous subsegment) of the array a. Your task is to reverse such a subarray that the sum βˆ‘_{i=1}^n a_i β‹… b_i is maximized. Input The first li...
instruction
0
105,498
12
210,996
Tags: brute force, dp, implementation, math, two pointers Correct Solution: ``` N = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) Base = 0 for i in range(N): Base += A[i] * B[i] Ans = Base for i in range(1, N - 1): Value = Base L = i - 1 R = i + 1 while L >= 0 ...
output
1
105,498
12
210,997
Provide tags and a correct Python 3 solution for this coding contest problem. You are given two integer arrays a and b of length n. You can reverse at most one subarray (continuous subsegment) of the array a. Your task is to reverse such a subarray that the sum βˆ‘_{i=1}^n a_i β‹… b_i is maximized. Input The first li...
instruction
0
105,499
12
210,998
Tags: brute force, dp, implementation, math, two pointers Correct Solution: ``` def readline(): return map(int, input().split()) def main(): n = int(input()) a = list(readline()) b = list(readline()) max_diff = 0 for begin in range(n): for end in (begin, begin + 1): index_s...
output
1
105,499
12
210,999
Provide tags and a correct Python 3 solution for this coding contest problem. You are given two integer arrays a and b of length n. You can reverse at most one subarray (continuous subsegment) of the array a. Your task is to reverse such a subarray that the sum βˆ‘_{i=1}^n a_i β‹… b_i is maximized. Input The first li...
instruction
0
105,500
12
211,000
Tags: brute force, dp, implementation, math, two pointers Correct Solution: ``` ###### ### ####### ####### ## # ##### ### ##### # # # # # # # # # # # # # ### # # # # # # # # # # # ...
output
1
105,500
12
211,001
Provide tags and a correct Python 3 solution for this coding contest problem. You are given two integer arrays a and b of length n. You can reverse at most one subarray (continuous subsegment) of the array a. Your task is to reverse such a subarray that the sum βˆ‘_{i=1}^n a_i β‹… b_i is maximized. Input The first li...
instruction
0
105,501
12
211,002
Tags: brute force, dp, implementation, math, two pointers Correct Solution: ``` n=int(input()) array1=list(map(int,input().split())) array2=list(map(int,input().split())) totalSum=sum([array2[i]*array1[i] for i in range(n)]) maxSum=totalSum """ for i in range(n): for j in range(i,i+2): start=i end=...
output
1
105,501
12
211,003
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given two integer arrays a and b of length n. You can reverse at most one subarray (continuous subsegment) of the array a. Your task is to reverse such a subarray that the sum βˆ‘_{i=1}...
instruction
0
105,502
12
211,004
Yes
output
1
105,502
12
211,005
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given two integer arrays a and b of length n. You can reverse at most one subarray (continuous subsegment) of the array a. Your task is to reverse such a subarray that the sum βˆ‘_{i=1}...
instruction
0
105,503
12
211,006
Yes
output
1
105,503
12
211,007
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given two integer arrays a and b of length n. You can reverse at most one subarray (continuous subsegment) of the array a. Your task is to reverse such a subarray that the sum βˆ‘_{i=1}...
instruction
0
105,504
12
211,008
Yes
output
1
105,504
12
211,009
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given two integer arrays a and b of length n. You can reverse at most one subarray (continuous subsegment) of the array a. Your task is to reverse such a subarray that the sum βˆ‘_{i=1}...
instruction
0
105,505
12
211,010
Yes
output
1
105,505
12
211,011
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given two integer arrays a and b of length n. You can reverse at most one subarray (continuous subsegment) of the array a. Your task is to reverse such a subarray that the sum βˆ‘_{i=1}...
instruction
0
105,506
12
211,012
No
output
1
105,506
12
211,013
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given two integer arrays a and b of length n. You can reverse at most one subarray (continuous subsegment) of the array a. Your task is to reverse such a subarray that the sum βˆ‘_{i=1}...
instruction
0
105,507
12
211,014
No
output
1
105,507
12
211,015
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given two integer arrays a and b of length n. You can reverse at most one subarray (continuous subsegment) of the array a. Your task is to reverse such a subarray that the sum βˆ‘_{i=1}...
instruction
0
105,508
12
211,016
No
output
1
105,508
12
211,017
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given two integer arrays a and b of length n. You can reverse at most one subarray (continuous subsegment) of the array a. Your task is to reverse such a subarray that the sum βˆ‘_{i=1}...
instruction
0
105,509
12
211,018
No
output
1
105,509
12
211,019
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a sequence a1, a2, ..., an of one-dimensional segments numbered 1 through n. Your task is to find two distinct indices i and j such that segment ai lies within segment aj. Segment [l1, r1] lies within segment [l2, r2] iff l1 β‰₯...
instruction
0
105,866
12
211,732
Tags: greedy, implementation, sortings Correct Solution: ``` n=int(input()) segs=[] for i in range(n): a,b=map(int,input().split()) segs.append([a,b,i]) segs.sort(key=lambda x:[x[0],-x[1]]) for i in range(1,n): if segs[i][1]<=segs[i-1][1]: print(segs[i][2]+1,segs[i-1][2]+1) exit() segs.sort(...
output
1
105,866
12
211,733
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a sequence a1, a2, ..., an of one-dimensional segments numbered 1 through n. Your task is to find two distinct indices i and j such that segment ai lies within segment aj. Segment [l1, r1] lies within segment [l2, r2] iff l1 β‰₯...
instruction
0
105,867
12
211,734
Tags: greedy, implementation, sortings Correct Solution: ``` import sys input=sys.stdin.readline n = int(input()) ls = [] for i in range(n): l, r = list(map(int, input().strip().split())) ls.append([l, r, i]) ls = sorted(ls, key=lambda x: (x[0], -x[1])) flag = False for i in range(n-1): cur_l, cur_r, moth...
output
1
105,867
12
211,735
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a sequence a1, a2, ..., an of one-dimensional segments numbered 1 through n. Your task is to find two distinct indices i and j such that segment ai lies within segment aj. Segment [l1, r1] lies within segment [l2, r2] iff l1 β‰₯...
instruction
0
105,868
12
211,736
Tags: greedy, implementation, sortings Correct Solution: ``` n = int(input()) arr = [] for i in range(n): l, r = map(int, input().split()) arr.append((l, -r, i)) ans = '-1 -1' a = sorted(arr) for i in range(len(a)): a[i] = (a[i][0], -a[i][1], a[i][2]) for i in range(len(a)-1): if a[i][0] <= a[i+1][0...
output
1
105,868
12
211,737
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a sequence a1, a2, ..., an of one-dimensional segments numbered 1 through n. Your task is to find two distinct indices i and j such that segment ai lies within segment aj. Segment [l1, r1] lies within segment [l2, r2] iff l1 β‰₯...
instruction
0
105,869
12
211,738
Tags: greedy, implementation, sortings Correct Solution: ``` n = int(input()) a = [] for i in range(1, n+1): l, r = map(int, input().split()) a.append((l, r, i)) a.sort() for i in range(n-1): if (a[i][0] == a[i+1][0]): print(str(a[i][2]) + ' ' + str(a[i+1][2])) break if (a[i][1] >= a...
output
1
105,869
12
211,739
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a sequence a1, a2, ..., an of one-dimensional segments numbered 1 through n. Your task is to find two distinct indices i and j such that segment ai lies within segment aj. Segment [l1, r1] lies within segment [l2, r2] iff l1 β‰₯...
instruction
0
105,870
12
211,740
Tags: greedy, implementation, sortings Correct Solution: ``` from sys import stdin class segment : def __init__(self,x,y,n) : self.a = x self.b = y self.no = n def __gt__(self,other): if(self.a == other.a): return self.b < other.b return self.a > other.a def __lt__(self,other): ...
output
1
105,870
12
211,741
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a sequence a1, a2, ..., an of one-dimensional segments numbered 1 through n. Your task is to find two distinct indices i and j such that segment ai lies within segment aj. Segment [l1, r1] lies within segment [l2, r2] iff l1 β‰₯...
instruction
0
105,871
12
211,742
Tags: greedy, implementation, sortings Correct Solution: ``` n = int(input()) l = [i for i in range(n)] d = [tuple(map(int, input().split())) for _ in range(n)] l.sort(key = lambda x: (d[x][0], -d[x][1])) for i in range(n - 1): if d[l[i + 1]][1] <= d[l[i]][1]: print(l[i + 1] + 1, l[i] + 1) exit() pr...
output
1
105,871
12
211,743
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a sequence a1, a2, ..., an of one-dimensional segments numbered 1 through n. Your task is to find two distinct indices i and j such that segment ai lies within segment aj. Segment [l1, r1] lies within segment [l2, r2] iff l1 β‰₯...
instruction
0
105,872
12
211,744
Tags: greedy, implementation, sortings Correct Solution: ``` n=int(input()) a=[list(map(int,input().split())) for i in range(n)] for i in range(n): a[i].append(i+1) a.sort() for i in range(n-1): if a[i][1]>=a[i+1][1]: exit(print(a[i+1][2],a[i][2])) if a[i][0]==a[i+1][0] and a[i][1]<a[i+1][1]: ...
output
1
105,872
12
211,745
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a sequence a1, a2, ..., an of one-dimensional segments numbered 1 through n. Your task is to find two distinct indices i and j such that segment ai lies within segment aj. Segment [l1, r1] lies within segment [l2, r2] iff l1 β‰₯...
instruction
0
105,873
12
211,746
Tags: greedy, implementation, sortings Correct Solution: ``` N = int(input()) A = [] for i in range(1, N+1): l, r = map(int, input().split()) A.append([l, r, i]) A.sort(key=lambda x:x[0]) if N == 1: print(-1, -1) quit() a = A[0][1] for i in range(1, N): if A[i][0] == A[i-1][0] and A[i][1] > A[i-1...
output
1
105,873
12
211,747
Provide tags and a correct Python 3 solution for this coding contest problem. You are given an array a_1, a_2, ..., a_n. All a_i are pairwise distinct. Let's define function f(l, r) as follows: * let's define array b_1, b_2, ..., b_{r - l + 1}, where b_i = a_{l - 1 + i}; * sort array b in increasing order; ...
instruction
0
106,184
12
212,368
Tags: combinatorics, data structures, math, sortings Correct Solution: ``` import sys MOD = (int)(1e9+7) def add(a, b): a += b if a >= MOD: a -= MOD return a def mul(a, b): return (a * b) % MOD class fenwickTree: def __init__(self, max_val): self.max_val = max_val + 5 self.tree = [0] * self.max_val def...
output
1
106,184
12
212,369
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given an array a_1, a_2, ..., a_n. All a_i are pairwise distinct. Let's define function f(l, r) as follows: * let's define array b_1, b_2, ..., b_{r - l + 1}, where b_i = a_{l - 1 +...
instruction
0
106,185
12
212,370
No
output
1
106,185
12
212,371
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given an array a_1, a_2, ..., a_n. All a_i are pairwise distinct. Let's define function f(l, r) as follows: * let's define array b_1, b_2, ..., b_{r - l + 1}, where b_i = a_{l - 1 +...
instruction
0
106,186
12
212,372
No
output
1
106,186
12
212,373
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given an array a_1, a_2, ..., a_n. All a_i are pairwise distinct. Let's define function f(l, r) as follows: * let's define array b_1, b_2, ..., b_{r - l + 1}, where b_i = a_{l - 1 +...
instruction
0
106,187
12
212,374
No
output
1
106,187
12
212,375
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given an array a_1, a_2, ..., a_n. All a_i are pairwise distinct. Let's define function f(l, r) as follows: * let's define array b_1, b_2, ..., b_{r - l + 1}, where b_i = a_{l - 1 +...
instruction
0
106,188
12
212,376
No
output
1
106,188
12
212,377
Provide tags and a correct Python 3 solution for this coding contest problem. You are given integer n. You have to arrange numbers from 1 to 2n, using each of them exactly once, on the circle, so that the following condition would be satisfied: For every n consecutive numbers on the circle write their sum on the blac...
instruction
0
106,205
12
212,410
Tags: constructive algorithms, greedy, math Correct Solution: ``` n=int(input()) if n%2: print("YES") ls=[0]*2*n c=1 i=-1 while c<=2*n: i=i+1 ls[i]=c i=(i+n)%(2*n) ls[i]=c+1 c=c+2 print(*ls) else: print("NO") ```
output
1
106,205
12
212,411
Provide tags and a correct Python 3 solution for this coding contest problem. You are given integer n. You have to arrange numbers from 1 to 2n, using each of them exactly once, on the circle, so that the following condition would be satisfied: For every n consecutive numbers on the circle write their sum on the blac...
instruction
0
106,206
12
212,412
Tags: constructive algorithms, greedy, math Correct Solution: ``` def almost_equal(n): if n%2==0: return None else: r = [1] r2 = [2] m = 1 while m<n: m += 2 r += [2*m,2*m -3] r2 += [2*m-1,2*m-2] return r+r2 n = int(input().s...
output
1
106,206
12
212,413
Provide tags and a correct Python 3 solution for this coding contest problem. You are given integer n. You have to arrange numbers from 1 to 2n, using each of them exactly once, on the circle, so that the following condition would be satisfied: For every n consecutive numbers on the circle write their sum on the blac...
instruction
0
106,207
12
212,414
Tags: constructive algorithms, greedy, math Correct Solution: ``` n = int(input()) a = [0] * (2*n) curr = 1 for i in range(n): if i%2 == 0: a[i] = curr curr += 1 a[i+n] = curr curr += 1 else: a[i+n] = curr curr += 1 a[i] = curr curr += 1 arr = a...
output
1
106,207
12
212,415
Provide tags and a correct Python 3 solution for this coding contest problem. You are given integer n. You have to arrange numbers from 1 to 2n, using each of them exactly once, on the circle, so that the following condition would be satisfied: For every n consecutive numbers on the circle write their sum on the blac...
instruction
0
106,208
12
212,416
Tags: constructive algorithms, greedy, math Correct Solution: ``` n = int(input()) n2 = 2 * n if n == 1: print('YES\n1 2') else: a = [None] * n2 now = n2 flag = True for i in range(n): if flag: a[i] = now a[n + i] = now - 1 else: a[i] = now - 1 a[n + i] = now flag = 1 - flag now -= 2 min_ans...
output
1
106,208
12
212,417
Provide tags and a correct Python 3 solution for this coding contest problem. You are given integer n. You have to arrange numbers from 1 to 2n, using each of them exactly once, on the circle, so that the following condition would be satisfied: For every n consecutive numbers on the circle write their sum on the blac...
instruction
0
106,209
12
212,418
Tags: constructive algorithms, greedy, math Correct Solution: ``` n=int(input()) if(n%2!=0): a=[0]*(2*n+1) for i in range(1,n+1): if(i%2==1): a[i]=2*i a[n+i]=2*i-1 else: a[i]=2*i-1 a[n+i]=2*i print("YES") for i in range(1,2*n+1): print(a[i],end=' ') else: print("NO") ```
output
1
106,209
12
212,419
Provide tags and a correct Python 3 solution for this coding contest problem. You are given integer n. You have to arrange numbers from 1 to 2n, using each of them exactly once, on the circle, so that the following condition would be satisfied: For every n consecutive numbers on the circle write their sum on the blac...
instruction
0
106,210
12
212,420
Tags: constructive algorithms, greedy, math Correct Solution: ``` n = int(input()) a = [1] b = [] counter = 2 for i in range(2, 2*n + 1): if counter < 2: a.append(i) else: b.append(i) counter = (counter + 1) % 4 c = a + b sums = [] sum = 0 for i in range(n): sum += c[i] sums.append(sum) ...
output
1
106,210
12
212,421
Provide tags and a correct Python 3 solution for this coding contest problem. You are given integer n. You have to arrange numbers from 1 to 2n, using each of them exactly once, on the circle, so that the following condition would be satisfied: For every n consecutive numbers on the circle write their sum on the blac...
instruction
0
106,212
12
212,424
Tags: constructive algorithms, greedy, math Correct Solution: ``` import sys readline = sys.stdin.readline N = int(readline()) if N & 1: print('YES') Ans = list(range(1, 1+2*N, 2)) + list(range(2, 1+2*N, 2)) for i in range(0, N, 2): Ans[i], Ans[i+N] = Ans[i+N], Ans[i] print(*Ans) el...
output
1
106,212
12
212,425
Provide tags and a correct Python 3 solution for this coding contest problem. A mad scientist Dr.Jubal has made a competitive programming task. Try to solve it! You are given integers n,k. Construct a grid A with size n Γ— n consisting of integers 0 and 1. The very important condition should be satisfied: the sum of a...
instruction
0
106,305
12
212,610
Tags: constructive algorithms, greedy, implementation Correct Solution: ``` import math import sys t = int(input()) result = [] for cs in range(t): n, k = map(int, input().split()) a = [[0] * n for _ in range(n)] result.append('0' if k % n == 0 else '2') for i in range(n): cur = 0 while ...
output
1
106,305
12
212,611
Provide tags and a correct Python 3 solution for this coding contest problem. A mad scientist Dr.Jubal has made a competitive programming task. Try to solve it! You are given integers n,k. Construct a grid A with size n Γ— n consisting of integers 0 and 1. The very important condition should be satisfied: the sum of a...
instruction
0
106,306
12
212,612
Tags: constructive algorithms, greedy, implementation Correct Solution: ``` t = int(input()) for test in range(t): n,k = [int(i) for i in input().split()] tab = [["0" for c in range(n)] for r in range(n)] row = 0 col = 0 while k>0: tab[row][col] = "1" row = (row+1)%n col += 1...
output
1
106,306
12
212,613
Provide tags and a correct Python 3 solution for this coding contest problem. A mad scientist Dr.Jubal has made a competitive programming task. Try to solve it! You are given integers n,k. Construct a grid A with size n Γ— n consisting of integers 0 and 1. The very important condition should be satisfied: the sum of a...
instruction
0
106,307
12
212,614
Tags: constructive algorithms, greedy, implementation Correct Solution: ``` import sys input = lambda:sys.stdin.readline().strip() t = int(input()) while t: t-=1 n,k = map(int,input().split()) if k%n==0: print(0) else: print(2) ans = [[0]*n for _ in range(n)] p = 0 q = 0 ...
output
1
106,307
12
212,615
Provide tags and a correct Python 3 solution for this coding contest problem. A mad scientist Dr.Jubal has made a competitive programming task. Try to solve it! You are given integers n,k. Construct a grid A with size n Γ— n consisting of integers 0 and 1. The very important condition should be satisfied: the sum of a...
instruction
0
106,308
12
212,616
Tags: constructive algorithms, greedy, implementation Correct Solution: ``` for z in range(int(input())): n,k = list(map(int,input().split())) arr = [[0 for i in range(n)] for i in range(n)] c = 0 s = [0,0] while(k!=0): # print(s) arr[s[0]][s[1]]=1 s[0] = (s[0]+1)%n s...
output
1
106,308
12
212,617
Provide tags and a correct Python 3 solution for this coding contest problem. A mad scientist Dr.Jubal has made a competitive programming task. Try to solve it! You are given integers n,k. Construct a grid A with size n Γ— n consisting of integers 0 and 1. The very important condition should be satisfied: the sum of a...
instruction
0
106,309
12
212,618
Tags: constructive algorithms, greedy, implementation Correct Solution: ``` input=__import__('sys').stdin.readline for _ in range(int(input())): n,k=map(int,input().split()) print(2if k%n else 0) ans=[['0']*n for i in range(n)] x=y=0 while k:k-=1;ans[x][y]='1';y=(y+1+int(x==n-1))%n;x=(x+1)%n for...
output
1
106,309
12
212,619
Provide tags and a correct Python 3 solution for this coding contest problem. A mad scientist Dr.Jubal has made a competitive programming task. Try to solve it! You are given integers n,k. Construct a grid A with size n Γ— n consisting of integers 0 and 1. The very important condition should be satisfied: the sum of a...
instruction
0
106,310
12
212,620
Tags: constructive algorithms, greedy, implementation Correct Solution: ``` t = int(input()) while t!=0: n,k=map(int,input().split()) list1=[[0 for i in range(n)] for j in range(n)] i,j=0,0 ans=0 if k%n==0: ans=0 else: ans=2 for _ in range(k): list1[i][j]=1 ...
output
1
106,310
12
212,621
Provide tags and a correct Python 3 solution for this coding contest problem. A mad scientist Dr.Jubal has made a competitive programming task. Try to solve it! You are given integers n,k. Construct a grid A with size n Γ— n consisting of integers 0 and 1. The very important condition should be satisfied: the sum of a...
instruction
0
106,311
12
212,622
Tags: constructive algorithms, greedy, implementation Correct Solution: ``` import sys import math strInp = lambda : input().strip().split() intInp = lambda : list(map(int,strInp())) for t in range(int(input())): n , k = intInp() if k == 0: print(0) for i in range(n): for j in rang...
output
1
106,311
12
212,623
Provide tags and a correct Python 3 solution for this coding contest problem. A mad scientist Dr.Jubal has made a competitive programming task. Try to solve it! You are given integers n,k. Construct a grid A with size n Γ— n consisting of integers 0 and 1. The very important condition should be satisfied: the sum of a...
instruction
0
106,312
12
212,624
Tags: constructive algorithms, greedy, implementation Correct Solution: ``` for _ in range(int(input())): n,k=map(int,input().split()) a=[["0" for i in range(n+1)] for j in range(n+1)] r=1 c=1 for i in range(k): a[r][c]="1" r+=1 c+=1 if c==n+1: c=...
output
1
106,312
12
212,625
Provide tags and a correct Python 3 solution for this coding contest problem. In this problem MEX of a certain array is the smallest positive integer not contained in this array. Everyone knows this definition, including Lesha. But Lesha loves MEX, so he comes up with a new problem involving MEX every day, including ...
instruction
0
106,341
12
212,682
Tags: binary search, data structures, two pointers Correct Solution: ``` from typing import TypeVar, Generic, Callable, List import sys from array import array # noqa: F401 def input(): return sys.stdin.buffer.readline().decode('utf-8') T = TypeVar('T') class SegmentTree(Generic[T]): __slots__ = ["size",...
output
1
106,341
12
212,683
Provide tags and a correct Python 3 solution for this coding contest problem. In this problem MEX of a certain array is the smallest positive integer not contained in this array. Everyone knows this definition, including Lesha. But Lesha loves MEX, so he comes up with a new problem involving MEX every day, including ...
instruction
0
106,342
12
212,684
Tags: binary search, data structures, two pointers Correct Solution: ``` from math import inf, log2 class SegmentTree: def __init__(self, array, func=max): self.n = len(array) self.size = 2**(int(log2(self.n-1))+1) if self.n != 1 else 1 self.func = func self.default = 0 if self.fun...
output
1
106,342
12
212,685