
[ACM ICPC]
文章平均质量分 86
yeweiouyang
这个作者很懒,什么都没留下…
展开
-
HDOJ 1247 -- Hat Words Trie
思路:先将所有的单词插入到 Trie 中,然后对于每个单词枚举前后位置 1 /* 2 PROG: Hat’s Words 3 ID : yewei 4 LANG: C++ 5 */ 6 #include 7 #include 8 #include 9 #include 10 11 //const int size = 102;原创 2013-03-05 09:56:53 · 803 阅读 · 0 评论 -
ACM ICPC过来人对初学者的建议
作为ACM ICPC的过来人,临近毕业之际,我觉得有必要对后人作出自己的一点贡献,不正之处,望不吝指出!原创 2013-10-25 14:40:07 · 2699 阅读 · 0 评论 -
旧代码 - 高精度阶乘
#include int casenum,bit;int buf,res;int answer[9000];int main(){ register int i,j; while (1 == scanf("%d", &casenum)) { bit = answer[0] = 1; for (i=1;原创 2013-03-05 09:53:37 · 824 阅读 · 0 评论 -
旧代码 - 高精度乘法
#include #include #include #include int i,j,aLen,bLen,cnt,nCases;int result[2005];char a[1001],b[1001];int main(){ scanf("%d",&nCases); while( nCases-- ) { me原创 2013-03-05 09:53:13 · 1012 阅读 · 0 评论 -
旧代码 - 高精度加法
#include #include #include int flag = 0 , cnt = 1;int casenum,buf,res,bit,aLen,bLen;char a[1001],b[1001],answer[1001];int main(){ register int i,j; scanf("%d", &casenum);原创 2013-03-05 09:52:47 · 780 阅读 · 0 评论 -
旧代码 - 手写堆
#include #include #define onlinejudgeconst int maxn = 1000010;const int INF = 0x3F3F3F3F;char ch;int casenum, kNum, cnt, num, heap[maxn];void shiftdown(int fa, int n){ int son, key=h原创 2013-03-05 09:45:03 · 1037 阅读 · 0 评论 -
旧代码 - 最小生成树 - Prim
/*PROG: MST_PRIMID : ouyangyeweiLANG: C++*/#include #include #include #define DEBUG 1const int MAXN = 1004;const int MAXM = 15004;const int INF = 0x3F3F3F3F;int N, M;int lowco原创 2013-03-05 09:48:17 · 845 阅读 · 0 评论 -
旧代码 - 最短路 Spfa(邻接表)
/*PROG: spfa_adjacent tableID : ouyangyeweiLANG: C++*/#include #include #include using namespace std;#define onlinejudgeconst int maxn = 1004;const int INF = 0x3F3F3F3F;bool inq[原创 2013-03-05 09:52:12 · 880 阅读 · 0 评论 -
旧代码 - 最短路 Spfa
/*PROG: spfaID : ouyangyeweiLANG: C++*/#include #include #include using namespace std;#define onlinejudgeconst int maxn = 1004;const int INF = 0x3F3F3F3F;bool inq[maxn];int N,原创 2013-03-05 09:51:43 · 941 阅读 · 0 评论 -
旧代码 - 最短路 Bellman Ford(邻接表)
/*PROG: Bellman FordID : ouyangyeweiLANG: C++*/#include #include #include #define onlinejudgeconst int maxn = 1004;const int INF = 0x3F3F3F3F;int N, M, destination;int dist[maxn]原创 2013-03-05 09:50:33 · 860 阅读 · 0 评论 -
旧代码 - 最短路 Bellman Ford
/*PROG: Bellman_FordID : ouyangyeweiLANG: C++*/#include #include #include #define onlinejudgeconst int maxn = 1004;const int INF = 0x3F3F3F3F;int N, destination, dist[maxn], path[原创 2013-03-05 09:49:15 · 801 阅读 · 0 评论 -
Poj 3626 BFS
#include #include #include #include #include int mat[1010][1010]; int i, nNum, tx, ty, ai, bi; int dx[] = {-1, 1, 0, 0}; int dy[] = {0, 0, -1, 1}; struct path { int x, y, step;原创 2013-03-07 13:44:19 · 842 阅读 · 0 评论 -
Hdoj 1509 -Windows Message Queue 优先队列最小堆实现
一开始提交后得到了好几个WA,搞得我一直很郁闷,于是重新看了一下题目,发现有一个地方我没有考虑到Note that one message can appear twice or more and if two messages have the same priority, the one comes first will be processed first.(i.e., FIFO f原创 2013-03-07 13:37:28 · 900 阅读 · 0 评论 -
HDOJ 1251 -- 统计难题 Trie
Trie的写法是很灵活的,感觉跟segment tree一样,要活用/* PROG: 统计难题 ID : LANG: C++ */ #include #include #include #include #include #include using namespace std; struct Trie_Node { int原创 2013-03-07 13:51:18 · 854 阅读 · 0 评论 -
HDOJ 1496 - Equations Hash
1 // Accept 31ms 544k 2 #include 3 #include 4 #include 5 #include string.h> 6 #include 7 8 /* 将方程分划为2个部分,前一个部分最多有100*100种可能 */ 9 #define MAX 3009310 11 int s[10010]={0};12 int a, b,原创 2013-03-07 13:39:16 · 974 阅读 · 0 评论 -
USACO 2.3.1 Longest Prefix --- Trie
/* PROG: prefix ID : LANG: C++ */ #include #include #include #include #include #include #include using namespace std; struct Trie_Node { bool IsEnd; Trie_Node原创 2013-03-07 13:45:59 · 888 阅读 · 0 评论 -
HDOJ - 4414 (Finding crosses)
/* PROG: Finding crosses ID : LANG: C++ */ //#pragma warnning (diaable : 4530) //#pragma warnning (disable : 4786) #include #include #include #include #include #include #i原创 2013-03-07 13:52:58 · 820 阅读 · 0 评论 -
UVA 705 - Slash Maze (Flood_Fill + DFS)
分析:1. 可以知道的是,給定的 slash Maze 中只存在 ‘/’ 和 ‘\’ ,將斜線或反斜線離散化為 3 * 3 單位的方格,比如 用數字 1 表示單位被覆蓋,數字 0 表示單位是空白,則 /001010100 也可以用 2 * 2 的單元格表示原创 2013-03-07 13:38:08 · 1018 阅读 · 0 评论 -
ZOJ 1649 - Rescue BFS/优先队列
在HDOJ上提交通过以后,再在zoj上提交,结果得到了无数个WA,后来发现有一种情况我并没有考虑到 有几个关键的地方需要注意:1. Angel的朋友不只有一个,可能有多个2. guard的存在可能会破坏广度优先树解决办法:BFS的做法:必须要保存guard与可行点‘.’的插入同步,因为guard的costTime不同,应该先不改变其坐标,costTi原创 2013-03-07 13:41:12 · 1215 阅读 · 0 评论 -
Poj 1915 - Knight Moves 双向广搜
#include #include int vis[305][305], mat[305][305]; int dx[] = {-2, -2, -1, 1, 2, 2, 1, -1}; int dy[] = {-1, 1, 2, 2, 1, -1, -2, -2}; int casenum, nNum, sx, sy, tx, ty, i; struct point {原创 2013-03-07 13:43:34 · 956 阅读 · 0 评论 -
Poj 3253 - Fence Repair 最小堆
题目大意:FJ需要修补牧场的围栏,他需要 N 块长度为 Li 的木头(N planks of woods)。开始时,FJ只有一块无限长的木板,因此他需要把无限长的木板锯成 N 块长度为 Li 的木板,Farmer Don提供FJ锯子,但必须要收费的,收费的标准是对应每次据出木块的长度,比如说测试数据中 5 8 8,一开始,FJ需要在无限长的木板上锯下长度 21 的木板(5+8+8=21),原创 2013-03-07 13:36:53 · 840 阅读 · 0 评论 -
HDOJ 1026 Ignatius and the Princess I
经典BFS+记忆表 解题思路:因为存在具有Hp为n的monster存在,如果直接压入队列,就有可能破坏广度优先树,因此必须在处理的过程中保证monster和‘.’的处理是保存同步的,处理方法:如果当前位置是monster,那么我就削减他一个HP,再压入队尾,直到HP为0时,把地图上monster的位置置为‘.’可行位置,这样一来,monster和‘.’的处理原创 2013-03-07 13:40:24 · 898 阅读 · 0 评论 -
HDOJ 1075 -- What Are You Talking About Trie( STL )
方法一:Trie思路:1. 开辟一个结构体数组dict,数组中存放索引值和索引,比如from fiwo2. 建立一颗Trie,Trie维护 整型变量 index,结构体指针数组 branch,在建立Trie的过程中,若是单词结尾,Trie中index赋值为dict的索引,否则为-1 写法一:string类降低编码复杂度,当然代价是时间复杂度加大约 2原创 2013-03-07 13:48:22 · 864 阅读 · 0 评论 -
旧代码 - 最短路 Floyd
/*PROG: floydID : ouyangyeweiLANG: C++*/#include #include #include #define onlinejudgeconst int maxn = 1004;const int INF = 0x3F3F3F3F;int N, M, destination;int edge[maxn][maxn],原创 2013-03-05 09:51:14 · 695 阅读 · 0 评论