Gildong has a square board comprising of n lines and n sections of square cells, each comprising of a solitary digit (from 0 to 9). The cell at the j-th section of the I-th line can be addressed as (i,j), and the length of the side of every cell is 1. Gildong prefers enormous things, so for every digit d, he needs to find a triangle with the end goal that:

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 Multiple Downvoted. Computer science.

Gildong has a square board comprising of n lines and n sections of square cells, each comprising of a solitary digit (from 0 to 9). The cell at the j-th section of the I-th line can be addressed as (i,j), and the length of the side of every cell is 1. Gildong prefers enormous things, so for every digit d, he needs to find a triangle with the end goal that: 

 

Every vertex of the triangle is in the focal point of a cell. 

 

The digit of each vertex of the triangle is d. 

 

Somewhere around one side of the triangle is corresponding to one of the sides of the board. You might expect that a side of length 0 is corresponding to the two sides of the board. 

 

The space of the triangle is boosted. 

 

Obviously, he can't simply be content with tracking down these triangles with no guarantees. Along these lines, for every digit d, he will change the digit of precisely one cell of the board to d, then, at that point, track down such a triangle. He transforms it back to its unique digit after he is finished with every digit. Observe the greatest space of the triangle he can make for every digit. 

 

Note that he can put different vertices of the triangle on a similar cell, and the triangle can be a ruffian triangle; for example the space of the triangle can be 0. Additionally, note that he is permitted to change the digit of a cell from one d to another. 

 

Input 

 

Each test contains at least one experiments. The primary line contains the number of experiments t (1≤t≤1000). 

 

The primary line of each experiment contains one integer n (1≤n≤2000) — the number of lines and segments of the board. 

 

The following n lines of each experiment each contain a line of n digits without spaces. The j-th digit of the I-th line is the digit of the cell at (i,j). Every digit is one of the characters from 0 to 9. 

 

It is ensured that the amount of n2 in all experiments doesn't surpass 4⋅106. 

 

Output 

 

For each experiment, print one line with 10 integers. The I-th integer is the greatest space of triangle Gildong can make when d=i−1, increased by 2.

 

 

Expert Solution
steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Knowledge Booster
Topological 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
  • 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