2014年9月11日
摘要: 暴力模拟细节处理很重要。。。 1 #include 2 #include 3 #include 4 using namespace std; 5 6 char s1[100],s[100]; 7 int len1,len; 8 int t; ... 阅读全文
posted @ 2014-09-11 23:04 gfc 阅读(137) 评论(0) 推荐(0) 编辑
  2014年9月10日
摘要: 博弈dp 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 7 int d[30][30][30][30]; 8 int visit[30][30][30][30]; 9 int a[50],b... 阅读全文
posted @ 2014-09-10 09:43 gfc 阅读(144) 评论(0) 推荐(0) 编辑
  2014年9月9日
摘要: 以前写过类似的,这个应该比那个难些(x/gcd(x,y,z))*(y/gcd(x,y,z))*(z*gcd(x,y,z)=lcm(x,y,z)/gcd(x,y,z);对lcm(x,y,z)/gcd(x,y,z)唯一分解;对于每个pi^ai,x/gcd(x,y,z),y/gcd(x,y,z),z/gc... 阅读全文
posted @ 2014-09-09 00:29 gfc 阅读(274) 评论(0) 推荐(0) 编辑
  2014年9月5日
摘要: 开始队友说是线段树,看了看貌似也是,上手敲了个嵌套的线段树,O(nlognlogn)的复杂度果断tle了 TAT思路:对h[i]排序,对每次涨水退水,先用二分查找,再用一个数组保存当前点之后所有点被淹的次数;temp[bs(b[i-1])+1]++,temp[bs(a[i])+1]--;最后遍历一遍... 阅读全文
posted @ 2014-09-05 09:59 gfc 阅读(273) 评论(0) 推荐(0) 编辑
  2014年9月3日
摘要: 唯一分解定理把n分解为 n=a1^p1*a2^p2*...的形式,易得每个ai^pi作为一个单独的整数最优。坑: n==1 ans=2; n因子种数只有一个 ans++; 注意溢出。 1 #include 2 #include 3 using namespace std;... 阅读全文
posted @ 2014-09-03 15:28 gfc 阅读(143) 评论(0) 推荐(0) 编辑
摘要: bfs+dfs很复杂的搜索题。因为数据很小,rock最多只有5个,coin最多只有10个,移动rock最多4^5=1024种状态;思路: 每次先把当前状态能拿到的coin拿走,并将地图当前位置设为'.' (拿走coin的位置为空) 拿走coin后,在搜索一次,碰到rock判断是否能push动,能... 阅读全文
posted @ 2014-09-03 11:53 gfc 阅读(323) 评论(1) 推荐(0) 编辑
  2014年9月2日
摘要: 最长公共上升子序列(LCIS)裸的算法题。动态规划: 两组数组a[n]、b[m]。 f[i][i]表示以a[i]、b[j]结尾的两个数组的LCIS。 转移方程: a[i]!=b[j] : f[i][j]=f[i-1][j]; a[i]==b[j] : f[i][j]=max (f[... 阅读全文
posted @ 2014-09-02 17:17 gfc 阅读(178) 评论(0) 推荐(0) 编辑
  2014年9月1日
摘要: 我该怎么说这道题呢。。。说简单其实也简单,就枚举模拟,开始卡了好久,今天看到这题没a又写了遍,看似会超时的代码交上去a了,果然实践是检验真理的唯一标准。。。 1 #include 2 #include 3 #include 4 using namespace std; 5 6 const i... 阅读全文
posted @ 2014-09-01 17:05 gfc 阅读(279) 评论(0) 推荐(0) 编辑
摘要: 最小生成树prim原理参见上篇 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 8 const int INF = 99999999 ; 9 const int maxn = ... 阅读全文
posted @ 2014-09-01 15:39 gfc 阅读(107) 评论(0) 推荐(0) 编辑
摘要: 最小生成树prim原理: 任取一点作为起始点,遍历当前点的所有的邻近点,维护更新到达邻近点的最小花费。选择权值最小的点作为下一次的起始点; 已经遍历过的点不再作为起始点。 1 #include 2 #include 3 #include 4 #include 5 #include 6 ... 阅读全文
posted @ 2014-09-01 15:02 gfc 阅读(284) 评论(0) 推荐(0) 编辑