Saturday, July 2, 2022
Codeforces: Permutation Graph
Wednesday, June 29, 2022
Happy days + learning cryptography
- $G(1^k)$ outputs a secret key of length $k$.
- $E(sk, m)$ takes a secret key and a message and outputs ciphertext.
- $D(sk, m')$ takes a secret key and a ciphertext and outputs plaintext.
- $G(1^k)$ outputs a random string from $\{0,1\}^k$.
- $E(sk, m)$ outputs $m \oplus sk$.
- $D(sk, m')$ outputs $m' \oplus sk$.
Friday, June 17, 2022
Some codeforces problem + a little puzzle
We are given some array $a$ of length $n$ which is initially populated with only $0$'s. We also have a pointer which starts pointed at the first element of $a$. Given the pointer is at position $i$, we can make the following moves:
- add $1$ to $a[i]$ and move the pointer one to the right, or
- subtract $1$ to $a[i]$ and move the pointer one to the left.
- number the glasses from $1$ to $n$.
- for every $g=1$ to $n$, flip all glasses except for glass $g$.
- What about $n>1$ odd? (Conjecture, it is not possible)
- Is our algorithm for even $n$ optimal. (Conjecture, yes)
Line Empire Codeforces
- Move the capital at $x_i$ to any conquered city at $x_j$ for a price of $a\cdot |x_i-x_j|$,
- Conquer an unconquered city at position $x_j$ where our capital is at $x_i$ for a price of $b\cdot |x_i-x_j|$ so long as all cities on path between capital and unconquered city are conquered already.
- We are forced to conquer the cities in the order $x_1, x_2, ..., x_N$ because of the condition that all cities on the path from the capital to the unconquered city must be already conquered.
- The first move must be to conquer $x_1$.
- We never want to move the capital left.
Tuesday, June 14, 2022
String equality
- if we see 'ab' we can change it to 'ba',
- if we see 'bc' we can change it to 'cb'.
Saturday, May 28, 2022
Kickstart: Ants on a stick
This is a twist of the well known ant problem, whereby we can view ants as walking through each other when they meet. In this case, we do not seek the latest time for an ant to fall off the stick, instead we want the order by which they fall off.
The first thing I noticed was that one of the leftmost or rightmost ants, $l$ and $r$ respectively, will fall off first. This is because they will either walk straight off, or they will walk into some ant and then walk towards the end of the stick. Now we just need to decide which of the two falls off first.
Since, we can view the ants as walking past each other when meeting, we know that the $n$ ants fall off the stick at times $t(1),t(2),...,t(n)$, where $t(i)$ is the time that the $i$th ant falls off the stick when it is alone on the stick. Then the first ant will fall off at time $\min_{i}\{t(i)\}$. Let $x$ be the ant which has this minimum value of $t(x)$. If $x$ and $l$ are facing each other, then $l$ will fall off first since $x$ and $l$ will meet at some time, forcing $l$ to fall off the stick first. There are other cases to examine, but we have now made the main observations.
Tuesday, May 17, 2022
Binary string
The problem link is here: https://codeforces.com/contest/1680/problem/C.
My approach and thoughts:
Let b start with $x$ zeros. We simplify the problem to only have deletions from the left side.
Let $s[i]$ denote the number of $1'$s in positions $[0,i)$. We want to delete prefix $[0,i)$ which minimises $\max\{x-(i-s[i]), s[i]\}$.
AtCoder shananigans
Here is the problem , and below is the raw transcript of my thoughts. Obs: It is always optimal to use all $K$ moves. intuitive proof. While...
-
We are given $N$ cities on an integer number line at positions $0<x_1<x_2<...<x_N$, where our capital is initially at position 0...
-
The problem is essentially, given $2\leq n\leq 10^5$ people, where the $i^{\text{th}}$ person has a skill level of $b_i$ in billiards and $p...
-
We are given a permutation of $1,2,...,n$, $a_1, a_2, ..., a_n$. Construct the undirected graph with vertex set $1, 2, ..., n$ and $(i, j)$ ...