uva 10816 最短路 tle

There is a group of adventurers who like to travel in the desert. Everyone knows travelling in desert can be very dangerous. That's why they plan their trip carefully every time. There are a lot of factors to consider before they make their final decision.

One of the most important factors is the weather. It is undesirable to travel under extremely high temperature. They always try to avoid going to the hottest place. However, it is unavoidable sometimes as it might be on the only way to the destination. To decide where to go, they will pick a route that the highest temperature is minimized. If more than one route satisfy this criterion, they will choose the shortest one.

There are several oases in the desert where they can take a rest. That means they are travelling from oasis to oasis before reaching the destination. They know the lengths and the temperatures of the paths between oases. You are to write a program and plan the route for them.

Input

Input consists of several test cases. Your program must process all of them.

The first line contains two integers N and E (1 ≤ N ≤ 100; 1 ≤ E ≤ 10000) where N represents the number of oasis and E represents the number of paths between them. Next line contains two distinct integers S and T (1 ≤ S, TN) representing the starting point and the destination respectively. The following E lines are the information the group gathered. Each line contains 2 integers X, Y and 2 real numbers R and D (1 ≤ X, YN; 20 ≤ R ≤ 50; 0 < D ≤ 40). It means there is a path between X and Y, with length D km and highest temperature R oC. Each real number has exactly one digit after the decimal point. There might be more than one path between a pair of oases.

Output

Print two lines for each test case. The first line should give the route you find, and the second should contain its length and maximum temperature.

Sample Input

6 9
1 6
1 2 37.1 10.2
2 3 40.5 20.7
3 4 42.8 19.0
3 1 38.3 15.8
4 5 39.7 11.1
6 3 36.0 22.5
5 6 43.9 10.2
2 6 44.2 15.2
4 6 34.2 17.4

Sample Output

1 3 6
38.3 38.3

Problemsetter : Raymond Chun
 
tle了,按照网上的解法:二分最高温度,dijkstra。
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<cstdlib>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>

using namespace std;

#define LL long long
#define ULL unsigned long long
#define UINT unsigned int
#define MAX_INT 0x7fffffff
#define cint const int
#define MAX(X,Y) ((X) > (Y) ? (X) : (Y))
#define MIN(X,Y) ((X) < (Y) ? (X) : (Y))
#define INF 100000000
#define MAXN 111
#define MAXM 21000

int n, m, s, t;

struct edge{
    int u, v;
    double r, d;
    int nxt;
}e[MAXM];
int h[MAXN], cc;

void add(int u, int v, double r, double d){
    e[cc]=(edge){u, v, r, d, h[u]};
    h[u]=cc++;

    e[cc]=(edge){v, u, r, d, h[v]};
    h[v]=cc++;
}

struct node{
    int u;
    double w;
    bool operator < (const node &rhs)const{
        return w>rhs.w;
    }
};

int p[MAXN];
double d[MAXN];
bool done[MAXN];
bool dijkstra(double thresh){
    priority_queue<node> q;
    fill_n(done+1, n, false);
    fill_n(d+1, n, INF);        d[s]=0;
    q.push((node){s, d[s]});
    while(!q.empty()){
        node ut = q.top();      q.pop();
        int u = ut.u;
        if(u == t) break;
        if(done[u]) continue;       done[u]=true;
        for(int i=h[u]; i!=-1; i=e[i].nxt){
            int v=e[i].v;
            double w=e[i].d, r=e[i].r;
            if(r<=thresh && d[u]+w<d[v]){
                d[v]=d[u]+w;
                p[v]=u;
                q.push((node){v, d[v]});
            }
        }
    }
    return d[t]<INF;
}

void solve(double l, double r){
    double temp, mid, dis;
    while(r-l>1e-3){
        mid = (l + r) / 2;
        if(dijkstra(mid)) r = temp = mid, dis=d[t];
        else l = mid;
    }
    stack<int> sta;
    for(int u=t; u!=s; u=p[u])
        sta.push(u);
    printf("%d", s);
    while(!sta.empty()){
        printf(" %d", sta.top());
        sta.pop();
    }
    printf("\n%.1f %.1f\n", dis, temp);
}

int main(){
//    freopen("C:\\Users\\Administrator\\Desktop\\in.txt","r",stdin);
    while(scanf(" %d %d %d %d", &n, &m, &s, &t)==4){
        int i, x, y;
        double r, d;
        double minn=INF, maxx=0;
        fill_n(h+1, n, -1);     cc=0;
        for(i=0; i<m; i++){
            scanf(" %d %d %lf %lf", &x, &y, &r, &d);
            add(x, y, r, d);
            minn=MIN(minn, r);
            maxx=MAX(maxx, r);
        }
        solve(minn, maxx);
    }
    return 0;
}

 

转载于:https://www.cnblogs.com/ramanujan/p/3371209.html

基于SSM框架的智能家政保洁预约系统,是一个旨在提高家政保洁服务预约效率和管理水平的平台。该系统通过集成现代信息技术,为家政公司、家政服务人员和消费者提供了一个便捷的在线预约和管理系统。 系统的主要功能包括: 1. **用户管理**:允许消费者注册、登录,并管理他们的个人资料和预约历史。 2. **家政人员管理**:家政服务人员可以注册并更新自己的个人信息、服务类别和服务时间。 3. **服务预约**:消费者可以浏览不同的家政服务选项,选择合适的服务人员,并在线预约服务。 4. **订单管理**:系统支持订单的创建、跟踪和管理,包括订单的确认、完成和评价。 5. **评价系统**:消费者可以在家政服务完成后对服务进行评价,帮助提高服务质量和透明度。 6. **后台管理**:管理员可以管理用户、家政人员信息、服务类别、预约订单以及处理用户反馈。 系统采用Java语言开发,使用MySQL数据库进行数据存储,通过B/S架构实现用户与服务的在线交互。系统设计考虑了不同用户角色的需求,包括管理员、家政服务人员和普通用户,每个角色都有相应的权限和功能。此外,系统还采用了软件组件化、精化体系结构、分离逻辑和数据等方法,以便于未来的系统升级和维护。 智能家政保洁预约系统通过提供一个集中的平台,不仅方便了消费者的预约和管理,也为家政服务人员提供了一个展示和推广自己服务的机会。同时,系统的后台管理功能为家政公司提供了强大的数据支持和决策辅助,有助于提高服务质量和管理效率。该系统的设计与实现,标志着家政保洁服务向现代化和网络化的转型,为管理决策和控制提供保障,是行业发展中的重要里程碑。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值