freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

算法合集之歐拉回路性質(zhì)與應(yīng)用探究-資料下載頁(yè)

2025-01-17 03:06本頁(yè)面
  

【正文】 e manager of the depot wants to rearrange the containers. Since the product delivery to the shops occurs by sending exactly one truck to each shop, and each truck carries one container of each product, a suitable arrangement is the following. The first M containers in the row must be labeled with different product labels, the second M containers in the row must be labeled with different product labels, and so on. Unfortunately, there is only one free place at the end of the row to hold a container. Therefore the rearrangement must be performed by successively picking up a container and moving it to the free place. After the rearrangement the free place must be at the end of the row.The goal is to achieve the required rearrangement by a minimal number of moves.TaskYou are to write a program that putes a rearrangement which needs the minimal number of moves.InputThe first line of the text file contains two integers, N and M. N (1 N 400) is the number of shops and M (1 M 400) is the number of products. The second line contains N*M integers, the labels of the containers in their initial order. Each product identifier x (1 x M) occurs exactly N times in the line.OutputThe first line of the text file contains one integer S, the minimal number of moves that are necessary to obtain a required order of the container row (Subtask A). The following S lines describe a rearrangement (Subtask B). Each line contains a pair of integers x y. The pair x y describes a move: the container at position x is to move to position y. Positions are identified by the numbers from 1 to N*M+1。 initially the position N*M+1 is free (holds no container). A move from x to y is legal only if position y is free prior to the move. After a move from x to y the position x will be free. It is enough to output only the first line if you solve only Subtask A.If there are multiple possibilities, your program should output only one。 it does not matter which one.Example5 64 1 3 1 6 5 2 3 2 3 5 6 2 1 4 5 6 4 1 3 2 4 5 5 1 2 3 4 6 689 3118 910 184 1031 430 3124 3031 24附錄5 例題五的英文原題GamblingA gambling machine consists of n generators of integers: G1, ..., Gn, where 1 = n = 1000. The generator Gi can generate integers only from the certain set Si included in the interval {1,..., n}, or 0 which means that the game is over. The Si can be an empty set. Let ki be the number of elements of the set Si. The sum of all the integers ki, for i = 1,..., n, cannot exceed 12000.While Gi is activated for the first time it generates an integer from the set Si. The next activating ends up in generating an integer from the set Si, which was not chosen before. If there is no such an integer, Gi generates zero.The machine starts with activating G1. Then the generators are activated according to the following rule : In case when a generator generated a positive integer r, the next activated generator is Gr. If zero is generated the machine stops.The machine looses if the generator Gn generates zero and the rest of the generators had exhausted their sets of integers.The machine is well constructed if it may generate a sequence of integers ending with zero, but not leading to a defeat (. a sequence shorter then 1 + ( the sum of integers ki for i = 1,...,n) ).TaskWrite a program that: Reads from the text file the description of the machine, . the number of generators n, integers ki and sets Si, Verifies, whether the machine described in the input file is well constructed, if it is well constructed, writes a sequence of integers, which may be generated by the machine, is ended with zero, and does not lead to defeat, if not, writes one word NIE (no in Polish) in the text file .InputIn the first line of the text file there is written one positive integer n = 1000. This is the number of generators. In the (i + 1)?st line (for i = 1,..., n) there is written an integer ki followed by all the elements of the set Si (written in arbitrary order). The integers in each line are separated by single spaces.OutputIn the text file there should be written one word NIE (if the machine isn39。t well constructed) or one line containing an appropriate finite series of integers separated by single spaces.ExampleFor the input file :22 1 21 2the correct answer is the output file :2 2 0For the input file :21 20the correct answer is the output file :NIE25
點(diǎn)擊復(fù)制文檔內(nèi)容
環(huán)評(píng)公示相關(guān)推薦
文庫(kù)吧 www.dybbs8.com
備案圖鄂ICP備17016276號(hào)-1