上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 30 下一页
摘要: 三个注意点: 1.给出的n个节点并不一定都在链表中 2.最后一组样例首地址即为-1 3.输出地址的时候一直忘记前面要补0。。。 #include <iostream> #include <algorithm> #include <cstdio> #include <string.h> using n 阅读全文
posted @ 2017-03-12 18:43 辰曦~文若 阅读(168) 评论(0) 推荐(0) 编辑
摘要: 由于最后输出的路径排序是降序输出,相当于dfs的时候应该先遍历w最大的子节点。 链式前向星的遍历是从最后add的子节点开始,最后添加的应该是w最大的子节点, 因此建树的时候先对child按w从小到大排序,然后再add建边。 水题一个,不多说了。 #include <iostream> #includ 阅读全文
posted @ 2017-03-12 18:15 辰曦~文若 阅读(242) 评论(0) 推荐(0) 编辑
摘要: 原本用map,发现超时了,后来便先用数组存储排个序,最后for一遍统计每种颜色出现的次数(每种颜色的首位索引相减+1),找出最多的即可。 #include <iostream> #include <cstdio> #include <algorithm> #include <string.h> #i 阅读全文
posted @ 2017-03-12 15:49 辰曦~文若 阅读(205) 评论(0) 推荐(0) 编辑
摘要: 题目简单,但解题的思路需要转换一下,按常规思路肯定超时,推荐~ 题意:给出n个人的姓名、年龄和拥有的钱,然后进行k次查询,输出年龄在[amin,amx]内的前m个最富有的人的信息。如果财富值相同就就先输出年龄小的,如果年龄相同就按照名字的字典序排序输出~ n范围为10^5,所以显然不能每次查询的时候 阅读全文
posted @ 2017-03-08 19:18 辰曦~文若 阅读(458) 评论(0) 推荐(0) 编辑
摘要: 有n个老鼠,第一行给出n个老鼠的重量,第二行给出他们的顺序。1.每一轮分成若干组,每组m个老鼠,不能整除的多余的作为最后一组。2.每组重量最大的进入下一轮。让你给出每只老鼠最后的排名。很简单,用两个数组模拟一下即可order1存储进入当前一轮老鼠的索引顺序order2存储进入下一轮老鼠的索引顺序 如 阅读全文
posted @ 2017-03-08 16:06 辰曦~文若 阅读(1412) 评论(0) 推荐(1) 编辑
摘要: 无语,这种水题还出,浪费时间,但又不得不A。。。 #include <iostream> #include <cstdio> #include <algorithm> #include <string.h> #include <cmath> #define SICKLE 17 #define KNU 阅读全文
posted @ 2017-03-06 18:35 辰曦~文若 阅读(141) 评论(0) 推荐(0) 编辑
摘要: 用素数筛选法即可。 范围long int,其实大小范围和int一样,一开始以为是指long long,想这就麻烦了该怎么弄。 而现在其实就是int的范围,那难度档次就不一样了,瞬间变成水题一枚,因为int根号后大小不超过60000。 即因子的大小不会超过60000,除非本身是质数。 int 4 -2 阅读全文
posted @ 2017-03-06 18:06 辰曦~文若 阅读(274) 评论(0) 推荐(0) 编辑
摘要: 根据中序遍历和前序遍历确定一棵二叉树,然后按“层次遍历”序列输出。输出规则:除根节点外,接下来每层的节点输出顺序是:先从左到右,再从右到左,交替输出 #include <iostream> #include <cstdio> #include <algorithm> #include <string 阅读全文
posted @ 2017-03-05 20:07 辰曦~文若 阅读(965) 评论(0) 推荐(0) 编辑
摘要: 题目已经告诉如何判断欧拉回路了,剩下的有一点要注意,可能图本身并不连通。 所以这里用并查集来判断图的联通性。 #include <iostream> #include <cstdio> #include <algorithm> #include <string.h> #include <string 阅读全文
posted @ 2017-03-05 20:03 辰曦~文若 阅读(620) 评论(0) 推荐(0) 编辑
摘要: 贪心水题,每次取最短的两个绳子合并,长度缩减成一半 #include <iostream> #include <cstdio> #include <algorithm> #include <string.h> #include <string> #include <map> using namesp 阅读全文
posted @ 2017-03-05 19:45 辰曦~文若 阅读(241) 评论(0) 推荐(0) 编辑
上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 30 下一页