Educational Codeforces 95 B - Negative Prefixes

Submission Code When swapping two elements $a_l$ and $a_r$, if $a_r > a_l$, the prefix sum increases in a certain range and remains unchanged elsewhere. In other words, you simply need to sort the unlocked elements in descending order. No change in prefix sum in the range $0 \sim l-1$ Prefix sum increases by $+(a_r-a_l)$ in the range $l \sim r-1$ No change in prefix sum in the range $r \sim n-1$

September 16, 2020

Codeforces #663 Div.2 D.505

Submitted Code If $n \ge 4$ and $m \ge 4$, it’s impossible to satisfy condition A (the number of 1s contained in a square with even vertical and horizontal lengths is odd). For example, when a $2 \times 2$ square satisfies condition A, if you connect four such squares, the sum becomes even. That is, a $4 \times 4$ square cannot satisfy condition A. In all other cases, you can always satisfy condition A by performing operations several times....

August 22, 2020

Educational Codeforces Round 92 C. Good String

Submitted Code Given a string $t$, we want to make the string after cyclic left shift and cyclic right shift equal. When removing some characters from $t$ to satisfy this condition, what is the minimum number of characters to remove? Let $n$ be the length of string $t$, and consider separately for even and odd cases. When $n$ is odd Take $t = t_1 t_2 t_3 t_4 t_5$ as an example....

August 4, 2020

Educational Codeforces Round 89 D. Two Divisors

Submitted Code Given an integer $a \ge 2$, we want to find a pair $(d_1, d_2)$ that satisfies $gcd(d_1+d_2, a)=1$. However, $d_1 \ge 2$ and $d_2 \ge 2$. Repeat this $n$ times. First, perform prime factorization as $a = {p_1}^{k_1} \cdot {p_2}^{k_2} \cdots {p_m}^{k_m}$. If $m = 1$ or $a$ is prime, the answer is $(-1, -1)$. If $m \ge 2$, the answer is $(p_1, p_2 \cdot p_3 \cdots p_m)$....

July 21, 2020

Codeforces Round 308 (Div.2), ARC040

I tried competitive programming for a bit. Codeforces #308 (Div.2) First time participating in Codeforces. In the end, I only solved A out of the 5 problems (A-E). Problem A was just implementation, so it didn’t take much time to solve. For problem B, I think it could have been solved by making a histogram, but I realized that too late. For problem C, I failed on the 4th pretest. I didn’t attempt D or E....

June 15, 2015