#30846: 這題好暴力www(〒︿〒)


20060705sean (pneumonoultramicroscopicsilico...)

學校 : 高雄市立高雄高級中學
編號 : 77753
來源 : [163.32.78.203]
最後登入時間 :
2024-04-23 14:49:02
i401. 3. 雷射測試 -- 2022年6月APCS | From: [111.254.195.52] | 發表日期 : 2022-06-15 21:41

以下為我的解題想法:

define the directions of light:
0 right
1 left
2 up
3 down

reflections:
/:
0 > 2
1 > 3
2 > 0
3 > 1
f(x) = (x + 2) % 4
\:
0 > 3
1 > 2
2 > 1
3 > 0
g(x) = 3 - x

------------------------------------------------------------------------------------------------

psuedo::start

mirrors sort by x -> X
mirrors sort by y -> Y
x_of_light = 0
y_of_light = 0
dir = 0
if (dir = 0) {
    new_mirror = upper_bound(Y[y_of_light], x_of_light)
}
if (dir = 1) {
    new_mirror = lower_bound(Y[y_of_light], x_of_light) - 1
}
if (dir = 2) {
    new_mirror = upper_bound(X[x_of_light], y_of_light)
}
if (dir = 3) {
    new_mirror = lower_bound(X[x_of_light], y_of_light) - 1
}
new_x = mirror.x
new_y = mirror.y
new_dir = f(dir) if new_mirror.dir = 0 else g(dir)

 

source: judges/i401 3 雷射測試.cpp at main · 20060705Sean/judges (github.com)

 
ZeroJudge Forum