tag:blogger.com,1999:blog-7126341455752435052022-03-28T02:13:25.739-04:00Doesn't ExistThis blog does not exist. || Blog of shewu.mecherry suhttp://www.blogger.com/profile/16615103822232949422noreply@blogger.comBlogger308125tag:blogger.com,1999:blog-712634145575243505.post-6885203296820706722022-01-16T14:59:00.001-05:002022-01-16T14:59:31.167-05:00Making Friends with Powers of 2<p>In the manga/anime series "Chihayafuru," the protagonist mentions that she "makes friends" with the universe of playing cards in her sport, Karuta, to help build a connection in hopes of achieving better results.</p><p>Note that all 2^n will be "the smallest positive even nth power," so I will omit from their descriptions. In combinatorics, 2^n is the size of the powerset for a size-N set.<br /></p><p>1: self explanatory</p><p>2: self explanatory; the one and only even prime number; base 2/binary<br /></p><p>4: self explanatory; all squares modulo 4 give residues 0 or 1 (prove it!); typical word size of a 32-bit Intel/AMD computer<br /></p><p>8: number of ounces in a cup (go USA); typical word size of a 64-bit Intel/AMD computer; base 8/octal<br /></p><p>16: 0xF + 1; base 16/hexadecimal; bits in a 2-byte integer<br /></p><p>32: bits in a 4-byte integer; number of ounces in 1/4-gallon (smaller carton of milk)<br /></p><p>64: bits in an 8-byte integer; number of ounces in half-gallon (larger carton of milk)<br /></p><p>128: number of ounces in a gallon (jug of milk); amount of memory (in MB) in the first iPhone<br /></p><p>256: 0xFF + 1; how much memory in MB my first Mac had<br /></p><p>512: how much memory in MB my first computer had<br /></p><p>1024: approximately interchangeable with 1000 = 10^3 for fast log2 and log10 computation; MB in a GB (or KB in a MB, or B in a KB, etc)<br /></p><p>2048: seen in computer hardware flyers<br /></p><p>4096: max memory (in MB) supported by 32-bit computers; seen in computer hardware flyers; pixel width of a true 4k screen<br /></p><p>8192: seen in computer hardware flyers<br /></p><p>16384: seen in computer hardware flyers</p><p>32768: one more than the largest positive value representable by a signed 16-bit integer<br /></p><p>65536: bits in a 16-byte integer</p><p>131072: smallest power of 2 larger than 10^5 (common constant in programming problems)<br /></p><p>262144: number of colours representable by a 18-bit panel when PC laptop makers were too cheap to use 24-bit panels in the 2000s; smallest power of 2 larger than 2*10^5 (common constant in programming problems)<br /></p><p>[...]<br /></p><p>1048576: smallest power of 2 greater than 10^6</p><p>[...] <br /></p><p>16777216: number of colours representable by a 24-bit panel (before 10-bit "high colour" panels became popular)<br /></p><p>[...]</p><p>1073741824: number of colours representable by a 30-bit panel (e.g. a "high colour" or "photography/video" panel); smallest power of 2 greater than 10^9</p><p>2147483648: one more than the largest positive value representable by a signed 32-bit integer<br /></p><p>4294967296: number of different values representable by 32 bits</p><p>[...]</p><p>Something that starts with 9223 and has a lot of digits: 2^63 or 2^63-1, the latter is the largest positive value representable by a signed 64-bit integer</p><p>For these large values, e.g. 2^30 and up, I only know the first handful of digits, which is usually sufficient.<br /></p><p>---</p><p>Writing these out, there are a few things that stand out to me:</p><ul style="text-align: left;"><li>much of these numbers are from computer-related activities, e.g. programming problems or browsing computer hardware brochures</li><li>the powers of 2 less than 100, especially those less than 10 (1, 2, 4), come up regularly for me in my day-to-day life</li></ul><p>If you find special meaning to a power of two, leave a comment below! I may also write about other numbers, so stay tuned. </p>cherry suhttp://www.blogger.com/profile/16615103822232949422noreply@blogger.com0tag:blogger.com,1999:blog-712634145575243505.post-81613263191719412172021-05-28T09:19:00.006-04:002021-05-28T09:19:51.079-04:00Thought process on Codeforces 1353E<p><a href="https://codeforces.com/contest/1353/problem/E">Link to problem</a></p><p>I remember seeing this problem almost a year ago during practice and getting stuck. Well, I finally solved it almost a year later!</p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://lh3.googleusercontent.com/-M233LHnj-LM/YLDmfGWGfiI/AAAAAAAAHUU/307ZUajPc9gzisCmwOwrCuJAPnXEHsJrgCLcBGAsYHQ/image.png" style="margin-left: 1em; margin-right: 1em;"><img alt="" data-original-height="412" data-original-width="902" height="146" src="https://lh3.googleusercontent.com/-M233LHnj-LM/YLDmfGWGfiI/AAAAAAAAHUU/307ZUajPc9gzisCmwOwrCuJAPnXEHsJrgCLcBGAsYHQ/image.png" width="320" /></a></div><br />Since the problem asks about equal spacing (of length K) between 1s in a binary string, I immediately thought of numbers of 0s and 1s for each residue mod K. We have enough time to try each residue if the work for each residue is linearly proportional to the number of bits in each residue, i.e. K residues * (N / K) bits in each residue = O(N) total work. We know that while we are trying each residue, the bits at positions not congruent to K mod N have to be off, which is an easy precomputation done in O(N).<div><div><br /></div><div>Our solution looks like this so far:<div><p></p><pre>i64 solve(const i64 N, const i64 K, string_view S) {<br /> i64 total_on = 0;<br /> vec<i64> resid_on(K, 0);<br /> for (i64 i = 0; i < N; ++i) {<br /> total_on += S[i] == '1';<br /> resid_on[i % K] += S[i] == '1';<br /> }<br /><br /> i64 best = N;<br /> for (i64 resid = 0; resid < K; ++resid) {<br /> let i64 turn_non_resid_off = total_on - resid_on[resid];<br /><br /> // gather the bits at resid (mod K) for convenience<br /> vec<bool> seq;<br /> for (i64 i = resid; i < N; i += K) {<br /> seq.push_back(S[i] == '1');<br /> }<br /> // TODO implement solve_resid<br /> let i64 subproblem_ans = solve_resid(seq);<br /> best = min(best, turn_non_resid_off + subproblem_ans);<br /> }<br /> return best;<br />}<br /></pre><p>Let's focus on bits at positions whose residues are resid (mod K). We know that they have to form the pattern 0*1*0*, i.e. 1111, 00111, 1000, 0000, 010, etc. So we have reduced the main problem to this problem. How do we solve it?</p><p>At first, my smooth brain thought this could be done with greedy. My approach was ignore leading 0s, ignore the 1s after the leading 0s. At the same time, ignore trailing 0s, and ignore the 1s before trailing 0s. Now we want to turn all the bits on in the middle subsegment. However, this fails on a case like:</p><p>10 2</p><p>0001000100</p><p>Because we can simply turn off one of the 1s rather turn on the 3 zeros in the middle.</p><p>At this point, my mind turned to dynamic programming. I started building my recurrences as follows:</p><p></p><ol style="text-align: left;"><li>Define f(pos) = minimum moves to make the suffix [pos, N) valid.</li><li>Define g(pos, state: {0, 1}) = minimum moves to make suffix [pos, N) valid such that bit at pos is state. This implies:</li><ol><li>g(pos, 1) = (pos != 1) + (moves to make the suffix [pos + 1, N) have the pattern 1*0*)</li><li>g(pos, 0) = (pos != 0) + f(pos + 1)</li></ol></ol><div>and we want to solve for f(0), which is min(g(pos, *)). The wildcard used here and below represents all possible values for that argument, i.e. {0, 1} here.</div><div><br /></div><div>This looks promising, but what is (moves to make the suffix [pos + 1, N) have the pattern 1*0*)?? It looked suspiciously "nice", i.e. something that I might be able to turn into a recurrence. OK, let's try that:</div><div><ol style="text-align: left;"><li>Define h(pos, state) = minimum moves to make the suffix [pos, N) have the pattern 1*0*. This implies:</li><ol><li>h(pos, 1) = (pos != 1) + min(h(pos + 1, *))</li><li>h(pos, 0) = \sum_{i = pos}^N (i != 0)</li></ol></ol><div>Well that was nice indeed. Putting it together by plugging h into g, we have:</div></div><div><ol style="text-align: left;"><li>g(pos, 1) = (pos != 1) + min(h(pos + 1, *))</li><li>g(pos, 0) = (pos != 0) + f(pos + 1), as before</li></ol><div>Implementation is straightforward:</div></div><p></p><p></p></div></div></div><pre>i64 solve_resid(const vec<bool>& seq) {<br /> vec<vec<i64>> h(seq.size() + 1, vec<i64>(2));<br /> for (i64 i = seq.size() - 1; i >= 0; --i) {<br /> h[i][0] = seq[i] + h[i + 1][0];<br /> h[i][1] = !seq[i] + min(h[i + 1][0], h[i + 1][1]);<br /> }<br /> vec<vec<i64>> g(seq.size() + 1, vec<i64>(2));<br /> for (i64 i = seq.size() - 1; i >= 0; --i) {<br /> g[i][0] = seq[i] + min(g[i + 1][0], g[i + 1][1]);<br /> g[i][1] = !seq[i] + min(h[i + 1][0], h[i + 1][1]);<br /> }<br /> return min(g.front()[0], g.front()[1]);<br />}<br /></pre><p>Voila, Accepted!</p>cherry suhttp://www.blogger.com/profile/16615103822232949422noreply@blogger.com0tag:blogger.com,1999:blog-712634145575243505.post-72417819174097084092021-01-19T09:21:00.006-05:002021-01-19T09:25:55.336-05:00FLPoTD: Writing Checks<p>This problem was inspired by a puzzle on the 2021 Mystery Hunt:</p><p>Given a string S of characters from the latin alphabet (a-z), find the smallest nonnegative amount (dollars and cents) whose spelled-out representation contains S as a subsequence.</p><p></p><ul style="text-align: left;"><li>The dollar amount should not include 'and': 123 is "one hundred twenty three", not "one hundred and twenty three".</li><li>If the amount is less than $1.00 (one dollar and zero cents), then the dollar amount is omitted: $0.46 is "forty six cents"</li><li>The cents is always expressed: $46.00 is "forty six dollars and zero cents"</li><li>This table contains the names of powers of 10: <a href="https://en.wikipedia.org/wiki/Power_of_10#Positive_powers">https://en.wikipedia.org/wiki/Power_of_10#Positive_powers</a></li></ul><div>Follow-up:</div><div><ul style="text-align: left;"><li>Given a list of strings, all of which use exclusively lowercase letters, find the most expensive word.</li></ul></div><p></p>cherry suhttp://www.blogger.com/profile/16615103822232949422noreply@blogger.com0tag:blogger.com,1999:blog-712634145575243505.post-53690491309270055142020-09-30T23:14:00.002-04:002020-10-01T17:59:15.450-04:00Min-Max Driving Sim<p>I have always wanted a driving sim, especially after reading about fellow driver/instructor Ian Korf's positive <a href="https://yousuckatracing.wordpress.com/how-to/">experiences</a>, but don't have much space and didn't want to spend a crazy amount of money.</p><p>To give you a sense of the driving sim landscape: on the low end, you have wheels without any force feedback (around the $99 mark) to 6-axis full motion sims for >$60k, which are not dissimilar what professional drivers use for training. <br /></p><p>Here's what I got:<br /></p><table border="1"> <tbody><tr> <th colspan="2">Component</th><th>Price (includes shipping & tax)<br /></th><th>Vendor</th><th>When Purchased</th> </tr> <tr> <td>Wheel</td><td>SimXperience Accuforce</td><td>$1055.64</td><td><a href="http://simxperience.com">simxperience.com</a></td><td>Jul 2020</td> </tr> <tr> <td>Computer</td><td>Dell Inspiron 3670</td><td>$402.37</td><td>Dell Outlet</td><td>Dec 2018</td> </tr> <tr> <td>GPU</td><td>Zotac GTX 1080 mini</td><td>$369.00</td><td>eBay</td><td>Feb 2019</td> </tr> <tr> <td>Pedals</td><td>Fanatec Clubsport v3</td><td>$356.60</td><td>eBay</td><td>Jun 2019</td> </tr> <tr> <td>Seat</td><td>Playseat Challenge</td><td>$242.93</td><td>Amazon</td><td>Jul 2020</td> </tr> <tr> <td>VR Headset</td><td>Lenovo Explorer</td><td>$99.00</td><td>B&H Photo Video</td><td>Nov 2018</td> </tr> <tr> <td>Power Supply</td><td>EVGA 500 W1</td><td>$43.29</td><td>Amazon</td><td>Jan 2019</td> </tr> <tr> <td colspan="2">Total</td><td>$2568.83</td><td><br /></td><td></td> </tr></tbody></table><p>I optimized for great driver inputs, e.g. the wheels and pedals. I figured that direct drive is the way to go, and read good things about the Accuforce. Popular alternatives included the OSW (OpenSimWheel) and the Fanatec Podium 1 & 2. I decided against hydraulic pedals (>$1+k, unless you mod your Logitech G920 <a href="http://perfectpedal.com/">brake pedal</a>). Looking at options half an order of magnitude lower, the Fanatec Clubsport was the popular choice.</p><p>I wanted the sim rig to take up the smallest amount of space and be easy to move, while having a solid mount between the seat and pedals so that the pedals won't slide away from me during braking. The Playseat Challenge was the obvious choice. It even has mounting holes, which are compatible with the Accuforce! </p><p>I didn't want to spend very much money or effort on the PC, so I went with a refurbished Dell with passable specs. This unit has a 6-core i5-8500, 8GiB RAM, 1TB spinner, and integrated graphics. Obviously I needed a better GPU to drive the VR headset, so I went with a GTX 1080 (not Ti). It turns out that the current generation of consumer desktops are barely wider than a mATX board, so I need a shorter version of a full-size GPU. Finally, I needed a beefier PSU that the Dell's 300W unit.<br /></p><p>If I insisted on building the PC myself, then the components (at the time of purchase, late 2018), would have not been much cheaper. The CPU retailed for $192, motherboard $80, memory $35, disk $40, for a total of $347, which is ~$20 less than the Dell cost before sales tax. (Obviously I would sit the parts on a piece of cardboard instead of getting a case, as well as ditching the optical drive and WiFi, if not integrated into the motherboard)</p><p>Finally, for an immersive experience, I went with the (now discontinued) Lenovo Explorer VR headset. I wanted something with at least a 1440x1440 eyepiece resolution since I had a bad experience with the first Oculus Rift, which had an eyepiece resolution of 1080x1280 -- I got extremely nauseous trying to focus on a blurry-to-my-20/13-vision image.</p><p>So there you have it! A solid setup, which fits conveniently into any corner:</p><div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-LirDITPef8c/X3VH0-SN7JI/AAAAAAAAGW8/IERTXvCKL-AOTNVAKAxOs7mXfn6RW4JZwCLcBGAsYHQ/s2048/2020-09-30%2B19.00.48.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="2048" data-original-width="1536" height="320" src="https://1.bp.blogspot.com/-LirDITPef8c/X3VH0-SN7JI/AAAAAAAAGW8/IERTXvCKL-AOTNVAKAxOs7mXfn6RW4JZwCLcBGAsYHQ/s320/2020-09-30%2B19.00.48.jpg" /></a></div><p>For its inaugural drive, I spent an hour playing Assetto Corsa driving at the WeatherTech Raceway Laguna Seca in various cars (30min in a NA Miata, then a bit in a McLaren 570S, and the rest in a Porsche GT4 Clubsport). Works pretty well!</p><p>Its next upgrade will likely be a yoga mat since the Accuforce's vibrations are felt throughout the Playseat chassis.<br /></p>cherry suhttp://www.blogger.com/profile/16615103822232949422noreply@blogger.com0tag:blogger.com,1999:blog-712634145575243505.post-83718858436704501262020-09-06T15:46:00.005-04:002020-09-06T18:17:23.760-04:00Codeforces Round #668 (Div. 2) Postmortem<p>Trying a different format with problem-by-problem breakdowns, which hopefully will be more useful when I review my postmortems. I will also backfill the postmortems.</p><p>A: I first implemented the metric computation (sort sums of adjacent elements) without having any idea of how to create a different permutation to achieve the same metric. Then I realized that reversing the input preserves the adjacent sums. I won't complain about a 0:02 submission.</p><p>B: If the first nonzero element were negative, then we have to incur cost equal to its magnitude. I thought this was it, but some sample inputs didn't pass. Then I noticed that if the first nonzero element were positive, we can add the magnitude to negative terms later in the array, which existed because of the constraint that all elements sum to 0 and that the sum stays 0 after every operation. I quickly patched my solution to keep a reserve from the magnitude of positive elements and using the reserve to decrease the cost of negative elements before incurring their costs. Again, not complaining about a 0:08 submission.</p><p>C: This is where I started to struggle. Having the same number of 0s as 1s in every K subarray is the same as the subarray sum equal to K/2. I got hung up on the "system of equations" representation, where every question mark was a variable (question mark at i would be a_i), which seemed extremely hard to solve. Then I thought that I can just look at the number of equations and the number of variables, which seemed sketchy, but I YOLO-ed and incurred a WA.</p><p>At about the 0:55 mark, I realized that the system of equations implied that a_i = a_j for i = j mod K. Facepalm. I quickly coded this solution for a 1:02 submission. RIP</p><p>D: Clearly, if B is at most DA away from A, then A can reach B in the first move and win. From the problem statement, I inferred that their 10^100 limit meant that either A will reach B in finite time, or B can always move to stay DA away from A. I quickly realized that the best chance of B dodging A is on the diameter of the tree, since in no other scenario will B have the space to run away from A. This implied that if A can go from the center(s) to the ends of the diameter in DA, then A can catch B.</p><p>I made the assumption that if DA > DB (it seemed intuitive), then A will be able to reach B eventually because B will run out of space. Thinking that these three criteria were sufficient, I submitted at 1:31 for my first WA on D. Given feedback that my solution failed pretest 2, I came up with the following counterexample to my solution:</p><center><table style="border: 1px solid black;"> <tbody><tr><td><pre>1---2---3---4---5---6<br /> ^ ^<br /> A B<br />DA = 2, DB = 3</pre> </td></tr></tbody></table></center><p>My solution would incorrectly say that A never reaches B, while after two moves, A will first move from 3 to 5 and B will move from 6 to 3, letting A move from 5 to 3 on the third move. This really tripped me up, leading me to think about the relative difference between DA and DB. I tried that if the relative difference is larger than the half the diameter of the tree, then A cannot catch B, for another WA at 1:44. Finally, as a last ditch attempt, I thought that if DB is twice or more than DA and if the diameter is greater than twice DA, then A cannot catch B, for my third and final WA at 1:59.<br /></p>cherry suhttp://www.blogger.com/profile/16615103822232949422noreply@blogger.com0tag:blogger.com,1999:blog-712634145575243505.post-83880571710612036102020-06-25T17:36:00.001-04:002020-06-25T17:37:47.124-04:00Educational Codeforces Round 90 Postmortem<div>What went well</div><div><ul style="text-align: left;"><li>B, C, D took me 5 minutes, 9 minutes, and 24 minutes respectively.</li></ul><div>What went poorly</div><div><ul style="text-align: left;"><li>A took 21 minutes (drew a huge blank; no, I did not wake up late), which was a massive penalty, since it increases the penalties for B, C, and D.</li><li>Couldn't get E in an hour.<br /></li></ul><div>Where I got lucky</div><div><ul style="text-align: left;"><li>D was on the easier side.<br /></li></ul></div></div></div>cherry suhttp://www.blogger.com/profile/16615103822232949422noreply@blogger.com0tag:blogger.com,1999:blog-712634145575243505.post-9033455812727791422020-06-23T16:34:00.002-04:002020-06-23T16:35:36.309-04:00Codeforces Round #652 (Div. 2) Postmortem<div>What went well</div><div><ul style="text-align: left;"><li>0:00 submission for A!</li><li>Got ABCD (albeit slowly).</li></ul><div>What went poorly</div><div><ul style="text-align: left;"><li>Incurred one wrong answer for B and C each (and took a long time too).</li><li>Took half an hour to recognize the recursion for the tree structure in D.</li><li>Thought that the residues of numbers compare the same way as the the numbers themselves (i.e. a > b implies (a % m) > (b % m)…no, just no).</li></ul><div>Where I got lucky</div><div><ul style="text-align: left;"><li>Got D with 9 minutes to go, which involved a slight wild guess.<br /></li></ul></div></div></div>cherry suhttp://www.blogger.com/profile/16615103822232949422noreply@blogger.com0tag:blogger.com,1999:blog-712634145575243505.post-44510480144448523932020-06-21T16:36:00.005-04:002020-06-23T16:41:44.589-04:00Codeforces Round #651 (Div. 2) Postmortem<div>What went well</div><div><ul style="text-align: left;"><li>Decently fast ABC (0:01, 0:10, 0:23).<br /></li></ul><div>What went wrong</div><div><ul style="text-align: left;"><li>Walled by D. I didn't recognize that binary search works because I didn't know how to verify that a subsequence with max less than or equal to a target value was doable in O(N).</li><li>I thought incorrectly (yet again) that O(N lg N) is too slow for N <= 10**6, so I tried something silly to find the minimum # subsequences of the form (01)+ or (10)+, when a straightforward O(N lg N) would have worked.<br /></li></ul><div>Where I got lucky</div><div><ul style="text-align: left;"><li>Gained rating!<br /></li></ul></div></div></div>cherry suhttp://www.blogger.com/profile/16615103822232949422noreply@blogger.com0tag:blogger.com,1999:blog-712634145575243505.post-18755897353948655932020-06-13T23:22:00.008-04:002020-06-23T16:35:54.070-04:00Bugforces (ft. senile logarithmic exponentiation)<div>Sad things happen when you lose your mind:</div><pre style="border: 1px solid black;">using i64 = long long;<br /><br />// Precondition: (base, exponent) won't cause overflow<br />i64<br />my_pow(const i64 base, const i64 exponent)<br />{<br /> i64 accumulator = 0;<br /> for (i64 exponent2 = exponent, current_power = base; exponent2 > 0;<br /> exponent2 >>= 1, current_pow *= current_pow)<br /> {<br /> if (exponent2 & 1)<br /> {<br /> accumulator += current_power;<br /> }<br /> }<br /> return accumulator;<br />}<br /></pre>cherry suhttp://www.blogger.com/profile/16615103822232949422noreply@blogger.com0tag:blogger.com,1999:blog-712634145575243505.post-27445409186685396152020-06-04T13:48:00.000-04:002020-06-06T13:48:42.894-04:00Codeforces Round #647 (Div. 2) Postmortem<div>What went well</div><div><ul style="text-align: left;"><li>Got B in 5 minutes -- straightforward problem.<br /></li><li>Got C in 5 minutes -- another straightforward problem.</li><li>Got D in 20 minutes, once I figured out how to read. :-P</li><li>New personal best!!!<br /></li></ul><div>What went poorly</div><div><ul style="text-align: left;"><li>Wrote an extremely clumsy solution for A because I decided after a brief tradeoff analysis to match the problem statement as close as possible instead of thinking about a better implementation<br /></li><li>IlliterateForces strikes again -- misread D, so submitted a solution that solves a similar problem, which cost ~20min and a submission penalty.</li><li>Couldn't get E.<br /></li></ul><div>Where I got lucky</div><div><ul style="text-align: left;"><li>Got extremely lucky with B and C. I have been struggling with Bs recently; this B's 5 minute solve time thankfully bucks the trend. My previous fastest C solve time was ~15 minutes.<br /></li></ul></div></div></div>cherry suhttp://www.blogger.com/profile/16615103822232949422noreply@blogger.com0tag:blogger.com,1999:blog-712634145575243505.post-79236242076210542952020-04-26T13:16:00.001-04:002020-04-26T13:32:56.735-04:00Bugforces (ft Education Codeforces Round 86)Consider the following implementation to find the smallest multiple of x at least as big as y:<br /><br /><pre style="border: 1px solid black;">typedef long long i64;<br /><br />i64<br />next_mult_ge(const i64 y, const i64 x)<br />{<br /> return ceil(y / (double) x) * x;<br />}<br /></pre><br />What can go wrong?cherry suhttp://www.blogger.com/profile/16615103822232949422noreply@blogger.com0tag:blogger.com,1999:blog-712634145575243505.post-28664830404182208462020-04-26T13:11:00.000-04:002020-04-26T13:30:45.514-04:00Educational Codeforces Round 86 PostmortemWhat went well<br /><ul><li>Sampling other submissions, my solution to C is cleaner and more intuitive (if only it worked!!!)</li></ul>What went poorly<br /><ul><li>A took a long time</li><li>My C implementation died to nuances of ceil(); I wanted to find the multiple of a number at least as large as some threshold.</li></ul>Where I got lucky<br /><ul><li>I was able to use fast-slow testing to determine a test case that breaks my C. </li></ul>cherry suhttp://www.blogger.com/profile/16615103822232949422noreply@blogger.com0tag:blogger.com,1999:blog-712634145575243505.post-73784067539935357522020-04-25T13:40:00.002-04:002020-04-25T13:40:24.264-04:00TopCoder SRM 784 PostmortemWhat went well<br /><ul><li>I was able to solve Div2C/Div1A.</li><li>I was able to fix a bug in my implementation for C.</li></ul>What went poorly<br /><ul><li>Got A wrong because I couldn't understand the problem.</li><li>I realized the bug in my C after submitting my code, so the resubmission incurred a significant (200pt) penalty).</li></ul>Where I got lucky<br /><ul><li> Div2C/Div1A seemed a lot easier than usual.</li></ul>cherry suhttp://www.blogger.com/profile/16615103822232949422noreply@blogger.com0tag:blogger.com,1999:blog-712634145575243505.post-40317569241908553982020-04-14T21:34:00.000-04:002020-04-16T13:24:23.587-04:00Codeforces Round #635 (Div. 2) PostmortemWhat went well<br /><ul><li>A was trivial.</li><li>B was easy.</li><li>I didn't feel stuck when attempting D. </li></ul>What went poorly<br /><ul><li>C took a long time because I didn't realize that I had to consider two criteria for the greedy solution (first Wrong Answer). Then I didn't realize that the two criteria were not mutually exclusive (second Wrong Answer). All said and done, I spent 1h30.</li></ul>Where I got lucky<br /><ul><li>Somehow still above 1700!</li></ul>cherry suhttp://www.blogger.com/profile/16615103822232949422noreply@blogger.com0tag:blogger.com,1999:blog-712634145575243505.post-46641645897312810922020-04-06T23:00:00.002-04:002020-04-06T23:00:12.686-04:00CA-1 Drive: Short Version<div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-9A_86umRx3I/XovMADg-fNI/AAAAAAAAF_c/pPN2MDvrfqALORN_8ZpWKr5trCnkFVoBQCLcBGAsYHQ/s1600/pch_short.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1562" data-original-width="1339" height="640" src="https://1.bp.blogspot.com/-9A_86umRx3I/XovMADg-fNI/AAAAAAAAF_c/pPN2MDvrfqALORN_8ZpWKr5trCnkFVoBQCLcBGAsYHQ/s640/pch_short.png" width="547" /></a></div>Start: CA-1 exit off US-101<br />First choice: CA-1 (orange) or Panoramic Drive (red)<br />Second choice: Petaluma (blue) or Santa Rosa (green)<br /><ul><li>There's a great restaurant in Santa Rosa called "Naked Pig." They serve the lightest waffles with optional bacon bits embedded.</li></ul>Return: US-101 South cherry suhttp://www.blogger.com/profile/16615103822232949422noreply@blogger.com0tag:blogger.com,1999:blog-712634145575243505.post-13075862271682757142020-03-03T23:12:00.002-05:002020-03-03T23:12:35.296-05:00Codeforces Ozon Tech Challenge (Div. 1 + Div. 2) PostmortemWhat went well<br /><ul><li>C was a silly number theory problem, which I got in ~10 minutes. This might be my fastest C solve yet.</li></ul>What went wrong<br /><ul><li>I was unable to debug my solution to D in ~2 hours. I initially started pursuing an idea which involved querying vertices from pairs of vertices, but then I wasn't sure which two of the (up to) four vertices I should query. Then I noticed that I can just "trim the tree" by querying two leaves at once and pruning the tree if the LCA were neither leaves queried. However, I overcomplicated my solution by removing the vertices in the path from the leaf to the LCA, so I'm sure the bug is somewhere in there.</li><li>I wasn't sure how to prove B, which took me 20 minutes to solve.</li></ul>Where I got lucky<br /><ul><li>I gained elo so my rating is back above 1700. Yay! </li></ul>cherry suhttp://www.blogger.com/profile/16615103822232949422noreply@blogger.com0tag:blogger.com,1999:blog-712634145575243505.post-35314649095079506752020-01-30T23:00:00.001-05:002020-01-30T23:00:04.761-05:00Educational Codeforces Round 81 PostmortemWhat went well<br /><ul><li>If I had actually solved 4 problems, I would have gained over 100 elo…</li><li>I solved D, which was a number theory problem. (Nick missed this problem; muahahaha)</li></ul>What went wrong<br /><ul><li>My impure thoughts on problem B died on system test #11. Since I passed all 10 pretests, I didn't think to revisit my solution and verify with fast-slow testing.</li><li>I took a long time to recognize the totient function. My first reaction was "some inclusion-exclusion counting" upon realizing a pattern from my scratch work. Then I needed two tries to code a fast (sqrt N) totient function.</li></ul> Where I got lucky<br /><ul><li>Everyone else died on B. Turns out it is rated 1800. </li></ul>cherry suhttp://www.blogger.com/profile/16615103822232949422noreply@blogger.com0tag:blogger.com,1999:blog-712634145575243505.post-90090953262696086912020-01-19T22:54:00.000-05:002020-01-30T22:54:24.810-05:00Codeforces Round #614 (Div. 2) PostmortemWhat went well<br /><ul><li>A was a fast 3-minute problem.</li><li>B was easy and I solved it decently quickly in 9 minutes.</li></ul>What went wrong<br /><ul><li>C took way too long to code, mainly because I didn't have a good representation on blocking either diagonal path. Turns out that if cell (r, c) is blocked, then I just needed to check (1-r, c-1), (1-r, c), and (1-r, c+1). Furthermore, if I used a 2x(N+2) grid instead of 2xN grid, then I wouldn't have to do any bounds checking because the (*, -1) and (*, N) cells could never be set.</li></ul>Where I got lucky<br /><ul><li> I didn't do so terribly so as to get demoted to green.</li></ul>cherry suhttp://www.blogger.com/profile/16615103822232949422noreply@blogger.com0tag:blogger.com,1999:blog-712634145575243505.post-48528158783804036392020-01-16T22:48:00.000-05:002020-01-30T22:49:33.488-05:00TopCoder SRM 775 (Div. 2) PostmortemWhat went well<br /><ul><li>My TopCoder career is off to a good start! I solved A and B for +199 rating, which puts me midway through blue (1300-1499).</li></ul>What went wrong<br /><ul><li>I apparently failed to understand A, so wasted 5 minutes implementing something else. </li><li>I was rusty on floodfill and took 40 minutes to solve B, where 30 minutes was debugging.</li></ul>Where I got lucky<br /><ul><li>I'm decently quick on easy problems, which luckily A and B were.</li></ul>cherry suhttp://www.blogger.com/profile/16615103822232949422noreply@blogger.com0tag:blogger.com,1999:blog-712634145575243505.post-64256169979968975012020-01-14T22:43:00.000-05:002020-01-30T22:44:08.371-05:00Educational Codeforces Round 80 PostmortemWhat went well<br /><ul><li>The contest was so hard that I really wanted to quit after reading A, but persevered to the end. Somehow I solved three problems…</li></ul>What went poorly<br /><ul><li>I'm terrible with floors and ceilings. I'm also apparently bad at quickly recognizing monotonic functions.</li><li>I'm also bad at bijecting problems; I did not recognize during the contest that C was asking for a monotonically increasing sequence of length 2n, rather than two sequences of length n with weird constraints on elements.</li></ul>Where I got lucky<br /><ul><li>Solving three problems with a high penalty only cost 8 elo.</li></ul>cherry suhttp://www.blogger.com/profile/16615103822232949422noreply@blogger.com0tag:blogger.com,1999:blog-712634145575243505.post-4457330741829289562020-01-10T23:42:00.003-05:002020-01-10T23:43:34.723-05:00Codeforces Round #613 (Div. 2) PostmortemLink to contest <a href="https://codeforces.com/contest/1285">here</a><br /><br />What went well<br /><ul><li>I found a most elegant solution to B: much more elegant than the editorial.</li><li>I figured out D, a bits (bitmasks?) problem! I think I'm really weak at bits and xors.</li></ul>What went wrong<br /><ul><li>B took ~50 minutes and two wrong submissions.</li></ul>Where I got lucky<br /><ul><li>I had to think a little for A to prove correctness, but end-to-end latency still only took 3 minutes.</li><li>I submitted C without proving correctness and got it right??! Lucky me!</li></ul>cherry suhttp://www.blogger.com/profile/16615103822232949422noreply@blogger.com0tag:blogger.com,1999:blog-712634145575243505.post-17767824364525368682020-01-06T21:20:00.001-05:002020-01-06T21:32:20.701-05:00McLaren 600LT Spider First Impressions<i>Author's note: This test drive was done in April 2019, but I have been procrastinating with publishing this post. In any case, enjoy!</i><br /><br />I had the opportunity to drive a 2020 McLaren 600LT Spider at McLaren of San Francisco! I never got a chance to test drive a 600LT couple since their debut last year, nor have I gotten a chance to test drive a 570S Spider that I so dear wanted once upon a time. Unfortunately, the test drive happened during mid-day on a weekday, which wasn't the best time to tour back roads.<br /><br /><div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-RUgMo-qXDCI/XhPqHMSnu1I/AAAAAAAAF2U/Cy9dj9BD6mg4SyHrYpDcIPgseosqsTMKgCEwYBhgL/s1600/2019-04-26%2B12.32.32.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1200" data-original-width="1600" height="240" src="https://1.bp.blogspot.com/-RUgMo-qXDCI/XhPqHMSnu1I/AAAAAAAAF2U/Cy9dj9BD6mg4SyHrYpDcIPgseosqsTMKgCEwYBhgL/s320/2019-04-26%2B12.32.32.jpg" width="320" /></a></div><br />600LT specific comments:<br /><ul><li>No creep! This is important to me because I struggle with chauffeur braking in automatic transmission cars. On that note, I also appreciate that Tesla provides a no-creep option.</li><li>Same great hydraulic steering is considerably heavier than in the 570S and 570GT, especially in "track" handling mode.</li><li>The gunshot/whip crack downshifts are not a lie. They are incredible to experience with the top down.</li><li>No flames were to be seen during mild street driving in daylight :-(</li><li>I feel like the LT cars have stiffer (or just solid) engine mounts. I felt a massage from the seat while sitting at a red light.</li><li>No comment on the upgraded brakes; they were fine for street use. No comment on comparing the upgraded system from the 720S to the normal ceramics on the 570S or to the steel brakes in the 570GT.</li><li>No comment on the lighter weight. Need to hit the back roads or track…</li><li>No comment on downforce from its cute little fixed wing. Definitely need to push a bit on the track for that.</li><li>The normal power seats didn't go as far forward in this 600LT as I thought they would. Speaking of normal power seats…</li><li>This test car didn't have the critically-acclaimed Senna seats! I think that the dealer has a second demo Spider with the Senna seats. I hope I can take that car for a proper spin!</li></ul><div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-tjTgUEZUhwQ/XhPqHtx3ZaI/AAAAAAAAF2U/Uwso9h6Q_QMzowDWggkkmXHO05lpPAmZACEwYBhgL/s1600/2019-04-26%2B12.33.03.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1600" data-original-width="1200" height="320" src="https://1.bp.blogspot.com/-tjTgUEZUhwQ/XhPqHtx3ZaI/AAAAAAAAF2U/Uwso9h6Q_QMzowDWggkkmXHO05lpPAmZACEwYBhgL/s320/2019-04-26%2B12.33.03.jpg" width="240" /></a></div><div style="text-align: center;"><i>Yes, this is my normal seating position. Marvel at the amount of space behind the seat! </i></div><br />Other:<br /><ul><li>I preferred the short metal shift paddles over the extended carbon fibre paddles. Something about the metallic clink when I tap my fingernails on the paddles that's lacking with the carbon paddles…</li><li>Having experienced the 720S Spider roof mechanism, the legacy system in the 600LT Spider feels slow as I put the top down prior to leaving the dealer.</li><li>Sport Series Spider cars: the high shelf provides little rearward visibility regardless of roof position. (but who needs to see what's behind them in a supercar??)</li><li>2018 and later Sport Series cars: Backup camera is in the instrument cluster screen. To me, it's harder to use in conjunction with the rearview mirror than the postage stamp display in the centre screen in the 2016/2017 cars.</li><li>Chicane Effect is Chicane Grey with orange metallic flakes:</li></ul><div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-b1lKiwbgAhU/XhPqCu66RyI/AAAAAAAAF2E/T4WD2BFofb0UaYgV6ON9jVl7_CW8AwxvwCEwYBhgL/s1600/2019-04-26%2B12.34.09.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1600" data-original-width="1200" height="320" src="https://1.bp.blogspot.com/-b1lKiwbgAhU/XhPqCu66RyI/AAAAAAAAF2E/T4WD2BFofb0UaYgV6ON9jVl7_CW8AwxvwCEwYBhgL/s320/2019-04-26%2B12.34.09.jpg" width="240" /></a></div><br /><br />I really want to do a proper test drive in the back roads with little traffic, and in a car with the Senna seats. This will almost certainly need to happen on a Saturday morning shortly after the showroom opens at 9a!<br /><br />How I would spec this car: pretty barebones. The only "must-haves" I think are the Senna seats, as well as small practical items such as the soft-close doors, front lift, and battery charger. Skip the visual carbon exterior (the standard palladium pieces are actually painted carbon fibre pieces), skip the carbon interior, skip the leather, skip the audio…<br /><ul><li>Colour of my choice. These days, I'm feeling MSO Amethyst Black, ever since having seen a Senna in this colour during Car Week last year.</li><li>Standard 10 spoke wheels.</li><li>Soft close doors.</li><li>Standard Alcantara interior. Maybe splurge for the orange "By McLaren" Alcantara interior if I'm feeling lucky…</li><li>Senna seats, regular fit.</li><li>Front lift.</li><li>Battery charger.</li></ul><br />Before driving this car, I used to think that the 600LT coupe is the car to get because of the possibility of the roof scoop (for the uninitiated, it makes for an unique soundtrack). However, that's available in any LT coupe, and the uniqueness of the top-firing exhaust in the 600LT cars is most accentuated by a convertible, which was confirmed by this short drive. Therefore the 600LT Spider is now my pick of the two.<br /><br />[1] Neoprufrok, Roof scoop noises. <a href="https://www.youtube.com/watch?v=rte0WJjJIgU">https://www.youtube.com/watch?v=rte0WJjJIgU</a><br />[2] Vehicle Virgins, 600LT delivery. <a href="https://youtu.be/-XqaoHCWuK0?t=936">https://youtu.be/-XqaoHCWuK0?t=936</a>cherry suhttp://www.blogger.com/profile/16615103822232949422noreply@blogger.com0tag:blogger.com,1999:blog-712634145575243505.post-42351015005160361442020-01-05T23:15:00.005-05:002020-01-05T23:15:55.362-05:00Codeforces Round #612 (Div. 2) PostmortemLink to contest <a href="https://codeforces.com/contest/1287">here</a><br /><br />What went well<br /><ul><li>I know how DP works?!</li></ul>What went wrong<br /><ul><li>I failed to read B correctly the first time. The problem is about Set (the game), which I have only played once, over 10 years ago. I thought that all features had to be same or different, instead of each feature being independent of each other.</li><li>I took an hour to debug C because I wasn't confident in my dp transition function. Amusingly, my initial state was wrong, which luckily triggered an assert I left in my code, quickly highlighting an issue. </li></ul>Where I got lucky<br /><ul><li> Somehow placed in the top 5% with just ABC???!</li></ul>cherry suhttp://www.blogger.com/profile/16615103822232949422noreply@blogger.com0tag:blogger.com,1999:blog-712634145575243505.post-44570287133052688492019-12-29T23:14:00.000-05:002020-01-05T23:14:39.202-05:00Good Bye 2019 PostmortemLink to contest <a href="https://codeforces.com/contest/1270">here</a><br /><br />What went well<br /><ul><li>I managed to prove that my solution to B is optimal.</li></ul>What went wrong<br /><ul><li>Proving that my B solution is optimal took close to an hour.</li><li>I wasn't sure what to do with C. After expressing the sum as S and the xor as X, I first fell into a trap thinking that I can do it with one number, i.e. S + a = 2*(X ^ a). Nothing really came to mind. Then I thought about using two numbers, i.e. S + a + b = 2*(X ^ a ^ b), where I use a to get rid of S, i.e. make the bits of S be all 0s or all 1s. This led me to think about the lowest power of 2 greater than S, but nothing came to mind. I also never thought about using a to get rid of X, i.e. maybe set a = X, which then leads to a really nice solution S + X + b = 2*b, i.e. b = S + X.</li></ul> Where I got lucky<br /><ul><li>A is a 3 minute problem! </li></ul>cherry suhttp://www.blogger.com/profile/16615103822232949422noreply@blogger.com0tag:blogger.com,1999:blog-712634145575243505.post-57528517786977690622019-12-28T10:16:00.000-05:002020-01-05T22:53:32.226-05:00COLDforces Round #611 (Div. 3) PostmortemLink to contest here<br /><br />What went well<br /><ul><li>The contest was at 9am local time, so I had a good 2.5 hours to wake up.</li></ul>What went wrong<br /><ul><li>I was ill with a cold (laryngitis?!)</li><li>My solution to E died to a silent index out of bounds!!! Time to switch to vector<T>::at() instead of vector<T>::operator[]?!</li><li>I did not think of a working solution for C during the contest, but did so after the contest (and doing the obvious greedy solution worked and was easy to prove correct…) The junk that I submitted managed to pass system tests, but eventually got exposed by the serial hacker, who hacked over 20 C submissions!</li></ul>Where I got lucky<br /><ul><li>I got my first 1 minute submission!! </li><li>C was such a massacre that I managed to gain elo despite solving only 3 problems! Back to blue again!</li></ul><ul></ul>cherry suhttp://www.blogger.com/profile/16615103822232949422noreply@blogger.com0