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

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 閱讀(632) 評論(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>
            亚洲精品一区二区三区不| 欧美亚洲三区| 亚洲国产欧美日韩| 欧美岛国在线观看| 在线视频精品一区| 亚洲一区二区三区在线播放| 国产精品网站一区| 欧美v日韩v国产v| 欧美精品在线一区二区| 亚洲欧美成人一区二区在线电影| 亚洲桃色在线一区| 黄色资源网久久资源365| 欧美激情在线免费观看| 欧美精品日韩综合在线| 欧美一区二区| 免费美女久久99| 亚洲欧美中文另类| 久久亚洲视频| 亚洲欧美日韩精品久久奇米色影视| 亚洲在线视频免费观看| 亚洲国产欧美精品| 亚洲欧美日韩国产成人精品影院| 国内偷自视频区视频综合| 亚洲国产婷婷综合在线精品 | 久久亚洲私人国产精品va| 蜜臀va亚洲va欧美va天堂| 亚洲自拍三区| 免费91麻豆精品国产自产在线观看| 亚洲图片自拍偷拍| 另类av导航| 欧美中文字幕在线| 欧美日韩免费观看一区=区三区| 久久免费精品日本久久中文字幕| 欧美乱在线观看| 欧美成人综合网站| 国产女人水真多18毛片18精品视频| 欧美黄色片免费观看| 国产一区二区三区高清在线观看| 亚洲日本视频| 亚洲国产欧美一区二区三区丁香婷| 亚洲欧美激情视频| 亚洲一区二区高清| 欧美激情一区二区三区在线| 狼狼综合久久久久综合网| 国产精品人人做人人爽| 亚洲美女尤物影院| 日韩网站免费观看| 免费不卡在线观看| 美女脱光内衣内裤视频久久网站| 国产精品男人爽免费视频1| 亚洲国产天堂网精品网站| 亚洲高清不卡av| 久久午夜精品| 久热精品视频在线免费观看| 国产在线精品一区二区中文| 亚洲欧美一区二区三区极速播放 | 在线成人中文字幕| 欧美尤物一区| 久久欧美中文字幕| 国产一区二区三区视频在线观看 | 欧美一区2区视频在线观看| 午夜久久tv| 国产欧美精品在线观看| 午夜久久久久久久久久一区二区| 午夜一区不卡| 国产日本欧美一区二区三区在线| 亚洲一区免费| 亚洲自拍三区| 国产日韩欧美一区二区| 欧美综合77777色婷婷| 久久在线精品| 亚洲高清毛片| 欧美喷潮久久久xxxxx| 亚洲精品永久免费| 午夜老司机精品| 狠色狠色综合久久| 欧美大片国产精品| 在线视频一区观看| 久久国产精品黑丝| 在线观看国产欧美| 欧美区日韩区| 亚洲欧美日韩综合| 欧美成人免费在线观看| 9l国产精品久久久久麻豆| 欧美午夜精品理论片a级按摩 | 亚洲国产精品久久久久秋霞不卡| 亚洲免费成人| 国产精品视频大全| 久久免费视频在线观看| 亚洲国产婷婷香蕉久久久久久99 | 亚洲黄色小视频| 亚洲免费视频成人| 一区二区亚洲精品| 欧美日韩四区| 久久视频在线免费观看| 亚洲精选久久| 久久综合网hezyo| 中文久久精品| 亚洲国产高潮在线观看| 国产精品电影观看| 免费在线亚洲| 香蕉av777xxx色综合一区| 亚洲第一中文字幕| 欧美一区二区三区四区高清| 亚洲激情视频在线播放| 国产精品久久久久一区二区三区共 | 午夜精品亚洲| 亚洲欧洲精品一区二区三区波多野1战4 | 久久久久久亚洲精品不卡4k岛国| 亚洲精品综合精品自拍| 麻豆av一区二区三区| 亚洲一区二区三区午夜| 亚洲黄一区二区| 国内精品福利| 国产麻豆91精品| 欧美日韩视频第一区| 久久久久国产一区二区三区四区| 制服丝袜亚洲播放| 亚洲精品孕妇| 最新亚洲视频| 欧美好骚综合网| 久久久视频精品| 欧美一区二区在线免费观看| 中文在线一区| 一本久久精品一区二区| 亚洲区中文字幕| 亚洲成人在线网站| 国外成人网址| 国产一区二区三区在线观看网站| 国产精品一区二区三区乱码| 欧美三级视频在线观看| 欧美精品在线免费观看| 欧美电影美腿模特1979在线看 | 亚洲伦理在线观看| 亚洲国产三级网| 亚洲国产精品成人综合色在线婷婷 | 国产欧美视频一区二区三区| 国产精品a久久久久| 欧美色区777第一页| 欧美日韩在线一区二区| 欧美日韩成人综合| 欧美日韩视频不卡| 国产精品草莓在线免费观看| 欧美精品日韩| 欧美视频免费| 国产欧美日韩视频| 国产一区在线看| 亚洲福利在线观看| 亚洲乱码国产乱码精品精可以看 | 亚洲综合日本| 香蕉久久久久久久av网站| 性欧美长视频| 久久亚洲国产精品一区二区| 老司机精品视频一区二区三区| 蜜乳av另类精品一区二区| 欧美激情视频一区二区三区不卡| 亚洲激情影院| 亚洲特色特黄| 久久久久久高潮国产精品视| 欧美成人精精品一区二区频| 欧美日韩另类综合| 国产女优一区| 亚洲福利视频一区| 亚洲一区在线观看免费观看电影高清| 亚洲男人天堂2024| 久久综合九色欧美综合狠狠| 亚洲国产精品成人一区二区| 一区二区av在线| 久久黄色小说| 欧美日韩免费网站| 国产一区二区三区在线观看免费视频 | 欧美日韩xxxxx| 国产午夜精品麻豆| 亚洲欧洲日产国产网站| 亚洲欧美精品| 亚洲二区在线| 亚洲影院污污.| 欧美激情欧美狂野欧美精品| 国产欧美日韩高清| 99国内精品久久| 久久久久久久91| 99精品福利视频| 久久女同互慰一区二区三区| 国产精品久久久久aaaa九色| 在线看片第一页欧美| 亚洲尤物在线视频观看| 牛牛国产精品| 亚洲欧美乱综合| 欧美日韩精品中文字幕| 亚洲电影免费观看高清| 性做久久久久久免费观看欧美| 欧美激情视频一区二区三区在线播放| 亚洲一区二区三区精品视频| 欧美精品在欧美一区二区少妇| 韩日在线一区| 欧美一区免费视频| 一区二区三区精密机械公司| 免费观看日韩av| 在线观看日韩www视频免费 | 一本色道久久99精品综合|