Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Q10504 - Hidden squares 星等 : ★★☆☆☆ 題組: Online-judge.uva.es PROBLEM SET Volume CV 題號: Q10504 - Hidden squares 解題者:薛祖淵、劉淑惠 解題日期: 2006 年 5 月 23 日 題意: 在.

Similar presentations


Presentation on theme: "1 Q10504 - Hidden squares 星等 : ★★☆☆☆ 題組: Online-judge.uva.es PROBLEM SET Volume CV 題號: Q10504 - Hidden squares 解題者:薛祖淵、劉淑惠 解題日期: 2006 年 5 月 23 日 題意: 在."— Presentation transcript:

1 1 Q10504 - Hidden squares 星等 : ★★☆☆☆ 題組: Online-judge.uva.es PROBLEM SET Volume CV 題號: Q10504 - Hidden squares 解題者:薛祖淵、劉淑惠 解題日期: 2006 年 5 月 23 日 題意: 在 N 階 (1<N<=1000) 方陣中找出有幾個 正方形

2 2 題意範例: ABBA BBBB ABBB ABBA the squares with vertices in A are: A--A ---- A--A the squares with vertices in B are: -BB- ---- ---------B----B-------B- -BB- -BB- ------BBB-B--B-B--B-B--- ---- -BB- -BB---BB-B----B--B-B---B ---- ---- -BB---------------B--B--

3 3 Sample Input Sample Output 4 ( 邊長 )A 1 2 ( 出現的點數 )B 8 ABBA BBBB ABBB ABBA A ( 第一種點 ) B ( 第二種點 ) 0 ( 結束 )

4 4 解法: 暴力法 針對每一點檢查可能行成的正方形 (1) 先考慮沒有旋轉的正方形 (2) 考慮旋轉的正方形 解法範例: 討論: 時間複雜度 : O(n 4 ) 空間複雜度 : O(n 2 )


Download ppt "1 Q10504 - Hidden squares 星等 : ★★☆☆☆ 題組: Online-judge.uva.es PROBLEM SET Volume CV 題號: Q10504 - Hidden squares 解題者:薛祖淵、劉淑惠 解題日期: 2006 年 5 月 23 日 題意: 在."

Similar presentations


Ads by Google