about a n by n chessboard. Its columns are numbered from 1 to n from the top to the base. Its sections are numbered from 1 to n from the passed on to one side. A cell on a convergence of x-th line and y-th section is indicated (x,y). The fundamental corner to corner of the chessboard is cells (x,x) for all 1≤x≤n.    A stage of {1,2,3,… ,n} is composed on the fundamental slanting

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

Computer science. Correct answer will be upvoted else downvoted.

 

Think about a n by n chessboard. Its columns are numbered from 1 to n from the top to the base. Its sections are numbered from 1 to n from the passed on to one side. A cell on a convergence of x-th line and y-th section is indicated (x,y). The fundamental corner to corner of the chessboard is cells (x,x) for all 1≤x≤n. 

 

A stage of {1,2,3,… ,n} is composed on the fundamental slanting of the chessboard. There is actually one number composed on every one of the cells. The issue is to segment the cells under and on the principle askew (there are by and large 1+2+… +n such cells) into n associated areas fulfilling the accompanying imperatives: 

 

Each district ought to be associated. That implies that we can move from any cell of a locale to some other cell of a similar area visiting just cells of a similar district and moving from a cell to a neighboring cell. 

 

The x-th area ought to contain cell on the fundamental inclining with number x for all 1≤x≤n. 

 

The number of cells that have a place with the x-th district ought to be equivalent to x for all 1≤x≤n. 

 

Every cell under and on the fundamental askew ought to have a place with precisely one area. 

 

Input 

 

The principal line contains a solitary integer n (1≤n≤500) meaning the size of the chessboard. 

 

The subsequent line contains n integers p1, p2, ..., pn. pi is the number composed on cell (i,i). It is ensured that every integer from {1,… ,n} shows up precisely once in p1, ..., pn. 

 

Output 

 

On the off chance that no arrangement exists, output −1. 

 

In any case, output n lines. The I-th line ought to contain I numbers. The j-th number on the I-th line ought to be x if cell (i,j) has a place with the area with x cells.

Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Binary numbers
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
  • SEE MORE 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