[問題] 座標壓縮

作者: WashFreeID (免洗)   2015-04-04 11:05:22
開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
g++
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
問題(Question):
書:培養與鍛鍊:程式設計的邏輯腦
上面的題目
問題描述
圖片版
https://dl.dropboxusercontent.com/u/14571319/pic1.jpg
https://dl.dropboxusercontent.com/u/14571319/pic2.jpg
https://dl.dropboxusercontent.com/u/14571319/pic3.jpg
文字版(與圖片上相同)
在w*h的格子上話n調垂直或水平且寬度為1的直線,請問格子被餡分成幾個區域呢?
輸入
w=10 h=10 n=5
x1 = {1,1,4,9,10}
x2 = {6,10,4,9,10}
y1 = {4,8,1,1,6}
y2 = {4,8,10,5,10}
看不太懂壓縮的地方
push完座標
sort(xs.begin(), xs.end());
xs.erase(unique(xs.begin(),xs.end())), xs.end());
這兩行我待資料進去 xs.size()也不會是壓縮後的寬度
不太清楚
餵入的資料(Input):
預期的正確結果(Expected Output):
錯誤結果(Wrong Output):
程式碼(Code):(請善用置底文網頁, 記得排版)
照片版
https://dl.dropboxusercontent.com/u/14571319/code1.jpg
https://dl.dropboxusercontent.com/u/14571319/code2.jpg
文字版
http://ideone.com/gqnMOe
補充說明(Supplement):
作者: Feis (永遠睡不著 @@)   2015-04-04 14:54:00
應該是為了省麻煩變成示意圖跟 code 不一樣

Links booklink

Contact Us: admin [ a t ] ucptt.com