Portal 题意: 给出排列 \(p_1,p_2,p_3,\dots,p_n\),定义一个区间 \([l,r]\) 是好的当且仅当 \(p_l,p_{l+1},p_{l+2},\dots,p_r\) 包含了连续的 \(r-l+1\) 个数。 \(q\) 次询问,每次询问给出两个数 \(l,r\), ...
分类:
其他好文 时间:
2020-12-31 12:03:23
阅读次数:
0
题目: 给定一个正整数 n,生成一个包含 1 到 n2 所有元素,且元素按顺时针顺序螺旋排列的正方形矩阵。 示例: 输入: 3 输出: [ [ 1, 2, 3 ], [ 8, 9, 4 ], [ 7, 6, 5 ] ] 代码: 1 class Solution { 2 public int[][] ...
分类:
其他好文 时间:
2020-12-30 10:52:55
阅读次数:
0
Given an array of non-negative integers nums, you are initially positioned at the first index of the array. Each element in the array represents your ...
分类:
其他好文 时间:
2020-12-29 11:18:24
阅读次数:
0
考虑莫队。 如果是单纯的莫队的话,还需要一个树状数组来维护逆序对数,这样子的话复杂度是 \(O(n^{1.5}\log n)\),难以接受。 怎么将这个树状数组消除? 考虑当前区间为 \([l,r-1]\) ,需要将右端点向右移动,即加入 \(a_r\) ,并且将答案加上 \(a_{l,l+1,\c ...
分类:
其他好文 时间:
2020-12-25 12:28:35
阅读次数:
0
原题链接:https://leetcode-cn.com/problems/longest-substring-without-repeating-characters/ class Solution { public int lengthOfLongestSubstring(String s) { ...
分类:
其他好文 时间:
2020-12-25 11:54:02
阅读次数:
0
Description This is the hard version of this problem. The only difference between the easy and hard versions is the constraints on $ k $ and $ m $ . I ...
分类:
其他好文 时间:
2020-12-25 11:42:12
阅读次数:
0
题:https://codeforces.com/contest/1463/problem/E 题意:给定拓扑图,在给定链(以边的形式给出),问是否能在拓扑顺序中找出一个序列使得这个序列包含给定的链(x->y->z)。 分析: 给定的拓扑图我们可以当作一个DAG,然后给定的m个边我们可以在原图上进行 ...
分类:
其他好文 时间:
2020-12-24 11:46:03
阅读次数:
0
简单线段树操作 咕咕咕 Transformation HDU - 4578 vj talk is cheap, chow the code. #include <iostream> #include <cstring> using namespace std; typedef long long l ...
分类:
其他好文 时间:
2020-12-23 12:30:38
阅读次数:
0
题意 这题大体意思就是你一开始给一个数1,之后每一天这个数都会自乘2,并且你可以在其中的任意一天把这个数加1,以此来得到你最终想要的数n,并且要求操作次数最少。 题目链接:https://codeforces.com/gym/102830/problem/C 解析 这种题其实遇到过好多次了,但是每次 ...
分类:
其他好文 时间:
2020-12-23 12:26: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