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

隨筆 - 87  文章 - 279  trackbacks - 0
<2025年12月>
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910

潛心看書研究!

常用鏈接

留言簿(19)

隨筆分類(81)

文章分類(89)

相冊

ACM OJ

My friends

搜索

  •  

積分與排名

  • 積分 - 221483
  • 排名 - 118

最新評論

閱讀排行榜

評論排行榜


Always On the Run

Time limit: 1 Seconds?? Memory limit: 32768K??
Total Submit: 125?? Accepted Submit: 70??

Screeching tires. Searching lights. Wailing sirens. Police cars everywhere. Trisha Quickfinger did it again! Stealing the `Mona Lisa' had been more difficult than planned, but being the world's best art thief means expecting the unexpected. So here she is, the wrapped frame tucked firmly under her arm, running to catch the northbound metro to Charles-de-Gaulle airport.

But even more important than actually stealing the painting is to shake off the police that will soon be following her. Trisha's plan is simple: for several days she will be flying from one city to another, making one flight per day. When she is reasonably sure that the police has lost her trail, she will fly to Atlanta and meet her `customer' (known only as Mr. P.) to deliver the painting.

Her plan is complicated by the fact that nowadays, even when you are stealing expensive art, you have to watch your spending budget. Trisha therefore wants to spend the least money possible on her escape flights. This is not easy, since airlines prices and flight availability vary from day to day. The price and availability of an airline connection depends on the two cities involved and the day of travel. Every pair of cities has a `flight schedule' which repeats every few days. The length of the period may be different for each pair of cities and for each direction.

Although Trisha is a good at stealing paintings, she easily gets confused when booking airline flights. This is where you come in.


Input

The input contains the descriptions of several scenarios in which Trisha tries to escape. Every description starts with a line containing two integers n and k. n is the number of cities through which Trisha's escape may take her, and k is the number of flights she will take. The cities are numbered 1, 2, ..., n, where 1 is Paris, her starting point, and n is Atlanta, her final destination. The numbers will satisfy 2 <= n <= 10 and 1 <= k <= 1000.
Next you are given n(n - 1) flight schedules, one per line, describing the connection between every possible pair of cities. The first n - 1 flight schedules correspond to the flights from city 1 to all other cities (2, 3, ..., n), the next n - 1 lines to those from city 2 to all others (1, 3, 4, ..., n), and so on.

The description of the flight schedule itself starts with an integer d, the length of the period in days, with 1 <= d <= 30. Following this are d non-negative integers, representing the cost of the flight between the two cities on days 1, 2, ..., d. A cost of 0 means that there is no flight between the two cities on that day.

So, for example, the flight schedule ``3 75 0 80'' means that on the first day the flight costs 75, on the second day there is no flight, on the third day it costs 80, and then the cycle repeats: on the fourth day the flight costs 75, there is no flight on the fifth day, etc.

The input is terminated by a scenario having n = k = 0.


Output

For each scenario in the input, first output the number of the scenario, as shown in the sample output. If it is possible for Trisha to travel k days, starting in city 1, each day flying to a different city than the day before, and finally (after k days) arriving in city n, then print ``The best flight costs x.'', where x is the least amount that the k flights can cost.

If it is not possible to travel in such a way, print ``No flight possible.''.

Print a blank line after each scenario.


Sample Input

3 6
2 130 150
3 75 0 80
7 120 110 0 100 110 120 0
4 60 70 60 50
3 0 135 140
2 70 80
2 3
2 0 70
1 80
0 0


Sample Output

Scenario #1
The best flight costs 460.

Scenario #2
No flight possible.

#include?<iostream>
using?namespace?std;

const?int?MAXN?=?11;
const?int?MAXM?=?1001;
const?int?INF?=??2000000000;

int?n,?m;
int?a[MAXN][MAXN][MAXM];
int?d[MAXM][MAXN];
int?num[MAXN][MAXN];

int?main()
{
????
int?i,?j,?k,?l;
????
int?t,?t1;
????
int?tmp?=?0;
????
while?(scanf("%d%d",?&n,?&m)?!=?EOF)?{
????????
if?(n?==?0?&&?m?==?0)?break;
????????memset(a,?
0,?sizeof(a));
????????
for?(i=1;?i<=n;?i++)?{
????????????
for?(j=1;?j<=n;?j++)?{
????????????????
if?(i?!=?j)?{
????????????????????scanf(
"%d",?&num[i][j]);
????????????????????
for?(k=1;?k<=num[i][j];?k++)?{
????????????????????????scanf(
"%d",?&a[i][j][k]);
????????????????????}

????????????????}

????????????}

????????}

????????
for?(i=1;?i<=m;?i++)?{
????????????
for?(j=1;?j<=n;?j++)?{
????????????????d[i][j]?
=?INF;
????????????}

????????}

????????
for?(j=1;?j<=n;?j++)?{
????????????
if?(a[1][j][1]?>?0)?{
????????????????d[
1][j]?=?a[1][j][1];
????????????}

????????}

????????
for?(i=2;?i<=m;?i++)?{
????????????
for?(j=1;?j<=n;?j++)?{
????????????????t?
=?INF;
????????????????
for?(k=1;?k<=n;?k++)?{
????????????????????
if?(k?==?j)?continue;
????????????????????t1?
=?i?%?num[k][j]?>?0???i?%?num[k][j]?:?num[k][j];
????????????????????
if?(a[k][j][t1]?>?0?&&?t?>?d[i-1][k]?+?a[k][j][t1])?{
????????????????????????t?
=?d[i-1][k]?+?a[k][j][t1];
????????????????????}

????????????????}

????????????????d[i][j]?
=?t;
????????????}

????????}

????????printf(
"Scenario?#%d\n",?++tmp);
????????
if?(d[m][n]?!=?INF)?{
????????????printf(
"The?best?flight?costs?%d.\n\n",?d[m][n]);
????????}
?else?{
????????????printf(
"No?flight?possible.\n\n");
????????}

????}

????system(
"pause");
????
return?0;
}

posted on 2006-10-12 00:41 閱讀(586) 評論(0)  編輯 收藏 引用 所屬分類: ACM題目
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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蜜臀av | 男女av一区三区二区色多| 黄色欧美成人| 亚洲国产日韩一级| 麻豆国产精品va在线观看不卡| 亚洲国产经典视频| 亚洲精品自在在线观看| 欧美视频第二页| 黄色小说综合网站| 欧美大香线蕉线伊人久久国产精品| 久久日韩粉嫩一区二区三区 | 欧美涩涩网站| 欧美在线观看你懂的| 久久蜜臀精品av| 一区二区三区欧美成人| 香蕉免费一区二区三区在线观看 | 黑人一区二区| 亚洲国产精品成人综合色在线婷婷| 欧美风情在线观看| 欧美在线视频在线播放完整版免费观看 | 一区二区三区欧美在线| 国产日韩亚洲欧美综合| 亚洲电影免费观看高清完整版在线观看| 欧美经典一区二区| 久久久久成人网| 欧美日韩免费| 女人香蕉久久**毛片精品| 欧美日韩亚洲国产一区| 久久综合九色综合欧美就去吻| 欧美久久视频| 欧美ed2k| 韩国女主播一区二区三区| 日韩亚洲欧美综合| 亚洲国产精品久久人人爱蜜臀| 亚洲一区制服诱惑| 99视频精品全国免费| 久久久久久久一区二区| 性欧美大战久久久久久久免费观看 | 99热在线精品观看| 亚洲第一天堂无码专区| 亚洲欧美中文字幕| 亚洲中字在线| 欧美日韩精品福利| 亚洲国产高清视频| 亚洲国产岛国毛片在线| 先锋a资源在线看亚洲| 亚洲私人影院| 欧美日韩国产成人在线观看| 欧美.日韩.国产.一区.二区| 国产伦精品一区二区三区在线观看| 亚洲欧洲久久| 亚洲精品乱码久久久久久按摩观| 久久精品国产久精国产一老狼| 国产嫩草影院久久久久 | 久久精品国产v日韩v亚洲 | 国产精品美女久久久久久久| 亚洲欧洲在线一区| 亚洲激情视频网站| 美女成人午夜| 欧美激情乱人伦| 亚洲高清资源| 欧美大片在线看免费观看| 欧美高清视频在线观看| 亚洲国产成人高清精品| 免费不卡欧美自拍视频| 欧美激情一区二区在线| 亚洲精品一区二区三区四区高清| 免费国产一区二区| 亚洲激情成人网| 中文精品视频| 国产精品久久久久久久一区探花| 亚洲视频在线一区| 久久福利电影| 1769国内精品视频在线播放| 免费一级欧美片在线播放| 亚洲风情在线资源站| 亚洲美女淫视频| 欧美日韩综合另类| 午夜在线精品偷拍| 蜜桃久久精品乱码一区二区| 亚洲韩国青草视频| 欧美日韩mv| 亚洲欧美日韩中文在线制服| 久久婷婷麻豆| 日韩视频免费观看高清在线视频 | 欧美精品日韩精品| 亚洲天堂成人| 美女主播视频一区| 一区二区91| 国产日韩欧美自拍| 牛牛影视久久网| 在线一区亚洲| 农村妇女精品| 亚洲综合国产| 亚洲国产精品一区二区第四页av | 国产精品青草久久久久福利99| 午夜精品久久久久久久99水蜜桃| 欧美91视频| 亚洲一区二区三区精品在线观看| 狠狠色狠狠色综合系列| 欧美人在线观看| 欧美一级免费视频| 日韩午夜一区| 欧美成人精品高清在线播放| 亚洲一区二区欧美| 亚洲国产精品久久久久秋霞影院 | 在线播放国产一区中文字幕剧情欧美| 欧美高清在线一区| 欧美综合77777色婷婷| 日韩视频免费观看高清完整版| 久久久久久电影| 亚洲先锋成人| 亚洲免费观看在线视频| 狠狠久久五月精品中文字幕| 国产精品videosex极品| 嫩草影视亚洲| 久久免费99精品久久久久久| 亚洲一级免费视频| 亚洲精品在线观看免费| 欧美bbbxxxxx| 猛干欧美女孩| 久久久亚洲国产美女国产盗摄| 亚洲影院一区| 一区二区三区四区国产| 亚洲韩国青草视频| 亚洲电影在线播放| 一区精品在线| 黄色一区二区三区| 国产一区二区三区免费在线观看| 国产精品卡一卡二| 欧美日韩直播| 欧美午夜a级限制福利片| 欧美韩日精品| 欧美另类高清视频在线| 欧美黄在线观看| 欧美精品日韩精品| 欧美日韩免费高清| 欧美日韩无遮挡| 欧美色网一区二区| 国产精品免费网站在线观看| 欧美色区777第一页| 欧美日韩亚洲一区三区| 欧美日韩另类视频| 欧美婷婷久久| 国产精品人成在线观看免费| 国产精品九九| 国产日韩免费| 黄色另类av| 亚洲精品在线二区| 一区二区三区黄色| 亚洲一区二区三区色| 亚洲综合色丁香婷婷六月图片| 亚洲与欧洲av电影| 久久国产精品久久久| 麻豆成人小视频| 91久久精品美女高潮| 99视频精品| 欧美一级黄色网| 麻豆成人综合网| 欧美视频专区一二在线观看| 国产精品一区二区在线观看| 国模精品娜娜一二三区| 亚洲激情一区二区三区| 亚洲图片自拍偷拍| 久久九九99| 亚洲青色在线| 亚洲综合首页| 亚洲激情一区| 亚洲一区二区毛片| 欧美中文在线字幕| 欧美福利电影在线观看| 国产精品二区在线| 尤妮丝一区二区裸体视频| 亚洲精品国产系列| 欧美在线资源| 亚洲黄色视屏| 香蕉视频成人在线观看| 欧美多人爱爱视频网站| 国产欧美精品| 日韩天堂av| 久久久久综合网| 夜夜爽99久久国产综合精品女不卡| 欧美一区国产在线| 欧美日韩成人在线视频| 韩国女主播一区| 午夜精品久久久久| 亚洲高清在线播放| 久久er99精品| 国产精品乱码久久久久久| 亚洲精品日韩一|