随笔分类 -  CodeForces

摘要:Problem Link Based on initial observation, it seems that greedily pick the smallest row / column length works. But the last example test case outputs 阅读全文
posted @ 2024-08-14 23:46 Review->Improve 阅读(82) 评论(0) 推荐(0)
摘要:Problem Statement 1. N is up to 35, so trying all possible subsequences is too slow (2^35). We can apply the meet in the middle technique and divide A 阅读全文
posted @ 2022-09-30 10:48 Review->Improve 阅读(43) 评论(0) 推荐(0)
摘要:Problem Link Dp[i][j]: the number of possible ways from s[0, i] with the ith statement ending with indentation j. dp[0][0] = 1, the 1st statement must 阅读全文
posted @ 2022-02-07 23:04 Review->Improve 阅读(81) 评论(0) 推荐(0)
摘要:A. Counting Kangaroos is Fun There can be only at most N / 2 hold and held pairs based the problem's statment. So a greedy approach is just to divide 阅读全文
posted @ 2022-01-24 12:52 Review->Improve 阅读(105) 评论(0) 推荐(0)
摘要:Problem First I thought about modelling this problem as a directed graph, where between each pair of nodes, an edge represents a valid < > or > < tran 阅读全文
posted @ 2022-01-20 01:05 Review->Improve 阅读(78) 评论(0) 推荐(0)
摘要:Problem S: the set of numbers said by player 1; P: the set of numbers said by player 2; S^2 * P = a; S * P^2 = b; a * b = (S * P)^3, so a * b must be 阅读全文
posted @ 2022-01-18 06:35 Review->Improve 阅读(27) 评论(0) 推荐(0)
摘要:Problem Each fence is increased at most 2 times, so dp[i][j] is the min cost to make A[0, i] great with the last fence A[i] increased j times. The ans 阅读全文
posted @ 2022-01-18 03:22 Review->Improve 阅读(48) 评论(0) 推荐(0)
摘要:Problem Key idea: 1. for any substring s, if we can do not consider padding prefix 0s, its decimal value is always >= its length. 2. Appending a binar 阅读全文
posted @ 2022-01-17 13:44 Review->Improve 阅读(81) 评论(0) 推荐(0)
摘要:I have run into 2 different problems that can be solved using binary lifting. Then there is second thread's tree basics youtube video that talks about 阅读全文
posted @ 2020-08-25 11:53 Review->Improve 阅读(256) 评论(0) 推荐(0)
摘要:Given 2 integers u and v, find the shortest array such that bitwise-xor of its elements is u, and the sum of its elements is v. Input The only line co 阅读全文
posted @ 2020-03-17 07:11 Review->Improve 阅读(294) 评论(0) 推荐(0)
摘要:Primitive Primes : two integers are coprime if their GCD is 1. If a number A is not divisible by another prime number P, then A and P are guranteed to 阅读全文
posted @ 2020-03-05 23:19 Review->Improve 阅读(147) 评论(0) 推荐(0)
摘要:An interesting problem using suffix sum. For each wrong tries that is correct until after index p[i], we add 1 to cnt[p[i]]. This represents that all 阅读全文
posted @ 2020-03-01 06:31 Review->Improve 阅读(129) 评论(0) 推荐(0)
摘要:Problem Statement Link Clarification: The problem states that for each pair of points, we consider the minimum possible distance over any possible mom 阅读全文
posted @ 2020-02-28 23:07 Review->Improve 阅读(362) 评论(0) 推荐(0)
摘要:Dynamic programming solution State: dp[i]: the minimum cost to cover all positions from[0, i]. (left shift by 1 to get 0 index) // if position i is al 阅读全文
posted @ 2019-11-18 08:53 Review->Improve 阅读(516) 评论(0) 推荐(0)
摘要:Given an array that has n integers, count the number of ways to split all elements of this array into 3 contiguous parts so that the sum of each part 阅读全文
posted @ 2019-10-29 02:10 Review->Improve 阅读(502) 评论(0) 推荐(0)
摘要:Consider a multiset of integers S, the union of n closed intervals of positive integers: S = [l1..r1] ∪ [l2..r2] ∪ · · · ∪ [ln..rn](recall that a clos 阅读全文
posted @ 2019-10-25 05:55 Review->Improve 阅读(246) 评论(0) 推荐(0)
摘要:Smaller input size: https://codeforces.com/contest/1249/problem/D1 Big input size: https://codeforces.com/contest/1249/problem/D2 Given n segments on 阅读全文
posted @ 2019-10-25 04:56 Review->Improve 阅读(587) 评论(0) 推荐(0)
摘要:Given n kinds of present and m boxes. Find out the different ways to pack all boxes with presents, using the following rules. 1. Each box can not have 阅读全文
posted @ 2019-10-18 11:25 Review->Improve 阅读(154) 评论(0) 推荐(0)