程式隨筆

Never give up!


  • Home

  • Categories

  • Archives

  • Tags

POJ3279

Posted on 2017-05-19 | In Competitive Programming , POJ

Fliptile

Solution sketch

這題有個非常重要的想法:

$$對於第一列的所有翻法進行窮舉,之後第二列開始就直接依照前一列的狀態直接進行 flip 操作即可!$$

如果,一路 flip 到最後一列,然而最後一列卻不是全 0 就代表著第一列翻法不成立。反之,該第一列的翻法是 ok 的。

輸出的部分,因為我們是按照字典順序枚舉翻法了,所以其實只要看 flip 局面的 1 的總數來更新答案即可。

Read more »

POJ3276

Posted on 2017-05-19 | In Competitive Programming , POJ

Face The Right Way

Solution sketch

對於所有的 $K$ 進行 枚舉 和 模擬反轉操作 的話,會是 $O(n^3)$ 所以會 TLE。

其實,一個點反轉兩次等於沒反轉。因此一個點有無被反轉,只需要看他前 $k - 1$ 的區間內反轉次數是奇數還數偶數就好。

因此,我們只要維護區間反轉次數,就可以壓到 $O(n^2)$ 了!

Read more »

Codeforces Educational Round 21

Posted on 2017-05-19 | In Competitive Programming , Codeforces

Codeforces Educational Round 21

A 的觀察挺直觀的

B 應該算是經典的 區間和 題目

C 就一般先排序後操作的題目

D 是個有趣的數列題

Read more »

POJ3061

Posted on 2017-05-12 | In Competitive Programming , POJ

Subsequence

Abridged problem statement

給定一個數列,求取最小的連續數字區間,其總和 $\geq s$。

Solution sketch

利用二分搜的話,邊界要小心設定呀! WA 兩次 都只是因為邊界選錯而已…

爬行法的話,實作基本上大原則就是右跑左追。

Read more »

Codeforces Round 413 Division 2

Posted on 2017-05-12 | In Competitive Programming , Codeforces , Division 2

Playrix Codescapes Cup (Codeforces Round #413, rated, Div.1 + Div.2)

A 不錯的數學題,但是不需要推公式就可做了… :)
B 不錯的思考題,但是實作QAQ

Read more »

Ubuntu Installation Notes

Posted on 2017-05-09 | In Ubuntu

Random notes…

Read more »

UVA230

Posted on 2017-05-08 | In Competitive Programming , UVa

Borrowers

Abridged problem statement

給定書名與作者 與 借還書歷史。在看到 SHELVE 時印出需要被上架的書籍的一些資訊。

Solution sketch

就模擬吧! 很煩的那種…

Read more »

Codeforces Round 412 Division 2

Posted on 2017-05-08 | In Competitive Programming , Codeforces , Division 2

Codeforces Round 412 Division 2

tourist 出題呀! WOW!

A 是不錯思考題

Read more »

Codeforces Round 411 Division 2

Posted on 2017-05-07 | In Competitive Programming , Codeforces , Division 2

Codeforces Round 411 Division 2

A 是不錯數學的觀察題

B 是不錯的回文有趣小題

D 是不錯的規律觀察題

Read more »

UVA1112

Posted on 2017-05-04 | In Competitive Programming , UVa

Mice and Maze

Solution sketch

裸的 最短路徑 題。

注意邊要反著建立,畢竟你的終點變起點了……

Read more »
12…7
Henry Tseng

Henry Tseng

64 posts
18 categories
57 tags
© 2017 Henry Tseng
Powered by Hexo
Theme - NexT.Pisces