摘要: http://livearchive.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2081解题:很暴力的spfa压线过了。。View Code #include<iostream>#include<cstdio>#include<algorithm>#include<vector>#include<queue>#include<cstring>#define maxn 2500 阅读全文
posted @ 2012-10-05 21:43 一把刷子 阅读(227) 评论(0) 推荐(0) 编辑
摘要: http://livearchive.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=3736解题:题目理解很关键。。因为只有两种颜色。。所以二进制枚举。。。 如果出现某一个集合只有一种颜色(全为0,或者全为1)返回false,否则返回true。。蛋疼的是读入。。蛋碎了一地。。用了stringstream搞定http://www.cppblog.com/Sandywin/archive/2007/07/13/27984.htmlView Code #i 阅读全文
posted @ 2012-10-05 21:35 一把刷子 阅读(209) 评论(0) 推荐(0) 编辑
摘要: 转自:http://www.cppblog.com/Sandywin/archive/2007/07/13/27984.htmlC++标准库中的<sstream>提供了比ANSI C的<stdio.h>更高级的一些功能,即单纯性、类型安全和可扩展性。在本文中,我将展示怎样使用这些库来实现安全和自动的类型转换。为什么要学习如果你已习惯了<stdio.h>风格的转换,也许你首先会问:为什么要花额外的精力来学习基于<sstream>的类型转换呢?也许对下面一个简单的例子的回顾能够说服你。假设你想用sprintf()函数将一个变量从int类型转换到字符串 阅读全文
posted @ 2012-10-05 20:54 一把刷子 阅读(440) 评论(0) 推荐(0) 编辑
摘要: http://livearchive.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=3734解题 :暴力枚举,二进制枚举状态。。View Code #include<iostream>#include<stdio.h>#include<string.h>#include<algorithm>#define inf ~0U>>1using namespace std;int n,m;const 阅读全文
posted @ 2012-10-05 00:43 一把刷子 阅读(203) 评论(0) 推荐(0) 编辑
摘要: http://livearchive.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=3735给了二叉树的先序遍历给成后续遍历。。解题: 分而治之。。View Code #include<iostream>#include<string.h>#include<algorithm>#include<stdio.h>using namespace std;const int maxn=100000;int n 阅读全文
posted @ 2012-10-05 00:16 一把刷子 阅读(222) 评论(0) 推荐(0) 编辑