stage is a succession of n integers from 1 to n, in which every one of the numbers happen precisely once. For instance, [1], [3,5,2,1,4], [1,3,2] are stages, and [2,3,2], [4,3,1], [0] are not.    Polycarp was given four integers n, l, r (1≤l≤r≤n) and s (1≤s≤n(n+1)2) and requested to find a stage p of numbers from 1 to n that fulfills the accompanying condition:

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Correct answer will be upvoted else downvoted. Computer science.

 

 stage is a succession of n integers from 1 to n, in which every one of the numbers happen precisely once. For instance, [1], [3,5,2,1,4], [1,3,2] are stages, and [2,3,2], [4,3,1], [0] are not. 

 

Polycarp was given four integers n, l, r (1≤l≤r≤n) and s (1≤s≤n(n+1)2) and requested to find a stage p of numbers from 1 to n that fulfills the accompanying condition: 

 

s=pl+pl+1+… +pr. 

 

For instance, for n=5, l=3, r=5, and s=8, the accompanying stages are reasonable (not all choices are recorded): 

 

p=[3,4,5,2,1]; 

 

p=[5,2,4,3,1]; 

 

p=[5,2,1,3,4]. 

 

However, for instance, there is no change reasonable for the condition above for n=4, l=1, r=1, and s=5. 

 

Help Polycarp, for the given n, l, r, and s, find a stage of numbers from 1 to n that fits the condition above. In case there are a few appropriate changes, print any of them. 

 

Input 

 

The primary line contains a solitary integer t (1≤t≤500). Then, at that point, t experiments follow. 

 

Each experiment comprise of one line with four integers n (1≤n≤500), l (1≤l≤n), r (l≤r≤n), s (1≤s≤n(n+1)2). 

 

It is ensured that the amount of n for all input informational indexes doesn't surpass 500. 

 

Output 

 

For each experiment, output on a different line: 

 

n integers — a stage of length n that fits the condition above if such a change exists; 

 

- 1, in any case.

 

 

Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Merge Sort
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education