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...
import sys input = sys.stdin.readline from itertools import accumulate t=int(input()) for tests in range(t): n,k=map(int,input().split()) A=list(map(int,input().split())) ANS=[0]*(k*2+3) for i in range(n//2): x,y=A[i],A[n-1-i] if x>y: x,y=y,x #print(x,y) 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...
inp=input li=list iinp=lambda : int(inp()) ent=lambda : map(int,inp().split()) lient=lambda : [int(i) for i in inp().split()] li0= lambda x: [0 for i in range(x)] stent=lambda : [i for i in inp()] s=sum t=iinp() for _ in range(t): n=iinp() tmp=n//2 if tmp%2!=0: print("NO") else: 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 java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.InputMismatchException; public class Main { InputStream is; PrintWriter out; String INPUT = ""; private static final long M = 1000000007; void solve...
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 bisect import bisect_right for _ in range(int(input())): n,k=map(int,input().split()) a=list(map(int,input().split())) sums=[0]*(2*k+1) mini=[] maxi=[] for i in range(n//2): sumi=a[i]+a[n-i-1] sums[sumi]+=1 mini.append(min(a[i],a[n-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...
t = int(input()) for i in range(t): n = int(input()) if (n // 2) % 2 != 0: print("NO") else: print("YES") even = sum_even = 0 for j in range(n // 2): even += 2 sum_even += even print(even, end=' ') odd = -1 sum_odd = 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...
t=int(input()) for _ in range(t): n=int(input()) if(n%4==0): print("YES") it=n//2 even=2 odd=1 ans=[] for i in range(it): ans.append(even) even+=2 it=n//2 for j in range(it): ans.append(odd) odd+=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 import sys t = int(input()) for cs in range(t): n = int(input()) lf = ri = 0 if n % 4: print("NO") continue print("YES") for i in range(n//2): print((i+1) * 2, end = " ") lf += (i+1) * 2 for i in range(n//2 - 1): print(i*2 + 1, 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 i in range(t): n=int(input()) if(n==2): print("NO") else: a=[] for i in range(1,(n//2)+1): a.append(2*(i)) i=1 while(len(a)<n-1): a.append(i) i=i+2 if((sum(a[0:n//2])-sum(a[n//2:n-1]))%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...
t = int(input()) for i in range(t): n = int(input()) if (n/2)%2 == 1: print('NO') else: print('YES') print(*[2*i for i in range(1, n//2+1)], *[2*i+1 for i in range(n//2+1) if i != 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...
for something in range(int(input())): n = int(input()) if n % 4 != 0: print("NO") else: print("YES") for i in range(2, n + 2, 2): print(i, end=' ') for i in range(1, n - 1, 2): print(i, end=' ') print(i + 2 + n // 2, 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...
import java.util.*; import java.io.*; public class Main{ public static void main(String[] args){ Scanner in = new Scanner(System.in); int t = in.nextInt(); for(int i = 0; i < t; i++){ int n = in.nextInt(); if(n%4 != 0){ System.out.println("NO"); }else{ System.out.println("YES"); 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...
#include <bits/stdc++.h> using namespace std; int main() { int t, n; cin >> t; while (t--) { cin >> n; if ((n / 2) % 2) { cout << "NO" << endl; } else { int half = n / 2; int arr[n]; long long sum, sum2; arr[0] = 2; sum = 2; for (int i = 1; i < half; 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...
def compute_array(element): output_array = [] even_odd_numbers = element/2 even_elements = [even_element*2 for even_element in range(1, even_odd_numbers + 1)] output_array.extend(even_elements) odd_elements = [odd_element*2 - 1 for odd_element in range(1, even_odd_numbers)] output_array.extend(...
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()) array=[] for i in range(n): array.append(int(input())) def calc(x): if (x//2)%2==0: a=[] for i in range(2,x+1,2): a.append(i) arr=[] for i in range(1,x-1,2): arr.append(i) arr.append(sum(a)-sum(arr)) a=a+arr 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...
t=int(input()) for i in range(t): a=int(input()) if a%4!=0: print("NO") else: print("YES") c=[] for j in range(2,a+1,2): c+=[j] d=[] for j in range(1,a-1,2): d+=[j] d+=[a+(a-1)//2] c=c+d print(*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...
#this solution is a translation of MikeMirzayanov's #c++ editorial solution def run(lst, n, k): ans = float("inf") cnt = [0 for i in range(int(2*k + 1))] for i in range(int(n/2)): soma = lst[i] + lst[n - i - 1] cnt[soma] += 1 # print(cnt) pref = [0 for i in range(int(2*k + 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 input=sys.stdin.buffer.readline #FOR READING PURE INTEGER INPUTS (space separation ok) t=int(input()) for _ in range(t): n,k=[int(x) for x in input().split()] arr=[int(x) for x in input().split()] sumCnts=[0 for __ in range(2*k+1)] #number of pairs summing to this (need 0 change) minim...
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())): a,b=2,1 l=[] m=[] n=int(input()) if n%4==0: print("YES") x=n//2 for j in range(n): if j<x: l.append(a) a=a+2 if x<j<n: m.append(b) b+=2 if j==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...
for _ in range(int(input())): n=int(input()) if((n//2)%2==1): print('NO') else: print('YES') os=es=0 even=2 odd=1 for i in range(n//2): print(even,end=' ') es+=even even+=2 for i in range(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; int main() { long long t, n; cin >> t; while (t--) { cin >> n; if (n % 4) cout << "NO\n"; else { cout << "YES\n"; for (int i = 0, k = 2; i < n / 2; i++) { cout << k << " "; k += 2; } int k = 1; for (int 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()) if n <= 2 or (n // 2) % 2 != 0: print("NO") else: print("YES") m1 = 2 m2 = 1 a = [] b = [] for p in range(n // 2): a.append(m1) m1 += 2 for p in range((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...
a=int(input()) for i in range(a): n=int(input()) if((n//2)%2!=0): print("NO") else: print("YES") l=[] for i in range(1,n//2+1): l.append(2*i) k=len(l) for 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()) inp = [0] * t for i in range(t): inp[i] = int(input()) a1 = [2] a2 = [1] for n in inp: if n % 4 != 0: print("NO") continue print("YES") while len(a1) < n // 2: i = len(a1) - 1 if i % 2 == 0: a1.append(a1[i] + 2) a2.append(a1[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()) if n % 4 != 0: print("NO") else: print("YES") a = [] i = 2 while len(a) < n // 2: a.append(i) a.append(i + 2) i += 6 i = 1 while len(a) < n: a.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...
t=int(input()) while(t): n=int(input()) if(n%4!=0): print("NO") else: print("YES") v=2 for i in range(n//2): print(v,end=' ') v=v+2 v=1 for i in range(n//2-1): print(v,end=' ') v=v+2 print(v+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...
MAX_VAL =400005 def countIntervals(arr, N): minimum = 2*10**5+2 maximum = 0 # Frequency array to keep track of # how many of the given intervals # an element lies in freq = [0] * (2*k+2) for i in range(0, N): li = arr[i][0] freq[li] = freq[li] + 1 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...
import math a=int(input()) for i in range(a): n=int(input()) n1=math.trunc(n//2) a1=[] a2=[] for i in range(1,math.trunc(n/2)+1): a1.append(i*2) a2.append(i*2-1) if((n/2)%2!=0): print("NO") else: print("YES") aq=sum(a1)-sum(a2) a2[len(a2)-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...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; long long sum = 0, k = 2, sum1 = 0, k1 = 1; for (int i = 1; i <= n / 2; i++) { sum += k; k += 2; } for (int i = 1; i < n / 2; i++) { sum1 += k1; k1 += 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.io.*; import java.util.*; public class Solution { private static PrintWriter out; public static void main(String[] args) { FastScanner fs = new FastScanner(); out = new PrintWriter(new BufferedOutputStream(System.out)); int t = fs.nextInt(); while (t-- > 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 input=stdin.buffer.readline t=int(input()) for _ in range(t): n=int(input()) if n%4!=0: print("NO") else: res=[] p1=2 p2=4 p3=1 p4=5 bb=[1,5] print("YES") for i in range(n//4): res.append(p1+6*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...
kl=int(input()) for l in range(kl): n=int(input()) k=n//2 if k%2!=0: print('NO') else: a=[1+2*int(i) for i in range(k)] b=[2*int(i) for i in range(1, k+1)] a[k-1]=a[k-1]+k rz=b+a print('YES') print(*rz)
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") for i in range(1,n//2+1): print(2*i, end=' ') for i in range(1,n//2): print(2*i-1, end=' ') print(n//2+(n)-1) 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...
for _ in range(int(input())): n = int(input()) if (n / 2) % 2: print("NO") else: print("YES") n //= 2 cnt = 2 for i in range(n): print(cnt, end = " ") cnt += 2 sum = n * (n + 1) cnt = 1 for i in range(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...
t=int(input()) while(t!=0): a=int(input()) b=a//2 if(b%2==0): print("YES") for i in range(2,a+1,2): print(i,end=" ") for i in range(1,a-2,2): print(i,end=" ") print((a-1)+b) else: print("NO") 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 tt in range (t): n=int(input ()) if(n%4!=0): print ('NO') else: print ('YES') a=[] for i in range (1, round (n/2)+1): a.append(2*i) for j in range (1, round (n/2)): a.append(2*j-1) a.append(2*i+round (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...
t = int(input()) for i in range(t): n = int(input()) c = 2 d = 1 la = [] lb = [] res = [] s1 = 0 s2 = 0 if(n%4 != 0): print("NO") else: print("YES") for i in range(n//2): la.append(c) s1 = s1 + c c = c + 2 for 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()) a = [0] * 3 *10**5 for _ in range(t): n = int(input()) if n%4: print("NO") continue print('Yes') for i in range(2,n+1,2): print(i) for i in range(1,n-1,2): print(i) print(n - 1 + int(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 a[300000]; int main() { int t; cin >> t; int n; int i, j, k, l; while (t--) { cin >> n; int r = 2; int e = 1; if (n % 4) cout << "NO" << endl; else { cout << "YES" << endl; int x = n / 2; for (i = 0; i < x; 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 i in range(0,t): n=int(input()) arr1=[] arr2=[] if n%4 != 0: print('NO') else: print('YES') for j in range(1,n+1): if j%2==0: arr1.append(j) else: arr2.append(j) arr2[-1]=arr2[-1]+int(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()) numlist=[] eve=[] odd=[] for i in range(t): numlist.append(int(input())) for n in numlist: if n%4!=0: print('NO') else: eve=[] odd=[] for j in range(1,(n//2)+1): eve.append(2*j) for j in range(1,n//2): odd.append((2*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...
from sys import stdin, stdout def f(n): if(int(n/2)%2 == 1): print("NO") return a = [] k = 0 c = 2 for i in range(int(n/2)): k+=c a.append(c) c+=2 j = 0 c = 1 for i in range(int(n/2)-1): a.append(c) j+=c c+=2 a.append(k-j) print("YES") print(*a) t = int(stdin.readline()) for _ 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...
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[~i])) 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(m...
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::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int t; long long n; cin >> t; vector<int> v; while (t--) { cin >> n; v.clear(); if (n % 4) { cout << "NO" << endl; continue; } else { cout << "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...
#include <bits/stdc++.h> using namespace std; const int N = 200003; int n, k, a[N]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t; cin >> t; while (t--) { cin >> n >> k; for (int i = 0; i < n; ++i) { cin >> a[i]; } vector<int> x(2 * k + 2, 0); for (int i = 0; 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...
from sys import stdin, stdout for _ in range(int(stdin.readline())): n = int(stdin.readline()) if (n//2)%2 != 0: print("NO") else: print("YES") array_even = [] array_odd = [] sign = -1 for i in range(3, 3 + (n//2)*4, 4): array_odd.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...
for t in range(int(input())): n=int(input()) if (n/2)%2==1: print('NO') else: even=[] odd=[] for i in range(n//2): even.append((i+1)*2) for i in range(n//2-1): odd.append(((i+1)*2)-1) odd.append(sum(even)-sum(odd)) ans=even+odd ...
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 ceil t = int(input()) for _ in range(t): n = int(input()) if not(n%4 == 0): print("NO") else: print("YES") a = [0]*n for i in range(0, n//2, 1): a[i] = i*2 + 2 a[i + n//2] = i*2 + 1 a[-1] += n//2 for i in a: print(i, 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...
#include <bits/stdc++.h> using namespace std; int main() { std::ios::sync_with_stdio(false); 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> pre(4 * k + 1, 0); map<long long int, long long int> mp; f...
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()) la,lb=[],[] a,b=2,1 if (n//2)%2!=0: print('NO') else: for i in range(n//2): la.append(a) a=a+2 lb.append(b) b=b+2 lb[(n//2)-1]=lb[(n//2)-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...
def ans(n): if n % 4 != 0: return 'NO' arr = [] for i in range(int(n/2)): arr.append(2*i+2) for i in range(int(n/2)-1): arr.append(2*i+1) arr.append(sum(arr[0:int(n/2)])-sum(arr[int(n/2):])) return arr t = int(input()) L = [] for i in range(t): n = 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...
'''input 5 2 4 6 8 12 ''' from collections import defaultdict as dd from collections import Counter as ccd from itertools import permutations as pp from itertools import combinations as cc from random import randint as rd from bisect import bisect_left as bl from bisect import bisect_right as br import heapq as hq fro...
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: l = n // 2 even = list(range(2, 2 * l + 1, 2)) odd = list(range(1, 2 * l + 1, 2)) odd[-1] += l print('YES') print(" ".join(map(str, even + odd))) 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 java.io.*; import java.util.*; import java.awt.*; public class B { BufferedReader in; PrintWriter ob; StringTokenizer st; public static void main(String[] args) throws IOException { new B().run(); } void run() throws IOException { in=new BufferedReader(new InputStreamRe...
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(n): if (n / 2) % 2: return "NO" print("YES") evens, odds = "", "" evenSum, oddSum = 0, 0 for i in range(1, n+1): if not i % 2: evens += str(i) + " " evenSum += i else: odds += str(i) + " " oddSum += i odds = odds.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...
a=int(input()) even=[] odd=[] for j in range(1,200001): if j%2==0: even.append(j) else: odd.append(j) for i in range(a): n=int(input()) ans=[] c0=[] if (n/2)%2!=0: print("NO") else: for j in range(int(n/2)): ans.append(even[j]) z=sum(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...
from sys import stdin def solve(n): x, ans, num, ac = 0, [], 1, 0 for i in range(1,(n//2)+1): ans.append(2*i); x+=(2*i) for i in range(1,1+(n//2)): if i==((n//2)): ans.append(x-ac) if (x-ac)%2==0: return [] else: ans.append(num) ac+=num ...
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): case = int(input()) half = case//2 if half % 2 == 1: print("NO") else: print("YES") evens = 2 odds = 1 ans = [] for x in range(half): ans.append(evens) evens += 2 for x in range(half - 1): ans.append(odds) odds += 2 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...
from sys import stdin,stdout t=int(stdin.readline().strip()) for _ in range(t): n=int(stdin.readline().strip()) a=[] if int(n/2)%2==0: a=[i for i in range(0,int(n/2),2)] for i in range(n,int(n/2)+n,2): a.append(i) for i in range(int(n/4)): a.append(a[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...
import sys if sys.subversion[0] == "PyPy": import io, atexit sys.stdout = io.BytesIO() atexit.register(lambda: sys.__stdout__.write(sys.stdout.getvalue())) sys.stdin = io.BytesIO(sys.stdin.read()) input = lambda: sys.stdin.readline().rstrip() RS = raw_input RI = lambda x=int: map(x,RS().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...
t=int(input()) for i in range(t): n=int(input()) if (n//2)%2==0: lista=[] x=2 for j in range((n//2)//2): lista+=[x] lista+=[x+2] x+=8 x=-3 for k in range(n//2): x+=4 lista+=[x] print("YES") for 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()) k=1 if (n % 4 ==2): print("NO") else: print("YES") for i in range(n-1): if (i<(n // 2)): print(2*i+2,end=" ") else: print(k,end=" ") k=k+2 print(6*(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 and n>=4): print('YES') l = [] m = [] for i in range(1, n+1): if(i%2 == 0): l += [i] else: m += [i] m[-1] += (n//2) l = l+m print(*l) 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...
# -*- coding: utf-8 -*- import sys from itertools import accumulate def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [[c] * b for i in range(a)] def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)] def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] 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()) a1 = [] a2 = [] for i in range(1, 100000): i4 = i * 8; a1.append(i4) a1.append(i4 - 2) a2.append(i4 + 1) a2.append(i4 - 3) for i in range(t): n = int(input()) if n % 4 != 0: print("NO") else: print("YES") print(' '.join(map(str, a1[:n // 2] + a2[:...
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 testcase in range(int(input())): n = int(input()) if (n // 2) % 2: print("NO") continue print('YES') print(*(i for i in range(2, n+1, 2)), end=' ') print(*(i for i in range(1, n-1, 2)), end=' ') print(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()) while t>0: n = int(input()) if (n//2)%2 != 0: print('NO') else: a = [] for i in range(2 , n+1, 2): a.append(i) even_sum = sum(a) odd_sum = 0 for i in range(len(a)): a.append(a[i] - 1) odd_sum += a[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.io.*; import java.util.*; public class Main{ public static void main(String[] args) throws Exception{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int t = Integer.parseInt(br.readLine()); while(t-->0){ int n = Integer.parseInt(br.readLine(...
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()) l = n//2 if (l & 1): print("NO") else: print("YES") a = [0]*n for i in range(1,l+1): a[i-1] = 2*i for i in range(l,n): a[i] = a[i-l] a[i] -= 1 a[n-1] += (l) 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...
t=int(input()) for _ in range(t): n=int(input()) s=0 if (n/2)%2!=0: print('NO') else: m=int(n/2) print('YES') for i in range(2,2*m+1,2): print(i,end=' ') for j in range(2,2*m,2): print(j-1,end=' ') s=s+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.Scanner; public class Main{ public static void main(String[] args) { // TODO Auto-generated method stub Scanner scn= new Scanner(System.in); int t =scn.nextInt(); while(t-->0){ int n=scn.nextInt(); if((n/2)%2!=0){ System.out.println("NO"); continue; } int val=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...
#!/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...
t=int(input()) for i in range(t): n=int(input()) if n//2%2==1: print("NO") continue else: ans=[] for i in range(n//2): ans.append(2*(1+i)) cnt=0 for i in range(n//2): if i<=(n//2)//2-1: ans.append(ans[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...
T = int(raw_input()) while T>0: T-=1 N = int(raw_input()) if N/2 & 1 == 1: print "NO" continue print "YES" N /= 2 total = N * (N+1) for i in range(1,N+1): print i*2, num = 1 count = 1 while count < N: print num, total-=num num+=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 ab(): b=int(input()) l=[] if(b==2): print("NO") return if(b%4==0): print("YES") for i in range(2,b+1,2): l.append(i) p=len(l) for i in range(0,p-1): l.append(l[i]-1) l.append(b+(b//2)-1) print(*l) return else: print("NO") return for i in range(0,int(input())): ab()
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 def input(): return sys.stdin.readline()[:-1] t = int(input()) for _ in range(t): n, k = map(int, input().split()) a = list(map(int, input().split())) cum = [0 for _ in range(2*k+2)] for i in range(n//2): x, y = a[i], a[n-i-1] cum[2] += 2 cum[min(x, y)+1] -= 1 cum[x+y] -= 1 cum[x+y+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...
t=int(raw_input()) ans=[] for i in range(t): n=int(raw_input()) arr=' ' sum1=0 sum2=0 if (n/2)%2==1: ans.append('NO') else: ans.append('YES') j=2 cn=0 while(cn!=n/2): arr+=str(j)+' ' sum1+=j j+=2 cn+=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 i in range(t): n = int(input()) if n%4!=0: print("NO") continue sum = 0 sum1 = 0 print("YES") for j in range(2,n+1,2): print(j,end=" ") sum+=j for j in range(1,n-1,2): print(j,end=" ") sum1+=j print(sum-sum1) #2 4 6 8 10 12 1 3 5 7 9 17
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") t1 = [2*i for i in range(1, n//2 + 1)] t2 = [2*i-1 for i in range(1, n//2)] t3 = [t1[-1] + n//2 -1] ## print(t1) ## print(t2) print(*(t1+t2+t3))
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 xrange(input()): n=input() if (n/2)%2==1: print 'NO' else: print 'YES' print ' '.join(map(str,range(2,n+1,2)+range(1,n-1,2)+[n/2+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; int main() { int t; cin >> t; int a[100000]; while (t--) { int n; cin >> n; int k = 1, l = 2; int sum = 0, sum1 = 0; if ((n / 2) % 2 != 0) cout << "NO\n"; else { cout << "YES\n"; for (int i = 0; i < n / 2; i++) { a[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 (interpreter) to run Python online. # Write Python 3 code in this online editor and run it. t = int(input()) for _ in range(t): n = int(input()) a = [] b = [] x = 1 y = 2 for i in range(n//2): b.append(y) if(i==(n//2)-1 and (sum(b)-sum(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...
k = int(input()) for j in range(k): n = int(input()) if n%4>0: print('NO') else: print('YES') a=[] b=[] cnt=1 for q in range(n//2-1): b.append(cnt) a.append(cnt+1) cnt+=2 a.append(cnt+1) b.append(sum(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...
from math import * t=int(input()) for _ in range(t): n=int(input()) if n%4!=0: print('NO') else: print('YES') k=n//2 r=[2] l=[1] s=2 c=1 if n==4: print(2,4,1,5) else: for i in range(1,k): r.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...
#include <bits/stdc++.h> using namespace std; const int maxn = 400100; long long arr[maxn]; long long cnt[maxn]; long long n, k; void solve() { cin >> n >> k; for (int i = 1; i <= n; i++) { cin >> arr[i]; } vector<long long> v, vmin; for (int i = 1; i <= n / 2; i++) { v.push_back(max(arr[i], arr[n - 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...
def main(): T = int(input()) for t in range(T): n = int(input()) if(n%4>0): print("NO") continue print("YES") for i in range(n//2): print(2*(i+1),end=" ") for i in range(n//2-1): print(2*(i+1)-1,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...
from collections import * from bisect import * #from math import * import sys input=sys.stdin.readline t=int(input()) while(t): t-=1 n=int(input()) if(n%4==2): print("NO") else: print("YES") f=0 for i in range(n//2): print((i+1)*2,end=" ") f+=(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 ctr in range(int(input())): n=int(input()) if n%4!=0: print("NO") else: print("YES") for i in range(1,n//2+1): print(i*2,end=" ") for i in range(1,n//2): print(i*2-1,end=" ") print(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.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.util.*; public class Main { public static void main(String args[]) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int test = Integer.parseInt(br.rea...
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") num,sum = 2,0 for j in range(n//2): print(num,end=" ") sum+=num num+=2 num = 1 for j in range((n//2)-1): print(num,end=" ") sum-=num ...
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&3!=0: print("NO") else: print("YES") soln=[0]*(n) sumi=0 number=2 sumofnumbers=0 for i in range(n//2): soln[i]=number soln[i+n//2]=number-1 sumi+=1 number...
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: l=[ x for x in range(2,n+1,2)] k=[ x for x in range(1,n,2)] k[-1]+=int(n/2) print("YES") for i in l: print(i,end=" ") for i in k: print(i,end=" ") print(end="\n") 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 tc in range(0, int(input())): n = int(input()) # length of array, even number if (n // 2) % 2 != 0 or n % 2 != 0: print("NO") else: left_half = [x for x in range(2,n+1,2)] right_half = [l-1 for l in left_half[0:-1]] right_half.append(sum(left_half) - sum(right_half)) full = [*left_half, *right_ha...
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=map(int,input().split()) map1={} pref=[] l=list(map(int,input().split())) for j in range(0,2*k+2): pref.append(0) for j in range(n//2): if(map1.get(l[j]+l[n-j-1])!=None): map1[l[j]+l[n-j-1]]+=1 else: map1[l[j]+l[n-j-1]]=1 summ=[] for j in range(n//2): summ.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 q in range(int(input())): n=int(input()) if n%2==1:print("NO") else: l,k=[],[] for x in range(n//2): l.append(2*(x+1)) for x in range(n//2-1): k.append(2*(x+1)-1) if (sum(l)-sum(k))%2==0:print("NO") else: print("YES") k.append(sum(l)-sum(k)) print(*(l+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 _ in range(t): n = int(input()) arrayeven = [i for i in range(2, n+1, 2)] arraynoteven = [i for i in range(1, n, 2)] del arraynoteven[-1] SumEven = sum(arrayeven) SumNotEven = sum(arraynoteven) k = 1 while SumEven != SumNotEven + k: if SumNotEven + k >= SumEv...
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,sys from sys import stdin, stdout from collections import Counter, defaultdict, deque input = stdin.readline I = lambda:int(input()) li = lambda:list(map(int,input().split())) def case(): n=I() if((n//2)%2==1): print("NO") else: ans=[] for i in range(2,n+1,2): ans.append(i) 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...
t = int(input()) for i in range(t): n = int(input()) diff = 0 if (n/2) % 2: print('NO') else: print('YES') for i in range(2, n + 1, 2): print(i, end=' ') for i in range(1, n - 1, 2): print(i, end=' ') print(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...
t = int(input()) for _ in range(t): n = int(input()) if ((n//2)%2 == 0): print("YES") x = n//2 odd = [] even = [] so = 0 i=1 leng = n//2 while len(odd) != leng: odd.append(i) so += i i+=2 se=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...
t=int(input()) def fun(n): k=n/2 if k%2==1: print("NO") else: a=[] o=2 for i in range(int(k)): a.append(o) o+=2 cur=1 su=a[0]+a[-1] for i in range(int(k/2)): a.append(cur) a.append(su-cur) ...
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 wa(): s2='' s3='' sum=0 l=[] for i in range(1,100,1): if(i%2!=0): l.append(i) return l def ans(a): s="" s2="" s3='' sum=a//2 f=0 f1=0 g=1 if(sum%2==0): print("YES") for i in range(1,a+1,1): if(i%2==0): ...