But one final question. I think that I should rotate with matrix:
(cos x, -sin x)
(sin x, cos x)
With this I rotate in positive direction - counterclockwise, which I think is the case of the problem. But the online-judge accepted my solution with matrix:
Ok I figured it out. But I think that you should have used positive number in the problem statement when the magnetic north is to the west. After all that is the positive (counterclockwise) direction. Or this was intentionally changed in order to delude the competitors?
10x for keeping me in suspense the whole afternoon.
But one final question. I think that I should rotate with matrix:
(cos x, -sin x)
(sin x, cos x)
With this I rotate in positive direction - counterclockwise, which I think is the case of the problem. But the online-judge accepted my solution with matrix:
(cos x, sin x)
(-sin x, cos x)
Consider your example. The contest says that, for negative d, "magnetic north is west of true north." This means that the pirate treasure should be 90 degrees west of your final location. You have the opposite in your diagram. I'm not exactly sure which you're rotating (the pirate route or your route) so I have difficulty answering your question. But I'm pretty sure the judge's solution gets it right.
BiK wrote:Ok I figured it out. But I think that you should have used positive number in the problem statement when the magnetic north is to the west. After all that is the positive (counterclockwise) direction. Or this was intentionally changed in order to delude the competitors?
10x for keeping me in suspense the whole afternoon.
On a protractor, positive is counterclockwise. But in navigational coordinates, positive is clockwise. North is 0; East is 90; South is 180; East is 270.
I recall getting into a long confusing discussion with Skiena (until we clarified this point) when he was preparing "Radar Tracking" for inclusion in "Programming Challenges."
That's strange, I didn't know that, I just basically changed signs with what I did with the offset, got AC and assumed that I misread the problem somewhere...
Any advice for future problems?
(I am curious though, as the sample cases work for either way of the interpretation, if this was intentional or not.. )
Larry wrote:That's strange, I didn't know that, I just basically changed signs with what I did with the offset, got AC and assumed that I misread the problem somewhere...
Any advice for future problems?
(I am curious though, as the sample cases work for either way of the interpretation, if this was intentional or not.. )
I'm not sure what you mean. +90 and -90 are distinguished by the sample cases.
It is pretty common in ACM problems to have incomplete sample cases. You have to use all the information in the problem to make sure you've got it right. In general, if you get WA, your first step should be to sit down and read every word of the problem statement very carefully. Then read every line of your program very carefully, and try to prove to yourself that your solution answers the question.
I'm also having trouble with this problem. I got the solution for the sample input no problem, and also managed to calculate 1.29 for this testcase:
2
NE 2
S 1
-90
I'm pretty sure the problem is something to do with the way I handle angles.. I probably put too much faith in c++ trigonometric functions I would really appreciate it if someone would post some more extensive sample input/output, or if you want I can try to explain in detail how I am handling angles (although that would pain me, my geometry isn't as strong as it should be).