APCS 2023/1/8 實作題 解題報告
2023/1/31 更
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
兩眼一黑 我的年份竟然打錯了
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
第一題
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
思路
直接輸入 算一算就好了
Code
點我看Code
第二題
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
思路
直接輸入 思考一下對應關係
注意輸出是要輸出哪一行,for i {for j} 輸出要array[j][i]
就好了
Code
點我看Code
第三題
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
我太爛了,現場沒f()來不及寫 :(
思路
我用遞迴解,定義兩個函數:
parse(string s)
用來解析字串,決定要先用哪個運算符號,將符號左右的數字做 parse(左字串) * or + parse(右字串)
或將判斷字串並將其丟進f(整個字串)運算,或是沒有運算符號則回傳數字。
f(string s)
功能如題目中所述,最大-最小,解析()
及,
,其中每個參數就丟進去parse()。
舉例
input: 12+f(13,2+f(8,1+2*3),1+1*f(20,4)*f(2))*2
parse( 12+f(13,2+f(8,1+2*3),1+1*f(20,4)*f(2))*2 )
parse( 12+f(13,2+f(8,1+2*3),1+1*f(20,4)*f(2)) ) * parse( 2 )
parse( parse( 12 ) + parse( f(13,2+f(8,1+2*3),1+1*f(20,4)*f(2)) ) ) * parse( 2 )
… 然後繼續套 我懶得寫了 HackMD排版有點困難
Code
點我看Code
考試時原本的想法
用stack解,速度應該會更快,而且不會有遞迴深度過深的問題。
但我當時沒有想到照正確順序push進stack的方法,就用了遞迴,對我來說比較好實現。
之後再來動腦
第四題
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
思路
- Greedy
- 將event按照結束時間排序。由小到大。如果結束時間相同,則按照開始時間排序。由小到大。
- 對每一筆event判斷,將event安排給前一個結束時間最大的machine
- 具體上為什麼,可以用測試資料2畫時間線圖(如下圖),就能理解為什麼這樣排。
- 這是我試過幾乎每一種Greedy的方式+
犧牲一張數學考卷成績以獲得思考得出的結論
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Code
- format是c++20的東西 拿來debug用的 不用理他
點我看Code
後記
APCS初體驗
這是我第一次考APCS,之前只有在ZJ上刷了幾題。資料結構跟演算法完全沒學,只看過資訊之芽的一點講義,我連BFS怎麼跑都沒有實作過。
選擇題部分,我覺得就是在考ability to read bad written code with bugs and without comment,寫起來很令人煩躁且無聊。好幾題都要腦中憑空模擬,或者去猜他背後的數學式子,感覺在寫數學考卷。
上機實作就是熟練度跟速度,我覺得第三題不難但很花時間(與ZJ上的考古題相比)。第四題當時我有想到Greedy,但我覺得總沒那麼簡單,因為考前看了資芽的Greedy,寫說"你覺得Greedy是最佳解很可能只是特例",我就沒寫,專心弄第三題(結果也沒寫完 :( )。
另外 幾個疑問
-
為什麼不能Alt + Tab
- 我都按Alt + Tab
- 隔幾秒發現不能用,只好用滑鼠切換視窗
- 非常影響心情
-
-
為什麼IDE那麼難用
- Eclipse我根本看不懂怎麼用
- Code::blocks的intellisense大概只有打i會出現int,其他時候都不能用
建議改名idiotsense
- Code::blocks沒辦法用GDB Debugger
- 沒有深色模式,我的眼睛:

- 也許是平常VScode/VS2022太好用了,沒intellisense+auto format就要手打/手動排版很多東西,變數名稱不能取太長。
-
鍵盤滑鼠
- 沒有習慣的機械鍵盤跟滑鼠,寫Code的效率低了許多。
考完試後一天
學長跟我抱怨他一直95%,為什麼第三題會少五分啦QQ (最後一筆Wrong answer: 153)
我們測了很多資料,都覺得沒問題
後來直接問出題者
看來出題者也累了ww (仍感謝有人花自己的時間搬運題目、生測資)
還我消失的五個小時
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
rejudge中 各位95%可以回去看看
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →