0w1

Entries from 2016-03-25 to 1 day

CFR 602 D. Lipshitz Sequence ( Segment Tree )

Problem - D - Codeforces It is well known fact that only the adjacent elements would have the maximum slope. Making use of this fact, we can always find the maximum slope, find all subsequences it will contribute to, then apply divide and …

CFR 602 C. The Two Routes ( Floyd Warshall )

Problem - C - Codeforces It's easy to see it is a complete graph, which means there exists exactly one path that could carry one from the start to the end. So the actual answer is quite simple, the maximum among the two shortest paths. Def…

BZOJ 1036 树的统计 ( 樹平方分割 )

Problem 1036. -- [ZJOI2008]树的统计Count このテクすごいね、猛練習しよう。 #include <bits/stdc++.h> using namespace std; const int MAXN = 3e4 + 4; const int MAXQ = 2e5 + 5; const int INF = 0x3f3f3f3f; int n; vector< int > es[ MAXN ], bes[ MAXN ]; int par[</bits/stdc++.h>…

BZOJ 1833 数字计数 ( 桁DP )

Problem 1833. -- [ZJOI2010]count 数字计数 Given a ≤ 1e12, b ≤ 1e12, find frequency for each digit in range [ a , b ]. dp[ i ][ j ][ k ]: chose i digits, less flag, not zero Note that when transferring, we are to add the number of ways of i…

NOI12 Day 1 Random Number Generator ( Fast Matrix Multiplication + Fast Multiplication )

PEG Judge - NOI '12 - Random Number Generator www.2cto.com See the formulae here. What's particularly interesting in this problem is that it might cause overflow when calculating the product for some long long integers. However, here again…

UVA 12086 Potentiometers ( 平方分割 Range Sum Query )

UVa Online Judge Range Sum Query の基礎問題を平方分割で処理した。 ncastar.hatenablog.com この記事が大変参考になりました。 #include <bits/stdc++.h> using namespace std; const int MAXN = 2e5 + 5; int kase; int n; int a[ MAXN ]; int BS; vector< int > bucket</bits/stdc++.h>…

CFR 13 E. Holes ( 平方分割 )

Problem - E - Codeforces 第一次寫平方分割,不太習慣。這題的關鍵在於維護一些值,使得可以O( 1 ) 完成一個塊的查詢。操作也要逆著做回來( 由右到左 ) 才會正確。 #include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 5; const int MAXM = 1e5 + 5; in</bits/stdc++.h>…

TOJ 101 哪裡有卦,哪裡就有源 ( 水題二分圖 )

http://sprout.tw/oj/pro/101/ 顯然就是二分圖。 #include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 5; const int MAXM = 2 * MAXN; int n; vector< int > G[ MAXN ]; void init(){ for(int i = 0; i < n; ++i) G[ i ].clear(); } int col[ MAXN ]; bo</bits/stdc++.h>…