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

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

潛心看書研究!

常用鏈接

留言簿(19)

隨筆分類(81)

文章分類(89)

相冊

ACM OJ

My friends

搜索

  •  

積分與排名

  • 積分 - 221500
  • 排名 - 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>
            亚洲综合大片69999| 一本色道久久88综合日韩精品 | 久久久999精品免费| 欧美成人在线免费视频| 亚洲人成在线免费观看| 久久国产精品一区二区| 亚洲成人资源| 亚洲欧美另类综合偷拍| 欧美成人精品一区| 国产精品国产三级国产a| 狠狠色综合日日| 一个色综合导航| 99香蕉国产精品偷在线观看| 久久综合伊人77777| 国产精品一区二区三区四区五区| 日韩视频国产视频| 欧美国产日韩免费| 亚洲欧美日韩在线一区| 欧美日韩在线不卡一区| 亚洲精品视频免费观看| 欧美高清自拍一区| 欧美视频不卡| 中日韩午夜理伦电影免费| 国产精品尤物| 久久蜜桃精品| 欧美中文在线观看| 国产免费一区二区三区香蕉精| 久久精品夜色噜噜亚洲a∨| 美女久久一区| 亚洲全部视频| 亚洲高清免费在线| 女人香蕉久久**毛片精品| 伊人久久婷婷| 欧美国产免费| 国产精品第2页| 免费精品视频| 麻豆视频一区二区| 亚洲欧美日韩精品| 亚洲欧美国产另类| 亚洲精品一区二区三区四区高清| 亚洲视频在线看| 国产欧美欧美| 久热精品在线视频| 久久久天天操| 999在线观看精品免费不卡网站| 亚洲电影成人| 国产一区二区在线观看免费| 老司机成人网| 国产精品夜夜夜一区二区三区尤| 亚洲欧美精品伊人久久| 欧美sm视频| 久久久99久久精品女同性| 欧美三级免费| 日韩视频在线一区二区| 国产日韩av高清| 99国产麻豆精品| 亚洲精品美女免费| 久久久久久综合| 久久噜噜噜精品国产亚洲综合| 欧美日韩国产精品| 久久精品夜色噜噜亚洲a∨| 国产精品啊啊啊| 久久天天躁夜夜躁狠狠躁2022 | 一本色道久久综合亚洲精品高清| 国产精品大片| 亚洲精选久久| 国产精品久久久久毛片软件| 欧美在线观看视频一区二区三区| 久久精品日产第一区二区三区| 亚洲精品永久免费精品| 麻豆亚洲精品| 免费久久精品视频| 亚洲国产精品久久久久婷婷老年| 亚洲精品午夜精品| 亚洲国产影院| 久久不射网站| 亚洲视频axxx| 国产精品福利网站| 亚洲女同精品视频| 欧美资源在线| 欧美三区在线观看| 一区二区三区四区在线| 亚洲国产黄色| 免费看成人av| 91久久久亚洲精品| 国内精品久久久久影院色| 亚洲九九精品| 亚洲一区二区免费看| 女仆av观看一区| 亚洲精品免费观看| 亚洲影院在线观看| 国产日韩欧美二区| 99re在线精品| 欧美一级视频| 国产精品久久999| 欧美在线三级| 亚洲电影网站| 亚洲免费视频一区二区| 国产亚洲福利一区| 欧美成人一区二区| 亚洲视频一区在线观看| 久久综合电影| 国产精品99久久不卡二区 | 久久精品免视看| 亚洲国产激情| 先锋影院在线亚洲| 亚洲韩国一区二区三区| 欧美小视频在线观看| 久久gogo国模裸体人体| 亚洲成色www8888| 欧美一区国产一区| 99re在线精品| 国产精品久久久久久av福利软件| 欧美在线观看视频| 日韩午夜电影av| 久久天天躁狠狠躁夜夜av| 中日韩午夜理伦电影免费| 影音先锋日韩资源| 国产精品视频成人| 欧美激情1区2区| 亚洲靠逼com| 久久综合九色综合欧美就去吻 | 黄色资源网久久资源365| 欧美在线播放视频| 亚洲精品小视频| 欧美国产亚洲另类动漫| 欧美综合二区| 亚洲女同同性videoxma| 亚洲精选一区| 亚洲国产日韩在线一区模特| 国产视频不卡| 国产精品影音先锋| 欧美日韩在线视频一区二区| 欧美成人免费观看| 久久久久久久综合狠狠综合| 午夜精品一区二区三区在线视| 久久久久久久久久久久久女国产乱| 亚洲夜晚福利在线观看| 亚洲乱码国产乱码精品精天堂| 伊伊综合在线| 在线精品视频免费观看| 欧美日韩免费观看一区二区三区| 久久资源av| 久久夜精品va视频免费观看| 99综合在线| 亚洲精品一区二区三区在线观看 | 久久成年人视频| 亚洲一区二区黄色| 亚洲网在线观看| 亚洲图片在线观看| 亚洲一区二区视频在线| 亚洲天堂av在线免费| 亚洲视频在线视频| 亚洲欧美国产日韩中文字幕| 亚洲一区二区三区高清 | 亚洲精品日韩欧美| 亚洲美女视频网| 在线午夜精品自拍| 精品不卡在线| 亚洲国产导航| 日韩视频一区二区| 亚洲综合色自拍一区| 欧美一进一出视频| 久久久久99精品国产片| 久久综合影视| 亚洲国产成人一区| 亚洲人成毛片在线播放女女| 99在线精品视频| 午夜精品久久久久久 | 亚洲国产mv| 亚洲免费观看在线视频| 亚洲视频碰碰| 久久精品视频免费播放| 久久尤物视频| 国产精品成人国产乱一区| 国产视频精品网| 91久久在线观看| 亚洲欧美一级二级三级| 一区二区日韩免费看| 欧美一区二区三区播放老司机 | 在线免费观看成人网| 亚洲黄色影院| 亚洲欧美激情四射在线日| 久久久之久亚州精品露出| 亚洲国产精品v| 免费试看一区| 一本色道久久88精品综合| 久久精品盗摄| 欧美日韩亚洲一区二区三区| 好看的日韩视频| 一本高清dvd不卡在线观看| 久久精品国产久精国产爱| 亚洲精品国偷自产在线99热| 欧美在线视频免费观看| 欧美激情在线| 欧美日韩午夜| 在线日韩中文字幕| 亚洲一区免费观看| 欧美电影免费观看高清| 亚洲一区二区三区四区中文|