D. Laying Cables time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output One-dimensional country has n cities, the i-th of which is located at the point xi and has population pi, and all xi, as we…
Description One-dimensional country has n cities, the i-th of which is located at the point xi and has population pi, and all xi, as well as all pi, are distinct. When one-dimensional country got the Internet, it was decided to place the main server…
洛谷 Codeforces 我竟然能在有生之年踩标算. 思路 首先考虑暴力:枚举左右端点直接计算. 考虑记录\(sum_x=\sum_{i=1}^x c_i\),设选\([l,r]\)时那个奇怪东西的平方为\(f(l,r)\),使劲推式子: \[ ans_{l,r}=(r-l+1)\times a-sum_r+sum_{l-1}-f(l,r)\\ ans_{l,r}+l\times a-a-sum_{l-1}=r\times a-sum_r-f(l,r)\\ ans_{l,r}+l\times…
原文链接http://www.cnblogs.com/zhouzhendong/p/9026184.html 题目传送门 - Codeforces 802I 题意 求一个串中,所有本质不同子串的出现次数的平方和. $|s|\leq 10^5$ 题解 首先,这一题用 SAM 做就是模板题,比较简单. 但是,本着练一练 SA 的心态,我开始了 SA+单调栈 的苦海. 真毒瘤. 这里讲一讲 SA 的做法,也是经典的做法. SA 闭着眼睛先写了再说. 首先,我们考虑出现次数大于 $1$ 次的子串. 考虑…
题目链接:http://codeforces.com/gym/100971/problem/K K. Palindromization time limit per test 2.0 s memory limit per test 256 MB input standard input output standard output Mihahim has a string s. He wants to delete exactly one character from it so that th…
题目链接:http://codeforces.com/contest/817/problem/D 题意:给你n个数a[1..n]定义连续子段imbalance值为最大值和最小值的差,要你求这个数组的imbalance总值 题解:首先要知道imbalance的值可以有所有区间的Max的和减去所有区间Min的和.那么就是怎么求所有区间的Max和与Min和.要知道如果是以a[i]为最小值那么最小值为a[i]的区间数为a[i]左边第一个小于a[i]的位置l,a[i]右边第一个大于等于a[i]的位置r,a…
D. Imbalanced Array time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You are given an array a consisting of n elements. The imbalance value of some subsegment of this array is the differenc…
A题  直接把问号全部变为陆地如果所有陆地连通    那么再逐个把刚才变成陆地的问号变为水如果依旧连通有多种解 为什么我的代码跑不过去,和网上的题解思路一模一样!!?? #include<cstdio> #include<algorithm> #include<cstring> #include<iostream> #define MAX_N 55 using namespace std; char map[MAX_N][MAX_N]; int n,m; i…
D - Laying Cables Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u One-dimensional country has n cities, the i-th of which is located at the point xi and has population pi, and all xi, as well as all pi, are distinct. Whe…
题目链接:https://cn.vjudge.net/problem/Gym-100971D 题目大意:给你n个城市的信息,每一个城市的信息包括坐标和人数,然后让你找每一个城市的父亲,作为一个城市的父亲具体满足的条件是:作为父亲的城市的坐标和当前城市的人数最多,,如果有多个满足的城市,则和原来的点相隔最近的作为父亲. 具体思路:首先,题目中说坐标和人数是不会有相同的值,所以我们对于每一个点,按照x轴进行排序之后,找出当前点的左边的第一个人数大于当前点的,然后再找出当前点的右边的第一个人数大于当前…