The Wise Man

MJ_094 Intra Metropolitan Univer...
Limits 1s, 512 MB

Lukman loves to search the root of everything.Once he was reading the holy Quran. At the beginning he found an attached article.It discusses that, "In Quran the word Insan (Man) comes 65 times, and the elements by which man is created; Turab (dust) comes 17 times, Nutfa (sperm-drop) comes 12 times, Alak (clinging clot) comes 6 times, Mudga (lump of flesh) comes 3 times, Ejam (bone) comes 15 times, Laham (flesh) comes12 times. By adding this values (17+12+6+3+15+12) it is found miraculously to be 65, the times the word Insan (Man) is mentioned."

This is not your task. Your task is to search similar types of miracle on an n*n grid, evaluating the rows, columns and diagonals.


The first input line contains an integer n (3 ≤ n ≤ 12) i.e the size of the grid.The next lines contain the cells filled with distinct positive integers in the range 1, 2, ..., n^2. Input will be terminate by EOF.


If you find it in the given orientation of the values on the grid Print YES, otherwise Print NO.


8 1 6
3 5 7
4 9 2
8 5 6
3 1 7
4 9 2


Login to submit.


76% Solution Ratio
rayhan50001Earliest, Jul '17
nill98Fastest, 0.0s
SIR.24Lightest, 0 B
SIR.24Shortest, 582B
Toph uses cookies. By continuing you agree to our Cookie Policy.