http://mirror.codeforces.com/contest/724/problem/C
I have been trying to solve this problem , but i don't have any ideas. can anyone help me ?? Thanks in Advance :)
# | 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 | Um_nik | 162 |
3 | maomao90 | 161 |
4 | atcoder_official | 160 |
5 | djm03178 | 158 |
5 | -is-this-fft- | 158 |
7 | adamant | 154 |
7 | Dominater069 | 154 |
9 | awoo | 152 |
9 | luogu_official | 152 |
http://mirror.codeforces.com/contest/724/problem/C
I have been trying to solve this problem , but i don't have any ideas. can anyone help me ?? Thanks in Advance :)
Name |
---|
Note that the ray trajectory is a straight line with slope either +1 or -1 (depending on reflection). Therefore these trajectories are: y = x + c and y = -x + k. Now for each point determine the value of the constants c and k, and store them mapped to {constant, slope}. Once this is done, simulate the situation given in the problem.
When the ray started at (0,0), determine its point of contact with the box walls. Now determine the slope after reflection ( -1 <-> +1 ) and also the direction (let's say upward/downward). Using the slope and point of contact, determine the value of the constant 'c' (y = mx+c) such that point of contact lies on the line. Now use this constant and slope to iterate through all points (we stored earlier) and calculate their answers (using their x/y coordinates, note that it takes 1 sec go 1 m in x/y dir). Use the direction and pt of contact to get the next point of contact. Repeat this until you cover all points or you reach a corner.
Since n, m < 10^5. We will have at max n+m lines with slope +1 and n+m for -1. Therefore this simulation can be done within the time limit.
Code