题目描述 C 国有 n 个大城市和 m 条道路,每条道路连接这 n 个城市中的某两个城市.任意两个 城市之间最多只有一条道路直接相连.这 m 条道路中有一部分为单向通行的道路,一部分 为双向通行的道路,双向通行的道路在统计条数时也计为 1 条. C 国幅员辽阔,各地的资源分布情况各不相同,这就导致了同一种商品在不同城市的价 格不一定相同.但是,同一种商品在同一个城市的买入价和卖出价始终是相同的. 商人阿龙来到 C 国旅游.当他得知同一种商品在不同城市的价格可能会不同这一信息 之后,便决定在旅游的…
要保证长度为L的序列下标字典序最小,当然要尽量选前面的数. 如何判断前面的数是否满足条件?,只需要知道这个数开头的递增序列的最长长度是多少,如果不小于L,那么必然可以加入这个数.还需判断一下它是否大于前面的那个数就行了. LIS用nlogn. # include <cstdio> # include <cstring> # include <cstdlib> # include <iostream> # include <vector> # in…
Description Freddy Frog is sitting on a stone in the middle of a lake. Suddenly he notices Fiona Frog who is sitting on another stone. He plans to visit her, but since the water is dirty and full of tourists' sunscreen, he wants to avoid swimming and…
原题链接:http://poj.org/problem?id=1797 Heavy Transportation Time Limit: 3000MS Memory Limit: 30000K Total Submissions: 24576 Accepted: 6510 Description Background Hugo Heavy is happy. After the breakdown of the Cargolifter project he can now expand…
查最小值,删除,翻转... 显然splay啊... #include<iostream> #include<cstdio> #include<algorithm> #include<cstring> #define N 200005 #define inf 0x3f3f3f3f using namespace std; int n; ], fa[N]; int a[N]; int mn[N],zhi[N],size[N]; void push_up(int…