acm
yxr0105
这个作者很懒,什么都没留下…
展开
-
hoj3269
题意:前n-1个数有序,问第n个数可以插入的位置的下标范围。 题解:水题。但是掌握一下 lower_bound 和 upper_bound 嘛。//a 升序 int l=lower_bound(a+1,a+1+n,v)-a;//返回第一个大于等于v的指针。 int r=upper_bound(a+1,a+1+n,v)-a;//返回第一个大于v的指针。//a 降序 #include<function原创 2017-11-09 18:53:14 · 201 阅读 · 0 评论 -
hoj3271
题意:nth_element 题解:stl中nth_element函数或者(伪)快排? nth_element(array, array+k, array+len); #include<cstdio> #include<cstdlib> #include<algorithm> using namespace std; #define N 10000005 #define ll long long原创 2017-11-09 18:58:51 · 187 阅读 · 0 评论 -
poj2507 Crossed ladders
题意: 已知x,y,c,求d 题解:答案满足单调性,即x,y恒定时,d越大,c越小。因此可以二分答案。#include<cstdio> #include<cmath> #include<algorithm> using namespace std; #define eps 1e-5 double l,r,mid,a,b,c,x,y,now; bool judge(double k){ x原创 2017-11-09 19:05:16 · 299 阅读 · 0 评论 -
bzoj4198 [Noi2015]荷马史诗
题意:k叉哈夫曼树 题解:2叉哈夫曼树的做法我们知道后,k叉哈夫曼树就是每次找前k小的。但是现在的问题是可能有非满叉结点。考虑到非满叉结点一定是在最后一层,所以只需要补x个0即可。推一推知道是x = k - 1 - (n - 1) % (k - 1)。#include<bits/stdc++.h> #define ll long long using namespace std; struct N原创 2017-11-17 19:49:48 · 283 阅读 · 0 评论 -
poj1328 Radar Installation
题目大意:在y轴正方向有n个岛屿(n <=1000),在x轴上建立雷达,其覆盖范围是d,求最少建立多少个雷达。 题解:贪心,每个岛屿在[l,r]范围内建立雷达即可覆盖,那么我们有n个区间,我们按照r排序,第一个在r处建立,从左往右扫描,依次建立,如果没被覆盖过,就在r处建雷达(在r总比在l优),复杂度O(n2)O(n^2)。#include<cstdio> #include<algorithm>原创 2017-11-14 13:19:25 · 164 阅读 · 0 评论 -
hojx triangles(题号之后补
description There are n points given in a space. There are no three points, such that they lie on the same straight line. Each pair of points is connected by a segment coloured red or black. Each tr原创 2017-12-21 15:04:13 · 377 阅读 · 0 评论 -
hoj2143 Songs 贪心
Description John Doe is a famous DJ and, therefore, has the problem of optimizing the placement of songs on his tapes. For a given tape and for each song on that tape John knows the length of the song原创 2017-12-21 15:35:22 · 196 阅读 · 0 评论 -
POJ1094 Sorting It All Out 拓扑排序
题意:给定一组字母的大小关系判断他们是否能组成唯一的拓扑序列。 题解:这是典型的拓扑排序,但输出格式上确有三种形式: 1.该字母序列有序,并依次输出; 2.该序列不能判断是否有序; 3.该序列字母次序之间有矛盾,即有环存在。 而这三种形式的判断是有顺序的:先判断是否有环(3),再判断是否有序(1),最后才能判断是否能得出结果(2)。注意:对于(2)必须遍历完整个图,而(原创 2017-12-21 15:42:07 · 213 阅读 · 0 评论 -
hdu2476 string painter 区间dp
(坑)#include <cstdio> #include <cstring> #include <algorithm> #define N 105 #define inf 0x7fffffff using namespace std; int dp[N][N],ans[N]; char a[N],b[N]; int n; int main(){ while(~scanf("%s%s", a原创 2017-12-21 15:45:43 · 231 阅读 · 0 评论