GR - Grand Reward
Grand is one of the best companies every month, The manager chooses the best employee and rewards him. This month there are 4 employees do the same effort Sameh, Ameen, Shafeek and Atef but the manager will give reward to one only, He got a good idea
Let's say that the 4 employees will stand in someway like that every employee in one of the four sides east (Sameh), north (Ameen), west (Shafik) and south (Atef) then, there's a square matrix of width and height N×N among them first element in matrix will start with 1 then next element increase by 1 from left to right and from top to down until N×N like that
Ameen
1 2 3
Sameh 4 5 6 Shafeek
7 8 9
Atef
then let's rotate the matrix T turns 90 degrees clockwise per turn and the winner is the person who the sum of his side is the greatest
For example let's say that T=4 and N=3,
Atef wins because the sum of his side is 7+8+9=24 and it's the greatest
It's your job now create a program that do this job.
Input
Two integers the size of the matrix N (3 ≤ N ≤ 25), and the number of turns (1 ≤ T ≤ 10^9).
Output
The final result of the matrix and the employee who will get the reward (Sameh, Ameen, Shafeek, Atef).
Example
Input: 3 4 Output: Atef 1 2 3 4 5 6 7 8 9
Input: 4 3 Output: Shafeek 4 8 12 16 3 7 11 15 2 6 10 14 1 5 9 13
hide comments
beginner:
2018-11-28 15:56:41
getting compilation error in spoj editor even though code is working fine on ideone |
|
swatantragupta:
2016-12-26 18:30:42
AC in one go..easy question |
|
vengatesh15:
2016-12-23 16:39:14
AC in 1 go :-) |
|
Akshat Jain:
2016-06-24 14:43:21
easy one...spelling of shafeek costed me a WA |
|
lt:
2016-06-12 16:21:47
AC in one go! :) |
|
atef:
2016-03-16 20:40:14
Thanks thanks :) <3 |
|
code_nit:
2016-03-14 18:16:38
ac in one go !! |
|
chawla_1209:
2016-03-14 15:00:10
Nice problem :)
|
|
farhan764:
2016-03-14 06:40:59
nice question......got ac after one wa
|
|
atef:
2016-03-12 17:21:54
Sai modified now it's ok sorry for that some problem happened when i was editing something |
Added by: | atef |
Date: | 2016-03-10 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 GOSU JS-MONKEY |
Resource: | http://codeforces.com/group/2GQNxUCcIL/contest/202218/problem/G |