我会告诉你我看了很久很久才把题目看懂吗???怀疑智商了 原来他给的l,r还有k个数字都是下标... 比如给了一个样例 l, r, k, x1,x2,x3...xk,代表的是一个数组num[l]~num[r],其中有k个数num[x1],num[x2]....num[xk]这k个数都比l~r区间剩下的(下标不是x1...xk)的任何一个数大.题目就是给m个这种信息然后构造一个符合条件的数列 知道了这一点可以发现每一个信息都是一组偏序关系,即num[x1] > l~r区间剩下的数 .....num[…
B. Legacy 题目连接: http://codeforces.com/contest/786/problem/B Description Rick and his co-workers have made a new radioactive formula and a lot of bad guys are after them. So Rick wants to give his legacy to Morty before bad guys catch them. There are…
分析:(官方题解) 首先考虑暴力,显然可以直接每次O(n^2) ​的连边,最后跑一次分层图最短路就行了. 然后我们考虑优化一下这个连边的过程 ,因为都是区间上的操作,所以能够很明显的想到利用线段树来维护整个图, 连边时候找到对应区间,把线段树的节点之间连边.这样可以大大缩减边的规模,然后再跑分层图最短路就可以了. 但是这样建图,每一次加边都要在O(logn)个线段树节点上加边,虽然跑的非常快,但是复杂度仍然是不科学的. 为了解决边的规模的问题,开两棵线段树,连边时候可以新建一个中间节点,在对应区…
B. Legacy 题目连接: http://codeforces.com/contest/786/problem/B Description Rick and his co-workers have made a new radioactive formula and a lot of bad guys are after them. So Rick wants to give his legacy to Morty before bad guys catch them. There are…
D. Legacy time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Rick and his co-workers have made a new radioactive formula and a lot of bad guys are after them. So Rick wants to give his legacy…
题意: 思路: 线段树+Dijkstra(要堆优化的) 线段树要支持打标记 一个栅栏 拆成两个点 :左和右 新加一个栅栏的时候 看看左端点有没有被覆盖过 如果有的话 就分别从覆盖的那条线段的左右向当前的左端点连一条边权为距离的边 右端点同理 跑一遍Dijkstra 就好啦 复杂度:O(nlogn) //By SiriusRen #include <queue> #include <cstdio> #include <cstring> #include <algor…
D. Slalom time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output Little girl Masha likes winter sports, today she's planning to take part in slalom skiing. The track is represented as a grid comp…
The Captain(BZOJ 4152) Description 给定平面上的n个点,定义(x1,y1)到(x2,y2)的费用为min(|x1-x2|,|y1-y2|),求从1号点走到n号点的最小费用. Input Format 第一行包含一个正整数n(2<=n<=200000),表示点数. 接下来n行,每行包含两个整数xi,yi(0<=xi,yi<=10^9),依次表示每个点的坐标. Output Format 一个整数,即最小费用. Sample Input 5 2 2 1…
[BZOJ3672][NOI2014]购票(线段树,斜率优化,动态规划) 题解 首先考虑\(dp\)的方程,设\(f[i]\)表示\(i\)的最优值 很明显的转移\(f[i]=min(f[j]+(dep[i]-dep[j])·p[i])+q[i]\) 其中满足\(dep[i]-dep[j]\le L[i]\) 然后就可以写出一个\(O(n^2)\)的做法啦 #include<iostream> #include<cstdio> #include<cstdlib> #in…
problem 线段树优化建图,拓扑,没了. #include <bits/stdc++.h> #define ls(x) ch[x][0] #define rs(x) ch[x][1] #define rep(i , j , k) for(int i = j ; i <= k ; i ++) #define Rep(i , j , k) for(int i = j ; i >= k ; i --) using namespace std ; using ll = long lon…