摘要: BigNum 1 #include <iostream> 2 #include <cstring> 3 #include <cstdio> 4 #include <algorithm> 5 using namespace std; 6 inline int Max(int x,int y) {ret 阅读全文

posted @ 2016-09-05 11:40 yyjxx2010xyu 阅读(175) 评论(0) 推荐(0) 编辑

只有注册用户登录后才能阅读该文。 阅读全文

posted @ 2016-05-13 14:33 yyjxx2010xyu 阅读(32) 评论(0) 推荐(0) 编辑

2017年7月1日

摘要: 数据结构 树链剖分 BZOJ 1036 (Max,Sum数组开小,调了很久) 线段树 区间合并+标记合并 BZOJ 1798 LCA BZOJ 1787 分类讨论一拨距离。 阅读全文

posted @ 2017-07-01 20:23 yyjxx2010xyu 阅读(112) 评论(0) 推荐(0) 编辑

2016年11月14日

摘要: BZOJ 1127 1 2 #include <cstdio> 3 #include <cstring> 4 #include <iostream> 5 #include <algorithm> 6 #define M 2020 7 using namespace std; 8 int n,k,a[ 阅读全文

posted @ 2016-11-14 23:26 yyjxx2010xyu 阅读(236) 评论(0) 推荐(0) 编辑

2016年11月11日

摘要: POJ 2891 x=r1 (mod a1) x=r2 (mod a2) x=a1*x+r1,x=a2*y+r2; a1*x-a2*y=r2-r1; 用Extend_Gcd求出m1*x+m2*y=d; d=Gcd(x,y); 那么就可以解出原来的x=(x*(r2-r1)/d) 那么代入原式r1=a1 阅读全文

posted @ 2016-11-11 13:15 yyjxx2010xyu 阅读(165) 评论(0) 推荐(0) 编辑

2016年11月10日

摘要: BZOJ 1455 左偏树即可 1 #include <cstdio> 2 #define LL long long 3 const LL Maxn=1000100; 4 struct Info{LL l,r,v,Dis;}Tree[Maxn]; 5 LL Father[Maxn],n,m,Dead 阅读全文

posted @ 2016-11-10 00:03 yyjxx2010xyu 阅读(154) 评论(0) 推荐(0) 编辑

2016年11月9日

摘要: BZOJ 1028 暴力枚举听的那张牌,和那个多余的两张牌,其余的mod3后模拟就可以了 1 #include <cstdio> 2 const int Maxn=510; 3 int n,m,a[Maxn],b[Maxn],cnt,Ans[Maxn],x; 4 bool Check() 5 { 6 阅读全文

posted @ 2016-11-09 23:53 yyjxx2010xyu 阅读(383) 评论(0) 推荐(0) 编辑

摘要: BZOJ 1580 直接解析算出每段的时间然后模拟即可 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <algorithm> 5 #include <queue> 6 #include <vecto 阅读全文

posted @ 2016-11-09 23:51 yyjxx2010xyu 阅读(311) 评论(0) 推荐(0) 编辑

2016年11月6日

摘要: POJ 2533 最长不降子序列 1 #include <cstdio> 2 const int Maxn=1010; 3 int a[Maxn],Pos[Maxn],F[Maxn],n,Ans; 4 inline int Max(int x,int y) {return x>y?x:y;} 5 i 阅读全文

posted @ 2016-11-06 18:24 yyjxx2010xyu 阅读(149) 评论(0) 推荐(0) 编辑

摘要: POJ 1830 列出n个方程右边为最后的情况 每一行代表第几个灯的情况,每一行代表是否按第几个按钮写出方程即可。 1 #include <cstdio> 2 #include <cstring> 3 const int Maxn=100; 4 int M[Maxn][Maxn],Ans,a[Max 阅读全文

posted @ 2016-11-06 17:29 yyjxx2010xyu 阅读(201) 评论(0) 推荐(0) 编辑

2016年11月3日

摘要: HDU 3068 HDU 3949 HDU 4311 HDU 4312 POJ 2155 BZOJ 2590 BZOJ 2068 阅读全文

posted @ 2016-11-03 19:47 yyjxx2010xyu 阅读(158) 评论(0) 推荐(0) 编辑

2016年11月2日

摘要: BZOJ 1461 && BZOJ 1729 KMP+BIT 一看就是字符串匹配但是不同的是要按照每个字符的排名情况。 首先对于数字x的排名,那么要判断x前小于x的数的个数,和x前小于等于x的数的个数,这两个都相等才相等。因为会有数字会有重复的. 然后可以先预处理出字串的每个数字的排名,这样就不需要 阅读全文

posted @ 2016-11-02 14:13 yyjxx2010xyu 阅读(245) 评论(0) 推荐(0) 编辑

2016年10月28日

摘要: POJ 1236 给定一个有向图,求: 1) 至少要选几个顶点,才能做到从这些顶点出发,可以到达全部顶点 2) 至少要加多少条边,才能使得从任何一个顶点出发,都能到达全部顶点 第一个就是缩点之后有多少入度为0的个数因为一定要从这些节点出发 第二个就是因为图本身就是联通的,设入度为0的点有n个,出度为 阅读全文

posted @ 2016-10-28 13:51 yyjxx2010xyu 阅读(166) 评论(0) 推荐(0) 编辑

摘要: POJ 1182 把一个点拆成x,x+n,x+2*n,x吃y可以表示认为x,y+n是一类的,x+n,y+2*n是一类,x+2*n,y是一类。 1 #include <cstdio> 2 3 const int Maxn=50100; 4 int F[Maxn*3],n,k,Type,x,y,Ans; 阅读全文

posted @ 2016-10-28 13:51 yyjxx2010xyu 阅读(160) 评论(0) 推荐(0) 编辑

2016年10月25日

摘要: LJOJ 1500: 题目:http://www.docin.com/p-601990756.html Sol:贪心,从叶子结点往上加入无法传递了,就需要建设。 Dfs返回的是到达叶子节点最多所要的能量,如果大于最大能量就需要建设放大器. 1 #include <iostream> 2 #inclu 阅读全文

posted @ 2016-10-25 17:21 yyjxx2010xyu 阅读(244) 评论(0) 推荐(0) 编辑

2016年10月24日

摘要: 求出子树的重心后求出它每个子节点的距离,排序后就可以统计距离小于等于K的点对的个数了,但是会在同一子树内重复,然后在每个子树里面减去小于等于K的点对个数就可以了。 1 #include <iostream> 2 #include <cstring> 3 #include <cstdio> 4 #in 阅读全文

posted @ 2016-10-24 20:47 yyjxx2010xyu 阅读(121) 评论(0) 推荐(0) 编辑

2016年10月17日

摘要: A 模拟 1 #include <cstdio> 2 #include <cstring> 3 int Ans; 4 char Str[110]; 5 inline int Abs(int x) {return x>0?x:-x;} 6 inline int Min(int x,int y) {re 阅读全文

posted @ 2016-10-17 20:14 yyjxx2010xyu 阅读(137) 评论(0) 推荐(0) 编辑

2016年9月29日

摘要: 1 #include <bits/stdc++.h> 2 using namespace std; 3 const int Maxn=2000100; 4 struct Info{int l,r;}P[Maxn]; 5 int n,Cnt,F[Maxn]; 6 map<int,int> M; 7 i 阅读全文

posted @ 2016-09-29 16:01 yyjxx2010xyu 阅读(102) 评论(0) 推荐(0) 编辑

摘要: 官方题解:这是一道论文题。集训队论文《根号算法——不只是分块》。 首先,题目要我们求的东西,就是下面的代码: 即:从 k开始,每隔p个数取一个数,求它们的和。 这个算法的复杂度是的。 令答案为,表示模数是p,余数是k. 那么,对于第i个数,如何处理它对ans的贡献呢? 这样看上去很妙的样子,然而的预 阅读全文

posted @ 2016-09-29 10:35 yyjxx2010xyu 阅读(153) 评论(0) 推荐(0) 编辑

2016年9月28日

摘要: 不能用分块。 1 #include <bits/stdc++.h> 2 using namespace std; 3 const int Maxn=1000100; 4 struct Info{int l,r,Id;}Q[Maxn]; 5 int a[Maxn],n,c,m,Last[Maxn],N 阅读全文

posted @ 2016-09-28 19:36 yyjxx2010xyu 阅读(132) 评论(0) 推荐(0) 编辑

摘要: 标记会重叠需要判断. 1 #include <bits/stdc++.h> 2 using namespace std; 3 inline int Max(int x,int y) {return x>y?x:y;} 4 inline int Max3(int x,int y,int z) {ret 阅读全文

posted @ 2016-09-28 19:09 yyjxx2010xyu 阅读(160) 评论(0) 推荐(0) 编辑

2016年9月27日

摘要: 1 2 #include <iostream> 3 #include <cstring> 4 #include <cstdio> 5 #include <algorithm> 6 #include <map> 7 using namespace std; 8 const int Maxn=10010 阅读全文

posted @ 2016-09-27 23:54 yyjxx2010xyu 阅读(1005) 评论(0) 推荐(0) 编辑

摘要: 显然若一个数大于n就不可能是答案。 1 2 #include <iostream> 3 #include <cstring> 4 #include <cstdio> 5 #include <algorithm> 6 #include <map> 7 #include <cmath> 8 using 阅读全文

posted @ 2016-09-27 23:53 yyjxx2010xyu 阅读(161) 评论(0) 推荐(0) 编辑

2016年9月23日

摘要: 1.有N(N<=1000)个贪婪的海盗,他们得到了100,000个金币,决定分赃。他们都很精明,都想自己利益最大化,并采取如下策略: 1、 首先N人排好次序。 2、 由编号最大者给出分赃方案。 3、 所有人表决,50%及以上的人赞成就分赃成功,否则转4。 4、 杀掉提案者(总人数少了1),转2。 你 阅读全文

posted @ 2016-09-23 11:49 yyjxx2010xyu 阅读(247) 评论(0) 推荐(0) 编辑

2016年9月20日

摘要: n^3logn非常显然。所以要用一种因为这个矩阵是一个循环矩阵,所以只要知道第一行就可以知道所有行了。 C[i][j]=C[i-1][j-1]; 1 #include <iostream> 2 #include <cstring> 3 #include <cstdio> 4 #include <al 阅读全文

posted @ 2016-09-20 18:49 yyjxx2010xyu 阅读(135) 评论(0) 推荐(0) 编辑

摘要: 显然序列不能超过sqrt(n),因为最差情况是每个都独立答案为n 1 #include <iostream> 2 #include <cstring> 3 #include <cstdio> 4 #include <algorithm> 5 #include <cmath> 6 using name 阅读全文

posted @ 2016-09-20 00:09 yyjxx2010xyu 阅读(103) 评论(0) 推荐(0) 编辑

2016年9月19日

摘要: 详见PoPoQQQ的博客.. 1 2 #include <iostream> 3 #include <cstring> 4 #include <cstdio> 5 #include <algorithm> 6 #define LL long long 7 using namespace std; 8 阅读全文

posted @ 2016-09-19 23:55 yyjxx2010xyu 阅读(220) 评论(0) 推荐(0) 编辑

2016年9月14日

摘要: 普及组水题. 按位模拟第一个序列和第二个序列,细节比较多.. 仅为部分看后面两位的和,如果大于10就近位小于8就不进位等于9就看下一位. 1 #include <cstdio> 2 #define LL long long 3 LL Bin[20],K,Ten[20],SqrA[20],SqrB[2 阅读全文

posted @ 2016-09-14 10:27 yyjxx2010xyu 阅读(119) 评论(0) 推荐(0) 编辑

摘要: 7.10 T1:求出一个矩阵中平均数大于0的子矩阵的最大面积. T2:给出一个N行的,第I行有n+1-i的倒三角形,从中选取m个数,只有当前数的左上角和右上角都被选是才能选当前数,求选的数字的最大和 T3:给一个有向无环图,求任意两点间距离除以边数的最小值. Sol: T1:n^2枚举行的两端,然后 阅读全文

posted @ 2016-09-14 10:23 yyjxx2010xyu 阅读(236) 评论(0) 推荐(0) 编辑

2016年9月5日

摘要: BZOJ 1666 水.. BZOJ 1579 分层图最短路. BZOJ 1782 从一开始若某头牛停在U,那么U的子树的时间都会加一用BIT维护DFS序就行了 BZOJ 1572 贪心+堆 排序后查看是否超过了时间,超过了就弹出 1 #include <iostream> 2 #include < 阅读全文

posted @ 2016-09-05 21:42 yyjxx2010xyu 阅读(150) 评论(0) 推荐(0) 编辑

2016年9月1日

摘要: Codeforces 7E 1 #include <iostream> 2 #include <cstring> 3 #include <cstdio> 4 #include <algorithm> 5 #include <map> 6 using namespace std; 7 map<stri 阅读全文

posted @ 2016-09-01 20:39 yyjxx2010xyu 阅读(406) 评论(0) 推荐(0) 编辑

2016年8月17日

摘要: nlogn的做法就是记录了在这之前每个长度的序列的最后一项的位置,这个位置是该长度下最后一个数最小的位置。显然能够达到最优。 BZOJ 1046中里要按照字典序输出序列,按照坐标的字典序,那么我萌可以把序列先倒着做最长下降子序列,然后我萌就可以知道以a[i]为开头的最长的长度了。每次扫一遍记录答案即 阅读全文

posted @ 2016-08-17 20:25 yyjxx2010xyu 阅读(136) 评论(0) 推荐(0) 编辑

2016年8月11日

摘要: 8.11 T1 给定一个序列M,求出能过构造出的序列使得(Si+Si+1)/2=Mi成立的序列个数.保证M,S递增。 T2 平面点集中最大的四边形面积 T3 不太懂得一道国家队选拔的加强版。 90+20+10=120 三题暴力 T1写了一个非常不正确的O(n)结果拿了90,T2只想到了n^3的做法, 阅读全文

posted @ 2016-08-11 23:13 yyjxx2010xyu 阅读(127) 评论(0) 推荐(0) 编辑

2016年7月25日

摘要: BZOJ 3270 :设置状态为Id(x,y)表示一人在x,一人在y这个状态的概率。 所以总共有n^2种状态。 p[i]表示留在该点的概率,Out[i]=(1-p[i])/Degree[i]表示离开该点的概率. 那么对于每一种状态a,b 则有P(a,b)=p[a]∗p[b]∗P(a,b)+Out[u 阅读全文

posted @ 2016-07-25 11:04 yyjxx2010xyu 阅读(106) 评论(0) 推荐(0) 编辑

2016年7月24日

摘要: 状压DP :F(S)=Sum*F(S)+p(x1)*F(S^(1<<x1))+p(x2)*F(S^(1<<x2))...+1; F(S)表示取状态为S的牌的期望次数,Sum表示什么都不取得概率,p(x1)表示的是取x1的概率,最后要加一因为有又多拿了一次.整理一下就可以了。 1 #include < 阅读全文

posted @ 2016-07-24 21:47 yyjxx2010xyu 阅读(85) 评论(0) 推荐(0) 编辑

2016年7月19日

摘要: 就是有n个点n条边,那么有且只有一个环那么用Dfs把在环上的两个点找到。然后拆开,从这条个点分别作树形Dp即可. 1 2 #include <cstdio> 3 #include <cstring> 4 #define LL long long 5 const LL Maxn=1001000; 6 阅读全文

posted @ 2016-07-19 13:53 yyjxx2010xyu 阅读(114) 评论(0) 推荐(0) 编辑

2016年7月16日

摘要: 1 #include <cstdio> 2 const int Maxn=100010; 3 inline void Get_Int(int &x) 4 { 5 char ch=getchar(); x=0; 6 while (ch<'0' || ch>'9') ch=getchar(); 7 wh 阅读全文

posted @ 2016-07-16 23:33 yyjxx2010xyu 阅读(727) 评论(0) 推荐(0) 编辑

摘要: 1 #include <cstdio> 2 #include <cstring> 3 const int Len=31; 4 const int Maxn=100100; 5 int cnt,Ans,b,x,n; 6 inline int Max(int x,int y) {return x>y?x 阅读全文

posted @ 2016-07-16 15:27 yyjxx2010xyu 阅读(159) 评论(0) 推荐(0) 编辑

2016年7月13日

摘要: 用8个bool维护即可分别为LURU,LURD,LDRU,LDRD,LULD,RURD,Side[1],Side[2]即可。 Side表示这一块有没有接到右边。Merge一下就可以了。码农题,WA了一次,发现未初始化,就AC了。。 1 #include <cstdio> 2 inline int M 阅读全文

posted @ 2016-07-13 21:18 yyjxx2010xyu 阅读(203) 评论(0) 推荐(0) 编辑

2016年7月11日

摘要: 1 #include <iostream> 2 #include <cstring> 3 #include <cstdio> 4 #include <algorithm> 5 #define LL long long 6 using namespace std; 7 const LL Mod=100 阅读全文

posted @ 2016-07-11 18:20 yyjxx2010xyu 阅读(153) 评论(0) 推荐(0) 编辑

2016年7月7日

摘要: 1 #include <cstdio> 2 const int Maxn=400010; 3 inline void Get_Int(int & x) 4 { 5 char ch=getchar(); x=0; 6 while (ch<'0' || ch>'9') ch=getchar(); 7 w 阅读全文

posted @ 2016-07-07 18:55 yyjxx2010xyu 阅读(213) 评论(0) 推荐(0) 编辑