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

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 閱讀(640) 評論(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>
            午夜亚洲一区| av成人免费观看| 欧美**人妖| 欧美高清影院| 一区二区三区福利| 亚洲少妇一区| 国产午夜精品全部视频播放 | 国产精品二区二区三区| 亚洲欧美激情在线视频| 午夜一级久久| 亚洲国产精品久久久久秋霞不卡| 亚洲国产天堂网精品网站| 久久精品国产综合| 亚洲视屏在线播放| 麻豆亚洲精品| 一区二区成人精品| 亚洲欧美日韩精品| 亚洲国产99精品国自产| 亚洲老司机av| 国产午夜亚洲精品羞羞网站| 欧美成人一区在线| 欧美日韩中国免费专区在线看| 在线午夜精品自拍| 欧美一区二区三区视频免费播放| 亚洲国产女人aaa毛片在线| 日韩午夜免费视频| 国产一区二三区| 欧美激情精品久久久久久黑人| 欧美日韩三区四区| 久久精品国产91精品亚洲| 久久香蕉国产线看观看av| 一区二区三区久久| 欧美中文字幕久久| 亚洲精品视频在线观看免费| 一区二区免费在线视频| 黄色成人在线免费| 亚洲人体影院| 国产日韩综合| 亚洲人人精品| 一区二区亚洲欧洲国产日韩| 日韩一二三区视频| 激情一区二区| 中文在线资源观看网站视频免费不卡 | 亚洲欧美日韩在线一区| 久久婷婷色综合| 亚洲一区在线视频| 久热国产精品| 欧美一级片一区| 欧美夫妇交换俱乐部在线观看| 欧美一区二区三区在线看| 欧美大片va欧美在线播放| 欧美在线观看网站| 欧美精品高清视频| 欧美在线一二三区| 欧美精品一级| 美日韩在线观看| 国产麻豆午夜三级精品| 最近中文字幕日韩精品| 国产亚洲欧洲| 99视频精品免费观看| 亚洲国产一区二区精品专区| 亚洲欧美日韩电影| 正在播放亚洲| 欧美va亚洲va国产综合| 久久免费视频网| 亚洲精品久久久久久久久| 欧美成年人网| 久久综合影音| 国产日韩久久| 一区二区三区精品视频| 亚洲精选视频免费看| 久久精品人人做人人综合| 午夜一级久久| 欧美色视频日本高清在线观看| 亚洲成人在线网| 国内精品久久久久久久果冻传媒| 亚洲视屏一区| 亚洲一区二区精品在线| 欧美成va人片在线观看| 欧美成人xxx| 国精产品99永久一区一区| 亚洲免费中文| 在线亚洲激情| 欧美激情一二三区| 欧美国产日韩亚洲一区| 精品av久久久久电影| 性欧美大战久久久久久久久| 亚洲永久免费| 欧美日韩亚洲网| 亚洲精品视频免费在线观看| 亚洲激情视频网站| 可以免费看不卡的av网站| 久久综合色播五月| 国产精品中文字幕在线观看| 在线综合亚洲| 亚洲欧美日本国产有色| 欧美三级免费| 一区二区国产在线观看| 制服丝袜激情欧洲亚洲| 欧美日韩一区二区欧美激情| 亚洲免费av网站| 夜夜夜久久久| 欧美乱妇高清无乱码| 亚洲国产综合视频在线观看| 亚洲精品麻豆| 欧美国产日本韩| 91久久精品一区二区别| 日韩视频中文字幕| 欧美日本不卡视频| 亚洲美女电影在线| 亚洲素人一区二区| 欧美午夜片在线观看| 中文在线不卡| 欧美在线免费看| 国产综合久久久久久鬼色| 久久福利一区| 麻豆精品在线视频| 亚洲国产欧美在线| 欧美fxxxxxx另类| 亚洲精品一二| 亚洲自拍偷拍麻豆| 国产日产亚洲精品系列| 欧美中日韩免费视频| 蜜桃精品一区二区三区| 亚洲国产精品一区二区www| 欧美国产欧美亚州国产日韩mv天天看完整| 亚洲国产精品va在线看黑人 | 久久先锋资源| 亚洲国产婷婷香蕉久久久久久99| 亚洲日本欧美日韩高观看| 欧美人与性动交α欧美精品济南到| 国产精品丝袜xxxxxxx| 亚洲永久视频| 久久久噜久噜久久综合| 亚洲国产日韩欧美| 欧美女激情福利| 99精品欧美一区二区蜜桃免费| 小黄鸭视频精品导航| 激情五月婷婷综合| 欧美高清在线精品一区| 中文国产成人精品| 久久久久久九九九九| 亚洲区免费影片| 国产精品啊啊啊| 欧美一区二区三区精品| 欧美黄色网络| 亚洲免费在线视频一区 二区| 国产欧美亚洲精品| 久久久综合网站| 亚洲免费精彩视频| 久久久精品一区二区三区| 亚洲国内在线| 国产精品进线69影院| 久久久久国产精品一区三寸| 亚洲国产一区二区三区在线播| 亚洲一区二区三区在线视频| 国产主播在线一区| 欧美巨乳在线观看| 午夜精品视频在线| 欧美黄免费看| 性欧美video另类hd性玩具| 在线免费日韩片| 欧美偷拍另类| 久久裸体视频| 99精品国产99久久久久久福利| 久久精品国产在热久久| 亚洲精品一二| 国产日韩精品一区二区三区在线 | 榴莲视频成人在线观看| 亚洲精品日韩精品| 国产精品乱码一区二三区小蝌蚪 | 亚洲大片av| 国产精品热久久久久夜色精品三区 | 国产日韩欧美综合一区| 欧美激情一区二区三级高清视频| 亚洲欧美日韩一区二区在线| 亚洲国产精品久久久| 欧美一区二区在线免费观看| 亚洲精品之草原avav久久| 国产麻豆一精品一av一免费| 欧美激情一区二区三区蜜桃视频| 欧美一级视频免费在线观看| 亚洲麻豆一区| 欧美 亚欧 日韩视频在线| 欧美一级一区| 一区二区三区av| 在线看国产一区| 国产欧美不卡| 欧美日韩精品免费观看视一区二区| 久久精品女人| 亚洲欧美久久久久一区二区三区| 91久久在线播放| 免费一级欧美在线大片| 欧美怡红院视频一区二区三区| 日韩午夜电影av| 在线观看视频一区二区| 国产欧美va欧美va香蕉在| 欧美日韩在线第一页| 麻豆国产va免费精品高清在线| 欧美一级久久久|