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... | def solve(n):
if n%4!=0:
print("NO")
return
print("YES")
sume = 0
sumo = 0
for i in range(2,n+1,2):
print(i, end=" ")
sume += i
for i in range(1,n-1,2):
print(i, end=" ")
sumo += i
print(sume-sumo)
t = int(input())
for _ in range(t):
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... | t = int(input())
for _ in range(t):
n = int(input())
if n%4 != 0:
print("NO")
else:
print("YES")
ans = []
for k in range(n//2):
ans.append((k+1)*2)
for k in range(n//2-1):
ans.append((k+1)*2-1)
ans.append(n//2-1+n)
print(*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... | #include <bits/stdc++.h>
using namespace std;
int main() {
long long int t;
cin >> t;
while (t != 0) {
long long int n, x, i;
cin >> n;
n /= 2;
if (n % 2 != 0) {
cout << "NO" << endl;
} else {
cout << "YES" << endl;
for (i = 0; i < n / 2; i++) {
cout << 2 + i * 2 << "... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are even (divisible by 2);
* the second n/2 elements of a are odd (not divisible by 2);
* all elements of a are distinct a... | t = int(input())
n = 0
for i in range(t):
n = int(input())
even = []
odd = []
a = []
for y in range(2 , n + 1 , 2):
even.append(y)
a.append(str(y))
for y in range(1 , n + 1 , 2):
odd.append(y)
a.append(str(y))
diff = (sum(even) - sum(odd))
if diff % 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... | from collections import Counter
t = int(input())
for i in range(t):
n,k = (int(x) for x in input().split())
a = list(map(int, input().split()))
pairs = n // 2
p = [(a[i],a[n-i-1]) for i in range(pairs)]
sump = [sum(x) for x in p]
pc = Counter(sump)
minp = [min(x)+1 for x in p]
maxp = [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... | # cook your dish here
t=int(input())
for _ in range(t):
n=int(input())
n/=2
if n%2==1:
print("NO")
else:
print("YES")
ans=0
st=""
for i in range(int(n)):
ans += (2+(i*2))
st+=str(2+(i*2))
st+=" "
for i in range(int(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 % 4 != 0:
print("NO")
else:
print("YES")
front = []
for i in range(1, n // 2 + 1):
print(i * 2, end=' ')
front.append(i * 2)
for i in range(n // 4):
print(front[i] - 1, end=' ')
for i in range(n /... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are even (divisible by 2);
* the second n/2 elements of a are odd (not divisible by 2);
* all elements of a are distinct a... | t = int(input())
for _ in range(t):
n = int(input())
if n%4:
print("NO")
else:
print("YES")
print(' '.join(map(str,[2*m for m in range(1, n//2 + 1)])),
' '.join(map(str,[2*m-1 for m in range(1, n//2) ])),
n-1 + n//2,
sep=' ')
|
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are even (divisible by 2);
* the second n/2 elements of a are odd (not divisible by 2);
* all elements of a are distinct a... | #code
for _ in range(int(input())):
n = int(input())
if(n%4!=0):
print("NO")
else:
print("YES")
p = 2
q = 0
l = []
for i in range(n//2):
l.append(p)
q+= p
p = p + 2
p = 1
r = 0
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 org.omg.CORBA.INTERNAL;
import java.io.*;
import java.nio.charset.Charset;
import java.util.*;
public class run {
public static void main(String args[]) throws IOException {
InputReader in = new InputReader(System.in);
PrintWriter pw = new PrintWriter(System.out);
int tc = in.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... | import math
num_case = int(input())
for i in range(num_case):
k = int(input())
con = int(k/2)
if con%2==1:
print("NO")
else:
print("YES")
result = []
count1=0
count2=0
for i in range(1, con+1):
result.append(2*i)
count1+=2*i
for i in range(1, con):
re... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are 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 q in range(t):
n=int(input())
if n%4!=0 : print('NO')
else :
print('YES')
for i in range(0,n,2):
print(i+2,end=' ')
for i in range(1,n-2,2):
print(i,end=' ')
print(int((3*n-2)/2)) |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are even (divisible by 2);
* the second n/2 elements of a are odd (not divisible by 2);
* all elements of a are distinct a... | from collections import Counter, defaultdict, deque
import bisect
from sys import stdin, stdout
from itertools import repeat
import math
import random
# sys.stdin = open('input')
def inp():
return map(int, raw_input().split())
def inst():
return raw_input().strip()
def my_main():
t = inp()[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... | #!/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... | #include <bits/stdc++.h>
using namespace std;
const long long int INF = LLONG_MAX;
vector<long long int> v1;
vector<pair<long long int, long long int> > v2;
string s1, s2, s3;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long int a, b, c, d, e, f, i, j, k, cnt1 = 0, cnt2 = 0, 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... | t = int(input())
for i in range(t):
n = int(input())
if n%4!=0:
print("NO")
continue
else:
print("YES")
for j in range(1,n//2+1):
print(j*2,end = " ")
for j in range(1,n//2):
print(j*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... | # -*- coding: utf-8 -*-
"""
Created on Sun Apr 19 19:15:09 2020
@author: USER
"""
for i in range(int(input())):
n=int(input())
if((n//2)%2==1):
print('NO')
r=1
else:
print('YES')
for j in range(2,n+1,2):
print(j,end=' ')
for j in range(1,(n//2)):
... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are even (divisible by 2);
* the second n/2 elements of a are odd (not divisible by 2);
* all elements of a are distinct a... |
#coding:utf-8
even = list()
odd = list()
t = input();
t = int(t)
for i in range(t) :
n = input()
n = int(n)
if n % 2 == 0 :
halfarray = int( n / 2 )
if halfarray % 2 == 0 :
print("YES")
a = 2
for i in range(1 , halfarray+1) :
even.append(a*i)
ev = 0
od = 0
for j in range(h... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are 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] * 200005
while T != 0:
T = T - 1
n = int(input())
if n % 4 == 0:
print("YES")
t = n * 2 + 2
len = n // 2
j = 2
for i in range(1, len // 2 + 1):
a[i] = j
a[len - i + 1] = t - j
j = j + 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 java.util.*;
public class test
{
public static void main(String[]args)
{
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
for(int l=1;l<=t;l++)
{
int n=sc.nextInt();
if((n/2)%2!=0)
{
System.... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are even (divisible by 2);
* the second n/2 elements of a are odd (not divisible by 2);
* all elements of a are distinct a... | #include <bits/stdc++.h>
using namespace std;
void result(int n) {
long long int a[n], sum_even = 0, sum_odd = 0;
for (int i = 0; i < n / 2; ++i) {
a[i] = 2 + i * 2;
sum_even += a[i];
}
for (int i = n / 2, j = 0; i < n - 1; ++i, ++j) {
a[i] = 2 + j * 2 - 1;
sum_odd += a[i];
}
a[n - 1] = sum_... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are even (divisible by 2);
* the second n/2 elements of a are odd (not divisible by 2);
* all elements of a are distinct a... | t = int(input(' '))
for i in range(0,t):
n = int(input(' '))
L = []
i = 0
x = 2
y = 1
if n%4 != 0 and n%2 == 0:
print("NO")
elif n%4 == 0:
print("YES")
while i < (n/2):
L.append(x)
i += 1
x += 2
p = sum(L)
while (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())
check = n // 2
if check%2 == 1:
print('NO')
else :
result = []
even = 0
for i in range(check) :
even = even + 2
result.append(even)
result.append(1)
odd = 1
for _ in range(chec... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are even (divisible by 2);
* the second n/2 elements of a are odd (not divisible by 2);
* all elements of a are distinct a... | # https://codeforces.com/contest/1343/problem/B
def solve(n):
'''
1 <= t <= 10^4
2 <= n <= 2 * 10^5, n % 2 == 0
'''
if n // 2 % 2:
return 'NO'
res = [0] * n
for i in range(n // 2):
res[i] = 2 * (i + 1)
res[i + n // 2] = 2 * i + 1
res[-1] += n // 2
print('YES')
return ' '.join(map(str, res))
if __name_... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are even (divisible by 2);
* the second n/2 elements of a are odd (not divisible by 2);
* all elements of a are distinct a... | output=[]
for __ in range(int(input())):
N=int(input())
if N%4!=0:
output.append("NO")
else:
x=list(range(2,(N//2)*2+1,2))
y=[]
for i in x[0:N//4]:
y.append(i-1)
for i in x[N//4:]:
y.append(i+1)
x=x+y
x=[str(num) for num in x]
... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are even (divisible by 2);
* the second n/2 elements of a are odd (not divisible by 2);
* all elements of a are distinct a... |
t=int(input())
for i in range(t):
n,k=map(int,input().split())
b=list(map(int,input().split()))
a=b[:int(n//2)]
c=b[int(n//2):]
c.reverse()
d=[0]*(2*k+2)
f=dict()
for j in range(1,2*k+1):
f[j]=0
for j in range(n//2):
r=a[j]+c[j]
f[r]+=1
x=min(a[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... | for _ in range(input()):
n=input()
if n%4!=0:
print "NO"
continue
l=[2*i for i in range(1,n/2+1)]
k=[2*i-1 for i in range(1,n/2+1)]
k[n/2-1]+=n/2
print "YES"
for i in l:
print i,
for i in k:
print i,
print
|
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are even (divisible by 2);
* the second n/2 elements of a are odd (not divisible by 2);
* all elements of a are distinct a... | t = int(input())
for tt in range(t):
n = int(input())
if n % 4 != 0:
print("NO")
continue
else:
print("YES")
ans = [*range(2, n+1, 2)] + [*range(1, n-1, 2)]
ans.append(ans[n//2-1]+n//2-1)
print(' '.join(map(str,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... | t = int(input())
even = []
odd = []
for i in range(6, 5 * 10 ** 5, 8):
odd.append(i + 1)
odd.append(i - 1)
even.append(i - 2)
even.append(i + 2)
for i in range(t):
n = int(input())
if n % 4 == 0:
print('YES')
total = even[:n // 2] + odd[:n // 2]
print(' '.join(map(str, to... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are 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 res(n):
return n%4==0
# print(res(5))
n = int(input())
for i in range(n):
k = int(input())
if res(k):
print('YES')
l = 2
for h in range(0,k//2):
print(l,end=' ')
l+=2
l=1
for h in range(0,k//2):
if h!=k//2-1:
pri... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are even (divisible by 2);
* the second n/2 elements of a are odd (not divisible by 2);
* all elements of a are distinct a... | t = int(input())
for _ in range(t):
a = int(input())
b = a/2
arr2 = [str((x+1)*2) for x in range(int(b))]
total = int(b*(b+1))
arr = [str((x*2)+1) for x in range(int(b)-1)]
arr.append(total - (b-1)*(b-1))
if arr[-1]%2 == 0:
print('NO')
else:
arr[-1] = str(int(arr[-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())
inf=float("INF")
def u(i,v):
i+=2*k
tr[i]+=v
while i>1:
i>>=1
tr[i]=tr[i<<1]+tr[i<<1|1]
def q(i):
l=2*k+1
r=i+2*k+1
res=0
while l<r:
if l&1:
res+=tr[l]
l+=1
if r&1:
r-=1
res+=tr[r]
l>>=1
r>>=1
return(res)
for _ in range(t):
n,k=map(int,input().split())
aa=list(map(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... | #include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 7;
long long t, n, k, a[N], v[N << 1], kk, ans;
inline void add(long long x, long long t) {
for (; x <= kk; x += x & -x) v[x] += t;
}
inline long long query(long long x) {
long long ans = 0;
for (; x > 0; x ^= x & -x) ans += v[x];
return ans;
}
i... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are even (divisible by 2);
* the second n/2 elements of a are odd (not divisible by 2);
* all elements of a are distinct a... | t=int(input())
for _ in range(t):
n=int(input())
if (n%4!=0):
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(3*n//2-1) |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are even (divisible by 2);
* the second n/2 elements of a are odd (not divisible by 2);
* all elements of a are distinct a... | for _ in range(int(input())):
n = int(input())
if (n//2)%2==0:
print("YES")
li1 = [i for i in range(2,n+1,2)]
for ele in li1:
print(ele,end=" ")
s = sum(li1)
a = 1
li2 = []
for i in range(len(li1)-1):
li2.append(a)
a = a... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are even (divisible by 2);
* the second n/2 elements of a are odd (not divisible by 2);
* all elements of a are distinct a... | def f(n):
if(n % 4 != 0):
print('NO')
return
print('YES')
print(*[2 * i + 2 for i in range((n >> 1))], end = ' ')
print(*[2 * i + 1 for i in range((n >> 1) - 1)], n - 1 + (n >> 1))
t = int(input())
for i in range(t):
n = int(input())
f(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 _ in range(t):
n = int(input())
n = n // 2
if n % 2 == 1:
print('NO')
else:
print('YES')
l = [0] * n * 2
l[0] = 2
for i in range(1, n):
l[i] = l[i - 1] + 2
l[n + i - 1] = l[i - 1] - 1
l[-1] = l[-2] + 2 + 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... | # python3
##=====================================================
from sys import stdin, stdout
from collections import defaultdict, Counter
from functools import lru_cache
from math import gcd, floor, ceil
def ilist():
return [int(x) for x in stdin.readline().strip().split(" ")]
def iint():
return int(stdin... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are even (divisible by 2);
* the second n/2 elements of a are odd (not divisible by 2);
* all elements of a are distinct a... | def solve(a,n,k):
cnt=[0]*(2*k+1)
one=[0]*(2*k+1)
for i in range(n//2):
s=a[i]+a[n-i-1]
minVal=min(a[i],a[n-i-1])
maxVal=max(a[i],a[n-i-1])
minSum=minVal+1
maxSum=maxVal+k
if maxSum<=(2*k-1): one[maxSum+1]-=1
one[minSum]+=1
cnt[s]+=1
for i in range(3,2*k+1): one[i]+=one[i-1]
ans=2e5
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... | import sys
import math
n=int(input())
for i in range(n):
t=int(input())
if t%4==0:
print("YES")
a=[]
b=[]
p=int(t//2)
j=0
x=2
y=1
for j in range(p):
a.append(x)
b.append(y)
x+=2
y+=2
b.pop()
... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are 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 Counter
t = int(input())
for i in range(t):
n,k = (int(x) for x in input().split())
a = list(map(int, input().split()))
pairs = n // 2
p = [(a[i],a[n-i-1]) for i in range(pairs)]
sump = [sum(x) for x in p]
pc = Counter(sump)
minp = [min(x)+1 for x in p]
maxp = [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... | import os
import sys
from io import BytesIO, IOBase
# region fastio
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode
self.write = self.buffer.wr... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are 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:
a=[];b=[];
for i in range(2,n+1,2):
a.append(i)
for i in range(1,n-2,2):
b.append(i)
print('YES')
print(*a,end=' ')
print(*b,end=' ')
print(sum(a)-sum(b))
else:
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... | t=int(input())
while t>0:
t-=1
n=int(input())
n=int(n/2)
if n%2:
print('NO')
continue
else:
print('YES')
e=0
for i in range(n):
e+=2
print(e,end=' ')
o=1
for i in range(n):
if i==n-1:
o+=n
... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are even (divisible by 2);
* the second n/2 elements of a are odd (not divisible by 2);
* all elements of a are distinct a... | for _ in range(int(input())):
n = int(input())
if((n//2)%2 == 1):
print("NO")
else:
print("YES")
even = []
k = 2
for i in range(n//2):
even.append(k)
k += 2
k = 1
odd = []
for i in range(n//2 - 1):
odd.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 = 2e5 + 10;
int a[MAXN];
const int MAXM = 4e5 + 10;
int ans[MAXM];
void add(int x, int y, int d) {
ans[x] += d;
ans[y + 1] -= d;
}
int main() {
int t;
scanf("%d", &t);
while (t--) {
memset(ans, 0, sizeof(ans));
int n, i, k;
scanf("%d %d"... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are even (divisible by 2);
* the second n/2 elements of a are odd (not divisible by 2);
* all elements of a are distinct a... | for _ in range(int(input())):
n=int(input())
if n%4!=0:
print("NO")
continue
print("YES")
l=[]
for i in range(n//2):
l.append((i+1)*2)
for i in range(n//2,3*(n//4)):
l.append(l[i-n//2]-1)
for i in range(3*(n//4),n):
l.append(l[i-n//2]+1)
for i in l:
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... | import sys
def input():
return sys.stdin.readline()
def print(val):
sys.stdout.write(str(val) + '\n')
def yo():
for _ in range(int(input().strip())):
n, k = map(int,input().split())
nums = list(map(int,input().split()))
common_values = [0 for _ in range(2*k+2)]
for i in range... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are 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:
t=t-1
n=int(input())
k=2
if n%4!=0:
print('NO')
else:
print("YES")
x = int(n/2)
for i in range(1,x+1):
print(2*i,end=' ')
for i in range(1,x):
print(2*i-1,end=' ')
print(3*x-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 itertools import accumulate
def solve(a, n, k):
pairs = [(min(x, y), max(x, y)) for x, y in zip(a[:n], a[::-1][:n])]
# print(f'{pairs=}')
one_change = [(x+1, y+k) for x, y in pairs]
# print(f'{one_change=}')
changes = [0] * (2*k+ 2)
for a, b in one_ch... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are 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())
result = []
if (n // 2) % 2 == 0:
print('YES')
for i in range(1, n+1):
if i % 2 == 0:
result.append(i)
for i in range(1, n-1):
if i % 2 == 1:
result.append(i)
a = 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... | # https://codeforces.com/contest/1343/problem/B
def solve():
n = int(input())
if n % 4 != 0:
print("NO")
else:
ev = list(range(2, n + 1, 2))
od = list(range(1, n + 1, 2))
od[-1] = sum(ev) - sum(od[:-1])
ans = ev + od
print("YES")
print(*ans)
if __nam... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are 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):
e=2
o=1
s=0
ch=''
n=int(input())
if (n//2)%2!=0:
print("NO")
else:
L=[0 for i in range(n)]
for j in range((n//2)):
L[j]=e
e+=2
s+=L[j]
for j in range(n//2,n-1):
L[j]=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... | t=int(input())
while t:
t-=1
n=int(input())
p=n//2
if p%2:
print("NO")
else:
ls=[i for i in range(2,n+1,2)]
sum1=sum(ls)
qs=[i for i in range(1,n-1,2)]
qs.append(sum1-sum(qs))
print("YES")
print(*(ls+qs)) |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are even (divisible by 2);
* the second n/2 elements of a are odd (not divisible by 2);
* all elements of a are distinct a... | for i in range(int(input())):
n=int(input())//2
if n%2==0:
print('YES')
evens=list(range(2, 1+2*n, 2))
odds=list(range(1, 2*(n+1), 2))
odds.remove(sum(odds)-sum(evens))
ans=evens+odds
for i in ans:
print(i, end=' ')
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... | '''
py cf636b.py
'''
for test in range(int(input())):
n = int(input())
if (n%4 != 0):
print('NO')
continue
x = n//2
f = []
s = []
f.append(2)
s.append(1)
for i in range(1,x):
f.append(4*(i+1))
if i%2 != 0:
s.append(f[-1]+1)
else:
s.append(f[-1]-1)
print('YES')
print(*(f+s))
|
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are even (divisible by 2);
* the second n/2 elements of a are odd (not divisible by 2);
* all elements of a are distinct a... | import math
t = int(input())
while t :
n = int(input())
l = []
if n%4 == 0:
print("YES")
for i in range(1,int((n/2))+1):
l.append(2*i)
for i in range(1,int(n/4)+1):
l.append(2*i-1)
for i in range(int(n/4)+1,int(n/2)+1):
l.append(2*i+1)
... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are even (divisible by 2);
* the second n/2 elements of a are odd (not divisible by 2);
* all elements of a are distinct a... | import math
n = int(input())
d=[]
def check(p):
x = []
p = int(p / 2)
sum = math.pow(p, 2)+p
for i in range(1, p+1):
x.append(str(2*i))
for i in range(1, p):
x.append(str(2*i-1))
sum-=int(x[-1])
x.append(str(int(sum)))
return x
for i in range(n):
b = 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... | #include <bits/stdc++.h>
const int32_t M = 1e9 + 7;
const int32_t mod = 998244353;
using namespace std;
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
long long int t;
cin >> t;
while (t--) {
int n;
cin >> n;
if (n % 4 != 0)
cout << "NO\n";
else {
cout << "... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are 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.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
public class d {
static BufferedReader s = new BufferedReader(new InputStreamReader(System.in));
public static void main(String[] args) throws IOException {
StringBuilder sb=new 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())
x=1
sum=0
if((n/2)%2==0):
print('YES')
for i in range(1,n//2+1):
print(2*i,end=' ')
for i in range(1,n//2):
print(x,end=' ')
x=x+2
y=n//2
print(y*(2+(y-1))- (y-1)*(1+(y-2)))
else:... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are even (divisible by 2);
* the second n/2 elements of a are odd (not divisible by 2);
* all elements of a are distinct a... | t = int(input())
while t:
n = int(input())
if n % 4 != 0:
print("NO")
else:
print("YES")
l = []
i = 2
temp = n//2
temp1 = temp
while temp:
l.append(i)
i += 2
temp -= 1
i = 1
while temp1:
l... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are even (divisible by 2);
* the second n/2 elements of a are odd (not divisible by 2);
* all elements of a are distinct a... | for _ in range(int(input())):
n=int(input())
##a=list(map(int,input().split()))
b=[]
b.append(1)
if n%4!=0:
print("NO")
else:
k=1
for i in range((n//2)-1):
x=((4*k)+2)//2
##print(x)
b.append(x)
k+=1
b[len(b)-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.util.*;
import java.math.*;
import java.lang.*;
import static java.lang.Math.*;
public class Cf131 implements Runnable
{
static class InputReader
{
private InputStream stream;
private byte[] buf = new byte[1024];
private int curChar;
private... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are even (divisible by 2);
* the second n/2 elements of a are odd (not divisible by 2);
* all elements of a are distinct a... | t = int(input())
for i in range(t):
n = int(input())
if n % 4 != 0:
print("NO")
else:
print("YES")
res = [num for num in range(2, n + 1, 2)] + [2 * num - 1 for num in range(1, n // 2)] + [2 * (n * 3 // 4) - 1]
print(*res)
|
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are even (divisible by 2);
* the second n/2 elements of a are odd (not divisible by 2);
* all elements of a are distinct a... | for i in range(int(input())):
n=int(input())
if n%4!=0:
print('NO')
else:
print('YES')
a=[i for i in range(2,n+1,2)]
b=[i for i in range(1,n-1,2)]
b.append(sum(a)-sum(b))
print(*(a+b)) |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are even (divisible by 2);
* the second n/2 elements of a are odd (not divisible by 2);
* all elements of a are distinct a... | import atexit, io, sys
buffer = io.BytesIO()
sys.stdout = buffer
@atexit.register
def write():
sys.__stdout__.write(buffer.getvalue())
vng = lambda: map(int, raw_input().split())
for cs in range(int(raw_input())):
(n, k), a = tuple(vng()), vng()
pri = [0] * (2*k+2)
for i in range(n/2):
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... | for _ in range(int(input())):
n = int(input())
if (n//2) % 2 == 1:
print("NO")
continue
print("YES")
for e in range(2, n+1, 2):
print(e, end=" ")
for o in range(1, n, 2):
if o==(n-1):
print(o+ n//2,end=" ")
continue
print(o, 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 k in range(t):
n=int(input())
od=[]
ev=[]
val=0
oval=0
ans=[]
if(int(n/2)%2==1):
print("NO")
else:
print("YES")
for i in range(1,int(n/2)):
od.append((2*i)-1)
oval=oval+((2*i)-1)
ev.append(i*2)
val... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are 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")
l=[]
x=2
while(x<=n):
l.append(x)
x+=2
i=-1
l1=l[:]
x=1
while(x<=n):
l.append(x)
x+=2
n1=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;
const int MAXN = 1e5 + 50;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
int main() {
std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
if (n % 4 != 0) {
cout << "NO" << endl;
co... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are 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.readline
from math import *
# print = stdout.write
for __ in range(int(input())):
# ttt=False
n,m=map(int,input().split())
ar=list(map(int,input().split()))
# if(__==0 and n==8 and m==8):
# ttt=True
r1={}
r2={}
h=[0]*(m+m+1)
for i in range(n//2):
x=ar[i]
y=ar[... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are 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 = lambda: sys.stdin.readline().rstrip("\r\n")
from math import log2
class SegmentTree:
def __init__(self, array):
self.n = len(array)
self.size = 2**(int(log2(self.n-1))+1)
self.default = 0
self.data = [self.default] * (2 * self.size)
self.process(array)
... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are even (divisible by 2);
* the second n/2 elements of a are odd (not divisible by 2);
* all elements of a are distinct a... | t = int(input())
for i in range(t):
n = int(input())
if(n%4!=0):
print("NO")
else:
arr = [0 for i in range(n)]
e = 2
s = 0
o = 1
s1 = 0
for i in range(n//2):
arr[i] = e
if(i!=n//2-1):
arr[n-1-i] = 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... | #include <bits/stdc++.h>
using namespace std;
int main() {
long long int t, n;
cin >> t;
while (t--) {
cin >> n;
if (n % 4)
cout << "NO" << endl;
else {
vector<long long int> o;
vector<long long int> e;
for (long long int i = 1; i <= n + 1; i++) {
if (i != n / 2 + 1) {
... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are even (divisible by 2);
* the second n/2 elements of a are odd (not divisible by 2);
* all elements of a are distinct a... | t=int(input())
for case in range(t):
n=int(input())
if(n/2)%2!=0:
print("NO")
else:
l=[None]*n
for i in range(n//2):
l[i]=2*(i+1)
if(i<n//2-1):
l[i+n//2]=l[i]-1
else:
l[i+n//2]=l[i]+(n//2-1)
print("YES")
for item in l:
print(item,end=" ")
|
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are even (divisible by 2);
* the second n/2 elements of a are odd (not divisible by 2);
* all elements of a are distinct a... | import math
t=int(input())
for i in range(t):
n=int(input())
even=[]
odd=[]
if((n/2)%2!=0):
print("NO")
else:
print("YES")
num=0
for i in range(0,n//2):
num=num + 2
even.append(num)
odd.append(num-1)
odd.pop()
num1=sum(even) - sum(odd)
odd.append(num1)
even=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... | import sys
t = int(sys.stdin.readline())
for _ in range(t):
n = int(sys.stdin.readline())
if n % 4 != 0:
print('NO')
else:
print('YES')
odds = [2 * i + 1 for i in range(n // 2)]
sumo = sum(odds)
pair = [2 * (i + 1) for i in range(n // 2)]
sump = sum(pair)
... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are even (divisible by 2);
* the second n/2 elements of a are odd (not divisible by 2);
* all elements of a are distinct a... | for i in range(int(input())):
n,k=[int(i) for i in input().split()]
arr=[int(i) for i in input().split()]
d={}
na=[0 for i in range(2*k+2)]
for i in range(n//2):
d[arr[i]+arr[-1-i]]=d.get(arr[i]+arr[-1-i],0)+1
na[max(arr[i],arr[-1-i])+k+1]+=-1
na[min(arr[i],arr[-1-i])+1]+=1
for i in range(1,2*k+... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are even (divisible by 2);
* the second n/2 elements of a are odd (not divisible by 2);
* all elements of a are distinct a... | for _ in range(int(input())):
n=int(input())
if(n%2==0 and n%4!=0):
print("NO")
else:
print("YES")
sum=0
for i in range(1,n+1):
if(i%2==0):
print(i,end=" ")
sum+=i
print(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... | import sys
input = sys.stdin.readline
def main():
t = int(input())
for _ in range(t):
N = int(input())
if (N // 2) % 2 == 1:
print("NO")
else:
print("YES")
A = [2 * i for i in range(1, N // 2 + 1)]
sa = sum(A)
sb = 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())
out = ''
while t > 0:
t -= 1
n = int(input())
if (n // 2) % 2 == 1:
out += 'NO\n'
continue
e = set()
o = set()
s_e = 0
s_o = 0
for i in range(2, n + 1, 2):
e.add(i)
s_e += i
for i in range(1, n - 1, 2):
o.add(i)
s_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 x in range(int(input())):
a = int(input())
l = []
if a>2:
for x in range(1,a//2+1):
l.append(x*2)
for i in range(1,a-1,2):
f=i
l.append(i)
if (f+2+a//2)%2==0:
print("NO")
else:
print("YES")
print(*l,f+2+a//2)
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... | t=int(input())
for _ in range(t):
n=int(input())
p=n//2
if p%2==0:
print("YES")
even=[]
odd=[]
j=2
k=1
for i in range(p):
even.append(j)
odd.append(k)
k+=2
j+=2
p=sum(even)
k=sum(odd)
j=od... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are even (divisible by 2);
* the second n/2 elements of a are odd (not divisible by 2);
* all elements of a are distinct a... | for i in range (int(input())):
n = int(input())
if n / 2 % 2 == 0 :
print('YES')
for x in range (2, n+2, 2):
print (x, end=' ')
c = n//2
a = c**2 + c
somme = 0
for x in range (1, n-1, 2):
print (x, end=' ')
somme += x
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... | '''
INPUT SHORTCUTS
N, K = map(int,input().split())
N ,A,B = map(int,input().split())
string = str(input())
arr = list(map(int,input().split()))
N = int(input())
'''
def main():
t = int(input())
while t:
N, K = map(int,input().split())
arr = list(map(int,input().split()))
prefix = [0 for _ in range((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... | n = int(input())
for i in range(n):
t = int(input())
if (t /2) % 2 != 0:
print("NO")
else:
print("YES")
se, so = 0, 0
for j in range(2, t+2, 2):
print(j, end = " ")
se = se+j
for k in range(1, t-2, 2):
print(k, end = " ")
... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are even (divisible by 2);
* the second n/2 elements of a are odd (not divisible by 2);
* all elements of a are distinct a... | from collections import defaultdict
for T in range(int(input())) :
n , k = list(map(int,input().split()))
arr = list(map(int,input().split()))
d = defaultdict(int)
prefix = [0]*(2*k +2)
for i in range(n//2) :
d[arr[i]+ arr[n-1 -i]] +=1
prefix[min(arr[i],arr[n-i -1])+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... | for _ in range(int(input())):
n=int(input())
if n%4!=0:
print("NO")
else:
k=2
arr=[]
for i in range((n//2)):
arr.append(k)
k+=2
k=1
for i in range(n//2,n-1):
arr.append(k)
k+=2
if (sum(arr[0:n//2])+sum(ar... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are 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, k, i, d[200001], v[400005], ans, a, b, sum;
cin >> t;
while (t--) {
cin >> n >> k;
for (i = 0; i < n; i++) {
cin >> d[i];
}
for (i = 2; i <= 2 * k + 1; i++) v[i] = 0;
for (i = 0; i < n / 2; i++) {
a = d[i];
... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are even (divisible by 2);
* the second n/2 elements of a are odd (not divisible by 2);
* all elements of a are distinct a... | t = int(input())
for _ in range(0,t):
n = int(input())
a_even = [2*int(i) for i in range(1,n//2+1)]
a_odd = [(2*int(i)+1) for i in range(0,n//2-1)]
if len(a_odd) and (sum(a_even)-sum(a_odd))%2:
a_odd.append(sum(a_even)-sum(a_odd))
print("YES")
print(*(a_even+a_odd))
else:
... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are even (divisible by 2);
* the second n/2 elements of a are odd (not divisible by 2);
* all elements of a are distinct a... | t = int(input())
for _ in range(t):
n,k = map(int,input().split())
arr = list(map(int,input().strip().split()))[:n]
from collections import defaultdict
store = defaultdict(int)
limits = [0]*(2*k+2)
for i in range(n//2):
a = min(arr[i],arr[n-i-1])+1
b = max(arr[i],arr[n-i-1])+k
... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are even (divisible by 2);
* the second n/2 elements of a are odd (not divisible by 2);
* all elements of a are distinct a... | # #
# author : samars_diary #
# 02-09-2020 │ 07:20:39 #
# #
import sys, os.path
# if(os.path.exists('input.txt')):
# sys.stdin = open('input.txt',"r")
# sys.stdout = open('output.txt',"w")
sys.setrecursionlimit(10 ** 5)
def II(): return 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... | for _ in range(int(input())):
n = int(input())
if (n//2)&1 == 1:
print("NO")
else:
print("YES")
summ = 0
for i in range(2,(n+1),2):
summ += i
print(i, end = ' ')
for i in range(1,(n-1),2):
summ -= i
print(i, end = ' ')
print(summ)
|
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are even (divisible by 2);
* the second n/2 elements of a are odd (not divisible by 2);
* all elements of a are distinct a... | for _ in range(int(input())):
n=int(input())
if (n//2)%2!=0:
print('NO')
continue
else:
l1=[]
l2=[]
for i in range(1,n//2):
l1.append(2*i)
l2.append((2*i)-1)
l1.append(n)
l2.append(n+(n//2-1))
l=l1+l2
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... | #Template 1.0
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from heapq import heappush, heappop, heapify, nlargest, nsmallest
def STR(): return list(input())
def INT(): return int(input())
def MAP(): return map(int, input().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... | """Template for Python Competitive Programmers prepared by Mayank Chaudhary """
# to use the print and division function of Python3
from __future__ import division, print_function
"""value of mod"""
MOD = 998244353
mod = 10**9 + 7
"""use resource"""
# import resource
# resource.setrlimit(resource.RLIMIT_STACK, [0x10... |
Problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are even (divisible by 2);
* the second n/2 elements of a are odd (not divisible by 2);
* all elements of a are distinct a... | #author : dokueki
import sys
from math import *
INT_MAX = sys.maxsize
INT_MIN = -(sys.maxsize)
sys.setrecursionlimit(10**7)
mod = 1000000007
def IOE():
sys.stdin = open("input.txt", "r")
sys.stdout = open("output.txt", "w")
def main():
t = int(sys.stdin.readline())
for _ in range(t):
n = 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 i in range (t):
n=int(input())
n=n//2
if n%2==1:
print('NO')
else:
print('YES')
a=[0]*(2*n)
j=2
for i in range(0, n, 2):
a[i]=j
a[i+1]=j+2
a[n+i]=a[i]-1
a[n+i+1]=a[i+1]+1
j+=6
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... | cases = int(input())
while cases:
cases -= 1
n = int(input())
if n % 4 == 0:
print("YES")
odd, even = 0,0
for i in range(1,n//2+1):
even += 2*i
print(2*i, end=" ")
for i in range(1,n//2):
odd += 2*i - 1
print(2*i -1,end = " ")
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.