Loading

02 2020 档案

摘要:题目链接: https://www.acwing.com/problem/content/1103/ 题解: !!! 要么在bfs内部定义queue,要么每次在进入bfs时将queue清空!!!! AC代码:#include <cstdio> #include <cstring> #include 阅读全文
posted @ 2020-02-28 19:49 Doubest 阅读(177) 评论(0) 推荐(0)
摘要:题目链接: https://www.acwing.com/problem/content/1240/ 题解: 双指针算法,注意率先移动前向的指针,当前向指针的时间-后向指针的时间超过了规定时间的话,后项指针要移动到该区间里才行 AC代码: #include <cstdio> #include <cs 阅读全文
posted @ 2020-02-28 19:15 Doubest 阅读(190) 评论(0) 推荐(0)
摘要:题目链接: https://www.acwing.com/problem/content/1272/ 题解: 线段树模板题,单点求和、区间查询都可 AC代码: #include <cstdio> #include <iostream> #include <algorithm> #include <c 阅读全文
posted @ 2020-02-16 22:03 Doubest 阅读(144) 评论(0) 推荐(0)
摘要:题目链接: https://www.acwing.com/problem/content/description/1266/ 题解: 模板题,记query()、add()、lowbit()函数即可 AC代码: #include <iostream> #include <cstdio> #includ 阅读全文
posted @ 2020-02-16 09:26 Doubest 阅读(185) 评论(0) 推荐(0)
摘要:题目链接: https://www.acwing.com/problem/content/790/ 题解: 左边部分的下标必定小于右边部分的下标,且左右两边都排好序了,计算即可。 AC代码: #include <iostream> #include <cstring> #include <cstdi 阅读全文
posted @ 2020-02-14 14:27 Doubest 阅读(151) 评论(0) 推荐(0)
摘要:题目链接: https://www.acwing.com/problem/content/description/789/ 题解: 1、找分界点。 2、分别排序 3、归并 递归实现 AC代码: #include <cstdio> #include <cstring> #include <iostre 阅读全文
posted @ 2020-02-14 13:34 Doubest 阅读(255) 评论(0) 推荐(0)
摘要:题目链接: https://www.acwing.com/problem/content/1233/ 题解: (飞行时间+时差 + 飞行时间 - 时差) / 2 = 飞行时间 AC代码: #include <cstdio> #include <cstring> #include <iostream> 阅读全文
posted @ 2020-02-13 22:43 Doubest 阅读(260) 评论(0) 推荐(0)
摘要:题目链接: https://www.acwing.com/problem/content/1231/ 题解: 估计自己太弱了,处理字符串比较痛苦,最后记得用unique去重。 代码: #include <cstring> #include <cstdio> #include <string> #in 阅读全文
posted @ 2020-02-12 15:54 Doubest 阅读(242) 评论(0) 推荐(0)
摘要:题目链接: https://www.acwing.com/problem/content/1221/ 题解: 对于分子分母都是整数的除法,例如a/b,除了可以用ceil()函数向上取整外,还可以直接用公式(a+b-1)/b; 代码: #include <algorithm> #include <io 阅读全文
posted @ 2020-02-12 14:37 Doubest 阅读(196) 评论(0) 推荐(0)
摘要:题目链接: https://www.acwing.com/problem/content/1206/ 题解: (1)getline()不会读\n,并且会抛弃读到的\n,而且不会留在缓冲区中。 (2)cin不会读\n,但是会把它留在缓冲区中等其他人读入 (3)stringstream在字符串、数字互转 阅读全文
posted @ 2020-02-11 22:16 Doubest 阅读(242) 评论(0) 推荐(0)
摘要:题目链接: https://www.acwing.com/problem/content/1216/ 题解: 一定要注意对于负数取余,要用数学上的定义,必须>=0 最后那个s也要记得用函数取余 AC代码: #include <iostream> #include <algorithm> #inclu 阅读全文
posted @ 2020-02-10 16:26 Doubest 阅读(297) 评论(0) 推荐(0)
摘要:题目链接: https://www.acwing.com/problem/content/description/1214/ 题解: DP问题混合怪兽 AC代码: #include <cstring> #include <iostream> #include <algorithm> #include 阅读全文
posted @ 2020-02-10 14:53 Doubest 阅读(168) 评论(0) 推荐(0)
摘要:题目链接: https://www.acwing.com/problem/content/897/ 题解: 一维DP问题,非常经典 AC代码: #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> 阅读全文
posted @ 2020-02-09 16:50 Doubest 阅读(105) 评论(0) 推荐(0)
摘要:题目链接: https://www.acwing.com/problem/content/2/ 题解: 关于DP问题,我们一般可以用一套模式去分析 1、分析状态表示f(i,j): 1)f(i,j)表示哪个集合?在01背包问题中,它表示选法的一个集合 2)i,j表示什么条件?在01背包问题中,它表示前 阅读全文
posted @ 2020-02-09 11:08 Doubest 阅读(118) 评论(0) 推荐(0)
摘要:题目链接: https://www.acwing.com/problem/content/101/ 题解: 边界问题最复杂,画图好好模拟一下,二维前缀和还是比较容易的 枚举的所有的边长为R的正方形,AC代码是枚举的正方形的左上端点。 AC代码: #include <cstdio> #include 阅读全文
posted @ 2020-02-08 13:07 Doubest
摘要:题目链接: https://www.acwing.com/problem/content/1232/ 题解: 这个公式最重要s[r] - s[l-1] % k == 0 等价于 s[r]%k == s[l-1] % k 意思就是说,只要s[n]和s[m]模k的值一样,他们必然可以组成一个k倍区间 边 阅读全文
posted @ 2020-02-07 19:06 Doubest 阅读(107) 评论(0) 推荐(0)
摘要:题目链接: https://www.acwing.com/problem/content/798/ 代码: #include <cstdio> #include <cstring> #include <algorithm> using namespace std; const int N = 100 阅读全文
posted @ 2020-02-07 14:24 Doubest 阅读(145) 评论(0) 推荐(0)
摘要:问题描述: Ubuntu系统运行没有问题,一个大问题就是鼠标不灵,失控,但是鼠标又没有问题 解决办法: 关闭桌面日历! 阅读全文
posted @ 2020-02-06 19:14 Doubest 阅读(128) 评论(0) 推荐(0)
摘要:题目链接: https://www.acwing.com/problem/content/732/ 题解: 这个题最重要的一点就是:用初始值丈量能不能行时,一定要及时停止,不然连long long都给你爆了。 二分的两个边界: l = (min + 1) / 2 r = max 原因是: x + x 阅读全文
posted @ 2020-02-06 13:55 Doubest 阅读(260) 评论(0) 推荐(0)
摘要:给定一个按照升序排列的长度为n的整数数组,以及 q 个查询。 对于每个查询,返回一个元素k的起始位置和终止位置(位置从0开始计数)。 如果数组中不存在该元素,则返回“-1 -1”。 输入格式 第一行包含整数n和q,表示数组长度和询问个数。 第二行包含n个整数(均在1~10000范围内),表示完整数组 阅读全文
posted @ 2020-02-06 11:35 Doubest 阅读(112) 评论(0) 推荐(0)