#include<cstdio>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;
#define _rep(i,a,b) for(int i=(a);i<=(b);i++)
typedef long long ll;
const int N=1e5+10;
struct node{
int id,h,l,r;
bool operator <(const node&rhs)const{
return h<rhs.h;}
}d[N];
int ans,n,m,p[N],l,r,pos,na[N],nb[N],a,b;
int f[N][25];//f[i][j]表示从第i个点出发ab每人开1<<j天所到的点
int sta[N][25],stb[N][25];//表示路程
ll x;
double minn=INT_MAX;
inline bool pd()//哪边更近
{
if(!l)return false;
if(!r)return true;
return d[pos].h-d[l].h<=d[r].h-d[pos].h;
}
inline int getid(int a,int b)//返回更近的城市编号
{
if(!a)return d[b].id;
if(!b)return d[a].id;
return d[pos].h-d[a].h<=d[b].h-d[pos].h?d[a].id:d[b].id;
}
void ST()//倍增法预处理出到达城市和ab行驶的距离
{
_rep(j,1,19)_rep(i,1,n)
{
f[i][j]=f[f
【题解】洛谷P1081(同CH5701)开车旅行[NOIP2012] 倍增优化DP+离散+链表
最新推荐文章于 2022-07-30 09:56:22 发布