0w1

Entries from 2016-03-28 to 1 day

CFR 300 B. Coach ( DFS )

Problem - 300B - Codeforces 暴力でやるだけ。実装が下手。 つまらないミスで時間を溶かした。 #include <bits/stdc++.h> using namespace std; const int MAXN = 48 + 2; const int MAXM = MAXN * MAXN / 2; int n, m; vector< int > G[ MAXN ]; struct UnionFind{ int fa</bits/stdc++.h>…

CFR 463 D. Gargari and Permutations ( LCS DP )

Problem - D - Codeforces Problem in short: Given k arrays of 1 ~ n permutation, find max LCS length Since the final LCS will be in the first array anyways, we can describe the state as dp[ i ] : maximum length of LCS when a[ 0 ][ i ] is th…

CFR 414 1B. Mashmokh and ACM ( DP )

Problem - 414B - Codeforces 2D/0D. #include <bits/stdc++.h> using namespace std; const int MAXN = 2000 + 2; const int MAXK = 2000 + 2; const int MOD = 1e9 + 7; int n, k; int dp[ MAXN ][ MAXK ]; // last digit i, length j, possible ways void solve(){ dp[ 1</bits/stdc++.h>…

CFR 260 1A. Boredom ( DP )

Problem - 455A - Codeforces First sort and compress the items. Now we will find that if a number x is to be taken, it will only affect that it might be illegal to take x - 1 or x + 1. So it is only possible to transfer to the next state th…

CFR 346 B. Lucky Common Subsequence ( LCS + DP + Restoration )

Problem - B - Codeforces Have an extra vector on the dp array for recording the growth of the virus. There will be some kmp failure function like moves being made at the end of the current string, and it is sufficient to describe it with t…