考虑莫队。 如果是单纯的莫队的话,还需要一个树状数组来维护逆序对数,这样子的话复杂度是 \(O(n^{1.5}\log n)\),难以接受。 怎么将这个树状数组消除? 考虑当前区间为 \([l,r-1]\) ,需要将右端点向右移动,即加入 \(a_r\) ,并且将答案加上 \(a_{l,l+1,\c ...
分类:
其他好文 时间:
2020-12-25 12:28:35
阅读次数:
0
4Sum II (M) 题目 Given four lists A, B, C, D of integer values, compute how many tuples (i, j, k, l) there are such that A[i] + B[j] + C[k] + D[l] is ze ...
分类:
其他好文 时间:
2020-12-22 12:32:53
阅读次数:
0
import turtle def drawTriangle(num,len,flag):#flag用来调整画三角形的方向 flag*=-1 len/=2 if(num==1): if(flag==1): turtle.left(60) turtle.fd(len) turtle.right(120 ...
分类:
其他好文 时间:
2020-12-19 12:32:01
阅读次数:
1
给定一个链表,返回链表开始入环的第一个节点。 如果链表无环,则返回 null。表为无头结点、单向。(由于涉及到结构体,所以写不了完整的测试代码,下面展示的代码为LeetCode中写的代码) //第一次尝试://方法:图文解释: //当然,这个方法有点不好想,我们还可以这样做:(这里就不演示了) st ...
分类:
其他好文 时间:
2020-12-19 12:20:15
阅读次数:
1
from docx.shared import Pt,RGBColor from docx.oxml.ns import qn #word中字体的颜色、大小、字体def style(tt,tsize,color,rfont): for ii in tt: for run1 in ii.runs: f ...
分类:
其他好文 时间:
2020-12-16 12:37:51
阅读次数:
2
ST表的功能很简单 它是解决RMQ问题(区间最值问题)的一种强有力的工具 它可以做到O(nlogn)预处理,O(1)查询最值 ST表是利用的是倍增的思想 拿最大值来说 我们用Max[i][j]表示,从i位置开始的2j个数中的最大值,例如Max[i][1]表示的是ii位置和i+1位置中两个数的最大值 ...
分类:
其他好文 时间:
2020-12-14 13:48:47
阅读次数:
3
此博客连接:https://www.cnblogs.com/ping2yingshi/p/14054440.html 存在重复元素2 题目链接:https://leetcode-cn.com/problems/contains-duplicate-ii/submissions/ 题目 给定一个整数数 ...
分类:
其他好文 时间:
2020-12-03 11:48:40
阅读次数:
2
problem: 给你n个数字,和m个查询. 将[l,r]之间数第一次出现的位置信息弄成一个新的数组,然后找出其中k/2大的数.(k为位置的数量) #include<bits/stdc++.h> using namespace std; const int maxn=2e5+100; const i ...
分类:
其他好文 时间:
2020-11-26 14:12:20
阅读次数:
3
Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: Integers in each row are sorted i ...
分类:
其他好文 时间:
2020-11-25 12:59:50
阅读次数:
14
LeetCode82 删除排序链表中的重复元素II 题目描述 给定一个排序链表,删除所有含有重复数字的节点,只保留原始链表中 没有重复出现 的数字。 样例 输入: 1->2->3->3->4->4->5 输出: 1->2->5 输入: 1->1->1->2->3 输出: 2->3 算法分析 时间复杂 ...
分类:
编程语言 时间:
2020-11-24 12:38:37
阅读次数:
6