prompt string | response string |
|---|---|
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are even (divisible by 2);
* the second n/2 elements of a are odd (not divisible by 2);
* all elements of a are distinct a... | for _ in range(int(input())):
n = int(input())
if (n/2)%2 != 0:
print("NO")
continue
else:
a = list(x for x in range(2,n+1,2))
b = list(x for x in range(1,n-2,2))
#b.append(sum(a)-sum(b))
b.append(int((n/2)**2+(n/2)-((n/2)-1)**2))
print("YES")
... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are even (divisible by 2);
* the second n/2 elements of a are odd (not divisible by 2);
* all elements of a are distinct a... | test = int(input())
for t in range(test):
n = int(input())
if(n%4!=0):
print("NO")
else:
print("YES")
sume = 0
for i in range(1,n//2 + 1):
print(2*i, end=' ')
sume += (2*i)
sum0 = 0
for i in range(1,n-2,2):
print(i,end=' ')
sum0 += i
print(sume-sum0)
|
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are 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())
integers=[]
for i in range(t):
integers.append(int(input()))
for integer in integers:
if (integer//2)%2!=0:
print("NO")
else:
fin=[]
a=2
count=0
for i in range(integer//2):
fin.append(a*(i+1))
for i in range(integer//2):
... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are even (divisible by 2);
* the second n/2 elements of a are odd (not divisible by 2);
* all elements of a are distinct a... | #include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
if ((n / 2) % 2 == 1)
cout << "NO" << endl;
else {
cout << "YES" << endl;
for (int i = 0; i < n / 2; i++) {
cout << 2 * (i + 1) << " ";
}
for (int i = 0;... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are even (divisible by 2);
* the second n/2 elements of a are odd (not divisible by 2);
* all elements of a are distinct a... | for _ in range(int(input())):
n = int(input())
print('NO' if n % 4 else 'YES')
if not n % 4: print(*map(str, [10 * i + x for x in [2, 4, 1, 5] for i 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... | def read_nums():
return [int(x) for x in input().split()]
def get_nums(n):
first = list(range(2, n + 1, 2))
second = list(range(1, n + 1, 2))
res = first + second
res[-1] += (-sum(second) + sum(first))
return res
def main():
for _ in range(int(input())):
n, = read_nums()
... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are 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 t1 in range(0,t):
n=int(input())
if(n%4==0):
print("YES")
l=[]
l1=[]
x=2
y=1
for i in range(0,(n//2)-1):
l.append(x)
l1.append(y)
x=x+2
y=y+2
l.append(x)
l1.append(sum(l)-sum(l1))
#print(sum(l),sum(l1))
l=l+l1
print(*l)
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 math,itertools,fractions,heapq,collections,bisect,sys,queue,copy
sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in 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())
if n % 4 != 0:
print("NO")
else:
print("YES")
d = 0
s = 0
for i in range(1, n // 2 + 1):
print(2 * i, end=" ")
s += 2 * i
for i in range(1, n // 2):
print(2 * i - 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... | #include <bits/stdc++.h>
using namespace std;
int t, n;
int main() {
cin >> t;
while (t--) {
cin >> n;
if (!((n / 2) % 2)) {
cout << "YES\n";
for (int i = 1; i <= n / 2; i++) cout << i * 2 << ' ';
for (int i = 1; i < n / 2; i++) cout << i * 2 - 1 << ' ';
cout << n + n / 2 - 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... | import java.util.*;
public class MyClass {
public static void main(String args[]) {
Scanner sc=new Scanner(System.in);
int q=sc.nextInt();
while(q-->0)
{
int n=sc.nextInt();
int k=sc.nextInt();
int a[]=new int[n];
for(int i=0;i<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... | #include <bits/stdc++.h>
using namespace std;
long long tra[100006], tra1[100006];
int main() {
long long t;
cin >> t;
while (t--) {
long long n, k;
cin >> n;
long long str[n + 4], s[n + 4];
long long sum = 0, m, l, r, type, j = 0, rev = 0;
long long num = n;
num = num * 2;
long long 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())
arr = [0]*n
isTrue = ""
if n//2 % 2 == 1:
isTrue = "NO"
else:
isTrue = "YES"
if isTrue == "YES":
for i in range(n//2):
arr[i] = 2*(i+1)
for j in range(n//4):
arr[n//2 + j] = arr[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 collections import defaultdict
from collections import Counter
from string import ascii_lowercase
import math
from sys import setrecursionlimit as srl
srl(2*10**6)
def solve(n):
a = [0]*n
if (n//2)%2 !=0:
return ["NO"]
odd = 2
for i in range(n//2):
a[i] = 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... | ans = []
arrys = []
for i in range(int(input())):
n = int(input())
temp = n % 4
if temp != 0:
ans.append('NO')
else:
ans.append('YES')
temp = [(i+1)*2 for i in range(int(n/2))]
temp2 = [(i*2+1) if i<(n/4) else (i*2+3) for i in range(int(n/2))]
temp.extend(temp2)
... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are 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().strip().split())
arr=list(map(int, input().strip().split()))
raj=dict()
rang=[]
for i in range(n//2):
if(raj.get(arr[i]+arr[n-i-1])==None):
raj[arr[i]+arr[n-i-1]]=1
else:
raj[arr[i]+arr[n-i-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(input())
for _ in range(t):
n=int(input())
if n%4 != 0:
print("NO")
else:
print("YES")
m=n//2
s=0
for i in range(1,m+1):
print(i*2,end=" ")
s+=i*2
x=0
for i in range(m):
if i==m-1:
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... | t = int(input())
for i in range(0,t) :
n = int(input())
if n >= 4 :
result,tab1,tab2 = [],[2,4],[1,5]
pos = 0
while(len(tab1) != n/2) :
tab1.append(tab1[pos] + 6)
tab2.append(tab2[pos] + 6)
pos+=1
if(sum(tab1) == sum(tab2)) :
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())
while(t > 0):
n = input()
n = int(n)
le=[]
lo = []
if (((n//2) -1 ) & 1) == 1:
print("YES")
i=1
k = 2
while i <= n//2:
if(i==n//2):
le.append(k)
lo.append(k+(n//2-1))
else:
le.app... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are 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())
even=[]
odd=[]
if((n//2)%2!=0):
print("NO")
else:
c=0
c1=0
for i in range(1,n//2+1):
ins=2*i
even.append(ins)
c+=ins
for j in range(1,n//2):
ins1=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... | import math
t=eval(input())
for j in range(t):
n=int(input())
if (n//2)%2==1:
print("NO")
else:
l=list(2*i for i in range(1,(n//2)+1))
l1=[1]
x=3
for i in range(2,n//2):
l1.append(x)
x=x+2
l1.append(sum(l)-sum(l1))
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... | for _ in range(int(input())):
n, k = [int(s) for s in input().split()]
arr = [int(s) for s in input().split()]
f1 = [0]*(2*k+1)
f2 = [0]*(2*k+1)
f3 = [0]*(2*k+1)
for i in range(n//2):
a = arr[i]
b = arr[n-i-1]
f1[a+b]+=1
f2[max(a,b)+k]+=1
f3[1+min(a,b)]+=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())
check = 0
for i in range(t):
n = int(input())
if n % 4 == 0:
ans = []
numc = 2
numc1 = 1
s1 = 0
s = 0
for j in range(n // 2):
s += numc
ans.append(numc)
numc += 2
for j in range(n // 2):
if 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 _ in range(t):
n=int(input())
if (n//2)%2==1:
print("NO")
else:
ans=[]
for i in range(1,n//2+1):
ans.append(2*i)
for j in range(1,n//2):
ans.append(2*j-1)
j=j+(((n//2)//2)+1)
ans.append(2*j-1)
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())):
t=int(input())
a=[]
add=0
if(int((t/2))%2!=0):
print("NO")
else:
print("YES")
for i in range(1,int((t/2))+1):
a.append(2*i)
add+=(2*i)
z=0
j=int(t/2)
k=1
while(j<t-1):
z... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are 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 math import *
def I():return map(int , input().strip().split())
for Q in range(int(input())):
n = int(input())
if bool((n//2)%2):print("NO")
else:
print("YES")
s1, s2 = 0,0
for i in range(2, n+1, 2):
s1 += i
print(i, end=' ')
... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are even (divisible by 2);
* the second n/2 elements of a are odd (not divisible by 2);
* all elements of a are distinct a... | import java.util.*;
import java.lang.*;
import java.io.*;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;
public class code
{
static class Reader
{
... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are 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")
m = 2*(n//2)
a = list(range(2, m + 1, 2))
s = sum(a)
for i in range(1, m - 1, 2):
a.append(i)
s -= i
a.append(s)
print(" ".join(map(str, 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... | #include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
if (n % 4 == 0) {
cout << "YES" << endl;
long long int sum = 0;
for (int i = 0; i < n / 2; i++) {
cout << (i + 1) * 2 << " ";
sum += (i + 1) * 2;
}
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,k=list(map(int,input().split()))
a=list(map(int,input().split()))
cnt=[0]*(2*k+2)
pref=[0]*(2*k+2)
for i in range(n//2):
z=sorted([a[i],a[n-i-1]])
cnt[sum(z)]+=1
pref[z[0]+1]+=1
pref[z[1]+k+1]-=1
for i in range(1,len(pref)): pref[i]... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are even (divisible by 2);
* the second n/2 elements of a are odd (not divisible by 2);
* all elements of a are distinct a... | import java.util.Scanner;
public class Main
{
public static void main (String[] args)
{
Scanner sc = new Scanner(System.in);
int test = sc.nextInt();
while(test-->0)
{
int n = sc.nextInt();
if(n%4 == 0)
{
System.out.println("YES");
int start = 2,c=0;;
while(c++ < n/2)
{
System.o... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are 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')
for i in range(2,n+1,2):
print(i,end=" ")
add=i
for i in range(n//2-1):
print(2*i+1,end= " ")
print(i+1+add) |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are 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:
t-=1
n = int(input())
s_even, s_odd = 0, 0
if (n//2)%2==1:
print("NO")
else:
print("YES")
for i in range(1,n//2+1):
s_even += 2*i
print(2*i, end = ' ')
for i in range(1,n//2):
s_odd += 2*i-1
pri... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are even (divisible by 2);
* the second n/2 elements of a are odd (not divisible by 2);
* all elements of a are distinct a... | def read_test():
return int(raw_input())
def solve(n):
d = n / 2
if d % 2 == 1:
return []
result = []
for i in range(d):
result.append((i + 1) * 2)
for i in range(d - 1):
result.append((i + 1) * 2 - 1)
result.append(d * 3 - 1)
return result
n = int(raw_input())
for i in range(n):
n = read_test()
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... | t = int(input())
for _ in range(t):
n = int(input())
if n%4 != 0:
print('NO')
continue
print('YES')
evens = []
for i in range(2, n+1, 2):
evens.append(i)
odds = set([])
for i in range(0, len(evens), 2):
sum = evens[i] + evens[i+1]
cur = evens[i]-1
while cur in odds:
cur -= 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 random
t = int(input())
while t :
t -= 1
n = int(input())
if n%4:
print("NO")
else:
print("YES")
e = 2
for i in range(n//2 - 1):
print(e, end=" ")
e += 2
print(e+n//2,end=" ")
e = 3
for i in range(n//2):... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are even (divisible by 2);
* the second n/2 elements of a are odd (not divisible by 2);
* all elements of a are distinct a... | #import sys
#sys.stdin= open('input.txt','r')
#sys.stdout = open('output.txt','w')
def solve(n): #output must be a string like object
if n%4!=0:
return None
else:
ans=[2*i for i in range(1,(n//2)+1)]
second=[(2*i)+1 if i<((n//2)-1) else (2*i)+1+(n//2) for i in range((n//2))]
ans+=second
return ans
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 = int(input())
if n == 2:
print("NO")
else:
k = n // 2
if k % 2 == 0:
print("YES")
l = []
for i in range (1, n // 2 + 1):
l.append(i * 2)
for i in range (1, n // 2 + 1):
i... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are even (divisible by 2);
* the second n/2 elements of a are odd (not divisible by 2);
* all elements of a are distinct a... | from sys import stdin, exit
input = stdin.readline
def i(): return input()
def ii(): return int(input())
def iis(): return map(int, input().split())
def liis(): return list(map(int, input().split()))
def print_array(a): print(" ".join(map(str, a)))
t = ii()
for _ in range(t):
n, k = iis()
a = liis()
counter = {}
... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are 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 test in range(t):
n,k = map(int,input().split());
arr = list(map(int,input().split()));
mn = [0 for i in range(2*k+2)];
mx = [0 for i in range(2*k+2)];
s = [0 for i in range(2*k+2)];
for i in range(n//2):
s[arr[i]+arr[n-1-i]]+=1;
mn[min(arr[i],arr[... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are even (divisible by 2);
* the second n/2 elements of a are odd (not divisible by 2);
* all elements of a are distinct a... | # import sys
# sys.stdin = open('input.txt', 'r')
# sys.stdout = open('output.txt', 'w')
for _ in range(int(input())):
n=int(input())
if((n//2)&1):
print("NO")
else:
print("YES")
a=2
c=1
k = 1
diff = 0
for i in range(n//2):
print(a,end=" ")
if(k==1):
k=0
diff=2
else:
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(1,t+1):
n=int(input())
a=[]
if (n//2)%2!=0:
print('NO')
else:
print('YES')
s=0
h=n//2
for i in range(2,(h*2+1),2):
a.append(i)
s+=i
x=1
i=0
while(i<h-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())
while (t):
t -= 1
n = int(input())
a1 = []
a2 = []
num = 0
for i in range(int(n / 2) - 1):
num += 2
a1.append(num)
a2.append(num - 1)
a1.append(num + 2)
if (sum(a1) - sum(a2)) % 2 != 0:
a2.append(sum(a1) - sum(a2))
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... | def solve(n):
l = int(n/2)
if l % 2 == 1:
print("NO")
return None
print("YES")
odd = []
even = []
for i in range(1,l+1):
even.append(i*2)
if i == l:
odd.append(sum(even)-sum(odd))
break
odd.append((i*2)-1)
ans = list(map(str,eve... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are 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
from collections import deque
mod = 10**9 + 7
import sys
import random
# sys.setrecursionlimit(10**6)
from queue import PriorityQueue
# def rl():
# return [int(w) for w in stdin.readline().split()]
from bisect import bisect_right
from bisect import bisect_left
from collections import defaultdi... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are 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 __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():
pass
# region fastio
BUFSIZE = 8192
class FastIO(IOBase)... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are 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
from collections import Counter
import bisect
from collections import defaultdict
import math
import random
import heapq as hq
from math import sqrt
import sys
from functools import reduce, cmp_to_key
from collections import deque
import threading
from itertools import combinations
from io impor... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are 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 Four_935A {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
int n;
int res1=0;
int res2=0;
int a[] = null;
int b[] = null;
while(t>0){
n = sc.nextInt();
if((n/2)%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... | #include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
int T;
cin >> T;
while (T--) {
int n;
cin >> n;
if ((n / 2) % 2 == 1) {
cout << "NO"
<< "\n";
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... | for _ in range(int(input())):
n=int(input())
p=n//2
if p%2!=0:
print("NO")
else:
print("YES")
L1=[]
L2=[]
p=2
for i in range(n//2):
L1.append(p)
p=p+2
p1=1
for i in range((n//2)-1):
L2.append(p1)
p1=p1+2
print(*(L1+L2+... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are 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')
lis=list(range(1,n+1))
lis=lis[1::2]+lis[::2]
lis[-1]+=n//2
print(*lis) |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are even (divisible by 2);
* the second n/2 elements of a are odd (not divisible by 2);
* all elements of a are distinct a... | import math
t=int(input())
for i in range(t):
n=int(input())
if(n%4==0):
print("YES")
s1=[]
s2=[]
for i in range(1,n+1):
if(i%2==0):
s1.append(i)
else:
s2.append(i)
s2.pop()
sum1=sum(s1)-sum(s2)
s2.append(sum1)
... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are 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;
n /= 2;
if (n & 1) {
cout << "NO" << endl;
continue;
}
cout << "YES" << endl;
for (int i = 1; i <= n; ++i) {
cout << i * 2 << " ";
}
for (int i = 1; i < ... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are even (divisible by 2);
* the second n/2 elements of a are odd (not divisible by 2);
* all elements of a are distinct a... | ns = [int(input()) for i in range(int(input()))]
for n in ns:
if n % 4 != 0:
print("NO")
continue
print("YES")
a = []
b = []
for i in range(1, int(n / 2) + 1):
a.append(str(i * 2))
b.append(str(i * 2 - 1))
b[-1] = str(int(b[-1]) + int(n / 2))
print(' '.join(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... | import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
# import time,random,resource
# sys.setrecursionlimit(10**6)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
def LI(... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are 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
rints = lambda: [int(x) for x in stdin.readline().split()]
out = []
for _ in range(int(input())):
n, k = rints()
a, mem = rints(), [0] * ((k * 2) + 2)
for i in range(n // 2):
s = a[i] + a[-1 - i]
mi, ma = min(a[i], a[-1 - i]), max(a[i], a[-1 - i])
mem[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... |
t = int(input())
for i in range(t):
x = int(input())
lst = []
lst2 = []
z = 1
y = 2
if (x // 2) % 2 != 0:
print('NO')
else:
print("YES")
for i in range(x//2):
lst2.append(y)
lst.append(z)
y += 2
z += 2
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.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;
/**
*
* @author Yash Nainsukha
*/
public class Solution {
public static void main(String[] args){
Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
int t = sc.nextI... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are 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:
print("YES")
for j in range(2,n+1,2):
print(j,end=" ")
for j in range(1,n-1,2):
print(j,end=" ")
print(j+2+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... | def solve():
n=int(input())
lis=[]
s=0
elem=2
if n%4==0:
print("YES")
for i in range(n//2):
lis.append(elem)
s+=elem
elem+=2
elem=1
for i in range(n//2-1):
lis.append(elem)
s-=elem
elem+=2
lis.append(s)
print(*lis)
else:
print("NO")
t=int(input())
for i in range(t):
sol... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are even (divisible by 2);
* the second n/2 elements of a are odd (not divisible by 2);
* all elements of a are distinct a... | #include <bits/stdc++.h>
using namespace std;
long long ans = 1ll;
long long MOD = 1000000007;
std::vector<long long> g[51];
bool visited[51];
void dfs(long long i) {
visited[i] = true;
for (long long child : g[i]) {
if (!visited[child]) {
ans *= 2;
dfs(child);
}
}
}
long long fact(long long 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... | testCases = int(input())
while testCases > 0:
n, k = map(int, input().split())
a = list(map(int, input().split()))[:n]
opened, closed, exist = {}, {}, {}
for i in range(2*k + 1):
opened[i] = closed[i] = exist[i] = 0
for i in range(int(n / 2)):
L, R = a[i], a[n - 1 - i]
exis... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are 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;
scanf("%lld", &t);
while (t--) {
long long n;
cin >> n;
if (n % 4 == 0) {
cout << "YES" << endl;
for (int i = 1; i <= n / 2; i++) {
cout << 2 * i << " ";
}
for (int i = 0; i < n / 2 - 1; i++) {
... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are even (divisible by 2);
* the second n/2 elements of a are odd (not divisible by 2);
* all elements of a are distinct a... | t = int(input())
while t > 0:
n = int(input())
if n == 0 or (n//2)%2 != 0:
print("NO")
else:
a = [i*2 for i in range(1, n//2+1)]
b = [i*2 for i in range(1, n//2+1)]
for i in range(0, len(a)):
if i >= len(a)//2:
b[i] = b[i] + 1
else:
... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are even (divisible by 2);
* the second n/2 elements of a are odd (not divisible by 2);
* all elements of a are distinct a... | n = int(input())
for i in range(n):
l = int(input())
if l % 4 != 0:
print("NO")
else:
print("YES")
for j in range(int(l/2)):
print((j+1)*2,end=" ")
for j in range(int(l/2-1)):
print((j+1)*2-1,end=" ")
print(int(l*1.5-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==2:print('NO')
else:
print('YES')
a=[]
m=1
s1=0
s2=0
for i in range(n//2):
a.append((i+1)*2)
s1+=a[i]
for i in range(n//2,n-1):
a.append(m)
m+=2
... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are even (divisible by 2);
* the second n/2 elements of a are odd (not divisible by 2);
* all elements of a are distinct a... | import java.util.Scanner;
import java.io.PrintWriter;
import java.util.*;
import java.io.*;
public class B1343 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int t = in.nextInt();
for (int i = 0; i < t; i++) {
int num = in.nextInt();
... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are 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())
N = []
for i in range(t):
N.append(int(input()))
'''Вроде бы очевидно, что первую половину нужно заполнить
подряд идущими четными'''
def main(n):
la = []
ra = []
for i in range(int(n/2)):
la.append(2*(i+1))
s=-1
while len(ra)<int(n/2)-1:
s +=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(0,t):
n=int(input())
p=n//2
z=p%2
if n==2:
print("NO")
elif z%2!=0:
print("NO")
else:
print("YES")
k=2
d=1
sum=0
sum1=0
for i in range(0,p):
print(k,end=" ")
sum1=sum1+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())
if n%4!=0:
print("NO")
else:
l=[0]*n
k=2
for i in range(0,int(n/2)):
l[i]=k
k+=2
#print('l=',l)
fh=[2]
sh=[1]
lf=2
ls=1
sf=2
ss=1
for i in ... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are even (divisible by 2);
* the second n/2 elements of a are odd (not divisible by 2);
* all elements of a are distinct a... | t = int(input())
for _ in range(t):
n = int(input())
half_n = int(n/2)
if half_n % 2 == 1:
print("NO")
continue
print("YES")
s1 = 0
for i in range(half_n):
i = (i+1)*2
s1 += i
print(i, end=" ")
s2 = 0
for i in range(half_n -1):
i = (i+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... | import java.io.*;
import java.nio.CharBuffer;
import java.util.*;
public class P1343D {
public static void main(String[] args) {
SimpleScanner scanner = new SimpleScanner(System.in);
PrintWriter writer = new PrintWriter(System.out);
int caseNum = scanner.nextInt();
while (caseNum-... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are 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())
even = []
odd = []
if ((n/2)%2==1):
print("NO")
else:
print("YES")
for i in range(n//2):
even.append(2*(i+1))
for i in range(len(even)-1):
odd.append(even[i]-1)
odd.append(even[-1]+len(even)-1)
for i in even:
print(i, end = " ")
for i in ... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are even (divisible by 2);
* the second n/2 elements of a are odd (not divisible by 2);
* all elements of a are distinct a... | // package practice;
import java.util.Scanner;
import java.util.Arrays;
public class FirstCode {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int t = scan.nextInt();
for(int tt=0;tt<t;tt++) {
int n = scan.nextInt();
int k = scan.nextInt();
int a[] = new int[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 int(n/2) % 2 != 0:
print("NO")
else:
print("YES")
l = []
for x in range(2, n + 1, 2):
l.append(x)
for y in range(0, n//2):
if y == n//2 - 1:
l.append(l[y] + (n//2-1))
else:
l.append(l[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... | t = int(input())
while t > 0:
n = int(input())
if (n//2)%2 != 0:
print("NO")
else:
print("YES")
o = []
e = []
s = 0
so = 0
for i in range(n//2):
e.append(2*i+2)
o.append(2*i+1)
s += e[i]
so += o[i]
e += o
so -= o[-1]
e[-1] = s - so
for i in e:
print(i, end=' ')
print()
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... | t=int(input())
for asdf in range(t):
n=int(input())
even_array=[]
odd_array=[]
if n%4!=0:
print('NO')
else:
print('YES')
even_array=[i for i in range(2,n+1,2)]
odd_array=[i for i in range(1,n,2)]
ans=[]
for i in range(n//2):
ans.append(even... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are even (divisible by 2);
* the second n/2 elements of a are odd (not divisible by 2);
* all elements of a are distinct a... |
L_bool = []
L_znach = []
k = 0
t = int(input())
for i in range(t):
n = int(input())
if(n%4!=0):
L_bool.append("NO")
else:
L_bool.append("YES")
L_znach.append([])
for j in range(2,n+1,2):
L_znach[k].append(j)
for j in range(1,n,2):
L_znach[k].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... | #!/usr/bin/env python
# coding: utf-8
# In[3]:
t = int(input())
cnt = 0
while (cnt < t):
a = []
cnt += 1
n = int(input())
if n % 4 != 0:
print('NO')
continue
else:
print('YES')
for i in range(2, n // 2 + 2, 2):
a.append(i)
a.append(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(t):
n=int(input())
if (n<=2):
print("NO")
else:
arr=[]
if (n//2)%2==0:
for j in range(2,n+1,2):
arr.append(j)
if len(arr)%2==0:
a=len(arr)
b=len(arr)//2
for j in range(len(arr)//2):
arr.append(arr[j]-1)
for j in range(b,a):
arr.append(arr[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... | T=int(input())
i=0
while i<T:
n=int(input())
if n%4==2:
print('NO')
else:
a=[4*i+4 for i in range(n//4)]+[4*i+2+2*n for i in range(n//4)]+[4*i+1 for i in range(n//4)]+[4*i+5+2*n for i in range(n//4)]
print("YES")
print(*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... | for _ in range(int(input())):
n=int(input())
if (n//2)%2==1:
print("NO")
else:
n=n//2
print("YES")
for i in range(1,n+1):
print(2*i,end=" ")
for i in range(1,n):
print(2*i-1,end=" ")
print(3*n-1)
|
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are even (divisible by 2);
* the second n/2 elements of a are odd (not divisible by 2);
* all elements of a are distinct a... | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
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<pair<int, int>> v;
for (int i = 0; i < (n / 2)... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are even (divisible by 2);
* the second n/2 elements of a are odd (not divisible by 2);
* all elements of a are distinct a... | def solve(n):
if (n // 2) % 2 == 1:
print('NO')
return
print('YES')
ans = list(range(4, 4 + 2 * (n // 2), 2)) + list(range(3, 3 + 2 * (n // 2 - 1), 2))
ans.append(3 + 2 * (n // 2 - 1) + (n // 2))
print(' '.join(str(i) for i in ans))
for _ in range(int(input())):
solve(int(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... | /*
-> Written by <-
-----------
|J_O_B_E_E_L|
|___________|
| ___ |
| (^_^) |
| /( | )\ |
|____|_|____|
*/
import java.lang.reflect.Array;
import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;
import java.nio.file.Path;
import java.util.Map.*;
public class Test {... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are even (divisible by 2);
* the second n/2 elements of a are odd (not divisible by 2);
* all elements of a are distinct a... | '''
# SHREYANS BHAVSAR #
# DDIT #
# @shreyans_9950 #
# CF,CC,HE,HR,GFG #
'''
# import math
# def shrey():
# /*!@#$%^&*()-+=*/
# s=list(input())
# l=len(s)
# ans=""
# for i in range(l):
# if(i==0 or i==l-1 or i%2!=0):
# ans+=s[i]
# print(ans)
# n=int(input())
# a=list(map(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... | x=int(input())
for i in range(x):
n=int(input())
if (((n+1)//2)+1)%2!=0:
print("YES")
even=[]
odd=[]
for i in range(1,n+2):
if i!=(((n+1)//2)+1) and i%2!=0 :
odd.append(i)
elif i!=(((n+1)//2)+1) and i%2==0:
even.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>0:
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)
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... | #include <bits/stdc++.h>
using namespace std;
const int max_n = 200111, inf = 1000111222;
int m[max_n];
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
int cnt = n / 2;
if (cnt % 2 == 1) {
puts("NO");
continue;
}
int cur = 4;
for (int i = 0; i < cnt; ++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(t):
n=int(input())
k=n//2
if(k%2==0):
print("YES",end="\n")
s=0
s1=0
for j in range(2,n+1,2):
s=s+j
print(j,end=" ")
for j in range(1,n-1,2):
s1=s1+j
print(j,end=" ")
print(s-s1,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 _ in range(int(input())):
n = int(input())
if n % 4 == 0:
ans = []
for i in range(1, n // 2 + 1):
ans.append(i * 2)
for i in range(1, n // 4 + 1):
ans.append(i * 2 - 1)
for i in range(n // 4 + 1, n // 2 + 1):
ans.append(i * 2 + 1)
p... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are even (divisible by 2);
* the second n/2 elements of a are odd (not divisible by 2);
* all elements of a are distinct a... | for _ in range(int(input())):
N = int(input())
if(N%4==0):
print("YES")
List = []
First = 0
count = 2
for i in range(int(N//2)):
List.append(count)
First+=count
count+=2
Second = 0
count = 1
for j in range(int(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... | def inp():
return (int(input()))
def inlt():
return (list(map(int, input().split())))
def insr():
s = input()
return (list(s[:len(s) - 1]))
def invr():
return (map(int, input().split()))
def findmin(x, y):
if x < y:
return x
return y
def findmax(x, y):
if x > 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 i in range(int(input())):
a = int(input())
l = []
if a % 4 != 0:
print('NO')
else:
print('YES')
for j in range(2 , a + 1 , 2):
l.append(j)
for k in range(1 , a - 1 , 2):
l.append(k)
l.append(a - 1 + (a // 2))
for m 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... | t = int(input())
for _ in range(t):
n = int(input())
if n % 4 == 2:
print("NO")
else:
print("YES")
A = []
for x in range(1, n//2 + 1):
A.append(2*x)
for x in range(1, n//4 +1):
A.append(2*x-1)
for x in range(n//4+1, 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... | for __ in range(int(input())):
n = int(input())
n //= 2
if n & 1:
print("NO")
continue
print("YES")
for i in range(1, n + 1):
print(i * 2, end=' ')
for i in range(1, n):
print(i * 2 - 1, end=' ')
print(3 * n - 1)
|
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are even (divisible by 2);
* the second n/2 elements of a are odd (not divisible by 2);
* all elements of a are distinct a... | t=int(input())
for i in range(t):
n=int(input())
a=n//2
if a%2!=0:
print("NO")
else:
l=[0]*n
for j in range(1,n//2+1):
l[j-1]=j*2
for k in range(n//2+1,n):
l[k-1]=2*(k-n//2)-1
b=a//2
b=b+1
l[n-1]=l[-2]+b*2
print("YES... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are even (divisible by 2);
* the second n/2 elements of a are odd (not divisible by 2);
* all elements of a are distinct a... | from collections import *
from sys import *
inp=stdin.readline
flag=1
if not flag:
out=stdout.write
str=str
else:out=print
def linp(x):
return list(map(int,x.split()))
def minp(x):
return map(int,x.split())
t=int(inp())
while t>0:
n=int(inp())
if n%2==0 and n%4==0:
even=[2*i for i in 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... | FAST_IO = 0
if FAST_IO:
import io, sys, atexit
rr = iter(sys.stdin.read().splitlines()).next
sys.stdout = _OUTPUT_BUFFER = io.BytesIO()
@atexit.register
def write():
sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
else:
rr = raw_input
rri = lambda: int(rr())
rrm = lambda: map(int, rr().s... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are even (divisible by 2);
* the second n/2 elements of a are odd (not divisible by 2);
* all elements of a are distinct a... | #include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 100;
struct node {
int flag, a, b;
long long sum;
} t[maxn * 8];
int a[maxn], cnt[maxn * 2], js[maxn * 2];
void pushdown(int x, int l, int r) {
if (t[x].flag) {
int num = t[x].flag;
t[2 * x].sum += num * l;
t[2 * x + 1].sum += num * ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.