摘要: 题目:http://poj.org/problem?id=2253题目大意:找到从点1到点2的某一条路中最长边,使最长的这条边尽量短算法:Kruscal思路:搜了题解……找最小生成树,加入某条边后点1和点2联通了,那么这条边就是所求边提交状况:OLE 1次, WA n次, AC 1次总结:从昨天上午纠结到今天中午……就是懒得建图……并查集也有问题,先是细节,再是路径压缩不对。我WA了一上午的题啊,同学过来不到两分钟就发现错误了……我掩面逃走……AC code :View Code 1 #include <stdio.h> 2 #include <stdlib.h> 3 阅读全文
posted @ 2011-07-23 13:49 cloehui 阅读(183) 评论(0) 推荐(0) 编辑
摘要: 题目:http://poj.org/problem?id=2387题目大意:找出从1到n的最短路算法:Dijkstra思路:很裸的Dijkstra,主要是想练习用邻接表建图提交情况:WA 3次, RE 3次, AC 1次总结:很裸的Dijkstra,主要是想练习用邻接表建图。AC的很纠结,先是懒没有判重,后来发现是无向图,改完就开始RE,开了2100的边集,一直RE,开到20100才AC。题目明明写的T <= 2000 啊,为什么就不够呢……AC code:View Code 1 #include <stdio.h> 2 #include <stdlib.h> 3 阅读全文
posted @ 2011-07-22 11:11 cloehui 阅读(223) 评论(0) 推荐(0) 编辑
摘要: 题目:http://poj.org/problem?id=2299题目大意:给出一串数字,求出逆序对的数目思路:用归并排序提交情况:AC 1次总结:拖了好久的题,终于做了。先开始对归并排序思路还是不理解,经过同学讲终于明白了。写题之前一定要仔细将原理想清楚啊。AC code:View Code 1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <string.h> 4 #define MAXN (500000 + 100) 5 #define I64 __int64 6 7 I64 num[MAXN] 阅读全文
posted @ 2011-07-22 08:23 cloehui 阅读(256) 评论(0) 推荐(0) 编辑
摘要: 题目:http://acm.hdu.edu.cn/showproblem.php?pid=2108题目大意:给出点数n, 逆时针顺序给出n个点的坐标,都为整数,判断所围多边形是凸的还是凹的。思路:按照逆时针顺序连出向量p0p1,p1p2,p3p4……若是凸多边形,那么b相对于a一定是向逆时针方向旋转的,判断两向量的旋转方向,可以使用向量的叉积a×b= x1×y2- x2×y1。自己想了好久不会,看了别人的题解,发现思路还是很清晰的……提交情况:AC 1次AC code :View Code 1 #include <stdio.h> 2 3 #inclu 阅读全文
posted @ 2011-07-20 16:32 cloehui 阅读(311) 评论(0) 推荐(0) 编辑
摘要: 题目:http://acm.hdu.edu.cn/showproblem.php?pid=3857题目很长,都是废话,就是找数组下表和值相同的数值。提交情况:WA n次, AC 1次总结:水题啊!大水题!突然想用'\b'退格键来处理最后一个数的格式,结果一直WA。因为输出了答案中不存在的字符,所以会WA。最后终于放弃退格,安分的分情况处理格式了。AC code:View Code 1 #include <stdio.h> 2 3 4 5 #define MAXN (10000 + 100) 6 7 8 9 int num[MAXN];10 11 12 13 void 阅读全文
posted @ 2011-07-20 16:31 cloehui 阅读(223) 评论(0) 推荐(0) 编辑
摘要: View Code 1 #include <cstdio> 2 3 #include <cstdlib> 4 5 #include <cstring> 6 7 8 9 #define MAXN (100000 + 100) 10 11 #define I64 __int64 12 13 14 15 int a[MAXN], f[MAXN]; 16 17 I64 head, tail; 18 19 I64 nowh, nowt; 20 21 I64 res; 22 23 24 25 void Clear() { 26 27 memset(a, 0, sizeo 阅读全文
posted @ 2011-07-20 16:30 cloehui 阅读(157) 评论(0) 推荐(0) 编辑
摘要: 题目:http://poj.org/problem?id=3259题目大意:有F个fields,N条正常的路径,W个虫洞,走正常路径耗时,走虫洞减时。要从原点走一条回路,满足再回到原点时所用时间和小于0思路:Bellman-Ford判断从源点可达的负权回路算法:Bellman-Ford提交情况:WA n次, AC 1次总结:正常路径是双向的,虫洞是单向的。所以最多一共有(2 * M + W)条路,先开始数据开小了。AC code :View Code 1 #include <cstdio> 2 3 #include <cstring> 4 5 #include < 阅读全文
posted @ 2011-07-20 16:30 cloehui 阅读(276) 评论(0) 推荐(0) 编辑
摘要: 题目:http://poj.org/problem?id=1861题目大意:要用最短的电缆把所有的电脑都连接起来。算法:Kruscal+并查集思路:常规Kruscal+并查集。先开始没注意到是SPJ,看样例输出一个环很是疑惑,纠结了半天,看了discuss,才知道是样例的问题……不用管样例,常规做就好提交情况:1次ACAC code:View Code 1 #include <cstdio> 2 3 #include <cstdlib> 4 5 #include <cstring> 6 7 #include <algorithm> 8 9 usi 阅读全文
posted @ 2011-07-20 16:29 cloehui 阅读(294) 评论(0) 推荐(0) 编辑
摘要: 题目:http://poj.org/problem?id=2395题目大意:找到连接所有农场的最小生成树,并找到其中最长的一条路。算法:Kruskal+并查集提交情况:1次AC思路:很裸的Kruskal+并查集,连边数都给出来了。建立边集,常规Kruskal+并查集,记录当前最小生成树中最大边。AC codeView Code 1 #include<stdio.h> 2 3 #include<stdlib.h> 4 5 #include<string.h> 6 7 #include<algorithm> 8 9 using namespace s 阅读全文
posted @ 2011-07-20 16:27 cloehui 阅读(261) 评论(0) 推荐(0) 编辑
摘要: 题目:http://acm.hdu.edu.cn/showproblem.php?pid=1061题目大意:求n^n的最右位。提交情况:n次WA。总结:记得每次都要取模,否则会溢出。特殊当 n== 0,输出1。思路:快速幂求n^n,每运算一次要模10。AC code:View Code 1 #include <cstdio> 2 3 #include <cstdlib> 4 5 #define I64 __int64 6 7 8 9 int Fuction(I64 n) {10 11 int res = 1;12 13 I64 b = n;14 15 if(!n) // 阅读全文
posted @ 2011-07-20 16:26 cloehui 阅读(278) 评论(0) 推荐(0) 编辑