This post is all about the solution of the "B. Funny PermutationCodeforces Round #826 (Div. 3) Problem Statement.

Codeforces logo

Codeforces




Problem Statement of B. Funny Permutation :

Possible combination refers to a series of m figures that includes all starting from 1 to  mexactly at first when. Configurations include the sequences [3,1,4,2], [1]
For a specified number m, start creating a permutation a that meets two needs at the same moment:
At least a single of the neighbours of the each component ai has a value that varies by 1 from the value of ai. That really is, for every ai (1<=j<=m) element, at least individual of its neighbours (to the left or right of ai) must be ai+1, or ai1.
There should be no cartesian coordinates inside the permutation. That is, aii must be satisfied for every I (1<=j<=m).
Let us just consider the permutation which meets such criteria humorous.
Output any hilarious permutation of length m for a provided positive integer m, or -1 when no hilarious permutation of fixed length exists.


Format of the Input :

The very first line of data input includes a unique numeric u (1<=u<=104) — the total number of tests.

The test cases have been described below as well.

Each testing phase shall consist of g single lines, every of containing one integer m (2<=m<=2*10^5).

It is assured that sum of m over all tests does not surpass 2*10^5.



Format of the Output :

Write the following on a different line for every testing phase:

whatever amusing permutation a of length m; or -1 if the possible combination you seek doesn't really exist.


Also Check this out:-

A. Compare T-Shirt Sizes Codeforces Round #826 (Div. 3) Problem Solution Click Here

B. Funny Permutation Codeforces Round #826 (Div. 3) Problem Solution Click Here

C. Minimize the Thickness Codeforces Round #826 (Div. 3) Problem Solution Click Here

D. Masha and a Beautiful Tree Codeforces Round #826 (Div. 3) Problem Solution Click Here


Velotio is Hiring Freshers for the role of Associate Software Engineer - Remote, Apply Now
CLOVER INFOTECH PRIVATE LIMITED is Hiring Fresher for the role of Software Engineer / Software Developer, Apply Now
Collins Aerospace is Hiring for the role of Graduate Engineer Trainee, Apply


Also Read :- Top Programming Languages of 2022 Click Here



EcoReturns by Saara is Hiring for the role of Software Developer (Frontend Developer - Remote), Apply Now
Datastack Technologies Pvt Ltd is Hiring for the role of Web Developer 2022, Apply Now
Surya Digital is Hiring for the role of Software Development Engineer - I Apply Now
Webbtree is Hiring for the role of Full Stack Developer 2022 Apply Now
Interactive Brokers is Hiring Fresher for the role of Backend Developer 2022, Apply Now
SOLVERINES TECHNOLOGY SOLUTIONS PRIVATE LIMITED is Hiring for Software Associate Developer - Trainee 2022 Apply Now
LogiNext is Hiring for Junior Software Engineer  2022 Apply Now


Couchbase is Hiring for Graduate Software Engineer , Freshers as well as Experience candidates can apply Apply Now
Teamlease Digital Private Limited is Hiring for Software Engineer 2022 Apply Now


Solution of the B. Funny Permutation problem: