
UVa
文章平均质量分 72
Daemoonn
编程呵呵哒~~
展开
-
UVa 11988 Broken Keyboard (a.k.a. Beiju Text) 数组模拟单向链表
#include #include #include using namespace std; const int maxn = 100000 + 5; //last表示最后一个字符是s[last],cur表示光标位于s[cur]后面 //Next[i]表示s[i]右面的字符编号(即在s中的下标) //last其实相当于指针链表中的指向尾节点的指针,而Next[i]相当于 /* 指针链表原创 2016-04-25 20:56:21 · 530 阅读 · 0 评论 -
UVa11997 K Smallest Sums 归并 + 优先队列
朴素算法O(n ^ n)啊,这都能做,想了想,最后只要输出其中和的前k小的就行了,有很多计算是冗余的啊,想了想,每行排个序,然后只算前两列,还有2 ^ k个,取k个绰绰有余了,O(2 ^ n),还能骗点分……扇自己一巴掌,卧槽你以为做PAT呢,还能骗分,然而还是忍不住交了一发…… WA代码: #include #include #include #include #in原创 2016-10-03 18:57:37 · 495 阅读 · 0 评论 -
UVa 10305 Ordering Tasks 拓扑排序
#include #include #include #include using namespace std; const int maxn = 100; int n, m, vis[maxn + 10], pr[maxn + 10], cnt; vector G[maxn + 5]; bool dfs(int u) { vis[u] = -1; for (vector::it原创 2016-05-17 14:39:15 · 424 阅读 · 0 评论 -
UVa 297 Quadtrees 递归
#include #include #include using namespace std; const int maxn = 1024; const int len = 32; char s[maxn + 10]; int buf[len + 5][len + 5], cnt; void draw(const char *a, int& p, int r, int c, int w原创 2016-05-17 10:20:46 · 418 阅读 · 0 评论 -
UVa10129 Play on Words 并查集判断连通+欧拉通路
10129 Play on Words Some of the secret doors contain a very interesting word puzzle. The team of archaeologists has to solve it to open that doors. Because there is no other way to open the door原创 2016-05-17 21:06:04 · 473 阅读 · 0 评论 -
UVa 548 Tree 根据后序遍历和中序遍历建树后DFS
#include #include #include #include #include #include #define PAUSE system("pause") using namespace std; const int maxv = 10000 + 10; //lch和rch分别记录当前节点的左右子树的根节点 int in_order[maxv], post_order[m原创 2016-04-28 12:08:17 · 484 阅读 · 0 评论 -
UVa 122 Trees on the level 建立二叉树BFS层序遍历
#include #include #include #include using namespace std; const int maxn = 256 + 10; char s[maxn]; struct node { int d; bool has_v; node *left, *right; node() : d(0), left(NULL), right(NULL)原创 2016-04-27 22:04:11 · 595 阅读 · 0 评论 -
UVa 12657 Boxes in a Line 数组模拟双向循环链表
#include #include #include using namespace std; const int maxn = 100000 + 10; int L[maxn], R[maxn]; void link(int X, int Y) { R[X] = Y; L[Y] = X; } void Swap(int& x, int& y) { int t = x; x =原创 2016-04-26 21:42:57 · 844 阅读 · 0 评论 -
UVa348 - Optimal Array Multiplication Sequence 区间DP
#include #include #include #include using namespace std; const int maxn = 10, INF = 0x7fffffff; int N; int r[maxn + 5], c[maxn + 5], a[maxn + 5][maxn + 5], pre[maxn + 5], post[maxn + 5]; int dp原创 2017-03-30 19:04:57 · 450 阅读 · 0 评论