![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
ACM_POJ
文章平均质量分 76
thatTime
这个作者很懒,什么都没留下…
展开
-
poj 3264 Balanced Lineup
RMQ(Range Minimum/Maximum Query)问题: RMQ问题是求给定区间中的最值问题。当然,最简单的算法是O(n)的,但是对于查询次数很多(设置多大100万次),O(n)的算法效率不够。可以用线段树将算法优化到O(logn)(在线段树中保存线段的最值)。不过,Sparse_Table算法才是最好的:它可以在O(nlogn)的预处理以后实现O(1)的查询效率。下面把Sp原创 2013-08-20 13:46:58 · 645 阅读 · 0 评论 -
ACM大纲
Changsha University of Science & TechnologyJuly 31, 20121 推荐题库• http://ace.delos.com/usaco/美国的OI 题库,如果是刚入门的新手,可以尝试先把它刷通,能够学到几乎全部的基础算法极其优化,全部的题解及标程还有题目翻译可以baidu 一个转载 2014-05-02 17:25:24 · 1454 阅读 · 0 评论 -
poj 贪心题
这几天快要期末考试了, 也不能新学习什么算法,但是又不怎么想复习,就按着poj上的分类做一下贪心题1 poj 1328 这道题今年暑假的时候就看到了,一直拖到现在, 哎 题意:海岸线的一边有岛屿, 现在要在海岸线上安装雷达,岛屿与雷达的距离在d之内可被雷达限号覆盖, 求最少雷大数 思路:求出每个雷达的在海岸线上可被覆盖的区间,问题就转化为 区间选点问题 #include原创 2013-12-27 19:59:36 · 1025 阅读 · 1 评论 -
poj 2251 Dungeon Master
三维空间的广搜, 与二维一样处理,注意细节就可以#include int dx[] = {0, -1, 1, 0, 0, 0, 0};int dy[] = {0, 0, 0, -1, 1, 0, 0};int dz[] = {0, 0, 0, 0, 0, -1, 1};const int inf = 99999999;char maze[35][35][35], s[35];i原创 2013-09-14 15:19:38 · 666 阅读 · 0 评论 -
poj 2245 Lotto
从今天开始, 花两个星期做一些搜索题。#include #include int a[15], b[10], vis[15];int k, t=0;void dfs(int n){ if(n == 7) { for(int i=1; i<=5; i++) printf("%d ", b[i]); printf("%d\n", b[6]);原创 2013-09-05 21:15:56 · 768 阅读 · 0 评论 -
poj 1562 Oil Deposits
八连快问题, 之前的题解一般都是通过dfs, 我尝试了bfs的写法, 两个时间都差不多不过dfs代码段一些dfs#include int dx[] = {0, -1, -1, -1, 0, 0, 1, 1, 1};int dy[] = {0, -1, 0, 1, -1, 1, -1, 0, 1};char grid[110][110], s[110];bool vis[原创 2013-09-11 19:01:18 · 646 阅读 · 0 评论 -
poj 1979 Red and Black
一开始你站在黑色的格子上, 每次可以上下左右走到相连的黑色格子, 但不能是红色格子, 求能走到的格子数图的遍历, bfs和dfs都可以, 时间差不多bfs#include int dx[] = {0, -1, 1, 0, 0};int dy[] = {0, 0, 0, -1, 1};char room[25][25], s[25];bool vis[25][25];i原创 2013-09-10 20:42:41 · 798 阅读 · 0 评论 -
poj EXTENDED LIGHTS OUT
开关问题是典型的高斯消元问题不过这道题我一直错了好久,后来发现在对系数矩阵a进行赋值时, 要每次都重新赋值, 不然a作为一个全局变量, 上一次计算的结果造成对下一次结果的影响,下面附上代码#include #include #include using namespace std;int a[35][35];void gauss(){ int i, j, k; for(k=原创 2013-09-01 14:14:53 · 742 阅读 · 0 评论 -
poj 1681 Painter's Problem
第三道高斯消元, 还是调试了好久, 有一些细节需要控制好, 不然虽然过了样例, 但还是错的, 特别在建立关系矩阵时不要弄错#include #include #include using namespace std;int a[250][250];char str[20];int gauss(int m){ int i, j, k; int col = 1; for(k=1原创 2013-09-01 19:40:34 · 710 阅读 · 0 评论 -
poj 1830 开关问题
高斯消元解异或方程组具体的可以参照大牛的博客http://blog.csdn.net/cjoilmd/article/details/6449566#include #include #include using namespace std;int a[35][35], str[35], end[35];int n;int gauss(){ int i, j, k原创 2013-08-30 11:00:45 · 750 阅读 · 0 评论 -
poj 2502 Subway
本题一个卡人的地方在于如何表示结束输入,可采用while(scanf() == 2),但结束输入时, scanf返回值是0,循环跳出#include #include #include #include using namespace std;const double inf = 99999999;double dis[210], cost[210][210];bool vis[原创 2013-08-25 16:49:44 · 719 阅读 · 0 评论 -
poj 3259
接近套用模板的最小生成树算法: vellaman-ford, 只要判断是否存在负环即可。 #include typedef struct{ int u; int v; int l;}path;path p[5500];int d[550];const int inf = 99999999;int f, n, m, w;void bellman(){ boo原创 2013-08-12 17:08:13 · 623 阅读 · 0 评论 -
poj 3311 Hie with the Pie
这道题主要是运用floyd算法加状态压缩dp, 有一定综合性, 但还算是一个水题, 就是这样一个水题, 做了我将近一天,其实想到这个题目怎么做的不难,但是因为我优先级弄错, 找了一天错误没有找出来。可先用floyd算法求出任意两个点之间的最短距离, 这样才能保证时间最短,然后采用状态压缩dp.#include #include using namespace std;const int原创 2013-08-23 13:30:33 · 695 阅读 · 0 评论 -
poj 3565
题意:给定平面上的n个白点和n个黑点,要求用n条线段连接白点和黑点, 并且每一条线段不想交分析:黑白点可看为二分图中的x集合和y集合,可得出当两个集合为最小圈匹配时一定满足条件#include #include #include #include const int N = 100 + 5;const double eps = 1e-10;int n;原创 2015-10-05 17:51:14 · 941 阅读 · 0 评论