青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

zoj3620

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 ≤ ct) 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

Author: FU, Yujun
Contest: ZOJ Monthly, June 2012

狀態搜索,
搜索寫了不少,但是以前幾乎沒寫過這一類的題目,
要開始練搜索啊

code
#include <cstdio>
#include 
<cstdlib>
#include 
<cstring>
#include 
<cmath>
#include 
<ctime>
#include 
<cassert>
#include 
<iostream>
#include 
<sstream>
#include 
<fstream>
#include 
<map>
#include 
<set>
#include 
<vector>
#include 
<queue>
#include 
<algorithm>
#include 
<iomanip>
#define maxn 15
#define inf 1000000000
using namespace std;
int mp[maxn][maxn];
int t,n,m,s,e,ti,x,y;
int a[maxn];
long long ans;
struct node
{
    
int v,st,val,ti;
} tmp,tmp1;
queue
<node> q;
int head,tail;
int get[15][1024];
int mt[15][1024];
int max(int a,int b)
{
    
return a>b?a:b;
}
int main()
{
    
int res;
    
while(scanf("%d%d%d",&n,&m,&t)!=EOF)
    {
        scanf(
"%d%d",&s,&e);
        
for(int i=0; i<n; i++) scanf("%d",&a[i]);
        
for(int i=0; i<n; i++)
        {
            
for(int j=i+1; j<n; j++)
                mp[i][j]
=mp[j][i]=inf;
        }
        
for(int i=1; i<=m; i++)
        {
            scanf(
"%d%d%d",&x,&y,&ti);
            
if(ti<mp[x][y])
            {
                mp[x][y]
=ti;
                mp[y][x]
=ti;
            }
        }
        memset(
get,0,sizeof(get));//這地方老是順手寫成sizeof(0)
        for(int i=0; i<n; i++)
        {
            
for(int j=0; j<(1<<n); j++)
            {
                mt[i][j]
=inf;
            }
        }
        
get[s][1<<s]=a[s];
        mt[s][
1<<s]=0;
        res
=0;
        tmp.v
=s;
        tmp.ti
=0;
        tmp.val
=a[s];
        tmp.st
=1<<s;
        q.push(tmp);
        
while(!q.empty())
        {
            tmp
=q.front();
            q.pop();
            
for(int i=0; i<n; i++)
            {
                
if(i==tmp.v) continue;
                
if(mp[tmp.v][i]+tmp.ti<=t)
                {
                    tmp1.val
=tmp.val;
                    tmp1.st
=tmp.st;
                    
if(!((tmp1.st>>i)&1))
                    {
                        tmp1.st
=tmp1.st|(1<<i);
                        tmp1.val
+=a[i];
                    }
                    
if(tmp1.val>get[i][tmp1.st]||(tmp1.val==get[i][tmp1.st]&&tmp.ti+mp[tmp.v][i]<mt[i][tmp1.st]))
                    {
                        
get[i][tmp1.st]=tmp1.val;
                        mt[i][tmp1.st]
=tmp.ti+mp[tmp.v][i];
                        tmp1.ti
=mt[i][tmp1.st];
                        tmp1.v
=i;
                        q.push(tmp1);
                    }
                }
            }
        }
        
for(int i=0; i<(1<<n); i++)
            res
=max(get[e][i],res);
        printf(
"%d\n",res);
    }
    
return 0;
}

posted on 2012-07-30 21:51 jh818012 閱讀(97) 評論(0)  編輯 收藏 引用


只有注冊用戶登錄后才能發表評論。
網站導航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


<2025年11月>
2627282930311
2345678
9101112131415
16171819202122
23242526272829
30123456

導航

統計

常用鏈接

留言簿

文章檔案(85)

搜索

最新評論

  • 1.?re: poj1426
  • 我嚓,,輝哥,,居然搜到你的題解了
  • --season
  • 2.?re: poj3083
  • @王私江
    (8+i)&3 相當于是 取余3的意思 因為 3 的 二進制是 000011 和(8+i)
  • --游客
  • 3.?re: poj3414[未登錄]
  • @王私江
    0ms
  • --jh818012
  • 4.?re: poj3414
  • 200+行,跑了多少ms呢?我的130+行哦,你菜啦,哈哈。
  • --王私江
  • 5.?re: poj1426
  • 評論內容較長,點擊標題查看
  • --王私江
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            美女视频网站黄色亚洲| 欧美激情综合色| 欧美在线视频观看| 欧美精品福利视频| 有码中文亚洲精品| 久久久久成人精品| 亚洲欧美激情视频在线观看一区二区三区 | 午夜影院日韩| 国产精品日韩二区| 亚洲一区二区精品| 亚洲最新在线| 欧美日韩在线播放一区| 亚洲网在线观看| 一本色道久久综合精品竹菊| 欧美日韩精品国产| 亚洲视频一区在线| 一区二区三区你懂的| 国产精品成人一区二区艾草| 亚洲一区久久| 亚洲尤物在线视频观看| 国产午夜精品久久久| 久久尤物视频| 玖玖玖国产精品| 亚洲清纯自拍| 日韩视频免费| 亚洲国内自拍| 亚洲免费在线电影| 国产精品盗摄久久久| 午夜精品网站| 欧美在线三级| 欧美视频中文在线看| 国产精品成人av性教育| 亚洲一区综合| 欧美一区不卡| 最新国产成人av网站网址麻豆| 亚洲第一级黄色片| 欧美福利一区| 亚洲欧美综合| 久久久青草青青国产亚洲免观| 亚洲激情黄色| 在线一区观看| 黄色一区二区三区四区| 亚洲福利国产精品| 国产精品免费视频观看| 久久久亚洲影院你懂的| 欧美激情片在线观看| 亚洲欧美在线一区| 麻豆国产精品777777在线 | 91久久国产综合久久91精品网站 | 亚洲欧美日韩直播| 久久精品亚洲一区| 99国产精品99久久久久久| 亚洲一区二区三区免费视频| 亚洲春色另类小说| 亚洲网在线观看| 亚洲精品美女在线观看| 亚洲欧美成人网| 亚洲美女在线看| 欧美一区中文字幕| 中文亚洲视频在线| 噜噜噜91成人网| 欧美综合国产| 欧美日韩亚洲一区二区三区四区 | 午夜伦理片一区| 亚洲美女av在线播放| 欧美一区二区视频观看视频| 一本到高清视频免费精品| 久久高清国产| 亚洲免费影院| 欧美好吊妞视频| 久久综合中文色婷婷| 国产精品v一区二区三区| 欧美福利视频一区| 国产综合在线视频| 亚洲一区在线播放| 夜夜精品视频| 免费人成网站在线观看欧美高清| 欧美影院成人| 欧美午夜电影在线观看| 亚洲国产专区| 亚洲国产精品成人一区二区| 欧美一二三区在线观看| 亚洲永久免费| 欧美日韩午夜视频在线观看| 亚洲国产成人在线视频| 亚洲国产精品成人综合| 欧美高清在线观看| 玖玖玖国产精品| 久久婷婷av| 国产一二精品视频| 午夜精品一区二区在线观看| 欧美一级视频精品观看| 国产女主播一区二区三区| 中日韩高清电影网| 亚洲桃花岛网站| 欧美三日本三级少妇三2023| 亚洲精品欧美激情| 亚洲天堂网在线观看| 欧美色图一区二区三区| 在线视频亚洲| 午夜精品一区二区三区在线| 国产精品盗摄久久久| 亚洲免费中文字幕| 欧美在线观看你懂的| 国产欧美日韩一区| 久久精品亚洲| 亚洲国产精品黑人久久久| 日韩午夜激情电影| 国产精品成人一区二区三区夜夜夜| 亚洲图片在线| 久久精品夜色噜噜亚洲a∨| 黄色在线成人| 欧美激情第一页xxx| 一本色道久久综合亚洲精品不 | 亚洲日本va午夜在线电影| 日韩视频一区二区在线观看| 欧美日韩视频一区二区| 亚洲欧美日韩一区在线观看| 久久久久久久97| 亚洲激情视频在线| 欧美精品www在线观看| 亚洲精品视频免费在线观看| 亚洲免费中文| 亚洲第一页自拍| 欧美视频在线看| 午夜欧美精品| 麻豆精品在线观看| 99视频有精品| 国产日韩精品一区观看| 麻豆精品在线播放| 亚洲视频大全| 欧美刺激性大交免费视频| 一区二区三区蜜桃网| 国产色婷婷国产综合在线理论片a| 久久五月激情| 亚洲一区二区3| 亚洲高清激情| 久久精品人人爽| 99热免费精品| 激情综合色综合久久| 欧美午夜电影在线观看| 久久综合伊人77777麻豆| 一区二区久久久久| 欧美xart系列高清| 亚洲专区在线| 亚洲精品无人区| 国产在线观看一区| 欧美性大战久久久久久久蜜臀| 久久一区二区三区av| 午夜国产欧美理论在线播放| 亚洲精品一区二区三区婷婷月| 麻豆成人91精品二区三区| 亚洲男人天堂2024| 99这里只有久久精品视频| 在线观看国产精品网站| 国产日韩在线亚洲字幕中文| 欧美日韩中文字幕| 欧美精品激情| 中文国产成人精品久久一| 欧美日韩在线不卡一区| 久久全球大尺度高清视频| 中文精品在线| 亚洲免费观看高清完整版在线观看熊| 美女久久一区| 久久综合色播五月| 久久er精品视频| 亚洲欧美日韩中文播放| 在线性视频日韩欧美| 99re这里只有精品6| 亚洲美女一区| 在线中文字幕日韩| 一区二区日韩| 99精品热视频只有精品10| 亚洲理论在线观看| 亚洲另类自拍| 日韩一二三区视频| 亚洲精品一区二| 亚洲理论电影网| 国产精品99久久久久久久女警| 亚洲美女av黄| 亚洲天堂网在线观看| 亚洲伊人久久综合| 午夜电影亚洲| 久久久久综合一区二区三区| 久久久综合精品| 欧美1区免费| 亚洲高清不卡在线| 99精品欧美一区二区蜜桃免费| 在线中文字幕一区| 性欧美18~19sex高清播放| 欧美一级淫片播放口| 久久久久女教师免费一区| 久久综合色播五月| 欧美乱在线观看| 国产精品久久二区二区| 国产亚洲综合性久久久影院| 伊人久久综合97精品| 最新国产精品拍自在线播放| 日韩视频永久免费观看| 亚洲欧美99|