1 / 14

HKOI2006 Analysis and Solution Senior Q2 – Toggle

HKOI2006 Analysis and Solution Senior Q2 – Toggle. HKOI Training Team 2006-01-07. Statistics. Attempts: 46 (out of 76) Mean: 35.98 Max: 100 (1) Min: 0 Std Dev: 23.66. Statistics. The Problem.

garth
Download Presentation

HKOI2006 Analysis and Solution Senior Q2 – Toggle

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. HKOI2006 Analysis and Solution Senior Q2 – Toggle HKOI Training Team 2006-01-07

  2. Statistics • Attempts: 46 (out of 76) • Mean: 35.98 • Max: 100 (1) • Min: 0 • Std Dev: 23.66

  3. Statistics

  4. The Problem • Given an initial board configuration, maximize the number of white cells through toggling column and/or rows • 1 ≤ N ≤ 16 • Partial score will be given if number of white cells ≥ Optimal solution

  5. Observations (1) • A row / column will be toggled only once • There is no point to toggle twice or more • Why?

  6. Observations (2) • Order of toggle moves does not matter • We only need to determine which rows/columns to toggle

  7. Observations (3) • On a N x N board, if a row has K white sides, it will have (N-K) white cells after the row is toggled • Max(N,N-K) ≥ N/2

  8. Algorithms (1) • Try all combinations of toggling moves • There are 2(2N-1) combinations • Good if N is small (e.g. ≤ 8)

  9. Algorithms (2) • Do not toggle any columns • For each row, determine whether to toggle or not, which ever gives a better result • Guarantees ≥ 50% white cells (From Observation 3), • but cannot guarantee optimal solution

  10. Algorithm (3) • Pick the row/column with most number of black cells, and toggle • Repeat the above step until toggling gives no improvement • Greedy Approach • Also guarantees ≥ 50% white cells (Why?) • but cannot guarantee optimal solution as well…

  11. The “Official” Solution • Algorithm 2 toggles rows only, what happened to the columns? • The algorithm produce the best possible result for rows-only moves • Suppose we toggle a column, then re-run Algorithm 2, what will we get?

  12. The “Official” Solution • Try all possible combinations of toggling columns and run Algorithm 2 for each combination

  13. Common Mistakes • Outputting invalid commands • e.g. @

  14. Questions?

More Related