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

隨筆 - 87  文章 - 279  trackbacks - 0
<2007年4月>
25262728293031
1234567
891011121314
15161718192021
22232425262728
293012345

潛心看書研究!

常用鏈接

留言簿(19)

隨筆分類(81)

文章分類(89)

相冊

ACM OJ

My friends

搜索

  •  

積分與排名

  • 積分 - 219411
  • 排名 - 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 閱讀(577) 評論(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>
            经典三级久久| 国产美女高潮久久白浆| 亚洲激情女人| 日韩天堂在线观看| 欧美性一区二区| 久久久91精品国产一区二区三区| 午夜精品福利一区二区蜜股av| 国产亚洲精品久久久久婷婷瑜伽| 久久在线91| 欧美激情精品久久久久| 亚洲一区视频在线| 欧美中文字幕在线播放| 亚洲国产美国国产综合一区二区| 亚洲精品少妇| 国产嫩草影院久久久久 | 国产精品福利片| 欧美一区二区视频在线观看| 久久精品夜夜夜夜久久| 99精品视频免费观看视频| 亚洲一区日韩| 亚洲九九九在线观看| 亚洲香蕉网站| 91久久精品国产91性色| 亚洲午夜一二三区视频| 韩国欧美一区| 一区二区三区日韩| 18成人免费观看视频| 亚洲最新中文字幕| 亚洲大胆av| 亚洲一区在线观看视频| 一区二区三区久久| 国产婷婷色一区二区三区在线| 亚洲国产专区校园欧美| 国产精品免费区二区三区观看| 欧美福利电影在线观看| 国产精品入口福利| 亚洲欧洲在线免费| 精品二区视频| 午夜精品婷婷| 亚洲无限乱码一二三四麻| 久久综合网hezyo| 欧美亚洲一级| 欧美视频官网| 91久久线看在观草草青青| 一区二区三区亚洲| 亚洲欧美中日韩| 亚洲一区二区三区在线播放| 欧美成人高清视频| 欧美成人精品影院| 黄色一区二区在线观看| 午夜精品一区二区三区四区| 亚洲午夜高清视频| 欧美日韩另类国产亚洲欧美一级| 欧美成人一品| 亚洲电影视频在线| 久久这里只精品最新地址| 亚欧成人在线| 国产日韩精品在线观看| 亚洲一区bb| 欧美一区二区三区日韩视频| 国产精品美女一区二区| 一区二区三区日韩精品| 一区二区不卡在线视频 午夜欧美不卡'| 久久亚洲国产成人| 亚洲第一成人在线| 亚洲理论电影网| 欧美日韩在线观看视频| 一区二区三区久久精品| 午夜精品一区二区三区在线视| 欧美午夜欧美| 亚洲一区激情| 久久久久久9| 亚洲国产成人久久综合一区| 六十路精品视频| 欧美成年人视频| 亚洲精品国产拍免费91在线| 欧美激情精品久久久久| 中文在线一区| 久久久久久久精| 亚洲精品123区| 欧美性理论片在线观看片免费| 9色国产精品| 久久精品一区四区| 亚洲人成高清| 国产精品第2页| 久久免费国产精品1| 亚洲黄网站在线观看| 亚洲欧美综合精品久久成人| 激情亚洲一区二区三区四区| 欧美黄色aa电影| 午夜精品影院在线观看| 亚洲电影免费| 午夜在线播放视频欧美| 亚洲大胆在线| 欧美亚洲成人免费| 久热精品视频在线观看| 一本久久a久久免费精品不卡| 久久激情视频久久| 亚洲精品视频在线观看免费| 国产精品视频免费观看www| 久久免费视频网站| 亚洲私人影院在线观看| 免费成人av在线| 午夜精品999| 亚洲国产精品va在线看黑人动漫| 欧美三级免费| 玖玖综合伊人| 欧美一级二级三级蜜桃| 亚洲精品女av网站| 久久国产精品99精品国产| 欧美在线电影| 中文日韩欧美| 亚洲人成啪啪网站| 欧美α欧美αv大片| 欧美一区二区日韩| 亚洲伊人网站| 99爱精品视频| 亚洲东热激情| 国语精品中文字幕| 国产精品欧美在线| 欧美日韩亚洲另类| 欧美激情成人在线视频| 久久婷婷综合激情| 久久不射电影网| 亚洲欧美激情一区| 亚洲视频久久| 一本色道久久综合亚洲精品小说| 亚洲第一精品在线| 欧美成人在线网站| 蜜桃久久精品乱码一区二区| 久久久国产成人精品| 欧美诱惑福利视频| 亚欧成人在线| 欧美在线一级va免费观看| 亚洲一区二区三区在线看| 一区二区av在线| 亚洲最新视频在线| 一本一本大道香蕉久在线精品| 亚洲人成啪啪网站| 亚洲美女视频网| 一区二区日韩精品| 一区二区三区视频在线观看| 一区二区三区精品国产| 一本色道久久88亚洲综合88| 9国产精品视频| 亚洲视频中文| 亚洲免费中文| 欧美中在线观看| 久久久91精品国产一区二区三区| 久久看片网站| 欧美大成色www永久网站婷| 亚洲高清123| 日韩亚洲精品视频| 亚洲欧美视频一区二区三区| 亚洲女同精品视频| 久久久久久9| 欧美激情一区二区三区全黄| 欧美日韩一区综合| 国产精品制服诱惑| 亚洲成人直播| 一区二区电影免费观看| 欧美一区二区国产| 欧美成人按摩| av不卡在线| 欧美一区国产一区| 欧美aⅴ99久久黑人专区| 欧美体内谢she精2性欧美| 国产亚洲精品bv在线观看| 亚洲国产岛国毛片在线| 亚洲午夜精品| 老司机午夜免费精品视频| 亚洲精品影院| 欧美在线观看www| 欧美第十八页| 国产女人aaa级久久久级| 亚洲人人精品| 欧美一区二区三区在| 欧美激情视频给我| 午夜精品福利一区二区三区av | 乱人伦精品视频在线观看| 欧美激情一区二区三区高清视频 | 欧美国产欧美亚州国产日韩mv天天看完整| 亚洲欧洲美洲综合色网| 欧美一区二区三区视频在线| 欧美成人按摩| 精品成人久久| 亚洲欧美日韩一区| 亚洲区国产区| 久久欧美中文字幕| 国产欧美一区二区精品婷婷| 99热在这里有精品免费| 久久免费午夜影院| 亚洲国产激情| 久久精品国产一区二区电影| 亚洲毛片在线观看.| 欧美va亚洲va香蕉在线| 国产午夜亚洲精品理论片色戒| 亚洲视频在线一区观看| 亚洲国产成人精品女人久久久 | 亚洲第一黄网|