Submit  All submissions  Best solutions  Back to list 
SPIRAL  Spiral 
Wersja polska  English version 
Input
There is unknown number of tests. Each of them consists of one line in which appear two integers: n (0<n<=10^{6}; n always odd)  size of the square matrix and m (0<m<=n^{2})  the number of the choosen cell.
Output
For each test print index of the row and index of the column of the choosen cell which is determined by m.
Example
Input:
7 28
5 13
1 1
5 1
5 5
3 9
Output:
7 4
5 1
1 1
3 3
2 2
3 3
Added by:  Piotr Ką kol 
Date:  20100510 
Time limit:  1.659s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: NODEJS OBJC SCM qobi VB.NET 
Resource:  Author of the problem: David Déharbe; Author of the illustration: Wanderley Guimarães 
hide comments


20140205 03:53:27 Piotr KÄ…kol
Yeah, but it's kind of unfair for other users who may have a valid solution which would be shorter then valid equivalent of the best current one. I know it's also unfair to change the problem now but I think it's a better solution. Apologies. I've already done this with other tasks so it should happen with this one as well. 

20140124 00:44:21 Mitch Schwartz
Eh, all of my submissions for this problem rely on some degree of input weakness, because of a precision issue for a special class of inputs for an isolated part of my code that is in every submission. On the one hand it's good to make the test data strong, but on the other hand it's annoying to deal with a moving target. It's like if there is a problem where using X digits of Pi can pass, but there's a missing case where X+1 digits would be required, and for every submission you used X digits... Last edit: 20140124 08:50:14 

20140118 17:27:41 Piotr KÄ…kol
Thanks for informing. Will fix it in Feb. 

20140118 14:25:58 Linghui Liu
there are some missing tests which my 75/76 awk code fails,e.g. 3 9. Last edit: 20140118 14:31:18 

20100522 11:30:51 Piotr KÄ…kol
Now there are only 25 tests. Last edit: 20100522 11:30:49 

20100521 19:36:26 Zoltán Zámbori
The Perl code which contains "use integer;" needs ~23sec, others get TLE :( +1 problem when the test data and/or the time limit is against "Shortening codes" :( Last edit: 20100521 19:52:57 

20100520 23:35:56 Piotr KÄ…kol
When I changed time limit into 30sec only one of Your submissions get AC. (what I may tell You is that there are exactly 100 tests ;) ) 

20100520 21:51:35 Zoltán Zámbori
Thank You! Running 100 times my code with these numbers needs 10.5 sec :( 

20100518 18:22:03 Piotr KÄ…kol
In: 885387 1649760493 Out: 463003 443199 Maybe not the biggest but one of the biggest. Last edit: 20100522 11:36:02 