zoj 3620 Escape Time II
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=4744
Escape Time II
Time Limit: 2 Seconds Memory Limit: 65536 KB
There is a fire in LTR ’ s home again. The fire can destroy all the things in t seconds, so LTR has to escape in t seconds. But there are some jewels in LTR ’ s rooms, LTR love jewels very much so he wants to take his jewels as many as possible before he goes to the exit. Assume that the ith room has ji jewels. At the beginning LTR is in room s, and the exit is in room e.
Your job is to find a way that LTR can go to the exit in time and take his jewels as many as possible.
Input
There are multiple test cases.
For each test case:
The 1st line
contains 3 integers n (2 ≤ n ≤ 10), m,
t (1 ≤ t ≤ 1000000) indicating the number of rooms, the
number of edges between rooms and the escape time.
The 2nd line contains 2
integers s and e, indicating the starting room and the
exit.
The 3rd line contains n integers, the ith
interger ji (1 ≤ ji ≤ 1000000)
indicating the number of jewels in the ith room.
The next
m lines, every line contains 3 integers a, b,
c, indicating that there is a way between room a and room
b and it will take c (1 ≤ c ≤ t)
seconds.
Output
For each test cases, you should print one line contains one integer the
maximum number of jewels that LTR can take. If LTR can not reach the exit in
time then output 0 instead.
Sample Input
3 3 5
0 2
10 10 10
0 1 1
0 2 2
1 2 3
5 7 9
0 3
10 20 20 30 20
0 1 2
1 3 5
0 3 3
2 3 2
1 2 5
1 4 4
3 4 2
Sample Output
30
80
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int maxx = ;
int Edge[maxx][maxx];
int val[maxx];
bool vis[maxx];
int big = ,e,n,t;
void dfs(int s, int num,int ju)
{
if(num>t) return; if(s == e)
if(ju > big && num<=t)
big = ju; vis[s] = true;
for(int i=;i<n;i++)
{
if(i!=s && Edge[s][i]<1e8 && !vis[i])
{
dfs(i,num + Edge[s][i],ju + val[i]);
}
}
vis[s] = false; }
void Floyd()
{
for(int i=; i<n;i++)
for(int j=; j<n; j++)
for(int k=; k<n; k++)
if(Edge[j][i] + Edge[i][k] < Edge[j][k])
Edge[j][k] = Edge[j][i] + Edge[i][k];
}
int main()
{
int m;
int s;
while(~scanf("%d %d %d",&n,&m,&t))
{
memset(Edge,0x6,sizeof(Edge));
memset(val,,sizeof(val));
memset(vis,,sizeof(vis));
scanf("%d %d",&s,&e);
for(int i=;i<n;i++)
scanf("%d",&val[i]);
for(int i=;i<=m;i++)
{
int u,v,w;
scanf("%d %d %d",&u,&v,&w);
Edge[u][v] = Edge[v][u] = w;
}
Floyd();
big = ;
vis[s] = true;
dfs(s,,val[s]);
printf("%d\n",big);
}
return ;
}
zoj 3620 Escape Time II的更多相关文章
- zoj 3620 Escape Time II dfs
题目链接: 题目 Escape Time II Time Limit: 20 Sec Memory Limit: 256 MB 问题描述 There is a fire in LTR ' s home ...
- zoj 3356 Football Gambling II【枚举+精度问题】
题目: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3356 http://acm.hust.edu.cn/vjudge/ ...
- ZOJ 3332 Strange Country II
Strange Country II Time Limit: 1 Second Memory Limit: 32768 KB Special Judge You want to v ...
- ZOJ 3042 City Selection II 【序】【离散化】【数学】
题意: 输入数据n,m.n代表工厂的数量,m代表城市的数量. 接下来n+m行为工厂和城市的坐标. 规定如图所示方向刮风,工厂的air会污染风向地区的air. 注意,工厂和城市的坐标表示的是从x到x+1 ...
- zoj 3627 Treasure Hunt II (贪心)
本文出自 http://blog.csdn.net/shuangde800 题目链接:zoj-3627 题意 直线上有n个城市, 第i个城市和i+1个城市是相邻的. 每个城市都有vi的金币. ...
- ZOj 3466 The Hive II
There is a hive in the village. Like this. There are 8 columns(from A to H) in this hive. Different ...
- ZOJ 3332 Strange Country II (竞赛图构造哈密顿通路)
链接:http://www.icpc.moe/onlinejudge/showProblem.do?problemCode=3332 本文链接:http://www.cnblogs.com/Ash-l ...
- ZOJ 3627 Treasure Hunt II (贪心,模拟)
题意:有n个城市并排着,每个城市有些珠宝,有两个人站在第s个城市准备收集珠宝,两人可以各自行动,但两人之间的距离不能超过dis,而且每经过一个城市就需要消耗1天,他们仅有t天时间收集珠宝,问最多能收集 ...
- ZOJ 3466 The Hive II (插头DP,变形)
题意:有一个n*8的蜂房(6边形的格子),其中部分是障碍格子,其他是有蜂蜜的格子,每次必须走1个圈取走其中的蜂蜜,在每个格子只走1次,且所有蜂蜜必须取走,有多少种取法? 思路: 以前涉及的只是n*m的 ...
随机推荐
- js使用正则表达式去空格
写成类的方法格式如下:(str.trim();) <script language="javascript"> String.prototype.trim=functi ...
- Codevs 1904 最小路径覆盖问题
1904 最小路径覆盖问题 时间限制: 2 s 空间限制: 256000 KB 题目等级 : 大师 Master 传送门 题目描述 Description 给定有向图G=(V,E).设P 是G 的一个 ...
- processon完全装逼指南
一.引言 作为一名IT从业者,不仅要有扎实的知识储备,出色的业务能力,还需要具备一定的软实力.软实力体现在具体事务的处理能力,包括沟通,协作,团队领导,问题的解决方案等,这些能力在关键时刻比硬性的技术 ...
- python 访问php程序,实现定时
#!/usr/bin/python #test2.py import sys import urllib2 j = True jj = 1##########用于统计,所以分页, url = 'htt ...
- centos 6.5 安装jenkins
Installation sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.rep ...
- softmax
void LogisticRegression_softmax(LogisticRegression *this, double *x) { int i; double max = 0.0; doub ...
- css设置文字不换行,超过的部分用“...”代替
设置文字不换行,超过的部分用“...”代替 overflow: hidden; text-overflow: ellipsis; white-space: nowrap; width: /*so ...
- yum使用详细
1.使用YUM查找软件包 命令:yum search~ 2.列出所有可安装的软件包 命令:yum list 3.列出所有可更新的软件包 命令:yum list updates 4.列出所有已安装的软件 ...
- 【java版坦克大战---准备篇】 java 绘图
要写坦克大战当然要先画出坦克.java画图是基础. package com.game; import java.awt.*; import javax.swing.*; public class Pr ...
- 安装 SQL Server 2012 的硬件和软件要求(官方全面)
以下各节列出了安装和运行 SQL Server 2012 的最低硬件和软件要求. 有关 SharePoint 集成模式下 Analysis Services 的要求的详细信息,请参阅硬件和软件要求(S ...