0w1

Entries from 2016-09-16 to 1 day

CFR 483 D. Interesting Array ( OR / AND Segment Tree )

Problem - D - Codeforces Let's try to simulate. First we have lazy-propagation on discretized segment tree where it only creates nodes when really needed, that is, the total memory consumption will be about O( M lg N ). The objective is cl…

CFR 558 C. Amr and Chemistry ( Ad hoc, Shortest Path )

Problem - C - Codeforces First we should notice that if some number x does not include factor p ( p > 2 and p is not of form 2^k ), it can never be p nor a multiple of p. We should also realize it is impossible that the optimal answer is o…

CFR 570 E. Pig and Palindromes ( DP )

Problem - E - Codeforces It is obvious we should perform DP, probably one from the upper-left, the other from the bottom-right, getting close to each other, marching across grids only when they match. We cannot store both the x-y-coordinat…

CFR 570 D. Tree Requests ( XOR, bits, DFS )

Problem - D - Codeforces First, we will notice that iff there are more than 1 alphabet with frequency of an odd number, a palindrome sequence cannot be formed. Thus we are only concerned with whether the frequency of each alphabet is odd o…

CFR 570 C. Replacement ( Ad hoc )

Problem - C - Codeforces We will first retrieve the answer for the original string, then update one by one in each query. Without loss of generality, we will assume that each update is meaningful ( that is, either changes a character to a …

CFR 570 B. Simple Game ( Ad hoc )

Problem - B - Codeforces Imagine the tile that occupies the range. Mark the position where the other player had chosen beforehand. It is now obvious that we will choose the range with greater range, and put ours exactly next to the foe's. …

Default Code ( 2016 / 09 / 16 )

#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair< int, int > pii; typedef pair< int, ll > pil; typedef pair< ll, int > pli; typedef pair< ll, ll > pll; typedef vector< int > vi; typedef vector< vi > vvi; typedef vector< ll</bits/stdc++.h>…