摘要: dfs+prune AC代码: #include <vector> #include <cstdio> #include <algorithm> #include <cmath> #include <numeric> using namespace std; class sol{ public: v 阅读全文
posted @ 2016-03-11 23:15 aldorado 阅读(329) 评论(0) 推荐(0) 编辑
摘要: 堆排序STL algorithm里有建堆make_heap,出栈 pop_heap(将堆首元素移至容器尾部),入栈push_heap,以及堆排序sort_heap AC代码 #include <vector> #include <cstdio> #include <string> #include 阅读全文
posted @ 2016-03-11 11:46 aldorado 阅读(185) 评论(0) 推荐(0) 编辑
摘要: 三维空间的DFS,挺新颖的一题 AC代码: #include <vector> #include <cstdio> #include <queue> using namespace std; int x[] = {0,0,1,0,-1,0}; int y[] = {0,1,0,-1,0,0}; in 阅读全文
posted @ 2016-03-10 22:59 aldorado 阅读(258) 评论(1) 推荐(0) 编辑
摘要: p,r用double类型,pat多题如果用float会WA AC代码 #include <vector> #include <cstdio> #include <cmath> using namespace std; int main(){ int n; double p,r; scanf("%d 阅读全文
posted @ 2016-03-10 22:24 aldorado 阅读(141) 评论(0) 推荐(0) 编辑
摘要: a x b = c 将a,b,c用out统一输出 AC代码: #include <cstdio> #include <string> using namespace std; long long gcd(long long x,long long y){ if(x == 0) return y; i 阅读全文
posted @ 2016-03-10 20:52 aldorado 阅读(215) 评论(0) 推荐(0) 编辑
摘要: 注意0的情况 AC代码: #include <string> #include <iostream> #include <vector> using namespace std; string number[] = {"ling","yi","er","san","si","wu","liu","q 阅读全文
posted @ 2016-03-09 22:49 aldorado 阅读(247) 评论(0) 推荐(0) 编辑
摘要: BFS,用递归的话会段错误,改用vector,变量idx记录下一层的起点 AC代码: #include <vector> #include <cstdio> #include <map> using namespace std; /*void bfs(vector<vector<int>>& g,v 阅读全文
posted @ 2016-03-09 19:44 aldorado 阅读(345) 评论(0) 推荐(0) 编辑
摘要: 最后一个测试点一直通不过,琢磨了一上午,终于找出bug 主要原因:考生k的第一个成绩是-1的情况,应将这项成绩记下,至于k是否所有提交的成绩都是-1,通过设置成员变量AC来判断,AC为true,写入vector参加后续排序,AC为false,不写入vector不参加后续排序。 AC代码: #incl 阅读全文
posted @ 2016-03-09 11:39 aldorado 阅读(140) 评论(0) 推荐(0) 编辑
摘要: 最后一个测试用例很坑,注意给出的n个节点不一定都在以h为头的链表上,这种测试用例在PAT链表相关的问题中多次出现,要予以注意。 AC代码 #include <vector> #include <map> #include <algorithm> #include <cstdio> using nam 阅读全文
posted @ 2016-03-09 00:04 aldorado 阅读(132) 评论(0) 推荐(0) 编辑
摘要: #include <string> #include <sstream> #include <map> #include <vector> #include <iostream> using namespace std; int main(){ vector<string> v; string tm 阅读全文
posted @ 2016-03-08 20:26 aldorado 阅读(259) 评论(0) 推荐(0) 编辑