Submit | All submissions | Best solutions | Back to list |
GRIDPNT - Grid points |
There's a Cartesian lattice with 0<=x,y<=n. Given one point (x1, y1>0) in this lattice rotating clockwise as little as possible around the origin find the next point (x2, y2). The given and searched points mustn't have another point between the origin (0, 0) and this point itself.
x1, y1, x2, y2 are non-negative integers.
Score is source length.
Input
In the first line the number T (T<100) of test cases.
Then T lines with the space-separated n (1<=n<=50), x1 and y1.
Output
For each test case the space-separated x2 and y2.
Example
Input: 3
1 1 1
5 3 2
50 48 49 Output: 1 0
5 3
49 50
Added by: | HWK |
Date: | 2011-05-24 |
Time limit: | 9.989s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All |
hide comments
|
||||||
2012-08-07 19:43:55 XeRoN!X
Sol. submitted at shorten. Lets see how much Jander is able to reduce now. Last edit: 2011-06-26 17:21:07 |
||||||
2012-08-07 19:43:55 HWK
@XeRon!X: Very nice solution with Bash. But you could save more bytes. I reached 108 without changing your algo. ;-) Edit 2: With your new approach I reach 101 bytes. ;-) If you want to annoy Jander submit your solution at http://www.spoj.pl/SHORTEN/problems/GRIDPNT/ Edit 3: 100 bytes. Do you want a hint? Last edit: 2011-06-26 16:57:43 |
||||||
2012-08-07 19:43:55 XeRoN!X
Edit: 106 now :) Last edit: 2011-06-26 09:41:56 |
||||||
2012-08-07 19:43:55 HWK
@XeRon!X: In SHORTEN the best solution requires 107 bytes with Perl. (https://www.spoj.pl/SHORTEN/problems/GRIDPNT/) |
||||||
2012-08-07 19:43:55 Piotr
[edit] Got it! Now to find a way to reduce the lenght of the code.... Last edit: 2011-06-09 13:45:35 |
||||||
2012-08-07 19:43:55 HWK
@Piotr: Almost correct, only 5 mistakes. There you print the same output as in the line before. ;-) |
||||||
2012-08-07 19:43:55 HWK
2 0 0, 2 1 0 (y must be >0) and 2 0 2 (0 1 lies between 0 2 and 0 0) are not possible. 2 1 1 -> 2 1 2 0 1 -> 1 2 I forgot: Rotation >0 degrees. Last edit: 2011-06-04 20:36:53 |
||||||
2012-08-07 19:43:55 Anshu Avinash
2 0 0 is not possible.(x1,y1>0) |
||||||
2012-08-07 19:43:55 XeRoN!X
Rotation > 0 or >= 0 ?? What will be the output for : 2 0 0 2 1 0 2 1 1 2 0 1 2 0 2 |
||||||
2012-08-07 19:43:55 HWK
@numerix: That's right. It's changed now. For motivation: Python 148, Perl 128 bytes. ;-) |