2016.11.15

BZOJ1009:DP+矩阵乘法+KMP

BZOJ1898:矩阵乘法

BZOJ4101:贪心,考虑我们往右边撞的时候,我们会向左边冲

      ,于是枚举答案点利用一个指针计算即可!

2016.11.14

OI队内测试

2016.11.13

BZOJ4512:乱搞

BZOJ4102:DP+bfs

BZOJ4395:bfs

BZOJ3889:双键值最短路

  1. BZOJ4512
  2.  
  3. #include <bits/stdc++.h>
  4. using namespace std;
  5. #define LL long long
  6. int N,sx,sy,ans;
  7. char s[];
  8. bool vis[][],north[][],east[][];
  9. int main(){
  10. // freopen("data.in","r",stdin);
  11. // freopen("A.out","w",stdout);
  12. scanf("%d%s",&N,s);
  13. sx=sy=;
  14. for (int i=;i<N;i++){
  15. vis[sx][sy]=;
  16. char ch=s[i];
  17. if (ch=='N'){
  18. sy++;
  19. if (!north[sx][sy-]&&vis[sx][sy])ans++;
  20. north[sx][sy-]=;
  21. }
  22. if (ch=='S'){
  23. sy--;
  24. if (!north[sx][sy]&&vis[sx][sy])ans++;
  25. north[sx][sy]=;
  26. }
  27. if (ch=='E'){
  28. sx++;
  29. if (!east[sx-][sy]&&vis[sx][sy])ans++;
  30. east[sx-][sy]=;
  31. }
  32. if (ch=='W'){
  33. sx--;
  34. if (!east[sx][sy]&&vis[sx][sy])ans++;
  35. east[sx][sy]=;
  36. }
  37. }
  38. printf("%d\n",ans);
  39. }
  40.  
  41. BZOJ4102
  42.  
  43. #include<iostream>
  44. #include<algorithm>
  45. #include<cstring>
  46. #include<cstdio>
  47. #include<cmath>
  48. #include<queue>
  49. #define ll long long
  50. #define ld long double
  51. #define N 1005
  52. #define M N*(N+1)
  53. using namespace std;
  54. int n,p,tot;
  55. int pre[M],v[M],now[N],f[N],dis[N][N];
  56. bool vis[N];
  57. queue<int>q;
  58. struct data{
  59. int val,pos;
  60. }a[N];
  61. int read()
  62. {
  63. int x=,f=; char ch;
  64. while (ch=getchar(),ch<''||ch>'') if (ch=='-') f=-;
  65. while (x=x*+ch-'',ch=getchar(),ch>=''&&ch<='');
  66. return x*f;
  67. }
  68. void ins(int a,int b){++tot; pre[tot]=now[a]; now[a]=tot; v[tot]=b;
  69. }
  70. bool cmp(data a,data b){return a.val<b.val;
  71. }
  72. void bfs(int u)
  73. {
  74. memset(vis,,sizeof(vis));
  75. q.push(u); dis[u][u]=; vis[u]=;
  76. while (!q.empty())
  77. {
  78. int x=q.front(); q.pop();
  79. for (int p=now[x]; p; p=pre[p])
  80. {
  81. int son=v[p];
  82. if (!vis[son])
  83. {
  84. dis[u][son]=dis[u][x]+;
  85. q.push(son); vis[son]=;
  86. }
  87. }
  88. }
  89. }
  90. int main()
  91. {
  92. n=read(); p=read();
  93. for (int i=; i<=n; i++)
  94. {
  95. int x=read(),d=read();
  96. a[i].val=x; a[i].pos=i;
  97. for (int j=; j<=d; j++) {int y=read(); ins(i,y); ins(y,i);}
  98. }
  99. for (int i=; i<=n; i++) bfs(i);
  100. sort(a+,a+n+,cmp);
  101. for (int i=; i<=n; i++) f[i]=a[i].val;
  102. for (int i=; i<=n; i++)
  103. for (int j=; j<=i-; j++)
  104. {
  105. if (a[i].val>a[j].val && dis[a[i].pos][a[j].pos])
  106. {
  107. f[i]=max(f[i],f[j]-dis[a[i].pos][a[j].pos]*p+a[i].val);
  108. }
  109. }
  110. int ans=;
  111. for (int i=; i<=n; i++) ans=max(ans,f[i]);
  112. printf("%d\n",ans);
  113. return ;
  114. }
  115.  
  116. BZOJ4395
  117.  
  118. #include<iostream>
  119. #include<algorithm>
  120. #include<cstring>
  121. #include<cstdio>
  122. #include<cmath>
  123. #include<queue>
  124. #define ll long long
  125. #define ld long double
  126. #define N 205
  127. #define M 40005
  128. using namespace std;
  129. int dx[]={,,,-},dy[]={,-,,};
  130. int pre[M],v[M],now[N*N],tot;
  131. int n,m,ans;
  132. queue<int>q;
  133. bool vis[N][N],lig[N][N];
  134. int read()
  135. {
  136. int x=,f=; char ch;
  137. while (ch=getchar(),ch<''||ch>'') if (ch=='-') f=-;
  138. while (x=x*+ch-'',ch=getchar(),ch>=''&&ch<='');
  139. return x*f;
  140. }
  141. int encode(int a,int b){return (a-)*n+b;
  142. }
  143. void ins(int a,int b){
  144. ++tot; pre[tot]=now[a]; now[a]=tot; v[tot]=b;
  145. }
  146. int main()
  147. {
  148. n=read(); m=read();
  149. for (int i=; i<=m; i++)
  150. {
  151. int a=read(),b=read(),c=read(),d=read();
  152. ins(encode(a,b),encode(c,d));
  153. }
  154. int last=; ans=;
  155. for (;;)
  156. {
  157. q.push(encode(,));
  158. memset(vis,,sizeof(vis)); vis[][]=; lig[][]=;
  159. while (!q.empty())
  160. {
  161. int pp=q.front(),x,y; q.pop(); //last++;
  162. for (int p=now[pp]; p; p=pre[p])
  163. {
  164. int son=v[p]; x=(son-)/n+,y=(son-)%n+;
  165. if (!lig[x][y]) lig[x][y]=,ans++;
  166. }
  167. x=(pp-)/n+,y=(pp-)%n+;
  168. for (int i=; i<; i++)
  169. {
  170. int xx=x+dx[i],yy=y+dy[i];
  171. if (xx< || xx>n || yy< || yy>n || !lig[xx][yy] || vis[xx][yy]) continue;
  172. vis[xx][yy]=; q.push(encode(xx,yy));
  173. }
  174. }
  175. if (last==ans) break;
  176. last=ans;
  177. }
  178. printf("%d\n",ans);
  179. return ;
  180. }
  181.  
  182. BZOJ3889
  183.  
  184. #include<iostream>
  185. #include<algorithm>
  186. #include<cstring>
  187. #include<cstdio>
  188. #include<cmath>
  189. #include<queue>
  190. #define ll long long
  191. #define ld long double
  192. #define inf 100000000000000
  193. #define N 1005
  194. using namespace std;
  195. int s,t,m,n;
  196. ll a[N][N],b[N][N],dis[N],d[N];
  197. int c[N];
  198. bool vis[N];
  199. queue<int>q;
  200. int read()
  201. {
  202. int x=,f=; char ch;
  203. while (ch=getchar(),ch<''||ch>'') if (ch=='-') f=-;
  204. while (x=x*+ch-'',ch=getchar(),ch>=''&&ch<='');
  205. return x*f;
  206. }
  207. void spfa()
  208. {
  209. for (int i=; i<=m; i++) dis[i]=inf;
  210. dis[s]=d[s]=; vis[s]=; q.push(s);
  211. while (!q.empty())
  212. {
  213. int x=q.front(); q.pop(); vis[x]=;
  214. //cout<<" "<<x<<endl;
  215. for (int i=; i<=m; i++)
  216. {
  217. // cout<<i<<" "<<dis[i]<<" "<<dis[x]<<" "<<a[x][i]<<endl;
  218. if (dis[i]>dis[x]+a[x][i] || ((dis[i]==dis[x]+a[x][i]) && d[i]>d[x]+b[x][i]))
  219. {
  220. // cout<<" "<<x<<" "<<i<<" "<<a[x][i]+dis[x]<<endl;
  221. dis[i]=dis[x]+a[x][i]; d[i]=d[x]+b[x][i];
  222. if (!vis[i]) vis[i]=,q.push(i);
  223. }
  224. }
  225. //|| (dis[i]==dis[x]+a[x][i] && d[i]>d[x]+b[x][i])
  226. }
  227. }
  228. int main()
  229. {
  230. s=read(); t=read(); n=read();
  231. for (int i=; i<=; i++)
  232. for (int j=; j<=; j++) a[i][j]=inf;
  233. for (int i=; i<=n; i++)
  234. {
  235. int len=read(),cnt=read();
  236. for (int j=; j<=cnt; j++) c[j]=read(),m=max(m,c[j]);
  237. for (int j=; j<=cnt; j++)
  238. for (int k=j+; k<=cnt; k++)
  239. if (a[c[j]][c[k]]>len || ((a[c[j]][c[k]]==len) && (b[c[j]][c[k]]>(k-j)))) a[c[j]][c[k]]=len,b[c[j]][c[k]]=k-j;
  240. }
  241. spfa();
  242. if (dis[t]==inf) dis[t]=-,d[t]=-;
  243. cout<<dis[t]<<" "<<d[t]<<endl;
  244. return ;
  245. }

2016.11.12

BZOJ3887: spfa(正边一次+反边一次)

BZOJ3886:状态压缩dp+二分(f[i]表示看电影状态为i的最长连续时间)

BZOJ4098:DP优化(f[i][j][k][l]:(i+j)==(k+l) 优化为f[i][j][k]:(i+j)满足滚动数组

BZOJ3888:把时间求出来+线段树

  1. BZOJ3887
  2.  
  3. #include<algorithm>
  4. #include<iostream>
  5. #include<cstring>
  6. #include<cstdio>
  7. #include<cmath>
  8. #include<queue>
  9. #define N 100005
  10. #define M 200005
  11. using namespace std;
  12. int read()
  13. {
  14. int x=,f=; char ch;
  15. while (ch=getchar(),ch<''||ch>'') if (ch=='-') f=-;
  16. while (x=x*+ch-'',ch=getchar(),ch>=''&&ch<='');
  17. return x*f;
  18. }
  19. int n,m;
  20. int a[N],b[N];
  21. int tot,pre[M],v[M],now[N];
  22. int bel[N],low[N],dfn[N],num[N],total,ind,top,z[N];
  23. int dist1[N],dist2[N];
  24. bool inq[N],vis[N];
  25. queue<int> q;
  26. void ins(int a,int b){++tot; pre[tot]=now[a]; now[a]=tot; v[tot]=b;}
  27. void tarjan(int x)
  28. {
  29. low[x]=dfn[x]=++ind;
  30. ++top; z[top]=x; inq[x]=;
  31. for (int p=now[x]; p; p=pre[p])
  32. {
  33. int son=v[p];
  34. if (!dfn[son]) tarjan(son),low[x]=min(low[x],low[son]);
  35. else if (inq[son]) low[x]=min(low[x],dfn[son]);
  36. }
  37. if (low[x]==dfn[x])
  38. {
  39. ++total; num[total]=; inq[x]=; bel[x]=total;
  40. while (z[top]!=x)
  41. {
  42. int son=z[top]; bel[son]=total; inq[son]=; num[total]++; top--;
  43. }
  44. top--;
  45. }
  46. }
  47. void build(int X)
  48. {
  49. memset(now,,sizeof(now)); tot=;
  50. for (int i=; i<=m; i++)
  51. {
  52. int x=a[i],y=b[i];
  53. if (bel[x]!=bel[y])
  54. {
  55. if (X==) ins(bel[x],bel[y]); else ins(bel[y],bel[x]);
  56. }
  57. }
  58. }
  59. void spfa1()
  60. {
  61. vis[bel[]]=; dist1[bel[]]=num[bel[]]; q.push(bel[]);
  62. while (!q.empty())
  63. {
  64. int x=q.front(); q.pop(); vis[x]=;
  65. for (int p=now[x]; p; p=pre[p])
  66. {
  67. int son=v[p];
  68. if (dist1[son]<dist1[x]+num[son])
  69. {
  70. dist1[son]=dist1[x]+num[son];
  71. if (!vis[son]) q.push(son),vis[son]=;
  72. }
  73. }
  74. }
  75. }
  76. void spfa2()
  77. {
  78. vis[bel[]]=; dist2[bel[]]=num[bel[]]; q.push(bel[]);
  79. while (!q.empty())
  80. {
  81. int x=q.front(); q.pop(); vis[x]=;
  82. for (int p=now[x]; p; p=pre[p])
  83. {
  84. int son=v[p];
  85. if (dist2[son]<dist2[x]+num[son])
  86. {
  87. dist2[son]=dist2[x]+num[son];
  88. if (!vis[son]) q.push(son),vis[son]=;
  89. }
  90. }
  91. }
  92. }
  93. int main()
  94. {
  95. n=read(); m=read();
  96. for (int i=; i<=m; i++) a[i]=read(),b[i]=read(),ins(a[i],b[i]);
  97. for (int i=; i<=n; i++) if (!dfn[i]) tarjan(i);
  98. build(); spfa1();
  99. build(); spfa2();
  100. int ans=;
  101. for (int i=; i<=m; i++) if (bel[a[i]]!=bel[b[i]] && dist1[bel[b[i]]] && dist2[bel[a[i]]])
  102. {
  103. ans=max(ans,dist1[bel[b[i]]]+dist2[bel[a[i]]]-num[bel[]]);
  104. }
  105. printf("%d\n",ans);
  106. return ;
  107. }
  108.  
  109. BZOJ3886
  110.  
  111. #include<iostream>
  112. #include<algorithm>
  113. #include<cstring>
  114. #include<cstdio>
  115. #include<cmath>
  116. using namespace std;
  117. int n,L;
  118. int num[],len[],c[][];
  119. int f[];
  120. int read()
  121. {
  122. int x=,f=; char ch;
  123. while (ch=getchar(),ch<''||ch>'') if (ch=='-') f=-;
  124. while (x=x*+ch-'',ch=getchar(),ch>=''&&ch<='');
  125. return x*f;
  126. }
  127. int find(int x,int s)
  128. {
  129. int l=,r=num[x],Ans=-;
  130. while (l<=r)
  131. {
  132. int mid=(l+r)>>;
  133. if (c[x][mid]<=s) Ans=mid,l=mid+; else r=mid-;
  134. }
  135. return Ans;
  136. }
  137. int main()
  138. {
  139. n=read(); L=read();
  140. for (int i=; i<=n; i++)
  141. {
  142. len[i]=read(); num[i]=read();
  143. for (int j=; j<=num[i]; j++) c[i][j]=read();
  144. }
  145. f[]=;
  146. int s=<<n,ans=0x7fffffff;
  147. for (int i=; i<s; i++) f[i]=-;
  148. for (int i=; i<s; i++)
  149. {
  150. if (f[i]==-) continue;
  151. int k=;
  152. if (f[i]>L)
  153. {
  154. for (int j=i; j; j>>=) if (j&) k++;
  155. ans=min(ans,k); continue;
  156. }
  157. for (int j=; j<=n; j++)
  158. {
  159. if (i&(<<(j-))) continue;
  160. int k=find(j,f[i]); if (k==-) continue;
  161. f[i|(<<(j-))]=max(f[i|(<<(j-))],c[j][k]+len[j]);
  162. }
  163. }
  164. if (ans==0x7fffffff) ans=-;
  165. printf("%d\n",ans);
  166. return ;
  167. }
  168.  
  169. BZOJ4098
  170.  
  171. #include<iostream>
  172. #include<algorithm>
  173. #include<cstring>
  174. #include<cstdio>
  175. #include<cmath>
  176. #define N 505
  177. #define mod 1000000007
  178. #define add(a,b) (a=(a+b)%mod)
  179. using namespace std;
  180. int n,f[][N][N];
  181. char s[N][N];
  182. int main()
  183. {
  184. scanf("%d",&n);
  185. for (int i=; i<=n; i++) scanf("%s",s[i]+);
  186. if(s[][]!=s[n][n])
  187. {
  188. puts("");
  189. return ;
  190. }
  191. int now=,last=;
  192. f[now][][]=;
  193. for (int h=; h<n; h++)
  194. {
  195. now^=; last^=;
  196. memset(f[now],,sizeof(f[now]));
  197. for (int i=; i<=h; i++)
  198. {
  199. int j=(h-i),a=i+,b=j+;
  200. for (int k=; k<=h; k++)
  201. {
  202. int l=h-k,x=n-l,y=n-k;
  203. /* if (s[a+1][b]==s[x][y-1]) (f[now][i+1][k+1]+=f[last][i][k])%mod;
  204. if (s[a+1][b]==s[x-1][y]) (f[now][i+1][k]+=f[last][i][k])%mod;
  205. if (s[a][b+1]==s[x][y-1]) (f[now][i][k+1]+=f[last][i][k])%mod;
  206. if (s[a][b+1]==s[x-1][y]) (f[now][i][k]+=f[last][i][k])%mod; */
  207. if(s[a+][b]==s[x-][y])add(f[now][i+][ k ],f[last][i][k]);
  208. if(s[a+][b]==s[x][y-])add(f[now][i+][k+],f[last][i][k]);
  209. if(s[a][b+]==s[x-][y])add(f[now][ i ][ k ],f[last][i][k]);
  210. if(s[a][b+]==s[x][y-])add(f[now][ i ][k+],f[last][i][k]);
  211. }
  212. }
  213. }
  214. int ans=;
  215. for (int i=; i<n; i++) add(ans,f[last][i][i]);
  216. printf("%d\n",ans);
  217. return ;
  218. }
  219.  
  220. BZOJ3888
  221.  
  222. #include<iostream>
  223. #include<algorithm>
  224. #include<cstring>
  225. #include<cstdio>
  226. #include<cmath>
  227. #define N 50005
  228. using namespace std;
  229. int n,tot;
  230. struct data{
  231. int h,l,r;
  232. }a[N];
  233. int b[*N],cov[N*];
  234. int read()
  235. {
  236. int x=,f=; char ch;
  237. while (ch=getchar(),ch<''||ch>'') if (ch=='-') f=-;
  238. while (x=x*+ch-'',ch=getchar(),ch>=''&&ch<='');
  239. return x*f;
  240. }
  241. bool cmp2(data a,data b){return a.h<b.h;
  242. }
  243. int get(int x,int c)
  244. {
  245. return x>=?:-x*c;
  246. }
  247. int cover(int k,int l,int r,int x,int y)
  248. {
  249. if (cov[k]) return ;
  250. if (x<=l && r<=y)
  251. {
  252. cov[k]=; return ;
  253. }
  254. bool ret=;
  255. int mid=(l+r)>>;
  256. if (x<=mid) ret|=cover(k*,l,mid,x,y);
  257. if (mid<y) ret|=cover(k*+,mid+,r,x,y);
  258. cov[k]=cov[k*]&cov[k*+];
  259. return ret;
  260. }
  261. int find(int x)
  262. {
  263. int l=,r=tot,ans=;
  264. while (l<=r)
  265. {
  266. int mid=(l+r)>>;
  267. if (b[mid]<=x) ans=mid,l=mid+; else r=mid-;
  268. }
  269. return ans;
  270. }
  271. int main()
  272. {
  273. n=read();
  274. for (int i=; i<=n; i++)
  275. {
  276. int x=read(),y=read(),c=read();
  277. int l=get(x+,c),r=get(x,c);
  278. a[i].l=l,a[i].r=r,a[i].h=y;
  279. b[++tot]=l; b[++tot]=r;
  280. }
  281. sort(b+,b+tot+);
  282. for (int i=; i<=n; i++) a[i].l=find(a[i].l),a[i].r=find(a[i].r)-;
  283. sort(a+,a+n+,cmp2);
  284. int ans=;
  285. for (int i=; i<=n; i++) ans+=cover(,,tot,a[i].l,a[i].r);
  286. printf("%d\n",ans);
  287. return ;
  288. }

2016.11.11

BZOJ4396 :贪心

BZOJ4397 :前缀和

BZOJ3943 :最小生成树

BZOJ4576:DP:这道题还可以网上有很多种写法

BZOJ4582:DP:之前看错题想了好久最后发现题目意思 好水

BZOJ4412:贪心:这道题也不错,我们首先将每个数减1,如果存在j-->x的子段和大于0,

         则说明一定有牛走出去,而我们可以知道在顺时针方向一定存在一个

         点没有牛越过去,于是我们找到那个点将环转化为链即可,而这个点

         一定是最大子段和的左节点,于是问题解决

2016.11.10

BZOJ1592 Usaco2008 Feb]Making the Grade 路面修整:离散+DP

BZOJ1051 HAOI 受欢迎的牛 :tarjan

BZOJ2442 修建草坪 :单调队列优化DP

BZOJ3890 Meeting time : 分层DP

BZOJ4390 Max Flow :树上差分

BZOJ4525 :二分答案判定

BZOJ4511 :DP

  1. BZOJ1592
  2.  
  3. #include<iostream>
  4. #include<algorithm>
  5. #include<cstring>
  6. #include<cstdio>
  7. #include<cmath>
  8. #define N 3005
  9. #define inf 0x7fffffff
  10. using namespace std;
  11. int n,m,ans,a[N],c[N],f[N][N];
  12. int read()
  13. {
  14. int x=,f=; char ch;
  15. while (ch=getchar(),ch<''||ch>'') if (ch=='-') f=-;
  16. while (x=x*+ch-'',ch=getchar(),ch>='' && ch<='');
  17. return x*f;
  18. }
  19. void solve()
  20. {
  21. sort(c+,c+n+);
  22. m=unique(c+,c+n+)-(c+);
  23. for (int i=; i<=n; i++) f[i][]=inf/;
  24. for (int i=; i<=n; i++)
  25. {
  26. for (int j=; j<=m; j++)
  27. {
  28. f[i][j]=min(f[i-][j]+abs(a[i]-c[j]),f[i][j-]);
  29. }
  30. }
  31. ans=f[n][m];
  32. for (int i=; i<=n; i++) f[i][m+]=inf/;
  33. for (int i=; i<=n; i++)
  34. {
  35. for (int j=m; j>=; j--)
  36. {
  37. f[i][j]=min(f[i-][j]+abs(a[i]-c[j]),f[i][j+]);
  38. }
  39. }
  40. ans=min(ans,f[n][]);
  41. }
  42. int main()
  43. {
  44. n=read();
  45. for (int i=; i<=n; i++) c[i]=a[i]=read();
  46. solve();
  47. printf("%d\n",ans);
  48. return ;
  49. }
  50.  
  51. BZOJ1051
  52.  
  53. #include<iostream>
  54. #include<cstring>
  55. #include<algorithm>
  56. #include<cmath>
  57. #include<cstdio>
  58. #define ll long long
  59. #define N 10005
  60. #define M 50005
  61. using namespace std;
  62. int n,m,ans,u[M],V[M];
  63. int now[N],pre[M],v[M],tot;
  64. int ind,top,total,z[N],dfn[N],low[N],num[N],in[N],out[N],belong[N];
  65. bool vis[N],inq[N];
  66. int read()
  67. {
  68. int x=,f=; char ch;
  69. while (ch=getchar(),ch<''||ch>'') if (ch=='-') f=-;
  70. while (x=x*+ch-'',ch=getchar(),ch>=''&&ch<='');
  71. return x*f;
  72. }
  73. void ins(int a,int b){
  74. ++tot; pre[tot]=now[a]; now[a]=tot; v[tot]=b;
  75. }
  76. void dfs(int x)
  77. {
  78.  
  79. dfn[x]=low[x]=++ind;
  80. vis[x]=inq[x]=; z[++top]=x;
  81. for (int p=now[x]; p; p=pre[p])
  82. {
  83. int son=v[p];
  84. if (!dfn[son]) {dfs(son); low[x]=min(low[x],low[son]);}
  85. else if (inq[son]) low[x]=min(low[x],dfn[son]);
  86. }
  87. if (low[x]==dfn[x])
  88. {
  89. ++total;
  90. belong[x]=total; inq[x]=; num[total]=;
  91. while (z[top]!=x)
  92. {
  93. int son=z[top];
  94. belong[son]=total; inq[son]=; num[total]++;
  95. top--;
  96. }
  97. top--;
  98. }
  99. }
  100. int main()
  101. {
  102. n=read(); m=read();
  103. for (int i=; i<=m; i++)
  104. {
  105. int x=read(),y=read();
  106. u[i]=x; V[i]=y;
  107. ins(x,y);
  108. }
  109. for (int i=; i<=n; i++) if (!dfn[i]) dfs(i);
  110. for (int i=; i<=m; i++) if (belong[u[i]]!=belong[V[i]])
  111. {
  112. // cout<<" "<<belong[u[i]]<<" "<<belong[V[i]]<<endl;
  113. ++out[belong[u[i]]]; ++in[belong[V[i]]];
  114. }
  115. // for (int i=1; i<=total; i++) cout<<num[i]<<endl;
  116. int sum=;
  117. for (int i=; i<=total; i++)
  118. {
  119. if (!out[i]) {ans=num[i]; sum++; if (sum>=) break;}
  120. }
  121. // cout<<ans<<endl;
  122. if (sum>) ans=; printf("%d\n",ans);
  123. return ;
  124. }
  125.  
  126. BZOJ
  127.  
  128. #include<iostream>
  129. #include<cstring>
  130. #include<algorithm>
  131. #include<cmath>
  132. #include<cstdio>
  133. #define ll long long
  134. #define N 100005
  135. using namespace std;
  136. int n,k,head,tail;
  137. ll ans,sum,f[N];
  138. int a[N],pos[N];
  139. int read()
  140. {
  141. int x=,f=; char ch;
  142. while (ch=getchar(),ch<''||ch>'') if (ch=='-') f=-;
  143. while (x=x*+ch-'',ch=getchar(),ch>=''&&ch<='');
  144. return x*f;
  145. }
  146. int main()
  147. {
  148. n=read(); k=read();
  149. for (int i=; i<=n; i++) a[i]=read(),sum+=a[i];
  150. for (int i=; i<=n; i++)
  151. {
  152. while (head<=tail && pos[head]<i-k-) head++;
  153. f[i]=f[pos[head]]+a[i];
  154. while (head<=tail && f[pos[tail]]>=f[i]) tail--;
  155. ++tail; pos[tail]=i;
  156. }
  157. ans=;
  158. for (int i=n-k; i<=n; i++) ans=min(ans,f[i]);
  159. printf("%lld\n",sum-ans);
  160. return ;
  161. }
  162.  
  163. BZOJ3890
  164.  
  165. #include<iostream>
  166. #include<cstring>
  167. #include<algorithm>
  168. #include<cmath>
  169. #include<cstdio>
  170. #define N 105
  171. #define M (N*(N+1))
  172. #define ll long long
  173. using namespace std;
  174. int pre[M],v[M],val1[M],val2[M],now[N],n,m,tot;
  175. bool f[N][M],g[N][M];
  176. int read()
  177. {
  178. int x=,f=; char ch;
  179. while (ch=getchar(),ch<''||ch>'') if (ch=='-') f=-;
  180. while (x=x*+ch-'',ch=getchar(),ch>=''&&ch<='');
  181. return x*f;
  182. }
  183. void ins(int a,int b,int c,int d)
  184. {
  185. ++tot; pre[tot]=now[a]; now[a]=tot; v[tot]=b; val1[tot]=c; val2[tot]=d;
  186. }
  187. int main()
  188. {
  189. n=read(); m=read();
  190. for (int i=; i<=m; i++)
  191. {
  192. int u=read(),v=read(),a=read(),b=read();
  193. ins(u,v,a,b);
  194. }
  195. f[][]=g[][]=;
  196. for (int i=; i<=n-; i++)
  197. {
  198. for (int p=now[i]; p; p=pre[p])
  199. {
  200. int son=v[p];
  201. for (int j=val1[p]; j<=; j++) f[son][j]|=f[i][j-val1[p]];
  202. for (int j=val2[p]; j<=; j++) g[son][j]|=g[i][j-val2[p]];
  203. }
  204. }
  205. bool bo=false;
  206. for (int i=; i<=; i++)
  207. if (g[n][i] && f[n][i])
  208. {
  209. bo=true;
  210. printf("%d\n",i);
  211. break;
  212. }
  213. if (!bo) printf("IMPOSSIBLE\n");
  214. return ;
  215. }
  216.  
  217. BZOJ4390
  218.  
  219. #include<iostream>
  220. #include<cstring>
  221. #include<algorithm>
  222. #include<cmath>
  223. #include<cstdio>
  224. #define N 60005
  225. #define M N*2
  226. #define ll long long
  227. using namespace std;
  228. int pre[M],v[M],now[N],tot,n,k,ans;
  229. int f[N][],bin[],deep[N],val[N];
  230. int read()
  231. {
  232. int x=,f=; char ch;
  233. while (ch=getchar(),ch<''||ch>'') if (ch=='-') f=-;
  234. while (x=x*+ch-'',ch=getchar(),ch>=''&&ch<='');
  235. return x*f;
  236. }
  237. void ins(int a,int b){++tot; pre[tot]=now[a]; now[a]=tot; v[tot]=b;
  238. }
  239. void dfs(int x)
  240. {
  241. for (int i=; i<= && bin[i]<=deep[x]; i++) f[x][i]=f[f[x][i-]][i-];
  242. for (int p=now[x]; p; p=pre[p])
  243. {
  244. int son=v[p]; if (son==f[x][]) continue;
  245. deep[son]=deep[x]+; f[son][]=x;
  246. dfs(son);
  247. }
  248. }
  249. int lca(int x,int y)
  250. {
  251. if (deep[x]<deep[y]) swap(x,y);
  252. int t=deep[x]-deep[y];
  253. for (int i=; bin[i]<=t; i++)
  254. {
  255. if (t&bin[i]) x=f[x][i];
  256. }
  257. for (int i=; i>=; i--) if (f[x][i]!=f[y][i]) x=f[x][i],y=f[y][i];
  258. if (x==y) return x;
  259. return f[x][];
  260. }
  261. void dfs2(int x,int fa)
  262. {
  263. for (int p=now[x]; p; p=pre[p])
  264. {
  265. int son=v[p]; if (son==fa) continue;
  266. dfs2(son,x); val[x]+=val[son];
  267. }
  268. ans=max(ans,val[x]);
  269. }
  270. int main()
  271. {
  272. n=read(); k=read();
  273. for (int i=; i<n; i++)
  274. {
  275. int x=read(),y=read();
  276. ins(x,y); ins(y,x);
  277. }
  278. bin[]=; for (int i=; i<=; i++) bin[i]=bin[i-]*;
  279. deep[]=; dfs();
  280. for (int i=; i<=k; i++)
  281. {
  282. int x=read(),y=read();
  283. int t=lca(x,y);
  284. val[x]++; val[y]++; val[t]--; val[f[t][]]--;
  285. }
  286. dfs2(,);
  287. printf("%d\n",ans);
  288. return ;
  289. }
  290.  
  291. BZOJ4525
  292.  
  293. #include<iostream>
  294. #include<cstring>
  295. #include<algorithm>
  296. #include<cmath>
  297. #include<cstdio>
  298. #define ll long long
  299. #define inf 0x7ffffff
  300. using namespace std;
  301. int n,k,ans;
  302. int a[];
  303. int read()
  304. {
  305. int x=,f=; char ch;
  306. while (ch=getchar(),ch<''||ch>'') if (ch=='-') f=-;
  307. while (x=x*+ch-'',ch=getchar(),ch>=''&&ch<='');
  308. return x*f;
  309. }
  310. bool pd(int mid)
  311. {
  312. int l=;
  313. for (int i=; i<=k; i++)
  314. {
  315. int pos=a[l+];
  316. while (l+<=n && ((a[l+]-pos)<=*mid)) l++;
  317. }
  318. if (l>=n) return true;
  319. return false;
  320. }
  321. int main()
  322. {
  323. n=read(); k=read();
  324. for (int i=; i<=n; i++) a[i]=read();
  325. sort(a+,a+n+);
  326. int l=,r=inf-;
  327. while (l<=r)
  328. {
  329. int mid=(l+r)>>;
  330. if (pd(mid)) ans=mid,r=mid-; else l=mid+;
  331. }
  332. printf("%d\n",ans);
  333. return ;
  334. }
  335.  
  336. BZOJ4511
  337.  
  338. #include<iostream>
  339. #include<cstring>
  340. #include<algorithm>
  341. #include<cmath>
  342. #include<cstdio>
  343. #define ll long long
  344. #define N 50005
  345. using namespace std;
  346. int ans,n,a[N],f[N][];
  347. int read()
  348. {
  349. int x=,f=; char ch;
  350. while (ch=getchar(),ch<''||ch>'') if (ch=='-') f=-;
  351. while (x=x*+ch-'',ch=getchar(),ch>=''&&ch<='');
  352. return x*f;
  353. }
  354. int main()
  355. {
  356. n=read();
  357. for (int i=; i<=n; i++) a[i]=read()%;
  358. memset(f,-,sizeof(f));
  359. f[][]=; for (int i=; i<=n; i++) f[i][a[i]]=;
  360. for (int i=; i<=n; i++)
  361. for (int j=; j<=; j++)
  362. if (f[i-][j]!=-) f[i][(j+a[i])%]=max(f[i][(j+a[i])%],f[i-][j]+);
  363. for (int i=; i<=n; i++) ans=max(ans,f[i][]);
  364. printf("%d\n",ans);
  365. return ;
  366. }

代码集合

2016.11.9

BZOJ1711: 最大流

BZOJ1642: 排序+DP

  1. BZOJ1711
  2.  
  3. #include<iostream>
  4. #include<cstring>
  5. #include<algorithm>
  6. #include<cmath>
  7. #include<cstdio>
  8. #include<queue>
  9. #define inf 0x7fffffff
  10. #define ll long long
  11. #define N 505
  12. #define M 50005
  13. using namespace std;
  14. int n,F,D,head,tail,list[N<<],tot=,S,T,ans=;
  15. int pre[M],v[M],cap[M],now[N],deep[N];
  16. queue<int>q;
  17. int read()
  18. {
  19. int x=,f=; char ch;
  20. while (ch=getchar(),ch<''||ch>'') if (ch=='-') f=-;
  21. while (x=x*+ch-'',ch=getchar(),ch>=''&&ch<='');
  22. return x*f;
  23. }
  24. void ins(int a,int b,int c){
  25. ++tot; pre[tot]=now[a]; now[a]=tot; v[tot]=b; cap[tot]=c;
  26. ++tot; pre[tot]=now[b]; now[b]=tot; v[tot]=a; cap[tot]=;
  27. }
  28. void init_build()
  29. {
  30. n=read(); F=read(); D=read();
  31. S=; T=n*+F+D+;
  32. for (int i=; i<=F; i++) ins(S,i,);
  33. for (int i=F+n*+; i<=F+n*+D; i++) ins(i,T,);
  34. for (int i=; i<=n; i++)
  35. {
  36. int A=read(),B=read();
  37. for (int j=; j<=A; j++) {int x=read(); ins(x,F+i,);}
  38. for (int j=; j<=B; j++) {int x=read(); ins(F+n+i,F+n*+x,);}
  39. }
  40. for (int i=;i<=n;i++) ins(F+i,F+i+n,);
  41. }
  42. bool bfs()
  43. {
  44. for (int i=S;i<=T;i++) deep[i]=-;
  45. deep[S]=; head=,tail=,list[]=S;
  46. while (head<tail)
  47. {
  48. int x=list[++head];
  49. for (int p=now[x]; p; p=pre[p])
  50. {
  51. int son=v[p];
  52. if (cap[p] && deep[son]==-)
  53. {
  54. deep[son]=deep[x]+;
  55. if (son==T) return ;
  56. list[++tail]=son;
  57. }
  58. }
  59. }
  60. return ;
  61. }
  62. int find(int x,int tmpflow)
  63. {
  64. int temp,re;
  65. if (x==T) return tmpflow;
  66. re=temp=;
  67. for (int p=now[x]; p; p=pre[p])
  68. {
  69. int son=v[p];
  70. if (cap[p] && deep[son]==deep[x]+)
  71. {
  72. temp=find(son,min(tmpflow,cap[p]));
  73. cap[p]-=temp;
  74. cap[p^]+=temp;
  75. re+=temp;
  76. tmpflow-=temp;
  77. if (tmpflow==) break;
  78. }
  79. }
  80. deep[x]=-;
  81. return re;
  82. }
  83. void dinic()
  84. {
  85. ans=;
  86. while (bfs())
  87. {
  88. ans+=find(S,inf);
  89. }
  90. }
  91. int main()
  92. {
  93. tot=;
  94. init_build();
  95. dinic();
  96. printf("%d\n",ans);
  97. return ;
  98. }
  99.  
  100. BZOJ
  101.  
  102. #include<iostream>
  103. #include<cstring>
  104. #include<cmath>
  105. #include<cstdio>
  106. #include<algorithm>
  107. using namespace std;
  108. int n,m,r,ans=;
  109. int read(){
  110. int x=,f=; char ch;
  111. while (ch=getchar(),ch<''||ch>'') if (ch=='-') f=-;
  112. while (x=x*+ch-'',ch=getchar(),ch>=''&&ch<='');
  113. return x*f;
  114. }
  115. struct data{
  116. int l,r,val;
  117. }a[];
  118. int f[];
  119. bool cmp(data a,data b)
  120. {
  121. return a.l==b.l?a.r<b.r:a.l<b.l;
  122. }
  123. int main()
  124. {
  125. n=read(); m=read()+; r=read();
  126. a[].l=a[].r=-; a[].val=;
  127. for (int i=; i<=m; i++)
  128. {
  129. a[i].l=read(),a[i].r=read()-,a[i].val=read();
  130. }
  131. sort(a+,a+m+,cmp);
  132. for (int i=; i<=m; i++)
  133. {
  134. for (int j=; j<=i-; j++)
  135. {
  136. if (a[j].r+r<a[i].l)
  137. {
  138. f[i]=max(f[i],f[j]+a[i].val);
  139. ans=max(ans,f[i]);
  140. }
  141. }
  142. }
  143. printf("%d\n",ans);
  144. return ;
  145. }

代码集合

2016.11.8

BZOJ1708:背包

BZOJ1690:01分数规划+spfa+二分

BZOJ1669:LIS问题+单调栈

  1. BZOJ
  2.  
  3. #include<iostream>
  4. #include<cstring>
  5. #include<algorithm>
  6. #include<cmath>
  7. #include<cstdio>
  8. #define ll long long
  9. using namespace std;
  10. int n,m;
  11. ll f[];
  12. int read()
  13. {
  14. int x=,f=; char ch;
  15. while (ch=getchar(),ch<''||ch>'') if (ch=='-') f=-;
  16. while (x=x*+ch-'',ch=getchar(),ch>=''&&ch<='');
  17. return x*f;
  18. }
  19. int main()
  20. {
  21. n=read(); m=read(); f[]=;
  22. for (int i=; i<=n; i++)
  23. {
  24. int x=read();
  25. for (int i=x; i<=m; i++) f[i]+=f[i-x];
  26. }
  27. printf("%lld\n",f[m]);
  28. return ;
  29. }
  30.  
  31. BZOJ1690
  32. #include<iostream>
  33. #include<cstring>
  34. #include<algorithm>
  35. #include<cmath>
  36. #include<cstdio>
  37. #define ll long long
  38. #define N 1005
  39. #define M 5005
  40. using namespace std;
  41. int n,m,tot;
  42. int a[N],now[N],pre[M],v[M];
  43. double ans,mid,val[M],value[N],dis[N];
  44. bool vis[N];
  45. int read()
  46. {
  47. int x=,f=; char ch;
  48. while (ch=getchar(),ch<''||ch>'') if (ch=='-') f=-;
  49. while (x=x*+ch-'',ch=getchar(),ch>=''&&ch<='');
  50. return x*f;
  51. }
  52. void ins(int a,int b,int c){++tot; pre[tot]=now[a]; now[a]=tot; v[tot]=b; val[tot]=c;
  53. }
  54. bool spfa(int x)
  55. {
  56. vis[x]=;
  57. for (int p=now[x]; p; p=pre[p])
  58. {
  59. int son=v[p];
  60. if (dis[son]<dis[x]+value[son]-mid*val[p])
  61. {
  62. if (!vis[son])
  63. {
  64. dis[son]=dis[x]+value[son]-mid*val[p];
  65. if (spfa(son)) return ;
  66. }
  67. else return ;
  68. }
  69. }
  70. return vis[x]=;
  71. }
  72. int main()
  73. {
  74. n=read(); m=read();
  75. for (int i=; i<=n; i++) value[i]=read();
  76. for (int i=; i<=m; i++)
  77. {
  78. int a=read(),b=read(),c=read(); ins(a,b,c);
  79. }
  80. double l=,r=,eps=1e-;
  81. while (r-l>eps)
  82. {
  83. memset(dis,,sizeof(dis));
  84. memset(vis,,sizeof(vis));
  85. mid=(l+r)/2.0; dis[]=0.0;
  86. if (spfa()) ans=mid,l=mid; else r=mid;
  87. }
  88. printf("%0.2lf\n",ans);
  89. return ;
  90. }
  91.  
  92. BZOJ1669
  93.  
  94. #include<iostream>
  95. #include<cstring>
  96. #include<algorithm>
  97. #include<cmath>
  98. #include<cstdio>
  99. #define N 5005
  100. #define ll long long
  101. using namespace std;
  102. int n,tot;
  103. int b[N];
  104. int read()
  105. {
  106. int x=,f=; char ch;
  107. while (ch=getchar(),ch<''||ch>'') if (ch=='-') f=-;
  108. while (x=x*+ch-'',ch=getchar(),ch>=''&&ch<='');
  109. return x*f;
  110. }
  111. int main()
  112. {
  113. int n=read(),tot=;
  114. for (int i=; i<=n; i++)
  115. {
  116. int x=read();
  117. if (x>b[tot])
  118. {
  119. tot++; b[tot]=x;
  120. }
  121. else
  122. {
  123. int l=tot;
  124. while (l>= && b[l]>=x) l--;
  125. //cout<<" "<<l<<endl;
  126. b[l+]=x;
  127. }
  128. }
  129. printf("%d\n",tot);
  130. return ;
  131. }

代码集合

2016.11.7

BZOJ3298:打表找规律

BZOJ3296:并查集

BZOJ1599:模拟

BZOJ1232:最小生成树

  1. BZOJ3298
  2.  
  3. #include<iostream>
  4. #include<cstring>
  5. #include<algorithm>
  6. #include<cmath>
  7. #include<cstdio>
  8. #define ll long long
  9. #define N 1000005
  10. using namespace std;
  11. int n,m,f[N];
  12. int read()
  13. {
  14. int x=,f=; char ch;
  15. while (ch=getchar(),ch<''||ch>'') if (ch=='-') f=-;
  16. while (x=x*+ch-'',ch=getchar(),ch>=''&&ch<='');
  17. return x*f;
  18. }
  19. int main()
  20. {
  21. n=read()+; m=read()+;
  22. f[]=; int t=;
  23. for (int i=; i<=m; i++)
  24. {
  25. if (f[i]) continue;
  26. t++; f[i]=i+t; if (i+t<=m) f[i+t]=i;
  27. }
  28. int T=read();
  29. while (T--)
  30. {
  31. int x=read()+,y=read()+;
  32. if (f[x]==y) printf("Farmer John\n"); else printf("Bessie\n");
  33. }
  34. return ;
  35. }
  36.  
  37. BZOJ3296
  38.  
  39. #include<iostream>
  40. #include<cstring>
  41. #include<algorithm>
  42. #include<cmath>
  43. #include<cstdio>
  44. #define ll long long
  45. #define N 40005
  46. using namespace std;
  47. int fa[N],id[N],n,m,ans;
  48. int read()
  49. {
  50. int x=,f=; char ch;
  51. while (ch=getchar(),ch<''||ch>'') if (ch=='-') f=-;
  52. while (x=x*+ch-'',ch=getchar(),ch>=''&&ch<='');
  53. return x*f;
  54. }
  55. int find(int x){return x==fa[x]?x:fa[x]=find(fa[x]);
  56. }
  57. int main()
  58. {
  59. n=read(); m=read();
  60. for (int i=; i<=n; i++) fa[i]=i;
  61. for (int i=; i<=n; i++)
  62. {
  63. int k=read();
  64. for (int j=; j<=k; j++){int x=read(); if (!id[x]) id[x]=i; else {fa[find(id[x])]=find(i); id[x]=i;}}
  65. }
  66. for (int i=; i<=n; i++) if (find(i)==i) ans++;
  67. printf("%d\n",ans-);
  68. return ;
  69. }
  70.  
  71. BZOJ1599
  72.  
  73. #include<iostream>
  74. #include<cstring>
  75. #include<algorithm>
  76. #include<cmath>
  77. #include<cstdio>
  78. #define ll long long
  79. using namespace std;
  80. int sum[],ans;
  81. int read()
  82. {
  83. int x=,f=; char ch;
  84. while (ch=getchar(),ch<''||ch>'') if (ch=='-') f=-;
  85. while (x=x*+ch-'',ch=getchar(),ch>=''&&ch<='');
  86. return x*f;
  87. }
  88. int main()
  89. {
  90. int a=read(),b=read(),c=read();
  91. for (int i=; i<=a; i++)
  92. for (int j=; j<=b; j++)
  93. for (int k=; k<=c; k++) sum[i+j+k]++;
  94. sum[]=; ans=; for (int i=; i<=a+b+c; i++) if (sum[i]>sum[ans]) ans=i;
  95. printf("%d\n",ans);
  96. return ;
  97. }
  98.  
  99. BZOJ1232
  100.  
  101. #include<iostream>
  102. #include<cstring>
  103. #include<algorithm>
  104. #include<cmath>
  105. #include<cstdio>
  106. #define ll long long
  107. #define N 100005
  108. using namespace std;
  109. int n,m;
  110. struct data{
  111. int u,v,val;
  112. }a[N];
  113. int c[N],Min=0x7fffffff,ans=,fa[N],cnt=;
  114. int read()
  115. {
  116. int x=,f=; char ch;
  117. while (ch=getchar(),ch<''||ch>'') if (ch=='-') f=-;
  118. while (x=x*+ch-'',ch=getchar(),ch>=''&&ch<='');
  119. return x*f;
  120. }
  121. bool cmp(data a,data b){return a.val<b.val;
  122. }
  123. int find(int x) {return x==fa[x]?x:fa[x]=find(fa[x]);}
  124. int main()
  125. {
  126. n=read(); m=read();
  127. for (int i=; i<=n; i++) fa[i]=i;
  128. for (int i=; i<=n; i++) c[i]=read();
  129. for (int i=; i<=m; i++) a[i].u=read(),a[i].v=read(),a[i].val=read()*+c[a[i].u]+c[a[i].v];
  130. sort(a+,a+m+,cmp);
  131. for (int i=; i<=m; i++)
  132. {
  133. int u=a[i].u,v=a[i].v,val=a[i].val;
  134. int fu=find(u),fv=find(v);
  135. if (fv!=fu)
  136. {
  137. fa[fv]=fu; Min=min(Min,min(c[u],c[v]));
  138. ans+=val; cnt++; if (cnt==n-) break;
  139. }
  140. }
  141. printf("%d\n",ans+Min);
  142. return ;
  143. }

代码集合

NOIP前刷水行动的更多相关文章

  1. NOIP前刷题记录

    因为本蒻实在太蒻了...对于即将到来的NOIP2018ssfd,所以下决心要把自己近期做过的题目(衡量标准为洛谷蓝题难度或以上)整理一下,归归类,简单地写一下思路,就当作自己复习了吧qwq 本随笔持续 ...

  2. NOIP前的水题记录

    CF147B Smile House 二分+矩阵快速幂,注意一下储存矩阵相乘结果的矩阵,初始化时,a[i][i]=-inf(而其他都可以a[i][i]=0,为了保证答案的可二分性). CF715B C ...

  3. Noip前的大抱佛脚----赛前任务

    赛前任务 tags:任务清单 前言 现在xzy太弱了,而且他最近越来越弱了,天天被爆踩,天天被爆踩 题单不会在作业部落发布,所以可(yi)能(ding)会不及时更新 省选前的练习莫名其妙地成为了Noi ...

  4. Noip前的大抱佛脚----Noip真题复习

    Noip前的大抱佛脚----Noip真题复习 Tags: Noip前的大抱佛脚 Noip2010 题目不难,但是三个半小时的话要写四道题还是需要码力,不过按照现在的实力应该不出意外可以AK的. 机器翻 ...

  5. NOIP前的一些计划

    一些想法 距离NOIP2018只剩下一个星期的时间了,通过这几天在长郡的考试,渐渐感觉还有好多东西自己还不够熟练,也有些东西到现在还不会,现将NOIP前的一些计划列在这里,希望能在考前把他们全部完成吧 ...

  6. Noip前的大抱佛脚----文章索引

    Noip前的大抱佛脚----赛前任务 Noip前的大抱佛脚----考场配置 Noip前的大抱佛脚----数论 Noip前的大抱佛脚----图论 Noip前的大抱佛脚----动态规划 Noip前的大抱佛 ...

  7. Noip前的大抱佛脚----字符串

    目录 字符串 经验 用FFT求解字符串匹配问题 两(多)串DP时状态合并 最长公共子序列转LIS 位运算最大值 挂链哈希 哈希处理回文串 树哈希 字符串模板库 KMP 最小循环表示 Mancher A ...

  8. Noip前的大抱佛脚----一些思路

    目录 一些思路 序列 函数问题 网格图 删除和询问 乘法问题 顺序问题 最值问题 研究成果 数论分块套数论分块的复杂度 一些思路 Tags:Noip前的大抱佛脚 序列 线段树(当然还要有主席树啊!) ...

  9. Noip前的大抱佛脚----数论

    目录 数论 知识点 Exgcd 逆元 gcd 欧拉函数\(\varphi(x)\) CRT&EXCRT BSGS&EXBSGS FFT/NTT/MTT/FWT 组合公式 斯特林数 卡塔 ...

随机推荐

  1. 转:Selenium中的几种等待方式,需特别注意implicitlyWait的用法

    最近在项目过程中使用selenium 判断元素是否存在的时候 遇到一个很坑爹的问题, 用以下方法执行的时候每次都会等待很长一段时间,原因是因为对selenium实现方法了解不足导致一直找不到解决方法. ...

  2. HDU 5240 Exam

    The 2015 ACM-ICPC China Shanghai Metropolitan Programming Contest 2015ACM-ICPC上海大都会赛 签到题 #include< ...

  3. sphinx分域搜索

    http://stackoverflow.com/questions/2526407/complex-query-with-sphinx 比如要实现和如下sql代码相同的功能: SELECT * FR ...

  4. Entity Framework 6新功能Logging/Store Procedure

    摘要 在Entity Framework6中有两个新的功能,DB Loggin和Stored Procedure的映射 Entity Framework 6已经从Beta版本来到了RC1版本,我们可以 ...

  5. Android5.0 Gallery2上编译Gallery模块出错

    Android5.0 Gallery2上编译Gallery模块出错 时间:2015-05-05 19:32:57      阅读:105      评论:0      收藏:0      [点我收藏+ ...

  6. 草,又学了个新命令,nc传文件。

    nc -l 5222 > aa nc 192.168.0.48 5222 < a http://www.linuxso.com/command/nc.html

  7. UILabel 解析及自适应

    CGFloat width1=[(NSString *)ob1 sizeWithFont:[UIFont systemFontOfSize:16] constrainedToSize:CGSizeMa ...

  8. Struts2--ModelDriven接收参数

    1. JSP文件调用格式: <a href="user/user!add?name=a&age=8">添加用户</a> 2. struts.xml文 ...

  9. C#读取word文件

    第一步:添加对在项目引用里添加上对Microsoft Word 11.0 object library的引用.右击--引用---在com标签下添加.

  10. Protocol buffers--python 实践(一) 简介以及安装与使用

    由于最近对grpc产生了浓厚的兴趣,但是那是一整套东西,看了一下用到的东西不少,所以抽丝剥茧先写写这几天调研的protocol buffer -python的收获. 简介: 以下引用自官方首页文档: ...