摘要: http://poj.org/problem?id=1160算水过的吧 四重循环没优化 CZ说爆可过 就爆了dp[i][j] = min(dp[i][j],dp[i-1][g]-s) 第i个点建在第j个村庄上 s 是这个点比上个点少的距离 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 using namespace std; 8 #define N 1010 9 #define INF 0xfffffff10 int h[N],dp[40][N];11 int main()12 {13 int ... 阅读全文
posted @ 2013-08-15 22:52 _雨 阅读(185) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=4681枚举A串和B串包含C串的区间 枚举区间端点算左右两端最长公共子序 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 #define N 1010 8 char s1[N],s2[N],s3[N]; 9 int dp1[N][N],dp2[N][N];10 struct node11 {12 int l,r;13 }p1[N],p2[N];14 int main()15 {16 ... 阅读全文
posted @ 2013-08-15 22:09 _雨 阅读(172) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=4678之前写了一并差集找连通块 貌似不对 比赛时写的dfs爆栈了 只好用bfs了单独数字块 为1空白+数字块 数字数%2+1异或 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 using namespace std; 8 #define N 1010 9 int dis[8][2] = {1,0,-1,0,0,1,0,-1,1,1,1,-1,-1,1,-1,-1};10 int n,m,k;11 int vis[N][. 阅读全文
posted @ 2013-08-15 21:01 _雨 阅读(246) 评论(0) 推荐(0) 编辑
摘要: http://poj.org/problem?id=3368追完韩剧 想起这题来了 想用线段树搞定来着 结果没想出来。。然后想RMQ 想出来了算是离散吧 把每个数出现的次数以及开始的位置及结束的位置记录下来 以次数进行RMQ 再特殊处理下区间端点就OK 了WA一次 盯了半小时 原来少了个=号 好吧好吧。。 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 using namespace std; 8 #define N 200005 9 struct node10 {11 int s,e,a;12 ... 阅读全文
posted @ 2013-08-15 00:33 _雨 阅读(208) 评论(0) 推荐(0) 编辑