prompt
string
response
string
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
for _ in range(int(input())): N,K=map(int,input().split());L=list(map(int,input().split()));prefix=[0]*(2*K+2);prefix[1]=N for i in range(N//2):x,y=sorted((L[i],L[N-i-1]));prefix[x+1]-=1;prefix[x+y]-=1;prefix[x+y+1]+=1;prefix[y+K+1]+=1 for i in range(1,2*K+2):prefix[i]+=prefix[i-1] print(min(prefix[1:])...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
''' import sys import math import bisect n=int(input()) arr=list(map(int,input().split())) n,m=map(int,input().split()) t=sys.stdin.buffer.readline() sys.stdin=open("input.txt") sys.stdout=open("output.txt", 'w') sys.stdout.write("Yes" + '\n') s="abcdefghijklmnopqrstuvwxyz" mod=1000000007 mod=998244353 vow=['a','e','i'...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
for _ in range(int(input())): n=int(input()) a=[0]*n for i in range(n//2): a[i]=2*i+2 a[n//2+i]=2*i+1 ev,od=sum(a[:n//2]),sum(a[n//2:]) if abs(ev-od)%2!=0: print("NO") else: print("YES") if ev>od: a[-1]+=ev-od else: a[n//2-1...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
#include <bits/stdc++.h> using namespace std; void solve() { long long n; cin >> n; n = n / 2; if (n & 1) { cout << "NO"; } else { cout << "YES" << "\n"; for (long long i = 1; i <= n; i++) cout << 2 * i << " "; long long i = 1; for (; i <= n / 2; i++) cout << 2 * i - 1 << " "; ...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
for _ in range(int(input())): n=int(input()) if (n//2)%2!=0: print("NO") continue arr=[] arr.append(2) count_even=2 for i in range(1,n//2): arr.append(arr[i-1]+2) count_even+=arr[i] arr.append(1) count_odd=1 for i in range(n//2+1,n-1): arr.appe...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
testCases= int(input()) for _ in range(testCases): n= int(input()) if((n//2) %2!= 0): print('NO') else: a= [i for i in range(2, n+ 1, 2)] b= [i for i in range(1, n+ 1, 2)] b[-1]+= n// 2 print('YES') print(*a, *b)
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
from bisect import bisect_left from collections import Counter def solve(n, k, a): s = [a[i] + a[n-i-1] for i in range(n//2)] amin = sorted([min(a[i], a[n-i-1]) for i in range(n//2)]) amax = sorted([max(a[i], a[n-i-1]) for i in range(n//2)]) ans = float('inf') counter = Counter(s) fo...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
t = int(input()) for i in range(t): n = int(input()) if n % 4 != 0: print('NO') else: print('YES') print(*range(2, n + 1, 2), *range(1, n - 1, 2), (n - 1) + n // 2)
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
import java.util.*; import java.io.*; import java.util.function.*; // import lib.util.*; // import lib.graph.*; // import lib.io.*; // import lib.math.*; public class Main { public static void main(String[] args) { FastScanner sc = new FastScanner(); PrintWriter out = new PrintWriter(System.out); ...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
# cook your dish here for _ in range(int(input())): n=int(input()) if (n//2)%2!=0: print("NO") else: print("YES") l=[0] for i in range(n//2): l.append(l[-1]+2) print(l[i+1],end=" ") for i in range(n//2): if i==(n//2-1): ...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
import java.util.*;import java.io.*;import java.math.*; public class Main { public static void process()throws IOException { int n=ni(); long arr[]=new long[n+1]; int temp=n/2; if(temp%2==1){ pn("NO"); return; } int i=1,j=n/...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
T = int(input()) for t in range(T): N = int(input()) if N // 2 % 2 == 1: print("NO") else: print("YES") even = [] odd = [] diff = 0 for i in range(1, N // 2 + 1): even.append(i * 2) diff += 1 if i == N // 2: ...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int t = 1; cin >> t; while (t--) { int n, k; cin >> n >> k; vector<int> a(n); for (auto &i : a) cin >> i; map<int, int> sums; vector<int> pos(2 * k + 2, 0); ...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
''' n = четное первые n/2 четные вторые n/2 нечетные все элементы разные и положительные сумма первых и вторых частей равна ''' t = int(input()) lstx = [] for i in range(t): n = int(input()) k = 0 lstp = [] for i in range(1,n+1): if i % 2 == 0: lstp.append(i) for i in range(n): ...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
for _ in range(int(input())): n = int(input()) if n % 4 == 0: print('YES') s = [0]*n for i in range(0,n//2): s[i] = ((i+1)* 4) for i in range(n//2,n): if i % 2 == 0: s[i] = s[i - n // 2] + 1 else: s[i] = s[i - n ...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
for _ in range(int(input())): n=int(input()) if n%2!=0: print("NO") else: n=n//2 if n%2==0: print("YES") x=sum(range(2,2*n+1,2)) y=sum(range(1,2*n-1,2)) print(*range(2,2*n+1,2),*range(1,2*n-1,2),x-y) else: print("NO"...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
import sys,math,itertools from collections import Counter,deque,defaultdict from bisect import bisect_left,bisect_right from heapq import heappop,heappush,heapify, nlargest from copy import deepcopy mod = 10**9+7 INF = float('inf') def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.stdin....
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
t = int(input()) for i in range(t): n = int(input()) arr1 = [x for x in range(1, n+1) if x % 2 == 0] avg = (sum(arr1)) // len(arr1) if avg % 2 == 1: print("YES") arr2 = [avg + 2*x for x in range(-n//4, n//4 + 1) if x != 0] final = arr1 + arr2 print(' '.join(map(str, fin...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
def solve(n): if n%4!=0: print("NO") return i=0 j=n-1 e=0 o=1 l=[0]*n while(i!=j and i<n and j>=0): l[i]=e l[j]=o e+=2 o+=2 i+=1 j-=1 l=l[::-1] l[0]=l[0]+n//2 print("YES") for i in l: print(i,end=" ") ...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
t = int(input()) for _ in range(t): n = int(input()) if (n // 2) % 2 == 1: print("NO") else: evens = [2*x for x in range(1, n//2+1)] odds = [2*x - 1 for x in range(1, n//2)] odds.append(sum(evens) - sum(odds)) print("YES") print(*evens, *odds, sep = ' ')
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
# cook your dish here for _ in range(int(input())): n = int(input()) if((n/(1+1))%2!=0): print("NO") continue else: print("YES") l = [0]*n k = 2 for i in range(0,n//(1+1),1+1): l[i] = k l[-i-1] = k-1 l[i+1] = k+1+1 l[-i-1-1] = k+3 k...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
t = int(input()) for i in range(t): n = int(input()) if (n // 2) % 2 == 1: print('NO') else: print('YES') sum = 0 even = 2 for j in range(n // 2): sum += even print(even, end=' ') even += 2 # print(sum) odd = 1 ...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
t=int(input()) for j in range(t): n=int(input()) if (n/2)%2==1: print("NO") else: l=list(2*i for i in range(1,(n//2)+1)) l1=[] k=1 for i in range(n//2-1): l1.append(k) k+=2 y=sum(l)-sum(l1) l1.append(y) print("YES") ...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
import os import sys from io import BytesIO, IOBase def solution(n): if ((n * (n + 1)) // 2) & 1 == 1: write('NO') return first = list(range(2, n + 1, 2)) second = list(range(1, n, 2)) sum_f = sum(first) sum_s = sum(second) while sum_f >= sum_s: second[-1] += 2 ...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
for t in range(int(input())): n = int(input()) if (n // 2) % 2 == 1: print("NO") else: print("YES") a = [] j = 2 s1 = 0 for i in range(n // 2): a.append(j) j += 2 s1 += j j = 1 s2 = 0 for i in range((...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
t = int(input()) for _ in range(t): n = int(input()) if n%4: print("NO") else: arr = [] j = 2 for i in range(n//2): arr.append(j) j += 2 mx = arr[-1] j = 1 for i in range(n//2 - 1): arr.append(j) j += 2 arr.append(mx + n//2 - 1) print("YES") for i in arr: print(i, end = ' ') prin...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
def solve(n): even = [] odd = [1] ev = 2 od = 1 if n%4 != 0: print('NO') return else: last = int(2 * (n/4 + 1)) for i in range(n//2): even.append(ev) ev += 2 for i in range(1,n//2): if i == n/2-1: od +=...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
for _ in range(int(input())): a=int(input()) mid=int(a/2) if mid%2 != 0: print("NO") else: print("YES") oddlist=[] evenlist=[] even,odd,left,right=0,1,0,1 oddlist.append(odd) for i in range(mid): even=even+2 evenlist.append(even) left=even+left if i < mid-2: odd=odd+2 oddlist.appen...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
def solve(n): if n==2 or (n//2)%2==1: print("NO") else: evsum = oddsum = 0 ans = [] for i in range(0,n//2): e = 2*(i+1) ans.append(e) evsum += (e) for i in range(0,n//2): o = 2*i+1 ans.append(o) if i...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
import java.util.Scanner; public class Balances_Array { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int test = sc.nextInt(); for (int i = 0; i < test; i++) { int size = sc.nextInt(); if (size % 4 != 0) { System.out.pr...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
import sys input = sys.stdin.buffer.readline def print(val): sys.stdout.write(str(val) + '\n') def yo(): for _ in range(int(input().strip())): n, k = map(int,input().split()) nums = list(map(int,input().split())) common_values = [0 for _ in range(2*k+2)] for i in range(n//2): ...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
import sys t=int(sys.stdin.readline()) for _ in range(t): n = int(sys.stdin.readline()) if (n//2)%2: print("NO") continue list_a = [0]*n for i in range(n//2): list_a[i] = 2*(i+1) for i in range(n//2): list_a[i+n//2] = 2*(i+1)-1 list_a[-1] += n//2 print("YES"...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
import sys import math import heapq from collections import defaultdict, deque input = sys.stdin.readline def r(): return int(input()) def rm(): return map(int,input().split()) def rl(): return list(map(int,input().split())) '''B Balanced Array''' for _ in range(r()): n=r() if (n//2)&1: pri...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
N = int(input()) for k in range(N): a = int(input()) mus = [] summ =0 if int(a/2) % 2 != 0: print("NO") else: for ka in range(1, int(a/2)+1): mus.append(ka*2) summ+=ka*2 for z in range(0, int(a/2)-1): mus.append((2*z+1)) summ-=(...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
import java.io.*; import java.util.*; public class CF1343D extends PrintWriter { CF1343D() { super(System.out); } Scanner sc = new Scanner(System.in); public static void main(String[] $) { CF1343D o = new CF1343D(); o.main(); o.flush(); } void main() { int t = sc.nextInt(); while (t-- > 0) { int n = sc....
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
for t in range(int(input())): n = int(input()) if n % 4: print('NO') else: a = list(range(2, n + 1, 2)) + list(range(1, n - 2, 2)) + [n + n // 2 - 1] print('YES\n' + ' '.join(map(str, a)))
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
def solve(): T = int(input()) for t in range(T): n = int(input()) # even #odd + odd = even #odd + even = odd #even + even = even if (n // 2) % 2 == 1: print('NO') continue print('YES') arr = [] even_acc = ...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
t=int(input()) for i in range(t): A=[] B=[] n=int(input()) if n%4!=0: print("NO") else: s=0 i=2 while s!=n: A.append(i) if s<n/2: B.append(i-1) else: B.append(i+1) s+=2 i+=2 ...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
n = int(input()) for peradaban in range(n): a = int(input()) if(a % 4 != 0): print('NO') continue print('YES') for i in range(a//2): print((i + 1)*2, end=' ') for i in range(a//2 - 1): print(2*i + 1, end = ' ') print(a + a//2 - 1)
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
import java.io.*; public class Main { public static void main(String[] args) throws IOException { StreamTokenizer cin = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); PrintWriter cout = new PrintWriter(new OutputStreamWriter(System.out)); cin.nextToken(); ...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
# import sys # sys.stdin = open('input.txt', 'r') # sys.stdout = open('output.txt', 'w') ans = [] for i in range(int(input())): m = int(input()) if((m//2)%2 == 1): ans.append(['NO']) else: k = 1 l = 0 flag = 1 temp = [] for _ in range(m//2): temp...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
t=int(input()) for tt in range(t): n = int(input()) if (n // 2) % 2 != 0: print("NO") else: a = [] b = [] for i in range(2, n+1, 2): a.append(i) if i <= n//2: b.append(i - 1) else: b.append(i + 1) a....
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
FAST_IO = 1 if FAST_IO: import io, sys, atexit rr = iter(sys.stdin.read().splitlines()).next sys.stdout = _OUTPUT_BUFFER = io.BytesIO() @atexit.register def write(): sys.__stdout__.write(_OUTPUT_BUFFER.getvalue()) else: rr = raw_input rri = lambda: int(rr()) rrm = lambda: map(int, rr().s...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
import java.util.Scanner; public class BalancedArray { public static void main(String[] args) { Scanner input = new Scanner(System.in); int tests = input.nextInt(); while (tests-- > 0) { int n = input.nextInt(); solve(n); } } private static void sol...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @author niko */ public class Main ...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
from sys import stdin t = int(stdin.readline()) for _ in xrange(t): n = int(stdin.readline()) if n%4==0: print 'YES' a = [] b = [] st = 2 while len(a) + len(b)!=n: a.append(st) a.append(st+2) b.append(st-1) b.append(st + 3) ...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
#include <bits/stdc++.h> using namespace std; int main() { int test; cin >> test; for (int i = 0; i < test; i++) { int n; int a = 2, aa = 4, b = 1, bb = 5; cin >> n; if ((n % 4) != 0) { cout << "NO" << endl; } else { cout << "YES" << endl; int k = n / 4; for (int j = 1;...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
n = int(input()) for i in range(n): x = int(input()) if x % 4 != 0: print("NO") else: print("YES") l1 = [] l2 = [] m = 2 for j in range(x//4): l1.append(str(m)) l1.append(str(m+2)) l2.append(str(m+3)) l2.append(...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
for _ in range(int(input())): n=int(input()) ki=n//2 if(ki%2!=0): print("NO") else: print("YES") a,k=[],2 for i in range(ki): a.append(k) k=k+4 for i in range(ki): if(i%2==0): a.append(a[i]-1) else: ...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
from sys import stdin, exit, setrecursionlimit from collections import deque from heapq import * from math import gcd from math import ceil, log2 setrecursionlimit(10000000) from collections import deque input = stdin.readline lmi = lambda: list(map(int, input().split())) mi = lambda: map(int, input().split()) si = lam...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
cases = int(input()) while(cases>0): cases -= 1 n = int(input()) if n%4==2: print("NO") continue print("YES") for x in range(1, int(n/2)+1): print(2*x, end=" ") for x in range(1, int(n/2)): print(2*x-1, end=" ") print(int(n/2)-1+n, end=" ") print("")
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
t = int(input()) for i in range(t): n = int(input()) if(n % 4 != 0): print("NO") continue else: print("YES") a = 99999990 for i in range(1, n//4+1): print(a - i*2, end = " ") print(a + i*2, end = " ") for i in range(1, n//4+1): ...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
#include <bits/stdc++.h> using namespace std; int main() { int t; long long a, b = 0, c, x = 1, i, n; cin >> t; while (t--) { cin >> a; if (a % 4 != 0) cout << "NO\n"; else { cout << "YES\n"; b = a / 2; for (i = 2; i <= a; i += 2) { cout << i << " "; } for...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
t = int(input()) nlist = [int(input()) for x in range(t)] for x in range(t): if nlist[x]%4!=0: print("NO") else: print("YES") sum = 0 sum2 = 0 for y in range(1,nlist[x]+1): if y<=(nlist[x]/2): print(y*2,end=" ") sum+=y*2 ...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
from math import * for i in range(int(input())): n=int(input()) n=n//2 if n & 1: print("NO") continue print("YES") for i in range(1,n+1): print(i*2,end=" ") for i in range(1,n): print(i*2-1,end=" ") print(3*n-1)
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
#include <bits/stdc++.h> using namespace std; using ll = long long; ll power(ll x, ll y); const ll MOD = 1000000007; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ll t; cin >> t; while (t--) { ll n, k; cin >> n >> k; ll arr[n]; for (int i = 0; i < n; i++) cin >> arr[i];...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
''' Online Python Compiler. Code, Compile, Run and Debug python program online. Write your code in this editor and press "Run" button to execute it. ''' import sys t=int(sys.stdin.readline()) for i in range (t): n=int(sys.stdin.readline()) sum1=0 sum2=0 if(...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
t=int(input()) for i in range(t): n=int(input()) a=0 num1=[] if n%4!=0: print("NO") a+=1 if n%4==0: for i in range(n//2): num1.append(2*(i+1)) for i in range(n//4): num1.append(2*(i)+1) for i in range(n//4): if i==0: ...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
// Long Contest 1, Problem L import java.nio.charset.Charset; import java.lang.StringBuilder; import java.io.InputStream; import java.io.OutputStream; import java.io.IOException; import java.util.Arrays; public class Main { public static void main(String[] args) { Charset charset = Charset.forName("ascii"); Fa...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
for t in zip(*[iter([*open(0)][1:])]*2): (n,k),a=[[*map(int,t.split())]for t in t] c=[n]+[0]*k*2 for i in range(n//2): x,y=sorted((a[i],a[~i])) c[x]-=1 c[x+y-1]-=1 c[x+y]+=1 c[k+y]+=1 for i in range(k*2):c[i+1]+=c[i] print(min(c))
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
t = int(input()) for p in range(0,t): n,k = map(int,input().split()) a = list(map(int,input().split())) zerocnt = [0]*((2*k)+1) onecnt = [0]*((2*k)+2) # twocnt = [0]*((2*k)+2) for i in range(0,n//2): # print(onecnt) # print(a) zerocnt[a[i]+a[n-(i+1)]] +=1 chota ...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
t = int(input()) for i in range(t): n = int(input()) if n % 4 == 0: print('YES') a = [0] * n for i in range(n // 4): a[i * 2] = 2 + 10 * i a[i * 2 + 1] = 4 + 10 * i a[i * 2 + n // 2] = 1 + 10 * i a[i * 2 + 1 + n // 2] = 5 + 10 * i p...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
#include <bits/stdc++.h> using namespace std; signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long t; cin >> t; for (long long j = 0; j < t; ++j) { long long n; cin >> n; if (n % 4 != 0) cout << "NO" << endl; else { cout << "YES" << endl; vector<long lon...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
#include <bits/stdc++.h> using namespace std; int main() { long long t; cin >> t; while (t--) { long long n; cin >> n; vector<long long> vec; if (n % 4 == 0) { cout << "YES" << endl; long long sum = 0; for (long long k = 2; k <= n; k += 2) { vec.push_back(k); sum ...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
t=int(input()) for i in range(t): n=int(input()) s=n//2 if n%4!=0: print("NO") else: r=[2] for i in range(1,s): r.append(r[i-1]+2) o=[1] for i in range(1,s): o.append(o[i-1]+2) o[len(o)-1]+=n//2 print("YES") print(*(...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
def solution(): from sys import stdout, stdin _input, _print = stdin.readline, stdout.write for _ in range(int(input())): n = int(input()) if n // 2 % 2 == 1: print("NO") else: print("YES") arr = [(i+1) * 4 for i in range(n//2)] last = ...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
for cases in range(int(input())): n = int(input()) if n%4 != 0: print("NO") else: print("YES") for i in range(1,int((n/2)+1)): print(2*i, end=" ") for i in range(1,int(n/2)): print((2*i)-1, end=" ") print(2*int(n/2)+int(n/2)-1)
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5, inf = 1e9; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t; cin >> t; while (t--) { int n; cin >> n; if ((n / 2) & 1) { cout << "NO\n"; } else { cout << "YES\n"; long long sum...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
import math t=int(input()) for i in range(t): n=int(input()) x=int(math.log2(n)) if (n//2)&1==0: print('YES') a=2 for i in range(n//2): print(a,end=' ') a+=2 a=1 for i in range(n//2 + 1): if i==n//4: a+=2 ...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
t = int(input()) l = [] for e in range(t): l.append(int(input())) for e in l: if e % 4 != 0: print('NO') else: sol = [] print('YES') for i in range(2,e+1,2): sol.append(str(i)) for i in range(1,e,2): sol.append(str(i)) sol[-1] = s...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
for _ in range(int(input())): n=int(input()) s = n*(n+1)//2 if s%2: print("NO") else: print("YES") a=[2]*(n//2) + [1]*(n//2) s1, s2 = 0, 0 for i in range(n): if a[i]%2==0: a[i]*=(i+1) s1+=a[i] else: ...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
t=int(input()) while(t): n=int(input()) A=[] for i in range(1,n+1): A.append(i) Ev=[] Od=[] for i in range(len(A)): if(A[i]%2==0): Ev.append(A[i]) else: Od.append(A[i]) c=Ev+Od d=sum(Ev) e=sum(Od) if(d==e): print("YES") ...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
for i in range(int(input())): n = int(input()) div = n//2 if(div % 2==0): print("YES",end = "\n") part1=0 part2=0 for i in range(2,n+1,2): part1 = part1 + i print(i,end = " ") for j in range(1,n-1,2): part2 = part2 + j p...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
for n in map(int,[*open(0)][1:]): n//=2 if n%2: print('NO') continue print('YES') a=[i*4for i in range(4,n+4)] a+=[i*4+(1,-1)[i%2]for i in range(4,n+4)] print(*a)
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
for _ in range(int(input())): n = int(input()) ans = [] if(n%4 != 0): print('NO') else: ach = 0 for i in range(2,n+1,2): ans.append(str(i)) ach += i cnt = int(n) tsum = 0 for i in range(1, n-1,2): tsum+=i ans...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
total = int(input()) numbers = [0] * total for i in range(total): numbers[i] = int(input()) for number in numbers: if number%4 == 0: print("YES") arr = [] for evens in range(2, (number)+1, 2): arr.append(evens) for odds in range(1, (number), 2): arr.append...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
q = int(input()) for _ in range(q): n, k = list(map(int, input().split(" "))) arr = list(map(int, input().split(" "))) ans = [0 for i in range(2*k + 1)] # count = 0 if n == 2: print(0) continue for j in range(n//2): x, y = arr[j], arr[n-1-j] mid = x ...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
#!/usr/bin/env python import os import sys from io import BytesIO, IOBase def main(): pass # region fastio BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = BytesIO() self.writable = "x" in file.mode or "r" not ...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
def solve(n): global arr if n % 4: return False arr = [-1] * n for i in range(n >> 1): arr[i] = (i << 1) + 2 k = 1 M = set() for i in range(0, n >> 1, 2): su = arr[i] + arr[i + 1] while k in M or (su - k) in M: k += 2 arr[i + (n >> 1)] = k ...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
T = int(input()) for t in range(T): n , k = map(int , input().split()) values = list(map(int , input().split())) zero = [0]*(2*k+2) one = [0]*(2*k+2) prefix_one = [0]*(2*k+2) two = [0]*(2*k+2) for i in range(n//2): temp = values[i] + values[n-i-1] min_sum = min(values[i] ,...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
for _ in range(int(input())): n = int(input()) lst = [0]*n even = 2 for i in range(n//2): lst[i] = even even += 2 odd = 1 for j in range(n//2, n): lst[j] = odd odd += 2 diff = abs(sum(lst[n//2:n]) - sum(lst[0:n//2])) if diff%2 == 0: lst[-1] += diff print("YES") print(*lst) else: print("NO")
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
def fun(n): if n == 2: print("NO") return if (n/2) % 2 == 1: print("NO") return print("YES") even = [i for i in range(1, n+1) if i % 2 == 0] count = 0 for i in even: print(i, end=" ") l = len(even) for i in range(l - 1): print(even[i]...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; vector<int> v1, v2; while (t--) { int n; cin >> n; int x = n / 2; if (x % 2 != 0) cout << "NO\n"; else { cout << "YES\n"; for (int i = 2; i <= n; i = i + 2) cout << i << " "; for (int i = 1; i...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
m=int(input()) for i in range(m): n=int(input()) b=n/2 if b%2!=0: print("NO") else: print("YES") a=[] for j in range(2,n+1,2): print(j,end=' ') a.append(j) for k in range((n//2-1)): print(a[k]-1,end=' ') print(a[-1]+n//2...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
t=int(input()) i=0 while i<t: n=int(input()) a=n//2 if a%2==0: print("YES") j=0 res1=0 sum1=0 while j<a: print(res1+2,end=" ") res1=res1+2 sum1=sum1+res1 j=j+1 j=0 #print(res1) sum2=...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
for _ in range(int(input())): n=int(input()) a=[] k=2 evensum=0 for i in range(n//2): a.append(k) evensum+=k k+=2 odd=1 oddsum=0 for i in range(n//2-1): a.append(odd) oddsum+=odd odd+=2 if(evensum-oddsum)%2==1: a.append((evensum...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
nu = int(input()) for i in range(0, nu): n = int(input()) a = [] b = [] if (n//2)%2 == 0: print("YES") for i in range(2, (n//2)*2+1, 2): a.append(i) for i in range(1, (n//2)*2+1, 2): b.append(i) s = sum(a) - sum(b) if (s == 0): c = a + b for i in range (0, n-1): print(c[i], end=' ') p...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
for j in range(int(input())): n = int(input()) if (n // 2) % 2 == 1: print('NO') else: print('YES') sum = 0 first_half = [0]*(n//2) for i in range(n//2): first_half[i] = (i+1)*2 sum+=(i+1)*2 second_half = [0]*(n//2) for i in...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
for _ in range(int(input())): n,k=map(int,input().split()) ar=list(map(int,input().split())) su=[0]*(2*k+2) for i in range(n//2): a,b=min(ar[i],ar[n-i-1]),max(ar[i],ar[n-i-1]) su[0]+=2 su[a+1]-=1 su[a+b]-=1 su[a+b+1]+=1 su[b+k+1]+=1 ans=[] prev=0 ...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
from sys import stdin, stdout read = stdin.readline write = stdout.write for _ in range(int(read())): n = int(read()) if (n / 2) % 2 == 1: write("NO" + '\n') else: write("YES" + '\n') for i in range(2, n + 1, 2): write(str(i) + ' ') for i in range(1, n - 2...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
for i in range(int(input())): n = int(input()) if n % 4 != 0: print("NO") else: print("YES") for k in range(1, n // 2 + 1): print(k * 2, end=' ') for j in range(1, n // 2): print(j * 2 - 1, end=' ') print(3 * (n // 2) - 1)
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
def f(n): L=[0]*n L[0]=2 L[n//2]=1 for i in range(1,n//2): if i%2==0: L[i]=L[i-1]+4 else: L[i]=L[i-1]+2 for j in range((n//2)+1,n): if j%2==0: L[j]=L[j-1]+2 else: L[j]=L[j-1]+4 return L N=int(input()) while N>0: ...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
import java.io.*; import java.util.*; public class Main { public static class FastReader { BufferedReader br; StringTokenizer root; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while (root == null || !root.hasMoreTokens()) { try { ...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
INT_MAX=10**18+7 MOD=10**9+7 def INPUT():return list(int(i) for i in input().split()) def LIST_1D_ARRAY(n):return [0 for _ in range(n)] def LIST_2D_ARRAY(m,n):return [[0 for _ in range(n)]for _ in range(m)] GETA=123 ############################################################################### for _ in range(int(input...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
def main(): t = int(input()) while t > 0: n, k = map(int, input().split()) arr = [int(e) for e in input().split()] mp = {} vec = [] for i in range(int(n/2)): if arr[i] + arr[n-i-1] not in mp: mp[arr[i]+arr[n-i-1]] = 0 mp[arr[i]+arr[...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
import java.io.*; import java.util.*; public class B_636 { public static void main(String[] args)throws IOException { BufferedReader ob=new BufferedReader(new InputStreamReader(System.in)); StringBuffer sb=new StringBuffer(); int test=Integer.parseInt(ob.readLine()); while(test-->0) { int n=Intege...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
# ------------------- fast io -------------------- import os import sys from io import BytesIO, IOBase BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = BytesIO() self.writable = "x" in file.mode or "r" not in file.mode...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
""" nombre: Balanced Array id: 1343B fuente: codeforces coder: Cgesu Coder """ for _ in range(int(input())): n = int(input()) k = n // 2 if k % 2 != 0: print("NO") else: print("YES") for i in range(k): if i != 0: print(" ", end="") ...
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
import math t=int(input()) for i in range(t): n=int(input()) if n%4==2: print("NO") else: print("YES") l=[] c=2 for w in range(n//2): l.append(c) c+=4 c=1 for w in range(0,n//2,2): l.append(l[w]-1) l.append(l[w+1]+1) print(' '.join(str(x) for x in l))
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a are odd (not divisible by 2); * all elements of a are distinct a...
#include <bits/stdc++.h> using namespace std; const long long lim = 1e9 + 10; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int t; cin >> t; while (t--) { long long i, j, n, x; cin >> n; x = n / 2; if (x % 2 == 1) { cout << "NO\n"; continue; } ...