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

coreBugZJ

此 blog 已棄。

POJ 1603 Risk

  1/*
  2POJ 1603 Risk
  3
  4
  5----問題描述:
  6
  7Risk is a board game in which several opposing players attempt to conquer the world. The gameboard consists of a world map broken up into hypothetical countries. During a player's turn, armies stationed in one country are only allowed to attack only countries with which they share a common border. Upon conquest of that country, the armies may move into the newly conquered country. 
  8
  9During the course of play, a player often engages in a sequence of conquests with the goal of transferring a large mass of armies from some starting country to a destination country. Typically, one chooses the intervening countries so as to minimize the total number of countries that need to be conquered. Given a description of the gameboard with 20 countries each with between 1 and 19 connections to other countries, your task is to write a function that takes a starting country and a destination country and computes the minimum number of countries that must be conquered to reach the destination. You do not need to output the sequence of countries, just the number of countries to be conquered including the destination. For example, if starting and destination countries are neighbors, then your program should return one. 
 10
 11The following connection diagram illustrates the first sample input. 
 12
 13
 14----輸入:
 15
 16Input to your program will consist of a series of country configuration test sets. Each test set will consist of a board description on lines 1 through 19. The representation avoids listing every national boundary twice by only listing the fact that country I borders country J when I < J. Thus, the Ith line, where I is less than 20, contains an integer X indicating how many "higher-numbered" countries share borders with country I, then X distinct integers J greater than I and not exceeding 20, each describing a boundary between countries I and J. Line 20 of the test set contains a single integer (1 <= N <= 100) indicating the number of country pairs that follow. The next N lines each contain exactly two integers (1 <= A,B <= 20; A!=B) indicating the starting and ending countries for a possible conquest. 
 17
 18There can be multiple test sets in the input file; your program should continue reading and processing until reaching the end of file. There will be at least one path between any two given countries in every country configuration.
 19
 20
 21----輸出:
 22
 23For each input set, your program should print the following message "Test Set #T" where T is the number of the test set starting with 1. The next NT lines each will contain the result for the corresponding test in the test set - that is, the minimum number of countries to conquer. The test result line should contain the start country code A the string " to " the destination country code B ; the string ": " and a single integer indicating the minimum number of moves required to traverse from country A to country B in the test set. Following all result lines of each input set, your program should print a single blank line.
 24
 25
 26----樣例輸入:
 27
 281 3
 292 3 4
 303 4 5 6
 311 6
 321 7
 332 12 13
 341 8
 352 9 10
 361 11
 371 11
 382 12 17
 391 14
 402 14 15
 412 15 16
 421 16
 431 19
 442 18 19
 451 20
 461 20
 475
 481 20
 492 9
 5019 5
 5118 19
 5216 20
 53
 54
 55----樣例輸出:
 56
 57Test Set #1
 581 to 20: 7
 592 to 9: 5
 6019 to 5: 6
 6118 to 19: 2
 6216 to 20: 2
 63
 64
 65----分析:
 66
 67Floyd 算法。
 68
 69
 70*/

 71
 72
 73#include <stdio.h>
 74#include <string.h>
 75
 76#define  N    23
 77#define  INF  0x3F3F3F3F
 78
 79int main() {
 80        int n, w[ N ][ N ], i, j, k, td = 0;
 81        while ( 1 == scanf( "%d"&k ) ) {
 82                memset( w, 0x3Fsizeof(w) );
 83                for ( i = 0; i < k; ++i ) {
 84                        scanf( "%d"&j );
 85                        w[ 1 ][ j ] = w[ j ][ 1 ] = 1;
 86                }

 87                for ( i = 2; i <= 19++i ) {
 88                        scanf( "%d"&k );
 89                        while ( 0 < k-- ) {
 90                                scanf( "%d"&j );
 91                                w[ i ][ j ] = w[ j ][ i ] = 1;
 92                        }

 93                }

 94
 95                for ( k = 1; k <= 20++k ) {
 96                        for ( i = 1; i <= 20++i ) {
 97                                for ( j = 1; j <= 20++j ) {
 98                                        if ( (i != j) && (i != k) && (k != j) ) {
 99                                                if ( w[ i ][ j ] > w[ i ][ k ] + w[ k ][ j ] ) {
100                                                        w[ i ][ j ] = w[ i ][ k ] + w[ k ][ j ];
101                                                }

102                                        }

103                                }

104                        }

105                }

106
107                scanf( "%d"&n );
108                printf( "Test Set #%d\n"++td );
109                while ( 0 < n-- ) {
110                        scanf( "%d%d"&i, &j );
111                        printf( "%d to %d: %d\n", i, j, w[ i ][ j ] );
112                }

113                printf( "\n" );
114        }

115        return 0;
116}

117

posted on 2012-05-14 16:13 coreBugZJ 閱讀(638) 評論(0)  編輯 收藏 引用 所屬分類: ACMAlgorithm課內作業

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            一本色道88久久加勒比精品| 亚洲级视频在线观看免费1级| 亚洲三级电影全部在线观看高清| 久久嫩草精品久久久精品一| 国内成人精品视频| 久久另类ts人妖一区二区| 欧美一级视频| 在线不卡中文字幕播放| 欧美r片在线| 欧美刺激午夜性久久久久久久| 亚洲黄色在线视频| 亚洲人体偷拍| 国产精品毛片a∨一区二区三区|国| 亚洲一区二区三区在线视频| 亚洲视屏在线播放| 国产精品日韩一区| 麻豆成人综合网| 欧美激情在线观看| 亚洲一区二区高清| 欧美一区二区三区免费在线看| 精品91免费| 91久久精品一区二区三区| 欧美视频一区| 久久亚洲国产精品一区二区| 欧美韩日一区二区三区| 亚洲一区二区三区四区五区黄 | 国内久久视频| 欧美激情一区在线观看| 欧美视频日韩视频在线观看| 久久久久久久久久看片| 狂野欧美激情性xxxx| 亚洲一区二区综合| 久久人体大胆视频| 亚洲一区二区免费视频| 久久久久一区| 亚洲影院色在线观看免费| 欧美资源在线观看| 一区二区三区毛片| 中文国产一区| 亚洲欧美中文字幕| 日韩视频中文| 久久精品理论片| 亚洲欧美成人一区二区在线电影| 久久动漫亚洲| 欧美亚洲免费高清在线观看| 欧美精品一区二| 久久视频一区二区| 国产精品久久毛片a| 亚洲高清自拍| 激情综合自拍| 亚洲欧美一区二区原创| 在线亚洲一区| 欧美精品大片| 欧美大尺度在线观看| 国产香蕉久久精品综合网| 99riav久久精品riav| 亚洲乱码国产乱码精品精| 欧美中文字幕视频| 香蕉成人久久| 欧美日韩在线大尺度| 欧美激情一区二区在线| 亚洲高清在线播放| 久久激情婷婷| 久久性天堂网| 国产一区日韩二区欧美三区| 亚洲欧美日韩国产一区二区| 亚洲欧美日本国产有色| 欧美日韩亚洲天堂| 亚洲免费观看视频| 日韩视频欧美视频| 欧美紧缚bdsm在线视频| 亚洲国产成人不卡| 亚洲精品网站在线播放gif| 久久亚洲不卡| 亚洲激情黄色| 99精品热视频| 欧美天天综合网| 制服诱惑一区二区| 亚洲影院色无极综合| 国产精品a久久久久| 亚洲无线视频| 欧美一区二区三区播放老司机 | 久久av红桃一区二区小说| 欧美一级视频精品观看| 国产日韩欧美精品在线| 欧美在线亚洲在线| 久久综合久色欧美综合狠狠| 亚洲电影自拍| 欧美日韩亚洲系列| 亚洲一区二区三区欧美| 久久久av毛片精品| 亚洲福利国产精品| 欧美美女操人视频| 亚洲性视频h| 久久亚洲综合色| 亚洲精品在线视频| 国产精品九九久久久久久久| 午夜免费久久久久| 欧美成人一区在线| 亚洲一区二区成人在线观看| 国产视频一区三区| 免费成人小视频| 日韩视频一区二区在线观看| 欧美日韩一区在线播放| 亚洲一区二区三| 欧美成人一二三| 亚洲欧美日韩成人高清在线一区| 国模私拍一区二区三区| 欧美激情一区二区三区在线| 午夜久久影院| 亚洲欧洲日韩女同| 久久久国产精品亚洲一区 | 亚洲午夜av| 国产亚洲福利一区| 欧美大片免费观看| 亚洲欧美视频一区| 亚洲精品一区在线| 久久精品中文字幕一区| av成人免费在线| 精品va天堂亚洲国产| 欧美特黄a级高清免费大片a级| 久久影视精品| 午夜伦理片一区| 99一区二区| 亚洲国产日韩欧美一区二区三区| 欧美制服第一页| 中日韩美女免费视频网站在线观看| 精品成人国产在线观看男人呻吟| 欧美性大战xxxxx久久久| 欧美电影在线播放| 久久精品亚洲精品| 亚洲欧美日韩成人高清在线一区| 亚洲人成在线观看一区二区| 久热精品视频在线观看| 欧美有码在线观看视频| 亚洲图片欧美一区| 一区二区三区国产| 日韩一级在线观看| 亚洲黄色三级| 亚洲激情在线观看| 亚洲国产精品一区二区第四页av | 欧美精品一二三| 欧美风情在线| 欧美成人综合网站| 免费人成精品欧美精品| 久久天堂av综合合色| 欧美亚洲日本国产| 亚洲欧美日韩在线一区| 亚洲免费视频网站| 亚洲制服av| 午夜精品亚洲| 欧美亚洲网站| 久久精品国产亚洲aⅴ| 欧美在线视屏| 久久婷婷丁香| 欧美freesex交免费视频| 蜜臀久久99精品久久久画质超高清| 久久嫩草精品久久久精品一| 久久综合一区二区三区| 欧美大片在线观看| 欧美日本二区| 国产精品裸体一区二区三区| 国产女人水真多18毛片18精品视频| 国产欧美一区视频| 狠狠久久亚洲欧美| 亚洲国产精选| 在线一区二区三区做爰视频网站| 亚洲综合第一| 久久精品视频在线播放| 美女视频一区免费观看| 亚洲国产精品一区二区www| 亚洲老板91色精品久久| 一本色道久久综合精品竹菊| 亚洲精品综合久久中文字幕| 在线视频日本亚洲性| 欧美一区二区大片| 久久综合影音| 日韩性生活视频| 午夜精品视频一区| 蜜桃久久av一区| 国产精品swag| 亚洲国产导航| 午夜天堂精品久久久久| 久久久一区二区| 亚洲精品美女久久7777777| 亚洲一区三区视频在线观看| 久久一区二区三区四区| 欧美日韩一区二区三区视频 | 欧美成在线视频| 国产乱理伦片在线观看夜一区| 亚洲国产成人av| 亚洲欧美中文日韩v在线观看| 欧美福利视频在线观看| 一本久久综合| 免播放器亚洲一区| 国产日韩欧美日韩大片| 日韩视频一区二区三区在线播放免费观看 | 日韩视频免费看| 久久久久这里只有精品| 亚洲精品一区二区三区婷婷月 |