網頁

Thursday, 6 November 2014

PhD 1: 食物篇

超市一般不叫 supermarket, 叫 grocery store
U village 有 QFC 和 Safeway
QFC 有相對大的 cheese area, 是真正的 cheese 不是 pre-packaged 那種
啤酒的選擇也很多, 值得一提的是有 Pilsner Urquell
不得不吐槽的是, 如同眾多 stereotyping, 很多東西都重甜
雖然 sample size 很小, 不過我發現 US 產的紅酒似乎都偏甜
其實不加糖的 sparkling water ($3-4/12cans) 完全可以取代汽水

不得不提 UW 的食街 University ave
其中有一間 U:Don 不得不推, self service 式 (免 10% service charge)
基本上整間店就只售各種烏冬, 相對上正宗
兩圖分別約 $7 (after tax)

Friday, 12 September 2014

PhD 0: HKG → SEA, stopover in Seoul

Seoul is the near-optimal stopover from Hong Kong → Seattle


Zoom in:

Of course, actual flight path deviates considering flight route, winds etc.
Stopover in Seoul is great too, with airport (ICN) awarded in SKYTRAX, and free transit tour


Seoul 12 hours stopover

ICN Airport → (AREX) → Seoul station → 南大門市場 → 明洞 → 仁寺洞 → 東大門  →
國立民俗博物館 → 景福宮 → 市政廳 →  Seoul station → (AREX) → ICN Airport



明洞, 不過其實無咩行

Monday, 4 August 2014

雲南 Grad Trip

21/7/2014 - 3/8/2014
香港 → 廣州 → 昆明 → 大理 → 麗江 → 香格里拉 → 昆明 → 廣州 → 香港

Wednesday, 16 July 2014

IOI 2014 Game

主要是為了跪拜 solution 3 所以打一下..

Problem: imagine there is an undirected graph G. Implement an adversary oracle, that opponent queries hasEdge(x, y) and you returns true/false. Goal: opponent cannot figure out whether G is connected using less than C(|V|, 2) queries. |V| ≤ 2500

Solution 1: idea: return false unless G will be disconnected eventually (even if all unqueried edge presents). Naive implementation O(n4). One can view as starting from a complete graph, and support operations:
- addEdge(x, y)
- removeEdge(x, y)
- queryConnect(x, y)
which is the Dynnamic Connectivity Problem. From here, it can be done in O(polylog n) which may not fast enough and probably coding-infeasible for IOI.

Solution 2: idea: relax the constraints for returning true. Assume there are several components in the graph currently. For every two components we will have an edge connecting them directly, but only reveal it when opponent queried all pairs of vertices from that two components. Implementation: maintain a counter for every pair of components. Merging components takes O(n) to update the counters, but we only do merge operation n-1 times so in total O(n2).

Solution 3: for query hasEdge(x, y), wlog x < y, 0-based, increase cnt[y] by 1. Return yes if and only if cnt[y] reaches y.
Intuitive explanation: eventually every vertex (except 0) will has 1 edge to a smaller label vertex, forming a tree. Also for this tree to be formed, C(|V|, 2) queries is required.

References: live video feed.

Monday, 16 June 2014

比賽 × 4

Topcoder SRM 624

題目非常 standard, 估計是為了測試 TopCoder 終於肯 support 大於 50 的 vector input
加上不久前開始 support special judge TopCoder 支援的題目類型終於可以跟其它 OJ 相提並論

E 在 system test fail 了, 不過憑著 5 棍 hack 和 RP 仍然保住 T-shirt 一件

終極 fail

Task H: 構造 integers input 使得 C++, Java 的 hash table (對應為 unordered_set 和 hashset) insert n 個 integer 的時間為 O(n2)

Contest 時沒有做, 不過若不是這題也未必會知道 C++/Java hash table 的 implementation
兩個 language 的 hash table 也是用 chaining, insert 時會 search 一次整個 bucket, 所以只要不斷 hash key collision 就可以退化為 O(n2)
然後跟據題解的不斷 dig into source code, 就可以發現:

- C++ 的 hash table size 必為 prime, 並 default 在 load factor = 1 時 double hash table size; 而 hash function 則為 modulo 現在的 hash table size
- Java 的 hash table size 為 2's power, load factor = 3/4 時兩倍化, hash function 則是用 shift bit

知道實際的數字就可以輕鬆殺掉 unordered_set 和 hashset! 所以以後 CodeForces 繼 anti Java Quicksort 後可能會出現 anti hashtable..


Task M: 求 s-t maxflow, 額外限制: 每條 s-t flow 長度不長於 L. Small: L ≤ 3, Large: L ≤ 6

Small 的話可以很容易 model 做 maxflow, 很 standard
Large 解題報告用了一個例子去說明很可能沒有 "一般" maxflow 的做法, 因為當 L > 3 存在 integral capacity graph 但答案不是 integer
但其實不難發現可以 model 為一個 O(L|E|) 個 variables 的 LP, 相當於 60000 個 variables.. 於是放棄之

Contest 過後看題解, 原來這個就是 intended solution! 不得不說 simplex 真是奇妙的東西

題解 booklet