I solved it as if y<0 and abs(y) >= abs(x) cout<<"NO"<<endl;
But this did not work even after trying so long.
why is this incorrect can anyone help this newbie?
THANKS!
# | User | Rating |
---|---|---|
1 | tourist | 3985 |
2 | jiangly | 3814 |
3 | jqdai0815 | 3682 |
4 | Benq | 3529 |
5 | orzdevinwang | 3526 |
6 | ksun48 | 3517 |
7 | Radewoosh | 3410 |
8 | hos.lyric | 3399 |
9 | ecnerwala | 3392 |
9 | Um_nik | 3392 |
# | User | Contrib. |
---|---|---|
1 | cry | 170 |
2 | maomao90 | 162 |
2 | Um_nik | 162 |
4 | atcoder_official | 160 |
5 | djm03178 | 158 |
5 | -is-this-fft- | 158 |
7 | adamant | 154 |
7 | Dominater069 | 154 |
9 | awoo | 153 |
10 | luogu_official | 152 |
I solved it as if y<0 and abs(y) >= abs(x) cout<<"NO"<<endl;
But this did not work even after trying so long.
why is this incorrect can anyone help this newbie?
THANKS!
Name |
---|
It's the simplest. Just run loops EASY PEASY
The $$$x$$$ never moves. You can always reach it in a finite number of moves. Only the $$$y$$$ does.
If y = -1, you move first and can therefor still reach it, as you'll be at -1 before it moves. You can move diagonally, so as long as y is greater than -1 you can reach it. Since regardless of the X, you can still move downwards at the same time as going to some side.
The basic idea is this: As x remains unchanged for the point under discussion: We try to reach x, and just to offset the fall, just assume we also go down every second. So, we move (1 right + 1 down) or (1 left + 1 down) depending on x. Now, after abs(x) moves, we reach x with y coordinate -abs(x). By this time, the coin is at y-coordinate: y_initial — abs(x) + 1. So, if the y-coordinate of the coin is above that of ours, we are through! Else, not. Note that this won't give the minimum moves, but just tells whether the situation is feasible or not.