随笔分类 -  AcWing笔记

摘要:题目链接:https://www.acwing.com/problem/content/802/ 双指针的妙用 先打暴力,在改成双指针。 正确解法 遍历l,确保不会漏 #include<iostream> using namespace std; const int maxn = 1e5 + 10; 阅读全文
posted @ 2020-12-04 23:42 ATKevin 阅读(119) 评论(0) 推荐(0)
摘要:1.有问题代码 class Solution { public: void nextPermutation(vector<int>& nums) { int n = nums.size(); int i = n-1; while(i > 0) { if(nums[i] <= nums[i-1]) i 阅读全文
posted @ 2020-11-30 09:31 ATKevin 阅读(124) 评论(0) 推荐(0)
摘要:前缀和 题目:https://www.acwing.com/activity/content/problem/content/829/1/ #include<iostream> using namespace std; const int maxn = 1e5; int n, m, l, r; in 阅读全文
posted @ 2020-10-11 11:09 ATKevin 阅读(114) 评论(0) 推荐(0)
摘要:这里涉及字典序的比较大小方式。string类型不是不能比大小,而是规则上有所不同 粗略地概括一下: 从最高位比起,ASCII码更大的字符串更大。如果相等,比次高位,以此向下类推。 所以在stringstring中,串 9 > 899>89 。因为最高位9 >89>8 阅读全文
posted @ 2020-09-15 15:57 ATKevin 阅读(1980) 评论(0) 推荐(0)
摘要:左边界模板 找第一个大于等于x的数 while(l < r) { mid = l+r >> 1; if(a[mid].s >= k) r = mid; else l = mid + 1; } if(a[l].s == k) cout << a[l].num << " "; else { cout < 阅读全文
posted @ 2020-09-02 20:33 ATKevin 阅读(119) 评论(0) 推荐(0)
摘要:基础算法 *排序 快排 不稳定(非复杂度) 时间复杂度:nlogn 思想:先排序,在递归。 题目:https://www.acwing.com/problem/content/787/ #include<iostream> using namespace std; const int maxn = 阅读全文
posted @ 2020-08-24 00:06 ATKevin 阅读(103) 评论(0) 推荐(0)