摘要: 双指针算法的核心目的是将o(n2)优化到o(n) 常见问题分类: (1) 对于一个序列,用两个指针维护一段区间 (2) 对于两个序列,维护某种次序,比如归并排序中合并两个有序序列的操作 如何写:先写模拟,再观察两个指针之间的单调关系。 模板: for (int i = 0, j = 0; i < n 阅读全文
posted @ 2021-07-21 21:16 infocodez 阅读(30) 评论(0) 推荐(0) 编辑
摘要: 796. 子矩阵的和 - AcWing题库 按自己思路写出来的代码比y总的复杂一些(二维前缀和数组的初始化部分),然后按y总的思路改了一下代码 #include<bits/stdc++.h> #define rep(i,a,b) for(int i=a;i<=b;i++) #define rpe(i 阅读全文
posted @ 2021-07-16 21:05 infocodez 阅读(38) 评论(0) 推荐(0) 编辑
摘要: ios::sync_with_stdio(false); ios_base::sync_with_stdio - C++ Reference (cplusplus.com) 优点是提高 cin>> 的读取速度,缺点是不能再使用 scanf() 输入规模≥一百万,建议使用 scanf() ——yxc 阅读全文
posted @ 2021-07-16 20:36 infocodez 阅读(559) 评论(0) 推荐(0) 编辑
摘要: 高精度加法: // C = A + B, A >= 0, B >= 0 vector<int> add(vector<int> &A, vector<int> &B) { if (A.size() < B.size()) return add(B, A); vector<int> C; int t 阅读全文
posted @ 2021-07-15 09:45 infocodez 阅读(48) 评论(0) 推荐(0) 编辑
摘要: 网络是怎样连接的 (豆瓣) 入门科普类。2018年按目录做的摘录: https://note.youdao.com/s/GsjjGocL ps.无语,里面的截图全挂了。——2023年3月留 阅读全文
posted @ 2021-07-14 08:48 infocodez 阅读(40) 评论(0) 推荐(0) 编辑
摘要: 整数二分模板: bool check(int x) {/* ... */} // 检查x是否满足某种性质 // 区间[l, r]被划分成[l, mid]和[mid + 1, r]时使用: int bsearch_1(int l, int r) { while (l < r) { int mid = 阅读全文
posted @ 2021-07-13 17:51 infocodez 阅读(32) 评论(0) 推荐(0) 编辑
摘要: 788. 逆序对的数量 - AcWing题库 #include<bits/stdc++.h> #define rep(i,a,b) for(int i=a;i<=b;i++) using namespace std; typedef long long ll; const int N=1e5+10; 阅读全文
posted @ 2021-07-13 00:33 infocodez 阅读(30) 评论(0) 推荐(0) 编辑
摘要: #include<bits/stdc++.h> #define rep(i,a,b) for(int i=a;i<=b;i++) using namespace std; const int N=1e5+10; int q[N],n,tmp[N]; void mergeSort(int q[],in 阅读全文
posted @ 2021-07-12 21:45 infocodez 阅读(20) 评论(0) 推荐(0) 编辑
摘要: 785. 快速排序 - AcWing题库 l + r >> 1的值一定是小于r的,不会取到r。l<r, l+r<2r, (l+r>>1)<(2r>>1), (l+r>>1)<r 而l + r + 1 >> 1的值一定是大于l的,不会取到l。证明类比于上面 >>右移1位,等同于/2 主要注意越界问题 阅读全文
posted @ 2021-07-12 19:10 infocodez 阅读(130) 评论(0) 推荐(0) 编辑
摘要: P5461 赦免战俘 - 洛谷 | 计算机科学教育新生态 (luogu.com.cn) 题解 P5461 【赦免战俘】 - Flandre_495 的博客 - 洛谷博客 (luogu.com.cn) 题解 P5461 【赦免战俘】 - Ritanlisa 的博客 - 洛谷博客 (luogu.org) 阅读全文
posted @ 2021-07-10 17:27 infocodez 阅读(145) 评论(0) 推荐(0) 编辑
摘要: P5743 【深基7.习8】猴子吃桃 - 洛谷 | 计算机科学教育新生态 (luogu.com.cn) 题解 P5743 【【深基7.习8】猴子吃桃】 - 菜鸡 return 的 blog - 洛谷博客 (luogu.com.cn) 题目很简单,循环或者递归都可解决,但这篇题解的思路很有趣。 题目描 阅读全文
posted @ 2021-07-09 23:06 infocodez 阅读(586) 评论(0) 推荐(0) 编辑
摘要: 题解 P5736 【【深基7.例2】质数筛】 - HsKr - 洛谷博客 (luogu.com.cn) ps.题没必要看 bool isprime(int n){ if(n<=1) return false; if(n==2||n==3) return true; if(n%6!=1&&n%6!=5 阅读全文
posted @ 2021-07-09 20:03 infocodez 阅读(111) 评论(0) 推荐(0) 编辑
摘要: P1321 单词覆盖还原 - 洛谷 | 计算机科学教育新生态 (luogu.com.cn) 题解 P1321 【单词覆盖还原】 - 又菜又烂,没救了 - 洛谷博客 (luogu.com.cn) ps.naozishigehaodongxikexiwomeiyou #include<bits/stdc 阅读全文
posted @ 2021-07-09 19:52 infocodez 阅读(129) 评论(0) 推荐(0) 编辑
摘要: P1957 口算练习题 - 洛谷 | 计算机科学教育新生态 (luogu.com.cn) 题解 P1957 【口算练习题】 - shangcheng 的博客 - 洛谷博客 (luogu.com.cn) #include<bits/stdc++.h> #define rep(i,a,b) for(in 阅读全文
posted @ 2021-07-09 17:18 infocodez 阅读(110) 评论(0) 推荐(0) 编辑
摘要: P1320 压缩技术(续集版) - 洛谷 | 计算机科学教育新生态 (luogu.com.cn) 题解 P1320 【压缩技术(续集版)】 - RedContritio 的博客 - 洛谷博客 (luogu.com.cn) 注意:题解的代码,无法跳出第二个循环 for(;~scanf("%c",&c) 阅读全文
posted @ 2021-07-08 15:42 infocodez 阅读(145) 评论(0) 推荐(0) 编辑
摘要: P1319 压缩技术 - 洛谷 | 计算机科学教育新生态 (luogu.com.cn) 题解 P1319 【压缩技术】 - RedContritio 的博客 - 洛谷博客 (luogu.com.cn) #include<bits/stdc++.h> using namespace std; int 阅读全文
posted @ 2021-07-08 09:42 infocodez 阅读(43) 评论(0) 推荐(0) 编辑
摘要: P1161 开灯 - 洛谷 题解 P1161 【开灯】 - 雨竹 的博客 - 洛谷博客 利用异或运算的性质解决,简单快捷。 #include<bits/stdc++.h> #define rep(i,a,b) for(long i=a;i<=b;i++) using namespace std; i 阅读全文
posted @ 2021-07-07 18:51 infocodez 阅读(55) 评论(0) 推荐(0) 编辑
摘要: http://wap.sciencenet.cn/blog-976045-704425.html 科学网—未定元与一元多项式环的构造 - 李建华的博文 (sciencenet.cn) 线代教材P163见“未定元”,不解,寻得此文。 阅读全文
posted @ 2020-12-19 21:14 infocodez 阅读(193) 评论(0) 推荐(0) 编辑
摘要: Statistics - OJ Tracker (ojhunt.com) (刷题数目统计,涵盖大部分oj) https://ojhunt.com/statistics code forces https://codeforces.com/ AtCoder https://atcoder.jp/ vj 阅读全文
posted @ 2020-11-21 23:37 infocodez 阅读(473) 评论(0) 推荐(0) 编辑
摘要: CTF Wiki https://wiki.x10sec.org/ 网安知识索引&资源 https://shimo.im/docs/gXqmeyl8YgfQ1lqo BugkuCTF - 练习平台 https://ctf.bugku.com/ CTFHub https://www.ctfhub.co 阅读全文
posted @ 2020-11-18 22:45 infocodez 阅读(535) 评论(0) 推荐(0) 编辑