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

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>
            免费国产一区二区| 羞羞视频在线观看欧美| 免费在线一区二区| 亚洲激情成人在线| 欧美激情一区二区三区四区| 免费不卡在线观看| 日韩亚洲精品视频| 一区二区久久久久| 国产日韩欧美中文在线播放| 久久久久久久999| 久久在线视频在线| 日韩一级欧洲| 亚洲图片欧美午夜| 狠狠色伊人亚洲综合网站色| 亚洲第一黄网| 欧美日本在线| 欧美一区二区三区免费观看视频| 亚洲欧美国内爽妇网| 在线观看日韩精品| 亚洲另类自拍| 国产日韩一区二区三区在线播放| 老色鬼精品视频在线观看播放| 久久永久免费| 亚洲欧美另类国产| 久久久99免费视频| 亚洲一区二区高清| 久久久久久高潮国产精品视| 一本一道久久综合狠狠老精东影业 | 国产精品对白刺激久久久| 欧美一级二区| 欧美成人综合在线| 亚洲欧洲99久久| 免费久久精品视频| 性欧美video另类hd性玩具| 久久精品成人| 亚洲一区二区三区精品在线| 欧美综合国产| 亚洲一区二区久久| 开心色5月久久精品| 欧美亚洲三级| 欧美精品久久久久久久久久| 久久久国产一区二区| 欧美日韩一区二区视频在线观看| 久久影音先锋| 国产精品乱码妇女bbbb| 亚洲福利国产| 狠狠色丁香婷婷综合影院 | 亚洲午夜一区二区| 美日韩免费视频| 久久久国产精品一区二区中文 | 欧美怡红院视频| 亚洲私人影院在线观看| 欧美 日韩 国产精品免费观看| 欧美在线视频在线播放完整版免费观看| 欧美电影在线观看完整版| 久久久久国产成人精品亚洲午夜| 国产精品xnxxcom| 亚洲区第一页| 亚洲美女av黄| 欧美高清视频一区| 亚洲国产成人av| 亚洲高清激情| 久久国产一区二区三区| 一本色道久久加勒比88综合| 欧美二区在线观看| 免费观看国产成人| 国产综合亚洲精品一区二| 亚洲一区二区三区精品在线| 一区二区三区国产在线| 麻豆91精品| 中文亚洲欧美| 国产精品一区二区男女羞羞无遮挡| 亚洲高清不卡| 亚洲欧洲日本在线| 免费成人激情视频| 男女视频一区二区| 国产精品视频yy9299一区| 亚洲免费网站| 欧美一区二区黄| 国产精品免费久久久久久| 亚洲精品一区中文| 一区二区三区视频在线观看| 欧美大成色www永久网站婷| 欧美黄色日本| 亚洲麻豆av| 欧美激情综合色| aa级大片欧美三级| 亚洲一区精品视频| 国产精品国产三级国产普通话99| 一区二区三区视频在线看| 亚洲免费伊人电影在线观看av| 欧美视频三区在线播放| 99re8这里有精品热视频免费| 亚洲午夜久久久久久久久电影网| 国产精品videossex久久发布| 蜜桃av噜噜一区二区三区| 99re热这里只有精品视频| 欧美人在线视频| 亚洲天天影视| 久久精品日产第一区二区| 极品裸体白嫩激情啪啪国产精品| 久久视频国产精品免费视频在线 | 欧美视频1区| 女同一区二区| 日韩一级免费观看| 国产精品视频九色porn| 欧美一区激情| 亚洲成人在线视频网站| 亚洲私拍自拍| 精品999日本| 欧美精品18+| 亚洲专区免费| 久久电影一区| 在线一区观看| 国产一区二区三区精品欧美日韩一区二区三区| 欧美在线视频观看免费网站| 欧美激情一区二区三区高清视频| 中文欧美在线视频| 尤物99国产成人精品视频| 欧美日韩国产bt| 欧美一级黄色录像| 美女国内精品自产拍在线播放| 亚洲精品久久| 国产女精品视频网站免费| 欧美不卡高清| 欧美一级日韩一级| 99国内精品久久| 美女脱光内衣内裤视频久久网站| 中文国产亚洲喷潮| 1024亚洲| 欧美日韩亚洲系列| 欧美精品激情blacked18| 欧美中文在线免费| 一区二区三区日韩欧美精品| 欧美成人一区二区三区片免费| 午夜视频在线观看一区| 日韩亚洲一区二区| 亚洲第一精品福利| 国产女人水真多18毛片18精品视频| 欧美在线观看视频在线| 一区二区三区久久精品| 欧美激情影院| 欧美国产日韩在线| 另类亚洲自拍| 久久久久久夜精品精品免费| 午夜精品久久久久久久久久久久久 | 亚洲一级特黄| 日韩午夜在线电影| 亚洲国产成人久久| 国产综合自拍| 狠色狠色综合久久| 国产精品美女xx| 国产精品久久久久久久久久妞妞| 欧美精品久久久久久久久老牛影院| 久久一区二区三区超碰国产精品| 亚洲无线视频| 亚洲欧美福利一区二区| 亚洲精品小视频在线观看| aaa亚洲精品一二三区| 亚洲精品自在在线观看| 亚洲精品国产无天堂网2021| 亚洲韩国日本中文字幕| 亚洲国产色一区| 亚洲国产精彩中文乱码av在线播放| 久久婷婷一区| 亚洲国产日本| 亚洲三级免费| 99人久久精品视频最新地址| 一本色道婷婷久久欧美| 亚洲影音一区| 欧美亚洲日本国产| 亚洲天堂av在线免费| 久久精品一本久久99精品| 久久久久久69| 欧美国产日本韩| 欧美日韩国产限制| 国产欧美 在线欧美| 国内外成人免费激情在线视频| 亚洲二区免费| 亚洲视频在线观看视频| 欧美一区二区黄色| 麻豆免费精品视频| 亚洲免费成人av电影| 亚洲一区二区在线观看视频| 久久爱www| 久久人体大胆视频| 欧美日韩视频在线一区二区观看视频 | 欧美一级视频精品观看| 久久久久久久久久看片| 亚洲电影在线播放| 亚洲精品裸体| 老鸭窝亚洲一区二区三区| 欧美精品在线观看一区二区| 国产免费成人| 亚洲青涩在线| 香蕉久久国产| 亚洲第一精品夜夜躁人人爽| 99综合视频| 欧美精品九九| 国内精品视频在线观看|