TmonoのACM
坚持是一种饼~
摘要: Problem 1542 - F - CountriesTime Limit: 1000MS Memory Limit: 65536KB Total Submit: 266 Accepted: 36 Special Judge: NoDescriptionThere are ... 阅读全文
posted @ 2014-04-01 15:56 Pobo_biu 阅读(136) 评论(0) 推荐(0) 编辑
摘要: #include#include#include#includeusing namespace std;#define INF 0x7fstruct node{ int x, y; int cont;};bool inq[8][8];node cb[9][9];cha... 阅读全文
posted @ 2014-03-26 16:56 Pobo_biu 阅读(134) 评论(0) 推荐(0) 编辑
摘要: 1、Euclidean algorithm【辗转相除法】 古老的求最大公约数(greatest common divisor GCD)的算法算法思想参见wikipedia:http://en.wikipedia.org/wiki/Euclidean_algorithmint ... 阅读全文
posted @ 2014-03-26 09:09 Pobo_biu 阅读(155) 评论(0) 推荐(0) 编辑
摘要: 拖了有段时间,今天来总结下两个常用的素数筛法:1、sieve of Eratosthenes【埃氏筛法】这是最简单朴素的素数筛法了,根据wikipedia,时间复杂度为,空间复杂度为O(n)。算法思想:先假定所有的数都是素数,然后从最小的素数2出发,把素数的所有倍数筛出去。又... 阅读全文
posted @ 2014-03-25 16:55 Pobo_biu 阅读(249) 评论(0) 推荐(0) 编辑
摘要: 题目大意:求最长上升子序列(LIS)长度,序列最大数不超过40000。因为只有上升排列的接口才不相交。思路:普通的 O(n^2)的做法肯定会超时;因此,dp[ ] 记录长度为 i+1 的子序列中最末元素的最小值,这一数组是单调递增的,因此对于dp[ ]数组内元素可以用二分搜索... 阅读全文
posted @ 2014-03-06 14:58 Pobo_biu 阅读(162) 评论(0) 推荐(0) 编辑
摘要: 题目大意: 已知n 个点,m条路线,s为终点;给出m条路线及其权值;给出w个起点,求最短路!思路:基础的dijkstra,有向无环正权最短路,只要把终点和起点 reverse考虑便可。AC代码如下:#include#include#includeusing namespace... 阅读全文
posted @ 2014-03-06 00:18 Pobo_biu 阅读(136) 评论(0) 推荐(0) 编辑
摘要: 最全输入函数 c/c++一:c=getchar();功能:读入一个字符说明:调用此函数时要求在程序的第一行有预编译命令:#include,不过在做c++时有#include也够了。变量c获得一个从标准设备上读取的字符代码值。当从键盘上输入^z(即CTRL和Z键同时按下)时,C... 阅读全文
posted @ 2014-03-05 09:39 Pobo_biu 阅读(164) 评论(0) 推荐(1) 编辑
摘要: 题目链接:http://poj.org/problem?id=2524题意: n个人,m对人宗教相同,输出一共有多少个不同的宗教。代码如下:#include#includeusing namespace std;#define M 500100int par[M];int h... 阅读全文
posted @ 2014-03-03 19:27 Pobo_biu 阅读(187) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://poj.org/problem?id=1611题意:输入n个人,m个组。初始化0为疑似病例。输入m个小组,每组中只要有一个疑似病例,整组人都是疑似病例。相同的成员可以在不同的组。找出一共有多少个疑似病例。解题思路:同组的同parent,查找,合并集合。... 阅读全文
posted @ 2014-02-27 15:19 Pobo_biu 阅读(166) 评论(0) 推荐(0) 编辑
摘要: 题目一:http://poj.org/problem?id=3468DescriptionYou have N integers, A1, A2, ... , AN. You need to deal with two kinds of operations. One type of operati... 阅读全文
posted @ 2013-12-08 00:50 Pobo_biu 阅读(167) 评论(0) 推荐(0) 编辑