这道题可以将前 \(\frac{n}{2}\) 个数的和(即$2,4,6,8,10...n$)存起来,最后令后$\frac{2}-1$个数(即$1,3,5,7,9...n-3$)的和减去前 \(\frac{n}{2}\) 个数的和,得到第 \(n\) 个数的值。而且另外地,如果$\frac{2} \ ...
分类:
其他好文 时间:
2020-06-28 12:35:08
阅读次数:
50
题目 Description 农夫约翰正在安排他的N头牛拍照片, 每头牛有一个身高,从1到N编号,排列成一行(h1,h2...hn),每头牛i左边比他高的牛的数量记为Li, 右边比他高的牛的数量记为Ri,如果存在i满足max(Ri,Li)>2*min(Li,Ri)则这个牛i是不平衡的,现在FJ需要你 ...
分类:
其他好文 时间:
2020-06-25 23:19:20
阅读次数:
38
题目链接:https://www.luogu.com.cn/problem/P3608 方法一 用树状数组求逆序对先后扫两遍,一次从前往后,一次从后往前,算出每头奶牛左右两边比她高的数量。 最后统计一下。 #include <bits/stdc++.h> using namespace std; i ...
分类:
其他好文 时间:
2020-06-25 11:56:09
阅读次数:
47
CodeForces 1237H Balanced Reversals 2s,512MB 长度为偶数 \(n\) 的01串 \(a,b\) . 问是否可以通过至多 \(n+1\) 次如下操作将 \(a\) 变成 \(b\) . 选择一个偶数 \(p \le n\) ,将 \(a\) 变成 \(a_p ...
分类:
其他好文 时间:
2020-06-25 11:38:20
阅读次数:
55
题目: You are given a string s consisting only of characters 0 and 1. A substring [l,?r] of s is a string sl,sl?+?1,sl?+?2... sr, and its length equals ...
分类:
其他好文 时间:
2020-06-14 16:38:35
阅读次数:
51
####Balanced Teams ####题意 给你n个数,将这n个数最多分成k组,但是每组中的数最大差值不超过5,k组中的人数最大 ####思路 先排序,先预处理找出每个数的最左端可以取到的数。 再进行dp,dp[i][j]表示前i个人分在j组最多可以放多少人 对于第i个人,不取$dp[i][ ...
分类:
其他好文 时间:
2020-06-14 16:34:33
阅读次数:
56
题目 Description Farmer John 决定给他的奶牛们照一张合影,他让 N (1 ≤ N ≤ 50,000) 头奶牛站成一条直线,每头牛都有它的坐标(范围: 0..1,000,000,000)和种族(0或1)。一直以来 Farmer John 总是喜欢做一些非凡的事,当然这次照相也不 ...
分类:
其他好文 时间:
2020-06-05 23:24:44
阅读次数:
121
Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary tree is defined as: a binary tree in which the lef ...
分类:
其他好文 时间:
2020-05-30 10:23:54
阅读次数:
65
#include<bits/stdc++.h>#define ll long longusing namespace std;//按照题意可知二分之n为偶数的时候存在这样的数组,按照题意分两部分存入数组即可int main(){ ll t,n; cin>>t; for(int i=0; i<t; i ...
分类:
其他好文 时间:
2020-05-23 11:26:47
阅读次数:
43
https://www.spoj.com/problems/QTREE6/ 考虑对0颜色和1颜色分别维护定根(no reverse)lct。 即在$c[x]$的lct上给$x$到$fa[x]$连一条边。 修改直接link、cut。 查询x的话,考虑access走到最上面的点,这个点实际上和x是不连通 ...
分类:
其他好文 时间:
2020-05-19 23:14:24
阅读次数:
100