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...
# -*- coding: utf-8 -*- """ Created on Thu Apr 2 19:56:34 2020 @author: NoOne This is for CodeForces """ t = int(input()) for _ in range(t): n = int(input()) if (n//2)%2 != 0: print('NO') else: print('YES') print(*list(range(2,n+1,2)),*list(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...
t=int(input()) import math while t: t=t-1 n=int(input()) n=n//2 if n%2==0: lst=[] i=2 s=0 m=n while n: n=n-1 s=s+i lst.append(i) i=i+2 i=1 while m: if m==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 compute(n): arr = [] if (n//2)%2 != 0: print("NO", end="") else: cur_even = 2 cur_odd = 1 cur_sum_even = 0 cur_sum_odd = 0 for _ in range(n//2): cur_sum_even += cur_even arr.append(cur_even) cur_even += 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; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); long long pow(long long x, long long n) { long long res = 1; while (n) { if (n & 1) res = (res * x); x = (x * x); n >>= 1; } return res; } int32_t main() { ios_base::sync_with_stdio(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 def solve(): n = int(input()) soe = (n//2)*((n//2) + 1) soo = (n//2)**2 if (soe - soo) % 2 == 1: print("NO") else: print("YES") e, o = 2, 1 for i in range(2, 2*(n//2) + 2, 2): print(i, end=" ") for i in range(1, 2*(n//2) - 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 _ in range(int(input())): n=int(input()) if n%4==2: print("NO") else: a=[] print('YES') s=0 for i in range(n//2): x=2*(i+1) a.append(x) s+=x s1=0 for i in range(n//2-1): x=2*i+1 a.append(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...
#include <bits/stdc++.h> using namespace std; void fast() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } long long int gcd(long long int x, long long int y) { if (y == 0) return x; return gcd(y, x % y); } long long int lcm(long long int a, long long int b) { return (a * b) / gcd(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...
import java.util.*; import java.io.*; public class D1343 { static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); static PrintWriter pr = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); static StringTokenizer st; public static void main(String[]args)throws IOExcept...
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 collections import deque tc=int(input()) for i in range(tc): n=int(input()) if (n//2)%2==0: print('YES') l=deque() for i in range(n//2): l.append((i+1)*2) for i in range(n//2): l.append(l[i]-1) l[-1]=l[(n//2)-1]+((n//2)-1) print(" ".jo...
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, k = map(int, sys.stdin.readline().split()) list_num = list(map(int, sys.stdin.readline().split())) list_check = [0]*(2*k+2) for i in range(n//2): a, b = sorted([list_num[i], list_num[-1-i]]) list_check[a+b] -= 1 list_...
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(int(input())) for x in range(t): n=int(input()) if(n<=2): print("NO") elif(n//2)%2!=0: print("NO") else: List=[0 for y in range(n)] e=2 i=0 while i<(n//2): List[i]=e e+=2 i+=1 e=1 while 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...
from math import * for zz in range(int(input())): n = int(input()) if n % 4 != 0: print('NO') else: print('YES') a = [] cs = 0 ce = 2 for i in range(n//2): a.append(ce) cs += ce ce += 2 ce = 1 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...
for _ in range(int(input())): n=int(input()) x=[] if n%4==0: print("YES") for i in range(1,n//2+1): x.append(2*i) for i in range(1,n//2+1): x.append(2*i-1) x[len(x)-1]=x[len(x)-1]+n//2 for i in range(len(x)): print(x[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...
for i in range(int(input())): num = int(input()) if num % 4 == 0: lis = [] print("YES") for n in range(2,num+1, 2): print(n, end = ' ') lis.append(n) c = 0 for k in lis: if k == num: print(num+c, 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...
from sys import stdin import sys from sys import stdout g = lambda : stdin.readline().strip() gl = lambda : g().split() gil = lambda : [int(var) for var in gl()] gfl = lambda : [float(var) for var in gl()] gcl = lambda : list(g()) gbs = lambda : [int(var) for var in g()] mod = int(1e9)+7 inf = float("inf") t, = gil...
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())//2 if n%2 == 1: print("NO") else: print("YES") a = [i*2 for i in range(1,n+1)] b = [i*2+1 for i in range(n-1)] b.append(sum(a) - sum(b)) print(*a, *b) t -= 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//2)%2!=0): print("NO") else: print("YES") l=[] for j in range(2,x+1,2): l.append(j) l1=[] for j in range(1,x+1,2): l1.append(j) #print(sum(l),sum(l1)) if(sum(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; int main() { int t; cin >> t; for (int j = 0; j < t; j++) { int n; cin >> n; if (n % 4 != 0) { cout << "NO" << endl; continue; } else { cout << "YES" << endl; } for (int j = 1; j <= n / 2; j++) { cout << j * 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 math t=int(input()) for i in range(t): n=int(input()) arr=[] x=2 c=0 for j in range(n//2): arr.append(x) x+=2 s=sum(arr) y=1 for j in range((n//2)-1): arr.append(y) s-=y y+=2 if(s%2==0): print("NO") else: arr.append(s) print("YES") print(*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...
k = int(input()) for i in range(k): n = int(input()) a = [0] * n b = 1 sum_i = 0 sum_j = 0 for i in range(1, n // 2 + 1): a[i - 1] = i * 2 sum_i += i * 2 for j in range(n // 2 + 1, n): a[j - 1] = b sum_j += b b += 2 if (sum_i - sum_j) % 2 != 0 or 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=[] if n%4!=0: print("NO") else: print("YES") e=0 for i in range(n//2): e+=2 s.append(e) o=1 for j in range(n//4): s.append(o) o+=2 for k in range(n//4): ...
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 x in range(t): n = int(input()) if n%4 != 0: print("NO") else: l = [2*i for i in range(1,n//2 + 1)] for i in range(n//2-1): temp = l[i] l.append(temp-1) temp = l[n//2 - 1] l.append(temp+n//2-1) 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, k = map(int, input().split()) a = list(map(int, input().split())) sum_costs = [n // 2] * (k * 2 + 1) lower_penalties = [0] * (k * 2 + 1) upper_penalties = [0] * (k * 2 + 1) for ai, aj in zip(a[:n // 2], reversed(a[n // 2:])): sum_costs[ai + aj] -=...
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: print("NO") else: print("YES") x = [] i = 2 for j in range(n//2): x.append(i) i += 2 sm = sum(x) i = 1 for j in range(n//2): x.append(i) 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...
t = int(input()) for _ in range(t): k = int(input()) n = k//2 if n % 2 != 0: print("NO") else: print("YES") l1 = [x for x in range(2, k+1, 2)] l2 = [x for x in range(1, k-2, 2)] for i in l1: print(i, end = ' ') for j in l2: print(j,...
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 for i in range(n)] if n%4!=0: print('NO') else: print('YES') for j in range (n//2): a[j]=(j+1)*2 for j in range (n//2, n): a[j]=1+j*2-n a[n-1]=a[n//2-1]+n//2-1 for j 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...
if __name__ == "__main__": t = int(input()) for _ in range(t): n = int(input()) if n % 4 == 0: j = 0 print("YES") for _ in range(0, n // 4): print(j + 2, j + 4, sep=" ", end= " ") j += 6 j = 0 for _ in ra...
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...
# benzene_ <> t = int(input()) for _ in range(t): n=int(input()) e=[2+i for i in range(0,n,2)] ;o=[] s=sum(e) for j in range(1,n-1,2): o.append(j) s=s-j if s<0 or s%2==0: print('NO') else: print('YES') e.extend(o) e.append(s) for g in e: ...
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()) n//=2 if(n%2==1): print("NO") else: print("YES") l=[] for i in range(1,n+1): l.append(2*i) s=sum(l) for i in range(n-1): l.append(2*i+1) l.append(s+s-(sum(l))) for i 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...
def solve(n): list=[] if int(n/2)%2!=0: print('NO') else: print('YES') for i in range(1,int(n/2)+1): list.append(2*i) for i in range(0,int(n/2)-1): list.append(1+(i*2)) k=int(n/2)*(int(n/2)+1)-((int(n/2)-1)**2) list.append(k) 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...
for i in range(int(input())): n = int(input()) if n%4!=0: print('NO') else: print('YES') print(*range(2,n+1,2),*range(1,n-1,2),(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...
import math from decimal import * getcontext().prec = 30 t = int(input()) while t: t -= 1 n, k = map(int, input().split()) a = list(map(int, input().split())) l=[0]*(2*k+2) for i in range(n//2): l[1]+=2 l[2*k+1]-=2 mini=min(a[i],a[n-1-i])+1 maxi=max(a[i],a[n-1-i])+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...
for _ in range(int(input())): n = int(input()) e = [] o = [] if n%4 != 0: print("NO") else: print("YES") for i in range(1,n+1): if i%2 == 0: e.append(i) else: o.append(i) l = e+o l[-1] = l[-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()) for _ in range(t): n=int(input()) k=n//2 if(k%2!=0): print("NO") continue print("YES") for i in range(1,k): print(2*i,end=" ") print(3*k,end=" ") for i in range(1,k+1): print(2*i+1,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()) while t>0: n=int(input()) if(n/2)%2==1: print("NO") else: print("YES") a=list(range(2,n+2,2))+list(range(1,2*(int(n/2)-1)+1,2))+[n+int(n/2)-1] print(*a,sep=' ') t=t-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 _ in range(t): n = int(input()) if n%4 != 0: print('NO') else: print('YES') print(*([i*2+2 for i in range(n//2)] + [i*2+1 for i in range(n//2-1)] + [n+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...
// I know stuff but probably my rating tells otherwise... // Kaafi din baad aaye hai... Swagat nhi kariyega??? // Kya hua, code samajhne ki koshish kar rhe ho?? Mat karo, // mujhe bhi samajh nhi aata kya likha hai import java.io.*; import java.util.*;...
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 ##################################################################### def iinput(): return int(stdin.readline()) def minput(): return map(int, stdin.readline().split()) def linput(): return list(map(int, stdin.readline().split())) ###################################################################...
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 sol(n): mid=n//2 l1=[ 2*i for i in range(1,mid+1) ] sum1=sum(l1) l2=[2*j-1 for j in range(1,mid)] sum2=sum(l2) diff=sum1-sum2 if diff%2==0: return 'NO',None else: l2.append(diff) l1.extend(l2) return 'YES',(' '.join(map(str,l1))) for _ in range(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...
t=int(input()) l=[] for i in range(t): m=int(input()) l.append(m) for i in l: if i%4==2: print("NO") else: print("YES") x=[] y=[] for j in range(int(i/2)): x.append(2*j+2) y.append(2*j+1) y.pop(-1) z=sum(x)-sum(y) y....
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('NO') continue else: print('YES') ev=[] od=[] for i in range(1,10000000,5): if(len(ev)+len(od)>=n): break if(i%2==1): ev.append(i+1) ev.append(i+3) od.append(i) od.append(i+4) else: od.append(i+1) od.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...
for i in range(0,int(input())): k = int(input()) if (k//2) % 2 == 1: print("NO") continue print("YES") k//=2 for i in range(1,k+1): print(i*2,end=' ') for i in range(1,k): print(i*2-1,end=' ') print(3*k -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 t in range(int(input())): n=int(input()) if n%4!=0: print("NO") else: li=[0]*n prev=-2 for i in range(0,n//2): if i%2==0: li[i]=prev+4 else: li[i]=prev+2 prev=li[i] counter=0 for i in rang...
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> void swap(int* x, int* y) { int u = *x; *x = *y; *y = u; return; } int main() { int t; scanf("%d", &t); for (int i = 0; i < t; i++) { int n; scanf("%d", &n); if ((n / 2) % 2 == 1) { printf("NO"); } else { printf("YES\n"); for (int j = 0; j < 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...
def task(n): if n % 4 != 0: print('NO') return a = [0] * n half = int(n / 2) chunks = int(n / 4) for i in range(0, chunks): a[i * 2] = i * 6 + 2 a[i * 2 + 1] = i * 6 + 4 a[half + i * 2] = i * 6 + 1 a[half + i * 2 + 1] = i * 6 + 5 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 _ in range(int(input())): n = int(input()) if (n//2)%2==1: print('NO') else: print('YES') a = [] b = [] for i in range(1,n+1,2): a += [i] for i in range(2,n+1,2): b += [i] a[-1] += sum(b)-sum(a) print(*b,*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...
t=int(input()) for i in range(t): n=int(input()) if(n%4==0): print("YES") k=2 sum1=0 for i in range(n//2): print(k,end=" ") sum1+=k k=k+2 k=1 sum2=0 for i in range(n//2-1): print(k,end=" ") 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...
for i in range(int(input())): n,k=[int(i) for i in input().split()] arr=[int(i) for i in input().split()] d={} na=[0 for i in range(2*k+2)] for i in range(n//2): d[arr[i]+arr[-1-i]]=d.get(arr[i]+arr[-1-i],0)+1 na[max(arr[i],arr[-1-i])+k+1]+=-1 na[min(arr[i],arr[-1-i])+1]+=1 for i in range(1,2*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...
for _ in range(int(input())): n=int(input()) if (n//2)%2: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...
t = int(input()) for _ in range(t): n=int(input()) if(((n//2)%2)!=0): print("NO") else: v=[] c=0 s=0 for i in range(n//2): q=(i+1)*2 v.append(q) c+=q for i in range(n//2,n-1): p=2*(i-n//2+1)-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.*; public class Main { public static void main(String[] args) { Scanner s=new Scanner(System.in); int t=s.nextInt(); while(t!=0){ int n=s.nextInt(); int k=n/2; int v=0,f=0; int e=2; int o=1; int sume=0,sumo=0; int a[]=new int[k]; int b[]=new 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 i in range(int(input())): aL = int(input()) n = aL // 2 sumOfEven = n*(n+1) sumOfOdd = n*n if (sumOfEven - sumOfOdd) % 2 == 0: print("YES") lst = [2*s for s in range(1,n+1)] olst = [2*s+1 for s in range(n)] olst[n-1] = olst[n-1] + sumOfEven - sumOfOdd lst....
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; mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count() + 'd' + 'o' + 'i' + 'n' + 'g' + 'g' + 'e' + 'y'); const int inf = 1e9; const double eps = 1e-6; double start_time; const int maxn = 5e5 + 1; int t0[maxn], t1[4 * maxn], t2[4 * maxn]; int...
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()) l=[] for _ in range(testcases): n=int(input()) l.append(n) for i in l: if((i//2)%2!=0): print("NO") else: print("YES") l2=[] c=2 for j in range(i//2): l2.append(c) c+=2 k=sum(l2) # l3=[] c=1 for j in range((i//2)-1): l2.append(c) c+=2 p=sum(l2[(i//2):]) l2.ap...
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...
/** * CodeForces * 02/12/2020 */ import java.util.*; public class B1343_0636_Balanced { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int t = scanner.nextInt(); for (int i = 0; i < t; i++) { int n = scanner.nextInt(); if (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...
from fractions import Fraction from collections import defaultdict import math 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....
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) { // TODO Auto-generated method stub Scanner scn = new Scanner(System.in); int test = scn.nextInt(); while (test > 0) { int N = scn.nextInt(); int c = N / 2; if (c % 2 != 0) { System.out.println("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 java.io.*; import java.util.*; import java.math.*; import java.lang.*; import static java.lang.Math.*; public class Solution implements Runnable { static class InputReader { private InputStream stream; private byte[] buf = new byte[1024]; private int curChar; private int numChars; private Space...
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; struct Fenwick { vector<long long int> BIT; long long int N; Fenwick(long long int n) { N = 2 * n + 2; BIT.resize(N + 10); } void reset() { for (long long int i = 0; i <= N; i++) BIT[i] = 0; } void add(long long int r, long long int value) { 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...
for _ in range(int(input())): y=int(input()) if y%4==2: print("NO") else: a=[] print('YES') s=0 for i in range(y//2): x=2*(i+1) a.append(x) s+=x s1=0 for i in range(y//2-1): x=2*i+1 a.append(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...
t = int(input()) for _ in range(t): n = int(input()) half = n//2 if half%2 != 0: print("NO") else: arr = [] start = 0 count = 0 print("YES") for i in range(n//2): arr.append(start+2) count += start+2 start += 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 _ in range(int(input())): n = int(input()) if (n%2)!=0:print("NO") elif (n//2)%2!=0:print("NO") else: print("YES") lo,last = 0,0 for i in range(1,n//2+1): print(2*i,end=" ") lo += 2*i last = 2*i lo -= last for i in range(1,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...
from sys import stdin, stdout for i in range(int(stdin.readline())): n = int(stdin.readline()) if n % 4 == 0: stdout.write('YES' + '\n') for j in range(1, n//2 + 1): stdout.write(str(j * 2) + ' ') for k in range(1, n//2 + 1): if k == n//2: stdout.w...
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; while (t--) { int n; cin >> n; if ((n / 2) % 2 != 0) cout << "NO" << endl; else { cout << "YES" << endl; vector<int> v(n); int k = 1, sum = 0, sum1 = 0; for (int i = 0; i < n / 2; 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...
t = int(input()) for _ in range(t): n, k = map(int, input().rstrip().split()) arr = list(map(int, input().rstrip().split())) pairsNeeding0chng = {} pairsNeeding01chng = [0]*(2*k+2) for pos in range(n//2): L = min(arr[pos], arr[n-pos-1]) R = max(arr[pos], arr[n-pos-1]) if L+R ...
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 bs(a): low = 0 high = len(li) - 1 while low <= high: if high - low < 5: for i in range(low, high+1): if li[i] >= a: return i return 0 mid = (low + high) // 2 if li[mid] >= a: high = mid 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...
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun May 3 17:02:53 2020 @author: neb0123 """ def max_overlap(start, end): n = len(start) start.sort() end.sort() inter = 1 max_inter = 1 i = 1 j = 0 while i < n and j < n: if start[i] <= end[j]: inte...
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; while (t--) { int n, k; cin >> n >> k; int a[n]; for (int i = 0; i < n; i++) cin >> a[i]; vector<int> sum(2 * k + 1), InRange(2 * k + 2); for (int i = 0; i < n / 2; i++) { sum[a[i] + a[n - 1 - 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...
import bisect import os import gc import sys from io import BytesIO, IOBase from collections import Counter from collections import deque import heapq import math import statistics def sin(): return input() def ain(): return list(map(int, sin().split())) def sain(): return input().split() def iin(): ...
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; long long gcd(long long a, long long b) { if (!a) return b; return gcd(b % a, a); } long long mpower(long long x, long long y, long long p) { long long res = 1; x = x % p; while (y > 0) { if (y & 1) { res = (res * x) % p; } y = y >> 1; x = (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...
#include <bits/stdc++.h> using namespace std; const int NMAX = 2 * 1e5 + 2; int t, n, valeurs[NMAX]; int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> t; for (int test = 1; test <= t; test++) { cin >> n; if (n % 4 != 0) { cout << "NO\n"; } else { int moitie = n / 2, somme = 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...
test=int(input()) for i in range(test): sum=int(input()) if ((sum>>1)%2)==1:print("NO") else: print("YES") sum=sum>>1 for i in range(1,sum+1): print(2*i,end=" ") for i in range(1,sum): print((2*i-1),end=" ") print((sum*3-1),end="\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 i in range(int(input())): n = int(input()) if n%4!=0: print("NO") else: print("YES") mid=n//2 arr = [int(i)*2 for i in range(1,mid+1)] x=sum(arr) y=0 for i in range(len(arr)-1): arr.append(arr[i]-1) y=y+ arr[i]-1 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...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t; cin >> t; while (t--) { long long int n; cin >> n; long long int x = n / 2; if (x % 2 != 0) { cout << "NO" << endl; } else { cout << "YES" << endl; long long...
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 for query in range(int(stdin.readline())): nk=stdin.readline().split() n=int(nk[0]) k=int(nk[1]) a=[int(x) for x in stdin.readline().split()] mylist=[0]*2*k b=[] for x in range(n//2): b.append([a[x],a[n-x-1]]) for x in b: mylist[1]+=2 mylist[min(x)]-=1 mylist...
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()) c=0 arl=[] while c<n//2: arl.append((c+1)*2) c+=1 arr=[] for ele in arl: arr.append(ele-1) arr[-1]=n//2-1+arl[-1] ar=arl+arr if arr[-1]%2: print("YES") for ele in ar: print(ele,end=" ") els...
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") else: print("YES") A = [2] z = 2 for i in range(1,N//2): A.append(A[i-1]+2) z+=(A[i-1]+2) A.append(1) y = 1 for i in range(N//2+1,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...
from sys import stdin, setrecursionlimit, stdout #setrecursionlimit(1000000) from collections import deque from math import sqrt, floor, ceil, log, log2, log10, pi, gcd, sin, cos, asin def ii(): return int(stdin.readline()) def fi(): return float(stdin.readline()) def mi(): return map(int, stdin.readline().split()) def...
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...
try: T=int(input()) for i in range(T): n=int(input()) if n%4!=0: print("NO") else: l=[] print("YES") for i in range(2,n+1,2): l.append(i) for i in range(1,n,2): l.append(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 io,os input=io.BytesIO(os.read(0,os.fstat(0).st_size)).readline import sys from itertools import accumulate def solve(n,k,A): L=[] for i in range(n//2): L.append((min(A[i],A[n-i-1]),max(A[i],A[n-i-1]))) Imos=[0]*(2*k+2) for a,b in L: #a<=b if a!=1: Imos[2]+=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()) for _ in range(t): n = int(input()) if (n // 2) % 2 != 0: print('NO') else: print('YES') ans = [] c = 2 for i in range(n // 2): print(c, end=' ') c += 2 c = 1 for j in range((n // 2) - 1): print(c, end=' ') c += 2 print(c + (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()) for i in range(0,t): n=int(input()) if n%4!=0: print('NO') else: l=[] j=2 for i in range(0,n//2,2): l.append(j) j+=2 l.append(j) j+=4 j=1 for i in range(n//2,n,2): l.append(j) ...
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()) arr = [] j =2 s = 0 s2 = 0 for i in range(n//2): arr.append(j) s+=j j+=2 j=1 for i in range(n//2 -1): arr.append(j) s2+=j j+=2 flag = 0 if s - s2> arr[n-2] and (s-s2)%2==1: arr.append(s-s2) flag = 1 if flag ==1: print("YES") print(*arr) 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...
#include <bits/stdc++.h> using namespace std; template <typename Arg1> void __f(const char* name, Arg1&& arg1) { std::cerr << name << " : " << arg1 << '\n'; } template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args) { const char* comma = strchr(names + 1, ','); std::cerr...
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.readline from itertools import accumulate t = int(input()) for _ in range(t): n,k = map(int,input().split()) a = list(map(int,input().split())) acc = [0]*(k*2+2) for i in range(n//2): a1,a2 = a[i],a[-i-1] mn = min(a1,a2) acc[a1+a2] -= 1 acc[mn+1] -= 1 acc[2] += 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 _ in range(int(input())): x : int = int(input()) y : int = int(x/2) if (y%2)==1 or x==2: print("NO") else: print("YES") arr = [] for i in range(y): arr.append((i+1)*2) sum = (y)*(y+1) for j in range(x-1): if (j<y): ...
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...
tc = int(input()) for ii in range(tc): num = int(input()) if (num//2)%2!=0: print("NO") else: even = [] odd = [] cumsum = 0 for i in range(1,num//2): cumsum+=1 even.ap...
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 answer(): n=int(input()) potato=n ans=[] while n: a=int(input()) if a%4: ans.append("NO") else: ans.append("YES") c=[2*i for i in range(1,int(a/2)+1)] d=[i*2-1 for i in range(1,int(a/2))] e=c[-1]+len(d) d.append(e) ...
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 s in[*open(0)][1:]:n=int(s)//2;a=range(2,4*n+1,4);print(*(['YES']+[*a]+[i+(-1)**(i//4)for i in a],['NO'])[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()) for i in range(0,t): x=int(input()) if (x/2)%2!=0: print('NO') else: lst=[] print('YES') for i in range(2,x+1): if i%2==0: lst.append(i) y=len(lst) for i in range(0,y): if i<y/2: lst.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...
for _ in range(int(input())): n=int(input()) a=list(range(2,n+1,2))+list(range(1,n,2)) a[-1]+=n//2 print(['YES','NO'][a[-1]&1==0]) if a[-1]&1: 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 i in range(int(input())): n=int(input()) if n%4==0: a=[] n=n//2 print("YES") for j in range(1,n+1): a.append(2*j) #a.append(n) for j in range(1,n): a.append(2*j-1) a.append(3*n-1) print(*a) 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...
/*package whatever //do not write package name here */ import java.util.*; import java.lang.*; import java.io.*; import java.util.ArrayList; public class GFG { public static void main (String[] args) { //code Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t-->0){ int n=sc.nextInt(); 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 math def solve(): n=int(input()) if(n%2==1): print("NO") else: v=n//2 if(v%2==1): print("NO") else: l1=[] sum1=0 sum2=0 c=2 for i in range(v): l1.append(c) sum1+=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...
n = int(input()) for i in range(n): x = int(input()) if (x/2)%2!=0: print("NO") else: print("YES") l=[] l1=[] for i in range(0,x+1,2): l.append(str(i)) l1.append(i) l.remove('0') l1.remove(0) for j in range(1,x-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...
#include <bits/stdc++.h> using namespace std; const int size = 2e5 + 11; int a[size], b[size]; int main(void) { int t, n; scanf("%d", &t); while (t--) { scanf("%d", &n); int k = 1; if (n % 4 != 0) cout << "NO" << endl; else { int w = n, c = 0, i = 0, j = 0; cout << "YES" << endl;...
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 from __future__ import division, print_function import os import sys from io import BytesIO, IOBase if sys.version_info[0] < 3: from __builtin__ import xrange as range from future_builtins import ascii, filter, hex, map, oct, zip def main(): t = inp() for i in range(t): ...
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 python3 from collections import defaultdict,deque from heapq import heappush, heappop from bisect import bisect_left, bisect_right import sys, random, itertools, math sys.setrecursionlimit(10**5) input = sys.stdin.readline sqrt = math.sqrt def LI(): return list(map(int, input().split())) def LF(): return...
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 = list(map(int,input().split())) arr = list(map(int,input().split())) count0 = [0]*(2*k+1) pre_arr = [0]*(2*k+2) for i in range(n//2): p1 = arr[i] p2 = arr[n-i-1] l = min(p1,p2) +1 r = max(p1,p2) + k count0[p1+p2]+=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 sys.setrecursionlimit(10 ** 6) int1 = lambda x: int(x) - 1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.readline()) def MI(): return map(int, sys.stdin.readline().split()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(ro...