<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Competitive-Programming on CuriousCoding</title><link>https://curiouscoding.nl/tags/competitive-programming/</link><description>Recent content in Competitive-Programming on CuriousCoding</description><generator>Hugo</generator><language>en</language><lastBuildDate>Tue, 17 Oct 2023 00:00:00 +0200</lastBuildDate><atom:link href="https://curiouscoding.nl/tags/competitive-programming/index.xml" rel="self" type="application/rss+xml"/><item><title>BAPCtools instruction</title><link>https://curiouscoding.nl/posts/bapctools-demo/</link><pubDate>Tue, 17 Oct 2023 00:00:00 +0200</pubDate><guid>https://curiouscoding.nl/posts/bapctools-demo/</guid><description>&lt;p&gt;Steps:&lt;/p&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;Clone &lt;a href="https://github.com/RagnarGrootKoerkamp/BAPCtools" class="external-link" target="_blank" rel="noopener"&gt;https://github.com/RagnarGrootKoerkamp/BAPCtools&lt;/a&gt;&lt;/li&gt;&#10;&lt;li&gt;Make an alias to the executable:&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ln -s ~/git/BAPCtools/bin/tools.py ~/bin/bt&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;/li&gt;&#10;&lt;li&gt;Create a new problem:&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; ~/problems&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;bt new_problem my_problem_name&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; ~/problems/my_problem_name&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;/li&gt;&#10;&lt;li&gt;You now have the following:&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;span class="lnt"&gt;20&#10;&lt;/span&gt;&lt;span class="lnt"&gt;21&#10;&lt;/span&gt;&lt;span class="lnt"&gt;22&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-txt" data-lang="txt"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;├── data&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;│   ├── sample&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;│   │   └── 1.in # Sample testcase input&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;│   │   └── 1.ans # Sample testcase output&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;│   └── secret&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;├── generators # for later&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;│   └── ...&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;├── input_validators # for later&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;│   └── ...&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;├── output_validators # for later&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;│   └── ...&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;├── problem_statement&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;│   ├── figure.tex.template&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;│   ├── problem.en.tex # The problem statement&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;├── problem.yaml&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;└── submissions&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; ├── accepted&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; │   └── name.cpp # A submission&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; ├── run_time_error&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; ├── time_limit_exceeded&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; └── wrong_answer&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;/li&gt;&#10;&lt;li&gt;Edit the statement &lt;code&gt;problem.en.tex&lt;/code&gt;&lt;/li&gt;&#10;&lt;li&gt;Make some samples by hand in &lt;code&gt;data/samples/*.{in,ans}&lt;/code&gt;&lt;/li&gt;&#10;&lt;li&gt;Write a solution in &lt;code&gt;submissions/accepted/&amp;lt;yourname&amp;gt;.{py,cpp,java}&lt;/code&gt;.&lt;/li&gt;&#10;&lt;li&gt;Use &lt;code&gt;bt run&lt;/code&gt; or &lt;code&gt;bt run submissions/accepted/&amp;lt;submission&amp;gt;&lt;/code&gt; to test your submission.&lt;/li&gt;&#10;&lt;/ol&gt;</description></item><item><title>Competitive Programming Lecture</title><link>https://curiouscoding.nl/posts/competitive-programming-lecture/</link><pubDate>Wed, 28 Sep 2022 00:00:00 +0200</pubDate><guid>https://curiouscoding.nl/posts/competitive-programming-lecture/</guid><description>&lt;div class="ox-hugo-toc toc"&gt;&#10;&lt;div class="heading"&gt;Table of Contents&lt;/div&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;a href="#contest-strategies" &gt;Contest strategies&lt;/a&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;a href="#pairwise-alignment-using-a" &gt;Pairwise Alignment using A*&lt;/a&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;a href="#exercises" &gt;Exercises&lt;/a&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/div&gt;&#10;&lt;!--endtoc--&gt;&#10;&lt;h2 id="contest-strategies"&gt;&#10; Contest strategies&#10; &lt;a class="heading-link" href="#contest-strategies"&gt;&#10; &lt;i class="fa-solid fa-link" aria-hidden="true" title="Link to heading"&gt;&lt;/i&gt;&#10; &lt;span class="sr-only"&gt;Link to heading&lt;/span&gt;&#10; &lt;/a&gt;&#10;&lt;/h2&gt;&#10;&lt;dl&gt;&#10;&lt;dt&gt;Preparation&lt;/dt&gt;&#10;&lt;dd&gt;&lt;ul&gt;&#10;&lt;li&gt;Thinking costs energy!&lt;/li&gt;&#10;&lt;li&gt;Sleep enough; early to bed the 2 nights before.&lt;/li&gt;&#10;&lt;li&gt;No practising on contest day (and the day before); it just takes energy.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/dd&gt;&#10;&lt;dt&gt;During the contest&lt;/dt&gt;&#10;&lt;dd&gt;&lt;ul&gt;&#10;&lt;li&gt;Eat! At the very least take a break halfway with the entire team and eat some snacks.&lt;/li&gt;&#10;&lt;li&gt;Make sure to read &lt;strong&gt;all&lt;/strong&gt; the problems before the end of the contest. In the&#10;beginning, split the problems to find the simple ones, but towards the end,&#10;find a problem you think you can solve (because of the scoreboard or because&#10;you like it), and work on it as a team.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/dd&gt;&#10;&lt;dt&gt;Coding&lt;/dt&gt;&#10;&lt;dd&gt;&lt;ul&gt;&#10;&lt;li&gt;Ideally, use C++. Otherwise, Python can be used too.&#10;&lt;ul&gt;&#10;&lt;li&gt;For big-integer problems, prefer Python.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;Use a TCR (e.g. &lt;a href="https://github.com/TimonKnigge/TCR" class="external-link" target="_blank" rel="noopener"&gt;https://github.com/TimonKnigge/TCR&lt;/a&gt;): a 25 page document&#10;containing algorithms. Ideally, implement all of them yourself so you know&#10;how they work. Otherwise download one.&lt;/li&gt;&#10;&lt;li&gt;Make a template, and add it to your TCR. One person should type this in the&#10;first minutes of the contest and copy it to &lt;code&gt;A.cpp&lt;/code&gt;, &lt;code&gt;B.cpp&lt;/code&gt;, &amp;hellip; .&lt;/li&gt;&#10;&lt;li&gt;When you think you solved a problem:&#10;&lt;ul&gt;&#10;&lt;li&gt;Decide &lt;em&gt;exactly&lt;/em&gt; how the code will look. Maybe write pseudocode on paper.&lt;/li&gt;&#10;&lt;li&gt;For hard problems: verify your solution with a teammate.&lt;/li&gt;&#10;&lt;li&gt;Once the keyboard is free, start typing it out. If needed, ask one&#10;teammate to look while you code.&lt;/li&gt;&#10;&lt;li&gt;Typical distribution:&#10;&lt;ul&gt;&#10;&lt;li&gt;1 person typing&lt;/li&gt;&#10;&lt;li&gt;1 person solving a new problem&lt;/li&gt;&#10;&lt;li&gt;1 person helping the other 2: spotting typos or working on problems.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/dd&gt;&#10;&lt;/dl&gt;&#10;&lt;h2 id="pairwise-alignment-using-a"&gt;&#10; Pairwise Alignment using A*&#10; &lt;a class="heading-link" href="#pairwise-alignment-using-a"&gt;&#10; &lt;i class="fa-solid fa-link" aria-hidden="true" title="Link to heading"&gt;&lt;/i&gt;&#10; &lt;span class="sr-only"&gt;Link to heading&lt;/span&gt;&#10; &lt;/a&gt;&#10;&lt;/h2&gt;&#10;&lt;p&gt;Some resources you can use:&lt;/p&gt;</description></item><item><title>Hashcode 2021 Finals</title><link>https://curiouscoding.nl/posts/hashcode-2021-finals/</link><pubDate>Sat, 24 Apr 2021 00:00:00 +0200</pubDate><guid>https://curiouscoding.nl/posts/hashcode-2021-finals/</guid><description>&lt;p&gt;&lt;strong&gt;Links:&lt;/strong&gt; &lt;a href="https://hashcodejudge.withgoogle.com/#/rounds/5879728443490304/" class="external-link" target="_blank" rel="noopener"&gt;Problem&lt;/a&gt; | &lt;a href="https://hashcodejudge.withgoogle.com/scoreboard" class="external-link" target="_blank" rel="noopener"&gt;Scoreboard&lt;/a&gt;&lt;br /&gt;&#10;&lt;strong&gt;Team:&lt;/strong&gt; &lt;code&gt;cat /dev/random | grep &amp;quot;to be or not to be&amp;quot;&lt;/code&gt;&lt;br /&gt;&#10;&lt;strong&gt;Who:&lt;/strong&gt; Jan-Willem Buurlage, Ragnar Groot Koerkamp, Timon Knigge, Abe Wits&lt;br /&gt;&#10;&lt;strong&gt;Score:&lt;/strong&gt; 274253375&lt;br /&gt;&#10;&lt;strong&gt;Rank:&lt;/strong&gt; 19 of 38&lt;/p&gt;&#10;&lt;p&gt;Not good.&lt;br /&gt;&#10;Not bad.&lt;br /&gt;&#10;Definitely ugly.&lt;/p&gt;&#10;&lt;p&gt;&lt;em&gt;Linkerrijtje&lt;/em&gt; (aka top half).&lt;/p&gt;&#10;&lt;p&gt;I would have liked to write that I&amp;rsquo;m happy with the result, but to be&#10;fair&amp;ndash;I&amp;rsquo;m not. Just the fact that I can&amp;rsquo;t sleep and feel the need to&#10;write this in the middle of the night surely is indication of this.&#10;Plenty of things could have gone better, and there are so many things we&#10;(I) could have done differently to actually break that elusive 300M&#10;barrier (and potentially get that top 10 place we were hoping for), that&#10;I&amp;rsquo;ll definitely be sad for a little while.&lt;/p&gt;</description></item><item><title>Hashcode 2021: A lucky ride</title><link>https://curiouscoding.nl/posts/hashcode-2021/</link><pubDate>Mon, 01 Mar 2021 00:00:00 +0100</pubDate><guid>https://curiouscoding.nl/posts/hashcode-2021/</guid><description>&lt;p&gt;&lt;strong&gt;Links:&lt;/strong&gt; &lt;a href="https://hashcodejudge.withgoogle.com/#/rounds/5879728443490304/" class="external-link" target="_blank" rel="noopener"&gt;Problem&lt;/a&gt; | &lt;a href="https://hashcodejudge.withgoogle.com/scoreboard" class="external-link" target="_blank" rel="noopener"&gt;Scoreboard&lt;/a&gt; | &lt;a href="https://codeforces.com/blog/entry/88188" class="external-link" target="_blank" rel="noopener"&gt;Codeforces announcement&lt;/a&gt;, &lt;a href="https://codeforces.com/blog/entry/88328" class="external-link" target="_blank" rel="noopener"&gt;this blog&lt;/a&gt; | &lt;a href="https://news.ycombinator.com/item?id=26319076" class="external-link" target="_blank" rel="noopener"&gt;Hacker News&lt;/a&gt;&lt;br /&gt;&#10;&lt;strong&gt;Team:&lt;/strong&gt; &lt;code&gt;cat /dev/random | grep &amp;quot;to be or not to be&amp;quot;&lt;/code&gt;&lt;br /&gt;&#10;&lt;strong&gt;Who:&lt;/strong&gt; Jan-Willem Buurlage, Ragnar Groot Koerkamp, Timon Knigge, Abe Wits&lt;br /&gt;&#10;&lt;strong&gt;Score:&lt;/strong&gt; 10282641&lt;br /&gt;&#10;&lt;strong&gt;Rank:&lt;/strong&gt; 16&lt;/p&gt;&#10;&lt;p&gt;Since we did quite well, here is a write-up of our participation in&#10;Hashcode 2021.&lt;/p&gt;&#10;&lt;h2 id="prep"&gt;&#10; Prep&#10; &lt;a class="heading-link" href="#prep"&gt;&#10; &lt;i class="fa-solid fa-link" aria-hidden="true" title="Link to heading"&gt;&lt;/i&gt;&#10; &lt;span class="sr-only"&gt;Link to heading&lt;/span&gt;&#10; &lt;/a&gt;&#10;&lt;/h2&gt;&#10;&lt;p&gt;All four of us had previously participated in Hashcode, but this was the&#10;first time in the current composition. Since we estimated our chances of&#10;getting through to the finals to be more than nothing, we decided to&#10;practice some previous Hashcode problems. Not all test sessions were&#10;equally successful, but we did manage to get a good division of work:&#10;while I start by immediately writing the IO &lt;code&gt;Input&lt;/code&gt; and &lt;code&gt;Output&lt;/code&gt;&#10;classes, and the &lt;code&gt;Output::score()&lt;/code&gt; function, the others always start&#10;with reading the statement, analysing the testcases, and writing at&#10;least one greedy solution. This already is a big step up from previous&#10;years/teams, where usually everybody would write the IO themselves.&lt;/p&gt;</description></item></channel></rss>