文章链接:http://www.cnblogs.com/Asm-Definer/p/4434601.html

题目链接:http://pan.baidu.com/s/1mgxIKli

官方数据:http://pan.baidu.com/s/1qW4wkVE

看巨神们都去虐ZJOI了,蒟蒻只能默默地码着CQOI的题解……

CQOI的难度分布也是挺神奇的,五小时五道题,三(或四)道水题一两道神题(只是对我来说比较神...),我猜让我去考我一定会写不完D题然后滚去备战高考= =

A.选数

题意:

从区间[L, H]中选出N个数(可以重复),求取出的N个数的最大公约数恰好为K的方案数。

其中$1 \leq L, H, N \leq 10^9, H - L \leq 10^5$

分析:

刚开始还以为这是道简单的莫比乌斯反演题,推了半天公式,发现是个依赖$\lfloor H / K \rfloor $的式子

$$\sum_{d=1}^{H/K} \mu(d) (\frac{H}{d*K} - \frac{L-1}{d*K})^N$$(由于LaTeX打取整式太不方便所以这个式子没有考虑细节)当$H/K$很大的时候mu就无法预处理了。

后来衡中的JSX同学(http://55242.cf/)告诉我一个不错的思路:对较小的mu用线性筛预处理,对较大的mu直接暴力分解质因数。而当d比较大的时候会有很多$(\frac{H}{d*K} - \frac{L-1}{d*K})$为0的区间,遇到这些区间就跳转一下就可以了。粘一下他的核心代码:

 for(int i = ;i <= R;++ i) {

     if((R/i) == (L/i)) {

         i = min((LL)R/(R/i) ,(LL)L / i ? L/(L/i) : INF);

         continue;

     } else {

         ans += (LL)quickpow((R/i)-(L/i),N) * get_mu(i);

         ans %= mod;

     }

 }

思路简单,效率也很不错。

不过……有强迫症的同学可能会想……如果这道题表达式的后半部分不是$(\frac{H}{d*K} - \frac{L-1}{d*K})$而只有$\frac{H}{d*K}$,这个式子就不会很快变成0了。这样还是否可做呢?

考虑到在取整后$\frac{H}{d*K}$的取值只有$\sqrt{\frac{H}{K}}$个,如果我们能快速地求出莫比乌斯的前缀和(梅腾斯函数),就可以在$O(1)$的时间内求出一段相等的区间的贡献了。

这个$M(N) = \sum_{i=1}^N \mu(i)$看起来似乎很难的样子……其实我们可以这样转化:

$$M(N)= \sum_{i=1}^N (\sum_{d|i}\mu(d) - \sum_{d|i \land d \neq i}\mu(d) ) \\
= 1 - \sum_{i=1}^N \sum_{d|i \land d \neq i} \mu(d) \\= 1 - \sum_{i'=2}^N \sum_{d=1}^{\lfloor \frac{N}{i'} \rfloor} \mu(d) \\ = 1 - \sum_{i'=2}^N M(\lfloor \frac{N}{i'}\rfloor)$$

这样,我们就只需在预处理出前$10^7$项梅腾斯函数后在处理较大的N时对

$\lfloor \frac{N}{i'}\rfloor$分块递归就可以快速地求出超过$10^7$的梅腾斯函数了。(这个带下取整的递推式复杂度究竟是多少呢……反正我不会分析……不过目测我们需要计算梅腾斯函数的次数非常少,所以这个复杂度已经足够了。

然而……出题人表示我们都太Simple啦,Sometimes Naive!我们观察一下题目中的条件……“$H - L \leq 10^5$"......注意到当N个数不全相同的时候,它们的最大公约数一定不会超过其中任意两个不同数的差。于是……我们只需要将边界除以K后递推”N个数不全相同且最大公因数为i($i \leq 10^5$)"的方案数,最后特判一下N个数都相同的情况,加上递归得到的F(1)就是答案了,复杂度是优美的$(H-L) log (H-L)$。

代码:

 1 /***********************************************************************/
 2 /**********************By Asm.Def-Wu Jiaxin*****************************/
 3 /***********************************************************************/
 4 #include <cstdio>
 5 #include <cstring>
 6 #include <cstdlib>
 7 #include <ctime>
 8 #include <cctype>
 9 #include <algorithm>
 #ifdef DEBUG
 #include <sys/timeb.h>
 #endif
 using namespace std;
 #define SetFile(x) ( freopen(#x".in", "r", stdin), freopen(#x".out", "w", stdout) );
 #define getc() getchar() 
 template<class T>inline void getd(T &x){
     char ch = getc();bool neg = false;
     while(!isdigit(ch) && ch != '-')ch = getc();
     if(ch == '-')ch = getc(), neg = true;
     x = ch - '';
     while(isdigit(ch = getc()))x = x *  - '' + ch;
     if(neg)x = -x;
 }
 #ifdef DEBUG
 #include <sys/timeb.h>
 timeb Tp;
 #endif
 /***********************************************************************/
 const int maxn = , mod = ;
 typedef long long LL;
 inline int powmod(int a, int n){
     int ans = ;
     while(n){if(n & )ans = (LL)ans * a % mod;a = (LL)a * a % mod;n >>= ;}
     return ans;
 }
 
 inline void work(){
     int f[maxn], N, K, L, H, i, j, t, *it;getd(N), getd(K), getd(L), getd(H);
     L = (L - ) / K;H /= K;
     int len = H - L;
     for(i = len, it = f + i;i;--i, --it){
         t = H / i - L / i;//澶氬皯涓猧鐨勫€嶆暟
         *it = (powmod(t, N) + mod - t) % mod;
         for(j = i << ;j <= len;j += i)
             *it = (*it + mod - f[j]) % mod;
     }
     if(L <=  && H > )++f[];
     printf("%d\n", f[]);
 }
 
 int main(){
 
 #ifdef DEBUG
     freopen("test.txt", "r", stdin);
     ftime(&Tp);
     time_t Begin_sec = Tp.time, Begin_mill = Tp.millitm;
 #elif !defined ONLINE_JUDGE
     SetFile(cqoi15_number);
 #endif
     work();
 
 #ifdef DEBUG
     ftime(&Tp);
     printf("\n%.3lf sec \n", (Tp.time - Begin_sec) + (Tp.millitm - Begin_mill) / 1000.0);
 #endif
     return ;
 }

A.递推

B.网络吞吐量

题意:

    在一个无向网络的最短路径构成的DAG上求最大流。

$|V| \leq 500, |E| \leq 100000 $

分析:

似乎不需要分析了,除了最短路+网络流外没有什么其他的东西……

注意到这里的原图是个稠密图,使用$O(|V|^2)$的Dijkstra 可以得到很好的运行效率。

代码:

  1 #include <cstdio>
  2 #include <cstring>
  3 #include <cstdlib>
  4 #include <ctime>
  5 #include <cctype>
  6 #include <algorithm>
  7 #include <cmath>
  8 using namespace std;
  9 #define USEFREAD
 10 #ifdef USEFREAD
 11 #define InputLen 5000000
 12 char *ptr=(char *)malloc(InputLen);
 13 #define getc() (*(ptr++))
 14 #else
 15 #define getc() (getchar())
 16 #endif
 17 #define SetFile(x) (freopen(#x".in", "r", stdin), freopen(#x".out", "w", stdout))
 18 template<class T>inline void getd(T &x){
 19     char ch = getc();bool neg = false;
 20     while(!isdigit(ch) && ch != '-')ch = getc();
 21     if(ch == '-')ch = getc(), neg = true;
 22     x = ch - '';
 23     while(isdigit(ch = getc()))x = x *  - '' + ch;
 24     if(neg)x = -x;
 25 }
 26 /***********************************************************************/
 27 const int maxn = , maxv = ;
 28 typedef long long LL;
 29 const LL INF = 0x3f3f3f3f3f3f3f3fll;
 30 int S, N, tmp[maxn][maxn], tmpcnt[maxn], val[maxn];
 31 LL dis[maxn], G[maxn][maxn];
 32 inline void init(){
 33     int M, i, u, v, d, *t = val + ;
 34     getd(N), getd(M);S =  + N;
 35     while(M--){
 36         getd(u), getd(v), getd(d);LL &e = G[u][v];
 37         if(!e || e > d)e = d, G[v][u] = d;
 38     }
 39     for(i = ;i <= N;++i, ++t)getd(*t);
 40 }
 41 
 42 struct Edge{
 43     int to, vol;Edge *op;
 44     inline void init(int t, int v, Edge *o){to = t, vol = v, op = o;}
 45 }adj[maxv][maxn];int adjcnt[maxv];
 46 
 47 inline void AddE(int u, int v, int vol){
 48     int &itu = adjcnt[u], &itv = adjcnt[v];
 49     adj[u][itu].init(v, vol, adj[v] + itv);adj[v][itv].init(u, , adj[u] + itu);++itu, ++itv;
 50 }
 51 
 52 inline void Dij(){
 53     memset(dis, INF, sizeof(dis));dis[] = ;
 54     bool tab[maxn] = {}, inS[maxn] = {,};
 55     int tablist[maxn], *tabiter = tablist, i, j, v, *it, *tmpt;
 56     LL *tmpd, *e, t;
 57     for(i = ,e = G[]+,tmpd = dis+;i <= N;++i,++e,++tmpd)if(*e)
 58         *(tabiter++) = i, *tmpd = *e, tmp[i][tmpcnt[i]++] = ;
 59     for(j = ;j <= N;++j){
 60         if(tabiter == tablist)break;
 61         t = INF;
 62         for(it = tablist;it < tabiter;++it)if(dis[*it] < t)
 63             tmpt = it, t = dis[*it];
 64         inS[v = *(it = tmpt)] = true;
 65         e = G[v] + ;
 66         swap(*it, *(--tabiter));
 67         for(i = ,tmpd = dis+;i <= N;++i,++e,++tmpd)if(*e && !inS[i]){
 68             if(*tmpd > t + *e){
 69                 *tmpd = t + *e;
 70                 *tmp[i] = v;tmpcnt[i] = ;
 71                 if(!tab[i])*(tabiter++) = i, tab[i] = true;
 72             }
 73             else if(*tmpd == t + *e)
 74                 tmp[i][tmpcnt[i]++] = v;
 75         }
 76     }
 77     for(i = ;i <= N;++i)for(it = tmp[i] + tmpcnt[i] - ;it >= tmp[i];--it)
 78         AddE(*it + N, i, INF);
 79     for(i = ;i <= N;++i)AddE(i, i + N, val[i]);
 80 }
 81 
 82 int dep[maxv], curadj[maxv];
 83 LL dfs(int cur, LL f){
 84     if(cur == N)return f;
 85     LL d = dep[cur], ans = , t;
 86     int &adjit = curadj[cur];
 87     Edge *it;
 88     for(;adjit < adjcnt[cur];++adjit)if((it = adj[cur]+adjit)->vol && dep[it->to] == d + ){
 89         t = dfs(it->to, min(f, (LL)it->vol));
 90         it->vol -= t, it->op->vol += t, ans += t, f -= t;
 91         if(!f)return ans;
 92     }
 93     return ans;
 94 }
 95 #include <queue>
 96 inline bool bfs(){
 97     memset(curadj, , sizeof(curadj));
 98     queue<int> Q;bool vis[maxv] = {};vis[S] = true;
 99     Q.push(S);
     int v;LL d;
     Edge *it, *end;
     while(!Q.empty()){
         v = Q.front();Q.pop();d = dep[v];
         for(it = adj[v],end = it + adjcnt[v];it < end;++it)if(it->vol && !vis[it->to])
             dep[it->to] = d + , Q.push(it->to), vis[it->to] = true;
     }
     return vis[N];
 }
 
 int main(){
     #ifdef DEBUG
     freopen("test.txt", "r", stdin);
     #else
     SetFile(cqoi15_network);
     #endif
     #ifdef USEFREAD
     fread(ptr,,InputLen,stdin);
     #endif
     init();
     Dij();
     LL ans = ;
     while(bfs())
         ans += dfs(S, INF);
     printf("%lld\n", ans);
 #ifdef DEBUG
     printf("\n%.3lf sec \n", (double)clock() / CLOCKS_PER_SEC);
 #endif
     return ;
 }

dijkstra+dinic

C.任务查询系统

题意:

    给出n个区间,每个区间有一个权值$P_i$;共m次询问,每次询问覆盖$x_i$点的所有区间中权值最小的$K_i$个区间的权值和。

数据规模 $\leq 10^5$

分析:

很经典的可持久化线段树的模型。对所有权值离散化后在所有点构造可持久化线段树,询问时对线段树做区间查询。

代码:

  1 #include <cstdio>
  2 #include <cstring>
  3 #include <cstdlib>
  4 #include <ctime>
  5 #include <cctype>
  6 #include <algorithm>
  7 #include <cmath>
  8 using namespace std;
  9 #define USEFREAD
 10 #ifdef USEFREAD
 11 #define InputLen 4000000
 12 char *ptr=(char *)malloc(InputLen);
 13 #define getc() (*(ptr++))
 14 #else
 15 #define getc() (getchar())
 16 #endif
 17 #define SetFile(x) (freopen(#x".in", "r", stdin), freopen(#x".out", "w", stdout))
 18 template<class T>inline void getd(T &x){
 19     char ch = getc();bool neg = false;
 20     while(!isdigit(ch) && ch != '-')ch = getc();
 21     if(ch == '-')ch = getc(), neg = true;
 22     x = ch - '';
 23     while(isdigit(ch = getc()))x = x *  - '' + ch;
 24     if(neg)x = -x;
 25 }
 26 /***********************************************************************/
 27 const int maxn = ;
 28 typedef long long LL;
 29 struct Event{bool Add;int Time, P;}E[maxn << ], *Eend = E;
 30 inline bool operator < (const Event &a, const Event &b){return a.Time < b.Time;}
 31 
 32 int Plist[maxn], *Pend = Plist;
 33 #define id(x) (lower_bound(Plist, Pend, x) - Plist)
 34 
 35 struct SegT *Pool;
 36 struct SegT{
 37     int L, R, cnt, mid;
 38     LL Sum;
 39     SegT *ls, *rs;
 40     inline void init(int l, int r){
 41         L = l, R = r, mid = (L + R) >> ;
 42         if(r - l == )return;
 43         ls = Pool++;rs = Pool++;
 44         ls->init(L, mid), rs->init(mid, R);
 45     }
 46     void Add(int i, int d){
 47         if(R - L == ){cnt += d;Sum += Plist[L] * d;return;}
 48         SegT *t = Pool++;
 49         if(i < mid)*t = *ls, t->Add(i, d), ls = t;
 50         else *t = *rs, t->Add(i, d), rs = t;
 51         cnt += d;Sum += d * Plist[i];
 52     }
 53     LL Query(int K){
 54         if(R - L == )return (LL)K * Plist[L];
 55         if(K >= cnt)return Sum;
 56         if(K <= ls->cnt)return ls->Query(K);
 57         return ls->Sum + rs->Query(K - ls->cnt);
 58     }
 59 }Root[maxn * ];
 60 
 61 inline int init(){
 62     int i, M, N, L, R, P;
 63     Event *it;
 64     getd(M), getd(N);
 65     Pool = Root + N + ;
 66     while(M--){
 67         getd(L), getd(R), getd(P);
 68         *(Pend++) = P;
 69         *(Eend++) = (Event){true, L, P};
 70         *(Eend++) = (Event){false, R + , P};
 71     }
 72     Eend->Time = maxn;
 73     sort(E, Eend);
 74     sort(Plist, Pend);
 75     Root->init(, Pend - Plist);
 76     SegT *u = Root, *v = Root + ;
 77     for(i = , it = E;i <= N;++i){
 78         *(v++) = *(u++);
 79         while(it->Time == i){
 80             u->Add(id(it->P),  * it->Add - );
 81             ++it;
 82         }
 83     }
 84     return N;
 85 }
 86 
 87 int main(){
 88     #ifdef DEBUG
 89     freopen("test.txt", "r", stdin);
 90     #else
 91     SetFile(cqoi15_query);
 92     #endif
 93     #ifdef USEFREAD
 94     fread(ptr,,InputLen,stdin);
 95     #endif
 96     
 97     int X, A, B, C, N;
 98     LL Pre = ;
 99     N = init();
     while(N--){
         getd(X), getd(A), getd(B), getd(C);
         Pre = Root[X].Query((Pre * A + B) % C + );
         printf("%lld\n", Pre);
     }
     
 #ifdef DEBUG
     printf("\n%.3lf sec \n", (double)clock() / CLOCKS_PER_SEC);
 #endif
     return ;
 }

可持久化线段树

D.多项式

题意:

已知整数$n, t, a_k(1 \leq k \leq n),  m,$ 求出能使$$\sum_{k=0}^n a_k x^k = \sum_{k=1}^n b_k (x-t)^k $$的b数列的第m项。

其中 $a_k$满足递推式:$$k = 0时,a_k = 1;k > 0时,a_k = (1234*a_{k-1} + 5678) \mod 3389$$.

其中 $0 < n \leq 10^{3000}, 0 \leq t \leq 10000, 0 \leq n-m \leq 5.$

分析:

天哪……为何这位出题人这么喜欢加这么奇怪的数据范围限制……

首先,对于多项式来说,这个x的取值是任意的。所以我们可以用x+t替换x代入条件,得到

$$\sum_{k=0}^n a_k (x + t)^k = \sum_{k=0}^n b_k x^k$$

$$ \sum_{k=0}^n b_k x^k = \sum_{k=0}^n a_k \sum_{j=0}^k \tbinom{j}{k} x^j t^{k-j} $$

考虑枚举k-j的值:$$\sum_{k=0}^n b_k x^k=\sum_{i=0}^n \sum_{d=0}^{n-i} a_{i+d} \tbinom{i}{i+d} t^d x^i $$

对齐每一项的系数,得到:

$$b_m = \sum_{d=0}^{n-m} a_{m+d} \frac{(m+d)! t^d}{m!d!}$$

注意到n-m不超过5,我们可以先得出$a_m$的值,递推(n-m)次把答案加起来即可。

考虑到n和m都可以很大,这里在求$a_m$的值时要用到10-based的矩阵快速幂。

代码:

  1 #include <cstdio>
  2 #include <cstring>
  3 #include <cstdlib>
  4 #include <ctime>
  5 #include <cctype>
  6 #include <algorithm>
  7 #include <cmath>
  8 using namespace std;
  9 //#define USEFREAD
 10 #ifdef USEFREAD
 11 #define InputLen 1000000
 12 char *ptr=(char *)malloc(InputLen);
 13 #define getc() (*(ptr++))
 14 #else
 15 #define getc() (getchar())
 16 #endif
 17 #define SetFile(x) (freopen(#x".in", "r", stdin), freopen(#x".out", "w", stdout))
 18 template<class T>inline void getd(T &x){
 19     char ch = getc();bool neg = false;
 20     while(!isdigit(ch) && ch != '-')ch = getc();
 21     if(ch == '-')ch = getc(), neg = true;
 22     x = ch - '';
 23     while(isdigit(ch = getc()))x = x *  - '' + ch;
 24     if(neg)x = -x;
 25 }
 26 /***********************************************************************/
 27 typedef unsigned uint;
 28 const uint mod = , maxn = , base = ;
 29 uint t, dmax, An;
 30 
 31 struct BigNum;
 32 /********************************************
 33 ***************高精度模板略****************
 34 ********************************************/
 35 
 36 struct Mat{uint a, b, c, d;Mat(uint w,uint x,uint y,uint z):a(w),b(x),c(y),d(z){}}F(,,,);
 37 inline void operator *= (Mat &x, const Mat &y){
 38     uint a = (x.a * y.a + x.b * y.c) % mod,
 39         b = (x.a * y.b + x.b * y.d) % mod,
 40         c = (x.c * y.a + x.d * y.c) % mod,
 41         d = (x.c * y.b + x.d * y.d) % mod;
 42     x = Mat(a, b, c, d);
 43 }
 44 
 45 inline Mat powmod(Mat a, uint n){
 46     Mat ans(,,,);
 47     while(n){
 48         if(n & )ans *= a;
 49         a *= a;
 50         n >>= ;
 51     }
 52     return ans;
 53 }
 54 inline Mat powmod(Mat a, const BigNum &n){
 55 //其实应该叫“万进制快速幂”……23333
 56     const int *it = n.a, *end = it + n.len;
 57     Mat ans(,,,);
 58     while(it < end){
 59         if(*it)ans *= powmod(a, *it);
 60         a = powmod(a, base);
 61         ++it;
 62     }
 63     return ans;
 64 }
 65 
 66 inline void init(){
 67     cin >> N;getd(t);cin >> M;
 68     int tmp = *N.a - *M.a;if(tmp < )tmp += base;
 69     dmax = tmp;
 70     Mat tf = powmod(F, M);
 71     An = (tf.a + tf.c) % mod;
 72 }
 73 
 74 inline void work(){
 75     BigNum Ans = An;
 76     uint d;
 77     for(d = ;d <= dmax;++d){
 78         fd = (fd * (M + d) * t) / d;
 79         An = (An *  + ) % mod;
 80         Ans = Ans + fd * An;
 81     }
 82     Ans.print();
 83 }
 84 
 85 int main(){
 86     #ifdef DEBUG
 87     freopen("test.txt", "r", stdin);
 88     #else
 89     SetFile(cqoi15_polynomial);
 90     #endif
 91     #ifdef USEFREAD
 92     fread(ptr,,InputLen,stdin);
 93     #endif
 94     
 95     init();
 96     work();
 97     
 98 #ifdef DEBUG
 99     printf("\n%.3lf sec \n", (double)clock() / CLOCKS_PER_SEC);
 #endif
     return ;
 }

高精度+十进制矩阵快速幂

E.标识设计

题意:

链接:COGS 1938

分析:

我真的是昨天才知道这个“标识”的“识”应该念zhi(4)……我真是文盲……

思路是轮廓线dp,dp状态记录扫描到某个位置时“是否需要连接左边的方格”,“当前已经放下了多少个L”和当前的轮廓。(这里“轮廓”的含义是有哪些列需要连接上方垂下来的竖直线)。由于任意状态垂下来的竖直线最多只有3条,轮廓的状态数很少(暴力枚举一下发现只有4090左右),可以利用离散化减少压位的数量。但以我极差的代码能力实在卡不进1s的时间限制……看了这位神犇的博客之后才知道上述的状态中“不合法状态”和“不可能到达的状态”都很多,所以用记忆化搜索来实现可以大大缩短枚举的时间。

代码:

 1 #include <cstdio>
 2 #include <cstring>
 3 #include <cstdlib>
 4 #include <ctime>
 5 #include <cctype>
 6 #include <algorithm>
 7 #include <cmath>
 8 using namespace std;
 9 #define USEFREAD
 #ifdef USEFREAD
 #define InputLen 1000
 char CHARPOOL[InputLen], *ptr=CHARPOOL;
 #define getc() (*(ptr++))
 #else
 #define getc() (getchar())
 #endif
 #define SetFile(x) (freopen(#x".in", "r", stdin), freopen(#x".out", "w", stdout))
 template<class T>inline void getd(T &x){
     char ch = getc();bool neg = false;
     while(!isdigit(ch) && ch != '-')ch = getc();
     if(ch == '-')ch = getc(), neg = true;
     x = ch - '';
     while(isdigit(ch = getc()))x = x *  - '' + ch;
     if(neg)x = -x;
 }
 /***********************************************************************/
 typedef long long LL;
 LL f[][][][][], Ans;//f[放了几个][列覆盖状态][是否要向右延伸][x][y] = 方案数
 int N, M, ST[], Scnt = ;
 #define id(x) (lower_bound(ST, ST + Scnt, x) - ST)
 #define bin(x) (1 << x)
 bool G[][];
 
 inline void init(){
     getd(N), getd(M);
     memset(f, -, sizeof(f));
     int i, j, k;
     for(i = ;i < N;++i){
         while((k = getc()) != '.' && k != '#');
         for(j = ;j < M;++j){
             G[i][j] = (k == '#');
             k = getc();
         }
     }
     for(i = ;i+ < M;++i){
         ST[Scnt++] = bin(i);
         for(j = ;j < i;++j){
             ST[Scnt++] = bin(i) | bin(j);
             for(k = ;k < j;++k)ST[Scnt++] = bin(i) | bin(j) | bin(k);
         }
     }
 }
 LL dp(bool lk, int cnt, int i, int j, int St){
     LL &ans = f[cnt][St][lk][i][j];
     if(~ans)return ans;
     ans = ;
     if(i == N)return ans = (!lk && !St && !cnt);
     if(j == M){if(!lk)ans = dp(,cnt,i+,,St);return ans;}
     register int b = bin(j), st = ST[St];
     if(lk && (b & st))return ;
     if(lk){//from left
         if(G[i][j])return ;
         return ans = dp(,cnt,i,j+,St) + dp(,cnt,i,j+,St);
     }
     if(b & st){//from above
         if(G[i][j])return ;
         return ans = dp(,cnt,i,j+,id(st^b)) + dp(,cnt,i,j+,St);
     }
     ans = dp(,cnt,i,j+,St);//skip 
     if(!G[i][j] && cnt && j+ < M)ans += dp(,cnt-,i,j+,id(st^b));// new
     return ans;
 }
 
 int main(){
     #ifdef DEBUG
     freopen("test.txt", "r", stdin);
     #else
     SetFile(cqoi15_logo);
     #endif
     #ifdef USEFREAD
     fread(ptr,,InputLen,stdin);
     #endif
     init();
     printf("%lld\n", dp(,,,,));
     
 #ifdef DEBUG
     printf("\n%.3lf sec \n", (double)clock() / CLOCKS_PER_SEC);
 #endif
     return ;
 }

轮廓线dp(用记忆化搜索实现)

最新文章

  1. 20145205 《Java程序设计》实验报告五:Java网络编程及安全
  2. git usage:常用git命令
  3. jquery-easyui-tree异步树
  4. 对JavaScript优化及规范的一些感想
  5. 设计模式学习之外观模式(Facade,结构型模式)(8)
  6. python Shapely 使用指南
  7. Drupal 7.23版本升级笔记
  8. CentOS 配置solr中文分词器
  9. android 在一个scrollView里面嵌套一个需要滑动的控件(listView、gridView)
  10. linux shadowsocket 安装和启动
  11. DNA序列组装(贪婪算法)
  12. Gradle 1.12用户指南翻译——第三十二章. JDepend 插件
  13. linux安装elk
  14. This application failed to start because it could not find or load the Qt platform plugin异常
  15. springboot+dubbo提示超时
  16. 如何备份/迁移wordpress网站
  17. Oracl数据库+PL/SQL安装与配置
  18. 细说tomcat之应用监控
  19. java笔记 -- java运算
  20. SpringBoot日记——分布式篇

热门文章

  1. Wood Cut
  2. 你真的了解js伪数组吗?深入js伪数组
  3. inherited 的研究。
  4. MySql数据库 主从复制/共享 报错
  5. 整理一下关于Crypto加密的坑
  6. BZOJ囤题计划
  7. js和php计算图片自适应宽高算法实现
  8. 【LOJ】#2041. 「SHOI2015」聚变反应炉
  9. 【POJ】2165.Gunman
  10. 包装印刷行业裕同集团&amp;易普优APS项目顺利验收!