Preface

最近恰好不知道做什么题,所以就按老叶要求做上面的比赛。

稍微看了下感觉难度适中,大部分题目偏向联赛难度,当然也有些题目打到了省选题的感觉(基本都是Div1的题)

这里就简单拿一些我做得动的题讲一下吧。排列顺序按照我做的顺序排(不一定按难度


F 爬爬爬山

开的时候先看了一眼榜,发现这题过的人最多,那么肯定最可做

看了题目想了大概5min才出解吧,我感觉我水题秒的还是不够快啊

首先容易发现只有所有高度\(>h_1+k\)的山需要降低高度,那么我们可以直接拆点

入点和出点之前连这座山需要降低的高度的代价(不改就赋为\(0\)),然后无向图建边,出点连入点

然后不就是最短路了么,随便写个DJ就过了(乘法没开long longWA了2发)

CODE

  1. #include<cstdio>
  2. #include<cctype>
  3. #include<queue>
  4. #define RI register int
  5. #define CI const int&
  6. #define Tp template <typename T>
  7. using namespace std;
  8. typedef long long LL;
  9. const int N=100005;
  10. const LL INF=1e18;
  11. struct edge
  12. {
  13. int to,nxt; LL v;
  14. }e[N*5]; int n,m,k,head[N<<1],cnt,h[N],x,y,z;
  15. class FileInputOutput
  16. {
  17. private:
  18. static const int S=1<<21;
  19. #define tc() (A==B&&(B=(A=Fin)+fread(Fin,1,S,stdin),A==B)?EOF:*A++)
  20. char Fin[S],*A,*B;
  21. public:
  22. Tp inline void read(T& x)
  23. {
  24. x=0; char ch; while (!isdigit(ch=tc()));
  25. while (x=(x<<3)+(x<<1)+(ch&15),isdigit(ch=tc()));
  26. }
  27. #undef tc
  28. }F;
  29. class SSSP
  30. {
  31. private:
  32. struct data
  33. {
  34. int id; LL val;
  35. inline data(CI Id=0,const LL& Val=0)
  36. {
  37. id=Id; val=Val;
  38. }
  39. inline friend bool operator < (const data& A,const data &B)
  40. {
  41. return A.val>B.val;
  42. }
  43. }; priority_queue <data> small; int all; bool vis[N<<1]; LL dis[N<<1];
  44. public:
  45. #define to e[i].to
  46. inline void Dijkstra(void)
  47. {
  48. RI i; for (i=2,all=n<<1;i<=all;++i) dis[i]=INF;
  49. small.push(data(1,0)); while (!small.empty())
  50. {
  51. int now=small.top().id; small.pop();
  52. if (vis[now]) continue; vis[now]=1;
  53. for (i=head[now];i;i=e[i].nxt)
  54. if (!vis[to]&&dis[to]>dis[now]+e[i].v)
  55. small.push(data(to,dis[to]=dis[now]+e[i].v));
  56. }
  57. printf("%lld",dis[all]);
  58. }
  59. #undef to
  60. }G;
  61. inline void add(CI x,CI y,const LL& z)
  62. {
  63. e[++cnt]=(edge){y,head[x],z}; head[x]=cnt;
  64. }
  65. inline LL sqr(CI x)
  66. {
  67. return x<0?0:1LL*x*x;
  68. }
  69. int main()
  70. {
  71. //freopen("CODE.in","r",stdin); freopen("CODE.out","w",stdout);
  72. RI i; for (F.read(n),F.read(m),F.read(k),i=1;i<=n;++i) F.read(h[i]);
  73. for (i=1;i<=n;++i) add(i,n+i,sqr(h[i]-h[1]-k)); for (i=1;i<=m;++i)
  74. F.read(x),F.read(y),F.read(z),add(n+x,y,z),add(n+y,x,z);
  75. return G.Dijkstra(),0;
  76. }

J 夺宝奇兵

其实并不是很适合二开的题目,但是先看到这题感觉不错就先写了,然后调一个边界花了半个多小时

先讲一下Div2版本的做法,我们可以枚举所有村民的宝物最大值,然后把大于这个值的村民的物品低价都拿了

然后如果不够怎么办,在剩下的里面拿小的知道超过这个最大值即可

但是这样复杂度\(O(nm)\),无法在Div1中通过

那么我们考虑优化,其实思想还是一样的,由于物品一共只有\(m\)个,我们可以想象对于每个人的物品按价格从小到大从上到下放置,那么我们倒序枚举最大值,那些物品是不是一个一层一层被取走的感觉

我们在维护被取走的物品的个数和总价值的同时,由于可能要有补足,所以要动态维护剩下的物品里的前\(k\)小值和

这个套路吧,一发值域线段树随便跑,复杂度\(O(m\log 10^9)\)

这里Div2的暴力懒得写了,所以直接上Div的CODE吧

  1. #include<cstdio>
  2. #include<cctype>
  3. #include<vector>
  4. #include<algorithm>
  5. #define RI register int
  6. #define CI const int&
  7. #define Tp template <typename T>
  8. using namespace std;
  9. typedef long long LL;
  10. const int N=100005,S=1e9;
  11. int n,m,x,y,mx,cur,lim; LL ans=1e18,ret; vector <int> v[N],p[N];
  12. class FileInputOutput
  13. {
  14. private:
  15. static const int S=1<<21;
  16. #define tc() (A==B&&(B=(A=Fin)+fread(Fin,1,S,stdin),A==B)?EOF:*A++)
  17. char Fin[S],*A,*B;
  18. public:
  19. Tp inline void read(T& x)
  20. {
  21. x=0; char ch; while (!isdigit(ch=tc()));
  22. while (x=(x<<3)+(x<<1)+(ch&15),isdigit(ch=tc()));
  23. }
  24. #undef tc
  25. }F;
  26. class Segment_Tree
  27. {
  28. private:
  29. static const int P=30;
  30. struct Segment
  31. {
  32. int ch[2],size; LL sum;
  33. }node[N*P]; int tot;
  34. public:
  35. int rt;
  36. #define lc(x) node[x].ch[0]
  37. #define rc(x) node[x].ch[1]
  38. #define Si(x) node[x].size
  39. #define S(x) node[x].sum
  40. inline void modify(int& now,CI val,CI opt,CI l=1,CI r=S)
  41. {
  42. if (!now) now=++tot; Si(now)+=opt; S(now)+=opt*val; if (l==r) return; int mid=l+r>>1;
  43. if (val<=mid) modify(lc(now),val,opt,l,mid); else modify(rc(now),val,opt,mid+1,r);
  44. }
  45. inline LL query(CI now,CI rk,CI l=1,CI r=S)
  46. {
  47. if (!now) return 0; if (l==r) return 1LL*l*rk; int mid=l+r>>1;
  48. return rk<=Si(lc(now))?query(lc(now),rk,l,mid):S(lc(now))+query(rc(now),rk-Si(lc(now)),mid+1,r);
  49. }
  50. #undef lc
  51. #undef rc
  52. #undef Si
  53. #undef S
  54. }T;
  55. inline bool cmp(CI x,CI y)
  56. {
  57. return x>y;
  58. }
  59. inline void maxer(int& x,int y)
  60. {
  61. if (y>x) x=y;
  62. }
  63. int main()
  64. {
  65. //freopen("CODE.in","r",stdin); freopen("CODE.out","w",stdout);
  66. RI i,j; for (F.read(n),F.read(m),i=1;i<=m;++i)
  67. F.read(x),F.read(y),v[y].push_back(x),T.modify(T.rt,x,1);
  68. for (i=1;i<=n;++i) sort(v[i].begin(),v[i].end(),cmp),maxer(mx,v[i].size());
  69. for (i=1;i<=n;++i) for (lim=v[i].size(),j=0;j<lim;++j)
  70. p[j+1].push_back(v[i][j]); for (i=mx+1;~i;--i)
  71. {
  72. for (lim=p[i].size(),cur+=lim,j=0;j<lim;++j)
  73. T.modify(T.rt,p[i][j],-1),ret+=p[i][j]; LL cost;
  74. if (cur>=i) cost=ret; else cost=ret+T.query(T.rt,i-cur);
  75. if (cost<ans) ans=cost;
  76. }
  77. return printf("%lld",ans),0;
  78. }

C 拆拆拆数

构造题?首先大力猜测答案不会很大!并顺手判掉\(n=1\)的情况

然后我首先想到了\(2\)于所有奇数互质,所以如果\(A,B\)都是奇数那么肯定可以分成\((A-2,2),(2,B-2)\)的形式

那有了偶数怎么办?还是利用上面的结论,由于这里的数都\(\ge 5\),因此肯定可以分成奇质数+奇数的形式

奇数的话我们还是从\(B\)里找一个\(2\)和它配对,那么接下来就是找一个奇质数于\(B-2\)互质了

由于前\(15\)个质数的累计已经超过了\(10^{18}\),所以我们大力枚举即可,复杂度最坏是单次\(O(15\log B)\)的

输出要注意一下,具体看CODE

  1. #include<cstdio>
  2. #include<cctype>
  3. #define int long long
  4. #define RI register int
  5. #define CI const int&
  6. #define Tp template <typename T>
  7. using namespace std;
  8. const int prime[15]={3,5,7,11,13,17,19,23,29,31,37,41,43,47,51};
  9. int t,x,y;
  10. class FileInputOutput
  11. {
  12. private:
  13. static const int S=1<<21;
  14. #define tc() (A==B&&(B=(A=Fin)+fread(Fin,1,S,stdin),A==B)?EOF:*A++)
  15. #define pc(ch) (Ftop<S?Fout[Ftop++]=ch:(fwrite(Fout,1,S,stdout),Fout[(Ftop=0)++]=ch))
  16. char Fin[S],Fout[S],*A,*B; int Ftop,pt[25];
  17. public:
  18. Tp inline void read(T& x)
  19. {
  20. x=0; char ch; while (!isdigit(ch=tc()));
  21. while (x=(x<<3)+(x<<1)+(ch&15),isdigit(ch=tc()));
  22. }
  23. Tp inline void write(T x,const char& ch)
  24. {
  25. if (!x) return (void)(pc('0'),pc(ch)); RI ptop=0;
  26. while (x) pt[++ptop]=x%10,x/=10; while (ptop) pc(pt[ptop--]+48); pc(ch);
  27. }
  28. inline void Fend(void)
  29. {
  30. fwrite(Fout,1,Ftop,stdout);
  31. }
  32. #undef tc
  33. #undef pc
  34. }F;
  35. inline int gcd(CI x,CI y)
  36. {
  37. return y?gcd(y,x%y):x;
  38. }
  39. signed main()
  40. {
  41. //freopen("CODE.in","r",stdin); freopen("CODE.out","w",stdout);
  42. for (F.read(t);t;--t)
  43. {
  44. F.read(x); F.read(y);
  45. if (gcd(x,y)==1)
  46. {
  47. F.write(1,'\n'); F.write(x,' ');
  48. F.write(y,'\n'); continue;
  49. }
  50. F.write(2,'\n'); if ((x&1)&&(y&1))
  51. {
  52. F.write(2,' '); F.write(y-2,'\n');
  53. F.write(x-2,' '); F.write(2,'\n'); continue;
  54. }
  55. bool flag=0; if (x&1) { int t=x; x=y; y=t; flag=1; }
  56. for (RI i=0;i<15;++i) if (gcd(prime[i],y-2)==1)
  57. {
  58. if (flag)
  59. {
  60. F.write(y-2,' '); F.write(prime[i],'\n');
  61. F.write(2,' '); F.write(x-prime[i],'\n'); break;
  62. } else
  63. {
  64. F.write(prime[i],' '); F.write(y-2,'\n');
  65. F.write(x-prime[i],' '); F.write(2,'\n'); break;
  66. }
  67. }
  68. }
  69. return F.Fend(),0;
  70. }

E 流流流动

这些题目名都是什么鬼?感觉这题分析成分更大一些。。。

首先那个连边方式你如果有一定数学基础的话很容易发现这个转移方式就是角谷猜想的形式。

乍一看角谷猜想是必然成环的,所以我开始就认为这种成环的东西不好做

不够如果你仔细读题的话会发现\(i=1\)的时候是不建边的,所以角谷猜想的关键步骤——以\(1\)为中转循环就被打破了

所以其实这个图是一个森林的形式,然后就是对每个联通块做一个简单DP即可。

CODE

  1. #include<cstdio>
  2. #define RI register int
  3. #define CI const int&
  4. using namespace std;
  5. const int N=105;
  6. struct edge
  7. {
  8. int to,nxt;
  9. }e[N<<1]; int n,head[N],cnt,a[N],b[N],f[N][2],ans; bool vis[N];
  10. inline void addedge(CI x,CI y)
  11. {
  12. e[++cnt]=(edge){y,head[x]}; head[x]=cnt;
  13. e[++cnt]=(edge){x,head[y]}; head[y]=cnt;
  14. }
  15. inline int min(CI a,CI b)
  16. {
  17. return a<b?a:b;
  18. }
  19. inline int max(CI a,CI b)
  20. {
  21. return a>b?a:b;
  22. }
  23. #define to e[i].to
  24. inline void DP(CI now,CI fa)
  25. {
  26. f[now][0]=0; f[now][1]=a[now]; vis[now]=1;
  27. for (RI i=head[now];i;i=e[i].nxt) if (to!=fa)
  28. {
  29. DP(to,now); f[now][0]+=max(f[to][0],f[to][1]);
  30. f[now][1]+=max(f[to][0],f[to][1]-b[min(now,to)]);
  31. }
  32. }
  33. #undef to
  34. int main()
  35. {
  36. RI i; for (scanf("%d",&n),i=1;i<=n;++i) scanf("%d",&a[i]);
  37. for (i=1;i<=n;++i) scanf("%d",&b[i]); for (i=2;i<=n;++i)
  38. if (i&1) { if ((3*i+1<=n)) addedge(i,3*i+1); } else addedge(i,i>>1);
  39. for (i=1;i<=n;++i) if (!vis[i]) DP(i,0),ans+=max(f[i][0],f[i][1]);
  40. return printf("%d",ans),0;
  41. }

I 起起落落

比较神的一道题,肝了一个晚上才出来233

首先容易想到一个暴力的DP,令\(f_i\)表示以\(i\)为结尾的答案,那么显然有转移:

\[f_i=\sum_{j<i} [p_j>p_i](f_j+1)\sum_{j<k<i} [p_k<p_i]
\]

这个可以直接往前枚举\(j\)的时候顺带算出\([p_k<p_i]\)的个数,\(O(n^2)\)可以过Div2的范围

那么考虑优化,注意到\(p\)其实是一个排列,所以我们可以很方便地用权值线段树(怎么又是它)来维护答案

用一个思想,我们在计算贡献是先把它全部算上去,然后到后面在减去多算的贡献。

具体地,我们在枚举一个数的时候,先把它当做\(i\)算一遍答案,然后在当作\(z\)给后面的数加上次数,最后在当作\(j\)更新当前答案

这样只需要写一个奇怪的线段树即可维护答案了,复杂度\(O(n\log n)\)

CODE

  1. #include<cstdio>
  2. #include<cctype>
  3. #define RI register int
  4. #define CI const int&
  5. #define Tp template <typename T>
  6. using namespace std;
  7. const int N=100005,mod=1e9+7;
  8. int n,x,ans,cur;
  9. class FileInputOutput
  10. {
  11. private:
  12. static const int S=1<<21;
  13. #define tc() (A==B&&(B=(A=Fin)+fread(Fin,1,S,stdin),A==B)?EOF:*A++)
  14. char Fin[S],*A,*B;
  15. public:
  16. Tp inline void read(T& x)
  17. {
  18. x=0; char ch; while (!isdigit(ch=tc()));
  19. while (x=(x<<3)+(x<<1)+(ch&15),isdigit(ch=tc()));
  20. }
  21. #undef tc
  22. }F;
  23. inline void inc(int& x,CI y)
  24. {
  25. if ((x+=y)>=mod) x-=mod;
  26. }
  27. inline int sum(CI x,CI y)
  28. {
  29. int t=x+y; return t>=mod?t-mod:t;
  30. }
  31. class Segment_Tree
  32. {
  33. private:
  34. struct Segment
  35. {
  36. int base,val,tag;
  37. }node[N<<2];
  38. #define B(x) node[x].base
  39. #define V(x) node[x].val
  40. #define T(x) node[x].tag
  41. inline void pushup(CI now)
  42. {
  43. B(now)=sum(B(now<<1),B(now<<1|1)); V(now)=sum(V(now<<1),V(now<<1|1));
  44. }
  45. inline void pushdown(CI now)
  46. {
  47. if (!T(now)) return; inc(T(now<<1),T(now)); inc(V(now<<1),1LL*T(now)*B(now<<1)%mod);
  48. inc(T(now<<1|1),T(now)); inc(V(now<<1|1),1LL*T(now)*B(now<<1|1)%mod); T(now)=0;
  49. }
  50. public:
  51. #define TN CI now=1,CI l=1,CI r=n
  52. #define O beg,end
  53. inline int queryval(CI beg,CI end,TN)
  54. {
  55. if (beg<=l&&r<=end) return V(now); int mid=l+r>>1,ret=0; pushdown(now);
  56. if (beg<=mid) inc(ret,queryval(O,now<<1,l,mid));
  57. if (end>mid) inc(ret,queryval(O,now<<1|1,mid+1,r)); return ret;
  58. }
  59. inline int querybase(CI beg,CI end,TN)
  60. {
  61. if (beg<=l&&r<=end) return B(now); int mid=l+r>>1,ret=0; pushdown(now);
  62. if (beg<=mid) inc(ret,querybase(O,now<<1,l,mid));
  63. if (end>mid) inc(ret,querybase(O,now<<1|1,mid+1,r)); return ret;
  64. }
  65. inline void modify(CI beg,CI end,CI val,TN)
  66. {
  67. if (beg<=l&&r<=end) return (void)(inc(T(now),val),inc(V(now),1LL*val*B(now)%mod));
  68. int mid=l+r>>1; pushdown(now); if (beg<=mid) modify(O,val,now<<1,l,mid);
  69. if (end>mid) modify(O,val,now<<1|1,mid+1,r); pushup(now);
  70. }
  71. #undef O
  72. inline void updata(CI pos,CI mb,CI mv,TN)
  73. {
  74. if (l==r) return (void)(inc(B(now),mb),inc(V(now),mv)); int mid=l+r>>1; pushdown(now);
  75. if (pos<=mid) updata(pos,mb,mv,now<<1,l,mid); else updata(pos,mb,mv,now<<1|1,mid+1,r); pushup(now);
  76. }
  77. #undef TN
  78. #undef B
  79. #undef V
  80. #undef T
  81. }T;
  82. int main()
  83. {
  84. //freopen("CODE.in","r",stdin); freopen("CODE.out","w",stdout);
  85. RI i; for (F.read(n),i=1;i<=n;++i)
  86. {
  87. F.read(x); inc(ans,cur=T.queryval(x+1,n)); T.modify(x+1,n,1);
  88. T.updata(x,cur+1,sum(-T.querybase(x+1,n),mod));
  89. }
  90. return printf("%d",ans),0;
  91. }

A 机器人

一个大力分类讨论的题,WA了快一页才过去

其实主要就是两种大的情况:\(B\)区要走以及\(B\)区不走

不走的情况很简单,就走一条线段即可,要走的最远点可以直接搞出来

然后考虑要走的情况,其实肯定就是一个矩形,我们在\(A,B\)的所有点中找到两个端点即可

但是大坑点来了,如果直接这么做就会忽略一种情况:出发点在最优矩形的外面!

然后经过一波分析,容易得出直接走到矩形是最优的走法,所以要特判一下

注意各种细节,写的时候脑子一定要清醒

CODE

  1. #include<cstdio>
  2. #include<cctype>
  3. #include<algorithm>
  4. #define RI register int
  5. #define CI const int&
  6. #define Tp template <typename T>
  7. using namespace std;
  8. const int N=100005;
  9. int n,r,m,k,s,p[2][N],cnt[2],sp[N],cnt_sp,x,y,mi=1e9,mx,pmi,pmx;
  10. class FileInputOutput
  11. {
  12. private:
  13. static const int S=1<<21;
  14. #define tc() (A==B&&(B=(A=Fin)+fread(Fin,1,S,stdin),A==B)?EOF:*A++)
  15. char Fin[S],*A,*B;
  16. public:
  17. Tp inline void read(T& x)
  18. {
  19. x=0; char ch; while (!isdigit(ch=tc()));
  20. while (x=(x<<3)+(x<<1)+(ch&15),isdigit(ch=tc()));
  21. }
  22. #undef tc
  23. }F;
  24. inline void miner(int& x,CI y)
  25. {
  26. if (y<x) x=y;
  27. }
  28. inline void maxer(int& x,CI y)
  29. {
  30. if (y>x) x=y;
  31. }
  32. int main()
  33. {
  34. //freopen("CODE.in","r",stdin); freopen("CODE.out","w",stdout);
  35. RI i; for (F.read(n),F.read(r),F.read(m),F.read(k),F.read(s),i=1;i<=r;++i)
  36. F.read(x),F.read(y),p[y][++cnt[y]]=x; sp[1]=1; sp[cnt_sp=2]=n;
  37. for (i=1;i<=m;++i) F.read(x),sp[++cnt_sp]=x;
  38. sort(sp+1,sp+cnt_sp+1); cnt_sp=unique(sp+1,sp+cnt_sp+1)-sp-1;
  39. sort(p[0]+1,p[0]+cnt[0]+1); sort(p[1]+1,p[1]+cnt[1]+1);
  40. if (cnt[0]) miner(mi,p[0][1]),maxer(mx,p[0][cnt[0]]);
  41. if (cnt[1]) miner(mi,p[1][1]),maxer(mx,p[1][cnt[1]]);
  42. pmx=lower_bound(sp+1,sp+cnt_sp+1,mx)-sp; pmx=sp[pmx];
  43. pmi=upper_bound(sp+1,sp+cnt_sp+1,mi)-sp-1; pmi=sp[pmi];
  44. if (!cnt[1])
  45. {
  46. if (mx<=s) pmx=s; if (mi>=s) pmi=s;
  47. return printf("%d",pmx-pmi<<1),0;
  48. }
  49. int cur=(pmx-pmi<<1)+(k<<1);
  50. if (s<pmi) cur+=(pmi-s<<1); if (s>pmx) cur+=(s-pmx<<1);
  51. return printf("%d",cur),0;
  52. }

B 吃豆豆(only for Div2)

我太菜了所以只会这题Div2的做法,Div1的感觉可以大小步DP,总之肯定有什么规律

Div2的话由于\(c\le 1018\),所以我们直接大力DP,以颜色为状态转移感觉不是很好策,所以我们以时间为状态

令\(f_{i,j,k}\)表示时间\(k\)在\(i,j\)时最多能得到多少糖果,转移的话分四个方向移动和不动转移一下即可

一边打麻将一边写的,随便搞了搞也过了233

CODE

  1. #include<cstdio>
  2. #include<cctype>
  3. #include<cstring>
  4. #define RI register int
  5. #define CI const int&
  6. #define Tp template <typename T>
  7. using namespace std;
  8. const int N=15,C=1100;
  9. int n,m,c,t[N][N],f[N][N][N*C],sx,sy,tx,ty,ans;
  10. class FileInputOutput
  11. {
  12. private:
  13. static const int S=1<<21;
  14. #define tc() (A==B&&(B=(A=Fin)+fread(Fin,1,S,stdin),A==B)?EOF:*A++)
  15. char Fin[S],*A,*B;
  16. public:
  17. Tp inline void read(T& x)
  18. {
  19. x=0; char ch; while (!isdigit(ch=tc()));
  20. while (x=(x<<3)+(x<<1)+(ch&15),isdigit(ch=tc()));
  21. }
  22. #undef tc
  23. }F;
  24. inline void maxer(int& x,CI y)
  25. {
  26. if (y>x) x=y;
  27. }
  28. inline void miner(int& x,CI y)
  29. {
  30. if (y<x) x=y;
  31. }
  32. int main()
  33. {
  34. //freopen("CODE.in","r",stdin); freopen("CODE.out","w",stdout);
  35. RI i,j,k; for (F.read(n),F.read(m),F.read(c),i=1;i<=n;++i)
  36. for (j=1;j<=m;++j) F.read(t[i][j]); F.read(sx); F.read(sy);
  37. F.read(tx); F.read(ty); memset(f,167,sizeof(f));
  38. for (f[sx][sy][0]=0,k=0;k<=10*c;++k) for (i=1;i<=n;++i) for (j=1;j<=m;++j)
  39. {
  40. if (i-1>=1) maxer(f[i-1][j][k+1],f[i][j][k]+((k+1)%t[i-1][j]?0:1));
  41. if (i+1<=n) maxer(f[i+1][j][k+1],f[i][j][k]+((k+1)%t[i+1][j]?0:1));
  42. if (j-1>=1) maxer(f[i][j-1][k+1],f[i][j][k]+((k+1)%t[i][j-1]?0:1));
  43. if (j+1<=m) maxer(f[i][j+1][k+1],f[i][j][k]+((k+1)%t[i][j+1]?0:1));
  44. maxer(f[i][j][k+1],f[i][j][k]+((k+1)%t[i][j]?0:1));
  45. }
  46. for (k=0;k<=10*c;++k) if (f[tx][ty][k]>=c) { ans=k; break; }
  47. return printf("%d",ans),0;
  48. }

Postscript

据说镜像赛Rank前10就送T恤,感觉如果现场打的话可能可以切出\(4,5\)题吧

所以就可以到Div1骗衣服了?感觉这比赛没什么人打啊,有些题策不太动啊

CCPC-Wannafly Winter Camp Day1部分题目解析的更多相关文章

  1. 2020 CCPC Wannafly Winter Camp Day1 C. 染色图

    2020 CCPC Wannafly Winter Camp Day1 C. 染色图 定义一张无向图 G=⟨V,E⟩ 是 k 可染色的当且仅当存在函数 f:V↦{1,2,⋯,k} 满足对于 G 中的任 ...

  2. 2020 CCPC Wannafly Winter Camp Day1 - I. K小数查询(分块)

    题目链接:K小数查询 题意:给你一个长度为$n$序列$A$,有$m$个操作,操作分为两种: 输入$x,y,c$,表示对$i\in[x,y] $,令$A_{i}=min(A_{i},c)$ 输入$x,y ...

  3. 2020 CCPC Wannafly Winter Camp Day1 Div.1&amp F

    #include<bits/stdc++.h> #define forn(i, n) for (int i = 0; i < int(n); i++) #define fore(i, ...

  4. CCPC Wannafly Winter Camp Div2 部分题解

    Day 1, Div 2, Prob. B - 吃豆豆 题目大意 wls有一个\(n\)行\(m\)列的棋盘,对于第\(i\)行第\(j\)列的格子,每过\(T[i][j]\)秒会在上面出现一个糖果, ...

  5. 2020 CCPC Wannafly Winter Camp Day2-K-破忒头的匿名信

    题目传送门 sol:先通过AC自动机构建字典,用$dp[i]$表示长串前$i$位的最小代价,若有一个单词$s$是长串的前$i$项的后缀,那么可以用$dp[i - len(s)] + val(s)$转移 ...

  6. 2020 CCPC Wannafly Winter Camp Day1-F-乘法

    题目传送门 sol:二分答案$K$,算大于$K$的乘积有多少个.关键在于怎么算这个个数,官方题解上给出的复杂度是$O(nlogn)$,那么计算个数的复杂度是$O(n)$的.感觉写着有点困难,自己写了一 ...

  7. 2019 wannafly winter camp day 3

    2019 wannafly winter camp day 3 J 操作S等价于将S串取反,然后依次遍历取反后的串,每次加入新字符a,当前的串是T,那么这次操作之后的串就是TaT.这是第一次转化. 涉 ...

  8. 2019 wannafly winter camp

    2019 wannafly winter camp Name Rank Solved A B C D E F G H I J K day1 9 5/11 O O O O O day2 5 3/11 O ...

  9. CCPC-Wannafly Winter Camp Day1 (Div2 ABCFJ) 待补...

    Day1 Div2 场外链接 按题目顺序~ A 机器人 传送门 题意:有两条平行直线A.B,每条直线上有n个点,编号为1~n.在同一直线上,从a站点到b站点耗时为两点间的距离.存在m个特殊站点,只有在 ...

随机推荐

  1. 如何理解git checkout -- file和git reset HEAD -- file

    http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000/001374831943254ee ...

  2. jumpserver篇--安装(高可用性 mariadb+haproxy)

    1. 需求 为了解决目前登陆方式多种多样,防火墙配置复杂,历史操作无记录,用户权限混乱等等 2. Jumpserver测试环境搭建 2.1. 环境 os:CentOS release 6.8 mini ...

  3. vm12 安装ubuntu15.10详细图文教程 虚拟机安装ubuntu安装 ubuntu更新软件 ubuntu一直卡在下载语言怎么办?

    1,准备工作-ubuntu下载 ubuntu官网下载 如何官网下载ubuntu http://www.ubuntu.com/download/ 2,打开虚拟机 虚拟机安装ubuntu15.10 虚拟机 ...

  4. 最近一年语义SLAM有哪些代表性工作?

    点击"计算机视觉life"关注,置顶更快接收消息! 本文由作者刘骁授权发布,转载请联系原作者,个人主页http://www.liuxiao.org 目前 Semantic SLAM ...

  5. Haskell复习笔记(二)

    Haskell中的递归 递归就是定义函数以调用自身的方式,关于递归解决问题的实例有很多,如斐波那契数列,还有汉诺塔问题,递归也正是Haskell中用来解决循环问题的关键. 自定义maxinum函数 m ...

  6. InnoSetup 客户端程序打包教程

    之前介绍过InstallShield打包工具,本文再介绍更加方便的打包工具Inno Setup Inno Setup相对来说,比InstallShield更容易使用,不需要在VS中创建项目,只要提供D ...

  7. Fundebug前端JavaScript插件更新至1.7.1,拆分录屏代码,还原部分Script error.

    摘要: BUG监控插件压缩至18K. 1.7.1拆分了录屏代码,BUG监控插件压缩至18K,另外我们还原了部分Script error,帮助用户更方便地Debug.请大家及时更新哈~ 拆分录屏代码 从 ...

  8. 【转】Js正则表达式

    //校验是否全由数字组成 var patrn=/^[0-9]{1,20}$/ //校验登录名:只能输入5-20个以字母开头.可带数字.“_”.“.”的字串 var patrn=/^[a-zA-Z]{1 ...

  9. vue HTTP 请求(vue-resource)

    来自:https://www.cnblogs.com/lhl66/p/8022423.html 侵删 //初始化页面需要做什么事情 //点击后需要做什么事情 //鼠标.键盘.冒泡.默认行为等事件 // ...

  10. 【Linux】【Java】CentOS7安装最新版Java1.8.191运行开发环境

    1.前言 本来在写[Linux][Apatch Tomcat]安装与运行.都快写完了. 结果...我忘记安装 Java 环境 然后...新开了博客编辑页面. 最后...我的那个没了...没了...真的 ...