• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
LyonLys
愿意在角落唱沙哑的歌 再大声也都是给你 请用心听 不要说话 Contact me via E-mail: lyon.lys@gmail.com
博客园    首页    新随笔    联系   管理    订阅  订阅
上一页 1 2 3 4 5 6 7 8 9 ··· 35 下一页
2013年7月25日
uva 11375 Matches (递推)
摘要: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2370 一道递推的题。 这道题的递推方程很容易可以想到,是枚举加上哪一个数字,把方法数累加起来。这道题主要是要注意前缀0的问题,可以通过枚举第一个数字不是一的所有情况,然后最后询问大于6的时候就加一。代码如下(JAVA): 1 import java.math.BigInteger; 2 import java.util.Scanner; 3 4 public class Main 阅读全文
posted @ 2013-07-25 21:00 LyonLys 阅读(360) 评论(0) 推荐(0)
uva 11806 Cheerleaders (容斥)
摘要: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2906 容斥原理,从反面去想。统计边界上都没有石子的情况。这时候就要用到容斥原理了。代码如下: 1 #include 2 #include 3 #include 4 #include 5 6 using namespace std; 7 8 typedef long long LL; 9 const LL MOD = 1000007;10 const int N = 25;11 c 阅读全文
posted @ 2013-07-25 19:49 LyonLys 阅读(148) 评论(0) 推荐(0)
2013年7月24日
hdu 3329 The Flood (Flood Fill + MFSet)
摘要: Problem - 3329 用pfs,将淹没时间调整回来,然后用并查集,时间倒序插入点。代码如下: 1 #include 2 #include 3 #include 4 #include 5 #include 6 7 using namespace std; 8 9 const int N = 111; 10 const int dx[4] = { -1, 0, 1, 0}; 11 const int dy[4] = { 0, -1, 0, 1}; 12 bool vis[N][N]; 13 int mat[N][N]; 14 15 typedef pai... 阅读全文
posted @ 2013-07-24 23:29 LyonLys 阅读(214) 评论(0) 推荐(0)
LightOJ 1269 Consecutive Sum (Trie树)
摘要: Jan's LightOJ :: Problem 1269 - Consecutive Sum 题意是,求给定序列的中,子序列最大最小的抑或和。 做法就是用一棵Trie树,记录数的每一位是0还是1。查询的时候,如果求最大值,就尽量让高位是1,相反就尽量让高位是0。代码如下,1y: 1 #include 2 #include 3 #include 4 #include 5 6 using namespace std; 7 8 const int N = 55555; 9 const int M = 32;10 11 struct Node {12 int c[2];13 ... 阅读全文
posted @ 2013-07-24 14:44 LyonLys 阅读(447) 评论(0) 推荐(0)
2013年7月23日
2013多校训练赛第一场 总结
摘要: http://acm.hdu.edu.cn/listproblem.php?vol=37hdu 4600~4610 2013HDU多校训练第一场 这次的组队训练好没状态,居然敲几题水题都搞了2个多种。最后我们队做出了4题,排在41名。不太想写东西,直接上题解了:Problem - 4604 这题做法其实还没想到,不过写出了一个能过目前所有数据的代码(比赛的时候数据更水,几乎算不出正确答案的代码都能过): 1 #include 2 #include 3 #include 4 #include 5 #include 6 7 using namespace std; 8 9 con... 阅读全文
posted @ 2013-07-23 23:48 LyonLys 阅读(277) 评论(0) 推荐(0)
hdu 3938 Portal (prim+离线)
摘要: Problem - 3938 题意是要求出给定权值下,满足要求的点对的数目。所谓的要求是,给出两点,之间会有很多路径,这个点对的最小距离是众多路径中,最短的一条路径的长度,路径长度是路径上最长边的长度。于是,认真观察可以发现,两个点能连在一起的前提条件是,之间的的边都小于给定值。于是,用边来构建最小生成树就可以得到这样的一些满足要求的点对了。如果是两个集合因为一条边的加入连在一起了,那么总的点对数目就增加Na*Nb。把答案存下来,然后查询的时候二分找出满足的那一个即可。代码如下:#include #include #include #include #include using namesp. 阅读全文
posted @ 2013-07-23 11:41 LyonLys 阅读(459) 评论(0) 推荐(0)
hdu 1811 Rank of Tetris (并查集+拓扑排序)
摘要: Problem - 1811 感觉这题的并查集以及拓扑排序并不难,但是做题的时候必须理解到矛盾(CONFLICT)与不确定(UNCERTAIN)直接的优先关系。 做这题的时候,构图什么的很简单,就是没有将矛盾摆在最高优先,一旦搜到不确定的情况就立即跳转,这是不对的。代码如下: 1 #include 2 #include 3 #include 4 #include 5 #include 6 7 using namespace std; 8 9 const int N = 11111; 10 struct MFS { 11 int fa[N]; 12 ... 阅读全文
posted @ 2013-07-23 02:24 LyonLys 阅读(226) 评论(0) 推荐(0)
2013年7月22日
uva 10566 Crossed Ladders (二分)
摘要: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1507 比较简单的一题,直接对答案二分。因为对于同一组case,答案m越大,交点的高度就越小,可以从计算交点的函数中看出来。计算交点,假设mx=sqrt(sqr(x)-sqr(m)),my=sqrt(sqr(y)-sqr(m)),这两个是梯子跟两堵墙的交点。那么,交点的高度就是mx*my/(mx+my)了。代码如下: 1 #include 2 #include 3 #include 阅读全文
posted @ 2013-07-22 20:05 LyonLys 阅读(232) 评论(0) 推荐(0)
hdu 1856 More is better (并查集)
摘要: Problem - 1856 水题。离散化,然后求最大集合元素个数。 忘记压缩路径了,tle了很久。- -代码如下: 1 #include 2 #include 3 #include 4 #include 5 #include 6 7 using namespace std; 8 9 const int N = 222222;10 map id;11 12 struct MFS {13 int fa[N], sz[N], mxsz;14 void init() {15 for (int i = 0; i 2 #include 3 #incl... 阅读全文
posted @ 2013-07-22 12:37 LyonLys 阅读(187) 评论(0) 推荐(0)
hdu 3234 Exclusive-OR (并查集)
摘要: Problem - 3234 题意不难理解,就是给出一些断言,以及一些查询,回答查询或者在找到断言矛盾以后沉默不做任何事。 这题其实就是一个并查集的距离存储问题,只要记录并查集元素的相对值以及绝对值就可以了。代码如下: 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 8 using namespace std; 9 10 const int N = 22222; 11 struct MFS { 12 int fa[N], rel[N], val[N]; 13 ... 阅读全文
posted @ 2013-07-22 11:25 LyonLys 阅读(269) 评论(0) 推荐(0)
上一页 1 2 3 4 5 6 7 8 9 ··· 35 下一页
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3