id
stringlengths 6
6
| slug_name
stringlengths 1
105
| pretty_content
stringlengths 1
27.2k
| test_cases
sequencelengths 1
1
|
---|---|---|---|
p00100 | Sale Result |
<H1>Sale Result</H1>
<p>
There is data on sales of your company. Your task is to write a program which identifies good workers.
</p>
<p>
The program should read a list of data where each item includes the employee ID <i>i</i>, the amount of sales <i>q</i> and the corresponding unit price <i>p</i>. Then, the program should print IDs of employees whose total sales proceeds (i.e. sum of p × q) is greater than or equal to 1,000,000 in the order of inputting. If there is no such employees, the program should print "NA". You can suppose that <i>n</i> < 4000, and each employee has an unique ID. The unit price <i>p</i> is less than or equal to 1,000,000 and the amount of sales <i>q</i> is less than or equal to 100,000.
</p>
<H2>Input</H2>
<p>
The input consists of several datasets. The input ends with a line including a single 0. Each dataset consists of:
</p>
<pre class="exp">
<i>n</i> (the number of data in the list)
<i>i</i> <i>p</i> <i>q</i>
<i>i</i> <i>p</i> <i>q</i>
:
:
<i>i</i> <i>p</i> <i>q</i>
</pre>
<H2>Output</H2>
<p>
For each dataset, print a list of employee IDs or a text "NA"
</p>
<H2>Sample Input</H2>
<pre>
4
1001 2000 520
1002 1800 450
1003 1600 625
1001 200 1220
2
1001 100 3
1005 1000 100
2
2013 5000 100
2013 5000 100
0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1001
1003
NA
2013
</pre>
| [
[
"4\n1001 2000 520\n1002 1800 450\n1003 1600 625\n1001 200 1220\n2\n1001 100 3\n1005 1000 100\n2\n2013 5000 100\n2013 5000 100\n0\n",
"4\n1001 2000 520\n1002 1800 450\n1003 1600 625\n1001 200 1220\n2\n1001 100 3\n1005 1000 100\n2\n2013 5000 100\n2013 5000 100\n0\n"
]
] |
p00101 | Aizu PR |
<H1>Aizu PR</H1>
<p>
An English booklet has been created for publicizing Aizu to the world.
When you read it carefully, you found a misnomer (an error in writing) on the last name of Masayuki Hoshina, the lord of the Aizu domain. The booklet says "Hoshino" not "Hoshina".
</p>
<p>
Your task is to write a program which replace all the words "Hoshino" with "Hoshina". You can assume that the number of characters in a text is less than or equal to 1000.
</p>
<H2>Input</H2>
<p>
The input consists of several datasets. There will be the number of datasets <i>n</i> in the first line. There will be <i>n</i> lines. A line consisting of english texts will be given for each dataset.
</p>
<H2>Output</H2>
<p>
For each dataset, print the converted texts in a line.
</p>
<H2>Sample Input</H2>
<pre>
3
Hoshino
Hashino
Masayuki Hoshino was the grandson of Ieyasu Tokugawa.
</pre>
<H2>Output for the Sample Input</H2>
<pre>
Hoshina
Hashino
Masayuki Hoshina was the grandson of Ieyasu Tokugawa.
</pre>
| [
[
"3\nHoshino\nHashino\nMasayuki Hoshino was the grandson of Ieyasu Tokugawa.\n",
"3\nHoshino\nHashino\nMasayuki Hoshino was the grandson of Ieyasu Tokugawa.\n"
]
] |
p00102 | Matrix-like Computation |
<H1>Matrix-like Computation</H1>
<p>
Your task is to develop a tiny little part of spreadsheet software.
</p>
<p>
Write a program which adds up columns and rows of given table as shown in the following figure:
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_matrixLike" width="640">
</center>
<H2>Input</H2>
<p>
The input consists of several datasets. Each dataset consists of:
</p>
<pre>
<i>n</i> (the size of row and column of the given table)
1st row of the table
2nd row of the table
:
:
<i>n</i>th row of the table
</pre>
<p>
The input ends with a line consisting of a single 0.
</p>
<H2>Output</H2>
<p>
For each dataset, print the table with sums of rows and columns. Each item of the table should be aligned to the right with a margin for five digits. Please see the sample output for details.
</p>
<H2>Sample Input</H2>
<pre>
4
52 96 15 20
86 22 35 45
45 78 54 36
16 86 74 55
4
52 96 15 20
86 22 35 45
45 78 54 36
16 86 74 55
0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
52 96 15 20 183
86 22 35 45 188
45 78 54 36 213
16 86 74 55 231
199 282 178 156 815
52 96 15 20 183
86 22 35 45 188
45 78 54 36 213
16 86 74 55 231
199 282 178 156 815
</pre>
| [
[
"4\n52 96 15 20\n86 22 35 45\n45 78 54 36\n16 86 74 55\n4\n52 96 15 20\n86 22 35 45\n45 78 54 36\n16 86 74 55\n0\n",
"4\n52 96 15 20\n86 22 35 45\n45 78 54 36\n16 86 74 55\n4\n52 96 15 20\n86 22 35 45\n45 78 54 36\n16 86 74 55\n0\n"
]
] |
p00103 | Baseball Simulation |
<H1>Baseball Simulation</H1>
<p>
Ichiro likes baseball and has decided to write a program which simulates baseball.</p>
<p>
The program reads events in an inning and prints score in that inning. There are only three events as follows:
</p>
<p>Single hit</p>
<ul>
<li>put a runner on the first base.</li>
<li>the runner in the first base advances to the second base and the runner in the second base advances to the third base.</li>
<li>the runner in the third base advances to the home base (and go out of base) and a point is added to the score.</li>
</ul>
<p>Home run</p>
<ul>
<li>all the runners on base advance to the home base.</li>
<li>points are added to the score by an amount equal to the number of the runners plus one.</li>
</ul>
<p>Out</p>
<ul>
<li>The number of outs is increased by 1.</li>
<li>The runners and the score remain stationary.</li>
<li>The inning ends with three-out.</li>
</ul>
<p>
Ichiro decided to represent these events using "HIT", "HOMERUN" and "OUT", respectively.
</p>
<p>Write a program which reads events in an inning and prints score in that inning. You can assume that the number of events is less than or equal to 100.
</p>
<H2>Input</H2>
<p>
The input consists of several datasets. In the first line, the number of datasets <i>n</i> is given. Each dataset consists of a list of events (strings) in an inning.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the score in the corresponding inning.
</p>
<H2>Sample Input</H2>
<pre>
2
HIT
OUT
HOMERUN
HIT
HIT
HOMERUN
HIT
OUT
HIT
HIT
HIT
HIT
OUT
HIT
HIT
OUT
HIT
OUT
OUT
</pre>
<H2>Output for the Sample Input</H2>
<pre>
7
0
</pre>
| [
[
"2\nHIT\nOUT\nHOMERUN\nHIT\nHIT\nHOMERUN\nHIT\nOUT\nHIT\nHIT\nHIT\nHIT\nOUT\nHIT\nHIT\nOUT\nHIT\nOUT\nOUT\n",
"2\nHIT\nOUT\nHOMERUN\nHIT\nHIT\nHOMERUN\nHIT\nOUT\nHIT\nHIT\nHIT\nHIT\nOUT\nHIT\nHIT\nOUT\nHIT\nOUT\nOUT\n"
]
] |
p00104 | Magical Tiles |
<H1>Magic Tile</H1>
<p>
There is a magic room in a homestead. The room is paved with H × W tiles. There are five different tiles:
</p>
<ul>
<li>Tile with a east-pointing arrow</li>
<li>Tile with a west-pointing arrow</li>
<li>Tile with a south-pointing arrow</li>
<li>Tile with a north-pointing arrow</li>
<li>Tile with nothing</li>
</ul>
<p>
Once a person steps onto a tile which has an arrow, the mystic force makes the person go to the next tile pointed by the arrow. If the next tile has an arrow, the person moves to the next, ans so on. The person moves on until he/she steps onto a tile which does not have the arrow (the tile with nothing). The entrance of the room is at the northwest corner.
</p>
<p>
Your task is to write a program which simulates the movement of the person in the room. The program should read strings which represent the room and print the last position of the person.
</p>
<p>
The input represents the room as seen from directly above, and up, down, left and right side of the input correspond to north, south, west and east side of the room respectively. The horizontal axis represents <i>x</i>-axis (from 0 to W-1, inclusive) and the vertical axis represents <i>y</i>-axis (from 0 to H-1, inclusive). The upper left tile corresponds to (0, 0).
</p>
<p>
The following figure shows an example of the input:
</p>
<pre>
10 10
>>>v..>>>v
...v..^..v
...>>>^..v
.........v
.v<<<<...v
.v...^...v
.v...^<<<<
.v........
.v...^....
.>>>>^....
</pre>
<p>
Characters represent tiles as follows:
</p>
<pre>
'>': Tile with a east-pointing arrow
'<': Tile with a west-pointing arrow
'^': Tile with a north-pointing arrow
'v': Tile with a south-pointing arrow
'.': Tile with nothing
</pre>
<p>
If the person goes in cycles forever, your program should print "LOOP". You may assume that the person never goes outside of the room.
</p>
<H2>Input</H2>
<p>
The input consists of multiple datasets. The input ends with a line which contains two 0. Each dataset consists of:
</p>
<pre class="exp">
H W
H lines where each line contains W characters
</pre>
<p>
You can assume that 0 < W, H < 101.
</p>
<H2>Output</H2>
<p>
For each dataset, print the coordinate (X, Y) of the person or "LOOP" in a line. X and Y should be separated by a space.
</p>
<H2>Sample Input</H2>
<pre>
10 10
>>>v..>>>v
...v..^..v
>>>>>>^..v
.........v
.v<<<<...v
.v.v.^...v
.v.v.^<<<<
.v.v.....v
.v...^...v
.>>>>^....
6 10
>>>>>>>>>v
.........v
.........v
>>>>v....v
^...v....v
^<<<<<<<<<
0 0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
5 7
LOOP
</pre>
| [
[
"10 10\n>>>v..>>>v\n...v..^..v\n>>>>>>^..v\n.........v\n.v\n",
"10 10\n>>>v..>>>v\n...v..^..v\n>>>>>>^..v\n.........v\n.v\n"
]
] |
p00105 | Book Index |
<H1>Book Index</H1>
<p>
Books are indexed. Write a program which reads a list of pairs of a word and a page number, and prints the word and a list of the corresponding page numbers.
</p>
<p>
You can assume that a word consists of at most 30 characters, and the page number is less than or equal to 1000. The number of pairs of a word and a page number is less than or equal to 100. A word never appear in a page more than once.
</p>
<p>
The words should be printed in alphabetical order and the page numbers should be printed in ascending order.
</p>
<!--
<p>
æ¬ã®æåŸã«ã¯çŽ¢åŒãèšããããŠããŸããæ¬ã®äžããæœåºããããèªå¥ããšãããŒãžçªå·ãã®çµãèªã¿åããæ¬ã®çŽ¢åŒãšããŠãèªå¥ããšãã®èªå¥ãè¡šãããããŒãžçªå·ã®ãªã¹ãããåºåããŠçµäºããããã°ã©ã ãäœæããŠäžããããã ãã1ã€ã®èªå¥ã®é·ãã¯30æå以å
ãšããããŒãžçªå·ã¯1,000以äžãšããŸããå
¥åã«å«ãŸããèªå¥ãšããŒãžçªå·ã®çµã¯100以äžãšãã1ã€ã®èªå¥ã¯åãããŒãžçªå·ã«è€æ°åçŸããªããã®ãšããŸãããŸããåºåã«é¢ããŠã¯ãèªå¥ã®é çªã¯ã¢ã«ãã¡ãããé ãšããããŒãžçªå·ã¯å°ããé (æé )ãšããŸãã
</p>
-->
<H2>Input</H2>
<pre>
<i>word page_number</i>
:
:
</pre>
<H2>Output</H2>
<pre>
<i>word</i>
<i>a_list_of_the_page_number</i>
<i>word</i>
<i>a_list_of_the_Page_number</i>
:
:
</pre>
<H2>Sample Input</H2>
<pre>
style 12
even 25
introduction 3
easy 9
style 7
document 13
style 21
even 18
</pre>
<H2>Output for the Sample Input</H2>
<pre>
document
13
easy
9
even
18 25
introduction
3
style
7 12 21
</pre>
</div>
| [
[
"style 12\neven 25\nintroduction 3\neasy 9\nstyle 7\ndocument 13\nstyle 21\neven 18\n",
"style 12\neven 25\nintroduction 3\neasy 9\nstyle 7\ndocument 13\nstyle 21\neven 18\n"
]
] |
p00106 | Discounts of Buckwheat |
<H1>Discounts of Buckwheat</H1>
<p>
Aizu is famous for its buckwheat. There are many people who make buckwheat noodles by themselves.
</p>
<p>
One day, you went shopping to buy buckwheat flour. You can visit three shops, A, B and C. The amount in a bag and its unit price for each shop is determined by the follows table. Note that it is discounted when you buy buckwheat flour in several bags.
</p>
<center>
<table class="withborder">
<tr><th></th><th> Shop A </th><th> Shop B </th><th> Shop C</th></tr>
<tr><th> Amount in a bag </th><td> 200g</td><td> 300g</td><td> 500g</td></tr>
<tr><th> Unit price for a bag (nominal cost)</th><td> 380 yen </td><td> 550 yen </td><td> 850 yen</td></tr>
<tr><th> Discounted units </th><td> per 5 bags </td><td>per 4 bags </td><td>per 3 bags</td></tr>
<tr><th> Discount rate</th><td> reduced by 20 %</td><td> reduced by 15 %</td><td> reduced by 12 %</td></tr>
</table>
</center>
<br/>
<p>
For example, when you buy 12 bags of flour at shop A, the price is reduced by 20 % for 10 bags, but not for other 2 bags. So, the total amount shall be (380 × 10) × 0.8 + 380 × 2 = 3,800 yen.
</p>
<p>
Write a program which reads the amount of flour, and prints the lowest cost to buy them. Note that you should buy the flour of exactly the same amount as the given input.
</p>
<H2>Input</H2>
<p>
The input consists of multiple datasets. For each dataset, an integer <var>a</var> (500 ≤ <var>a</var> ≤ 5000, <var>a</var> is divisible by 100) which represents the amount of flour is given in a line.
</p>
<p>
The input ends with a line including a zero. Your program should not process for the terminal symbol. The number of datasets does not exceed 50.
</p>
<H2>Output</H2>
<p>
For each dataset, print an integer which represents the lowest cost.
</p>
<H2>Sample Input</H2>
<pre>
500
2200
0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
850
3390
</pre>
| [
[
"500\n2200\n0\n",
"500\n2200\n0\n"
]
] |
p00107 | Carry a Cheese |
<H1>Carry a Cheese</H1>
<p>
Jerry is a little mouse. He is trying to survive from the cat Tom. Jerry is carrying a parallelepiped-like piece of cheese of size <i>A</i> × <i>B</i> × <i>C</i>. It is necessary to trail this cheese to the Jerry's house. There are several entrances in the Jerry's house. Each entrance is a rounded hole having its own radius <i>R</i>. Could you help Jerry to find suitable holes to be survive?
</p>
<p>
Your task is to create a program which estimates whether Jerry can trail the cheese via each hole.
The program should print "<span>OK</span>" if Jerry can trail the cheese via the corresponding hole (without touching it). Otherwise the program should print "<span>NA</span>".
</p>
<p>
You may assume that the number of holes is less than 10000.
</p>
<H2>Input</H2>
<p>
The input is a sequence of datasets. The end of input is indicated by a line containing three zeros. Each dataset is formatted as follows:
</p>
<pre>
<i>A B C</i>
<i>n</i>
<i>R</i><sub>1</sub>
<i>R</i><sub>2</sub>
.
.
<i>R</i><sub><i>n</i></sub>
</pre>
<p>
<i>n</i> indicates the number of holes (entrances) and <i>R<sub>i</sub></i> indicates the radius of <i>i</i>-th hole.
</p>
<H2>Output</H2>
<p>
For each datasets, the output should have <i>n</i> lines. Each line points the result of estimation of the corresponding hole.
</p>
<H2>Sample Input</H2>
<pre>
10 6 8
5
4
8
6
2
5
0 0 0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
NA
OK
OK
NA
NA
</pre>
| [
[
"10 6 8\n5\n4\n8\n6\n2\n5\n0 0 0\n",
"10 6 8\n5\n4\n8\n6\n2\n5\n0 0 0\n"
]
] |
p00108 | Operation of Frequency of Appearance |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>åºçŸé »åºŠæäœ</H1>
<p>
æéæ°åã®å€ææäœã«åºçŸé »åºŠæäœãšãããã®ããããŸããæ°å $S = \{s_1, s_2,... s_n\}$ ã®å€æçµæã¯åãé·ãã®æ°åãšãªããŸãããã®çµæã $C = \{c_1,c_2, ..., c_n\}$ ãšãããšã $c_i$ ã¯æ°å $S$ ã«ããã $s_i$ ã®åæ°ãè¡šããŸãã
</p>
<p>
äŸãã° $S = \{3,4,1,5,9,2,6,5,3\}$ ãªãã° $C = {2,1,1,2,1,1,1,2,2}$ ãšãªããŸããããã«ãã®æ°å $C$ ã«åºçŸé »åºŠæäœãè¡ããš $P = \{4,5,5,4,5,5,5,4,4\}$ ãåŸãŸãããã®æ°åã¯åºçŸé »åºŠæäœã§å€ããããšããããŸããããã®ãããªæ°å $P$ ãæ°å $S$ ã®äžåç¹ãšåŒã³ãŸããã©ã®ãããªæ°åã«å¯ŸããŠãåºçŸé »åºŠæäœãç¹°ãè¿ãã°ããã®äžåç¹ãæ±ããããšãåºæ¥ããšããããšãç¥ãããŠããŸãã
</p>
<p>
äžã®äŸã¯åºçŸé »åºŠæäœã®æé ã瀺ãããã®ã§ãã1 è¡ç®ãæ°å $S$ ã2 è¡ç®ãæ°å $C$ãæçµè¡ãæ°å $P$ ãšããŸããæ°å $S$ ã®æåã®èŠçŽ ($s_1 = 2$) ãšåãæ°ã¯ 3 åããã®ã§æ°å $C$ ã®æåã®èŠçŽ $c_1$ 㯠3ã次ã®èŠçŽ ($s_2 = 7$) ãšåãæ°ã¯ 2 åããã®ã§ $c_2 = 2$ããšãã£ãå
·åã«åæ°ãæ°ã $c_i$ ãæ±ããŠãããŸãã
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_frequency" width="600">
</center>
<br/>
<p>
æ°åã®é·ã $n$ ãšæ°å $S$ ãå
¥åããäžåç¹ã®æ°å $P$ ããã³ã$P$ ãåŸãããã«å®è¡ããåºçŸé »åºŠæäœã®æå°ã®åæ°ãåºåããããã°ã©ã ãäœæããŠãã ããã
</p>
<H2>Input</H2>
<p>
è€æ°ã®ããŒã¿ã»ãããäžããããŸããåããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããŸãã<br/>
<br/>
$n$<br/>
$s_1$ $s_2$ ... $s_n$<br/>
</p>
<p>
1 è¡ç®ã«æ°åã®é·ããè¡šãæŽæ° $n$ ($n \leq 12$) ãäžããããŸããïŒè¡ç®ã«æ°å $S$ ã®èŠçŽ ãè¡šãæŽæ°ã$s_i$ ($1 \leq s_i \leq 100$) ã空çœåºåãã§äžããããŸãã
</p>
<p>
å
¥åã¯ïŒäžã€ã®è¡ã§çµãããŸããããŒã¿ã»ããã®æ°ã¯ 200 ãè¶
ããŸããã
</p>
<H2>Output</H2>
<p>
åããŒã¿ã»ããã«ã€ããŠãïŒè¡ç®ã«åºçŸé »åºŠæäœã®æå°ã®å®è¡åæ°(æŽæ°)ãïŒè¡ç®ã«å¯Ÿå¿ããäžåç¹ã®æ°å $P$ ã®èŠçŽ $p_1$, $p_2$, ..., $p_n$ ã空çœåºåãã§åºåããŠãã ããã
</p>
<H2>Sample Input</H2>
<pre>
10
4 5 1 1 4 5 12 3 5 4
0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
3
6 6 4 4 6 6 4 4 6 6
</pre>
| [
[
"10\n4 5 1 1 4 5 12 3 5 4\n0\n",
"10\n4 5 1 1 4 5 12 3 5 4\n0\n"
]
] |
p00109 | Smart Calculator |
<H1>Smart Calculator</H1>
<p>
Your task is to write a program which reads an expression and evaluates it.
</p>
<ul>
<li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li>
<li>The operators includes +, - , *, / where respectively represents, addition, subtraction, multiplication and division.</li>
<li> Precedence of the operators is based on usual laws. That is one should perform all multiplication and division first, then addition and subtraction. When two operators have the same precedence, they are applied from left to right.
</li>
<li>You may assume that there is no division by zero.</li>
<li>All calculation is performed as integers, and after the decimal point should be truncated</li>
<li>Length of the expression will not exceed 100.</li>
<li>-1 × 10<sup>9</sup> ≤ intermediate results of computation ≤ 10<sup>9</sup></li>
</ul>
<H2>Input</H2>
<p>
The input is a sequence of datasets. The first line contains an integer <i>n</i> which represents the number of datasets. There will be <i>n</i> lines where each line contains an expression.
</p>
<H2>Output</H2>
<p>
For each datasets, prints the result of calculation.
</p>
<H2>Sample Input</H2>
<pre>
2
4-2*3=
4*(8+4+3)=
</pre>
<H2>Output for the Sample Input</H2>
<pre>
-2
60
</pre>
| [
[
"2\n4-2*3=\n4*(8+4+3)=\n",
"2\n4-2*3=\n4*(8+4+3)=\n"
]
] |
p00110 | Alphametic |
<H1>èŠé¢ç®</H1>
<p>
æ°åŒã®äžéšãé ããŠããŸã£ãŠãé ããæ°åãæ¢ãåé¡ãèŠé¢ç®ãšãããŸããä»åã¯ãæ°åŒã®äžã®ããæ°åã®ããã€ãã X ã§é ããŠããŸã£ãåŒãæ±ããŸãã以äžã®æ°åŒãå
¥åããŠãçµæãåºåããããã°ã©ã ãäœæããŠãã ããã
</p>
<p> æ°åŒ</p>
<ul>
<li>ãæ°åå + æ°åå = æ°ååãã®åœ¢ã§ã1 è¡ã®åçŽãªè¶³ãç®åŒã§ãã</li>
<li> ãæ°ååãã¯ãæ°å 0 ãã 9 ãšæå X ã®äžŠã³ã§ãã</li>
<!--<li> ãæ°ååãã¯ã8 æ¡ä»¥äžã®æŽæ°ãè¡šããã®ãšããŸãã</li>-->
<li> 2 æ¡ä»¥äžã®ãæ°ååãã®å·Šç«¯ã®æ°å㯠0 ã§ã¯ãªããã®ãšããŸãã</li>
<li> X ã¯ãæ°åŒå
šäœã®äžã§å¿
ã 1 ã€ä»¥äžå«ãŸããŸãã</li>
</ul>
<p> çµæ</p>
<ul>
<li> èŠé¢ç®ã®çãã§ããæ°åŒãæãç«ã€æ§ãª X ã®å€ã§ 0 ~ 9 ã®ã©ãã 1 ã€ã§ãã2 ã€ä»¥äžã®çãã¯ãªããã®ãšããŸãã</li>
<li> çãããªãå Žåãçµæã¯âNAâãšããŠãã ããã</li>
</ul>
<H2>Input</H2>
<p>
è€æ°ã®ããŒã¿ã»ãããäžããããŸããåããŒã¿ã»ãããšããŠãX ã 1 ã€ä»¥äžå«ã足ãç®åŒ(空çœãå«ãŸãªã 126 æå以å
ã®æåå) ãïŒè¡ã«äžããããŸããããŒã¿ã»ããã®æ°ã¯ 150 ãè¶
ããŸããã
</p>
<H2>Output</H2>
<p>
åããŒã¿ã»ããã«ã€ããŠãèŠé¢ç®ã®çµæãïŒè¡ã«åºåããŠãã ãããæ°å 0 ~ 9 ãŸã㯠NA ãåºåããŠãã ããã
</p>
<H2>Sample Input</H2>
<pre>
123+4X6=X79
12X+4X6=X79
XX22+89=X2XX
</pre>
<H2>Output for the Sample Input</H2>
<pre>
5
NA
1
</pre>
| [
[
"123+4X6=X79\n12X+4X6=X79\nXX22+89=X2XX\n",
"123+4X6=X79\n12X+4X6=X79\nXX22+89=X2XX\n"
]
] |
p00111 | Doctor's Memorable Codes |
<H1>å士ã®æå·</H1>
<p>
å 士 : ?D-C'KOPUA
</p>
<p>
ããŒã¿ãŒ : ã©ããããã§ãããããããå士? ããã®ããããªãããšãå«ã¶ã®ã«ã¯ããæ
£ããŸãããã
ä»æ¥ã¯æç« ã«ãããªã£ãŠããŸãããã
</p>
<p>
å 士 : ã»ãã
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_memorableCodes1">
</center>
<br/>
<p>
ããŒã¿ãŒ : ãªãã§ãã? ãã®è¡šã¯......ãããäºéžã®åé¡ã«ãããªã®ããããŸãããè¡šã䜿ã£ãŠæåã眮ãæã
ããšæåæ°ãæžããã§ãããããŸããäºéžãšæ¬éžã§åãåé¡ãåºããŠæãæããã£ãŠæ°ãããªãã§ã
ãããã
</p>
<p>
å 士 : éãããã
</p>
<p>
ããŒã¿ãŒ : é? ãªãã»ã©ãä»åºŠã¯çãããæååãå
ã«æ»ããã£ãŠåé¡ã§ããããšããããšã¯ã?D-C'KOPUAãã®
æåãããã®è¡šã䜿ã£ãŠãæåãããã笊å·ãã«çœ®ãããããã§ãã......ã§ããŸãããã
</p>
<pre>
11111 00011 11101 00010 11110 01010 01110 01111 10100 00000
</pre>
<p>
å 士 : ããã次ã¯ããããã
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_memorableCodes2">
</center>
<br/>
<p>
ããŒã¿ãŒ : ããããããããªè¡šããããŸãããããããéã«äœ¿ããã ããã笊å·ããããæåãã«çœ®ãæããã°ãã
ãã§ãããã§ããæåã¯ã11111ãã§ããè¡šã«ãããŸããã?
</p>
<p>
å 士 : ãããããšãã¯ããã£ãšçãããããåŸããšã€ãªãããããŠã¿ãã®ã ãã
</p>
<p>
ã ㌠㿠㌠: ãããçãããŠ......ãã ã111ããªããããŸãããããæåã¯ãPãã§ããããããããšæ®ãã¯ã11ãã§ããã
ããã¯ãŽã£ããåãã®ããªããã次ã®ã00011ããã 1 æååããŠã110ãã«ããã°ãããã§ããã
</p>
<p>
å 士 : ãããããã€ãŸããEãã ãã
</p>
<p>
ã ㌠㿠㌠: ããã§æ®ãã®ãã0011ããªã®ã§ãããã次ããåããŠã00111ãã«ããŠãTããš......ãå
šéšã§ããŸãããæ
åŸã®ã0000ãã¯æšãŠã¡ããã°ãããã§ããã?
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_memorableCodes3">
</center>
<br/>
<p>
å 士 : ãããããããããã次ã¯ããããã
</p>
<pre>
?D-C'?-C'-LMGZN?FNJKN- WEYN?P'QMRWLPZLKKTPOVRGDI
</pre>
<p>
å 士 : ããã«ããããã
</p>
<pre>
?P'QNPY?IXX?IXXK.BI -G?R'RPP'RPOVWDMW?SWUVG'-LCMGQ
</pre>
<p>
å 士 : ä»äžãã«ããããã
</p>
<pre>
?P'QMDUEQ GADKOQ ?SWUVG'-LCMG?X?IGX,PUL.?UL.VNQQI
</pre>
<p>
ã ㌠㿠㌠: ãã£ããé¢åã ãªããå士ãä»åºŠã¯èªåã§ããã°ã©ã ãäœã£ãŠäžãããã
</p>
<p>
ãšããããšã§ãå士ã®ãããã«ãäžã®æç« ã眮ãæããããã°ã©ã ãäœæããŠãã ããã
</p>
<H2>Input</H2>
<p>
è€æ°ã®ããŒã¿ã»ãããäžããããŸããåããŒã¿ã»ãããšããŠãïŒã€ã®æååïŒè¡šã«å«ãŸããæåãããªã 200 æå以äžã®æååïŒãïŒè¡ã«äžããããŸããå
¥åã®çµãããŸã§åŠçããŠãã ãããããŒã¿ã»ããã®æ°ã¯ 200 ãè¶
ããŸããã
</p>
<H2>Output</H2>
<p>
åããŒã¿ã»ããããšã«ãå€æåŸã®æååãïŒè¡ã«åºåããŠãã ããã
</p>
<H2>Sample Input</H2>
<pre>
?D-C'KOPUA
</pre>
<H2>Output for the Sample Input</H2>
<pre>
PETER POTTER
</pre>
<!--
<p>
Judge error has been fixed on 2009/10/12. We are very sorry for the inconvenience.
</p>
-->
| [
[
"?D-C'KOPUA\n",
"?D-C'KOPUA\n"
]
] |
p00112 | A Milk Shop |
<h1>ãã«ã¯ã·ã§ãã</h1>
<p>
éŽæšããã¯äŒæŽ¥å°åã«æ°ããæŸãããŠãã«ã¯ã®ç§»å販売ã®ãåºãéããŸããããã®æ¥è²·ãæ±ãã«æ¥ãã客ããã¯å
šå¡æã¡åž°ãããã®ããã«ãæã£ãŠæ¢ã«ãåºã«äžŠãã§ããŠããã以äžå¢ããªããã®ãšããŸããã客ããã¯ãããã1åã ããã泚æããŸãããã¿ã³ã¯ã®èå£ãäžã€ãããªãã®ã§ãäžäººãã€é çªã«è²©å£²ããªããã°ãªããŸãããããã§ãéŽæšããã¯ãªãã¹ã䞊ãã§ããã客ããã®åŸ
ã¡æéãå°ãªãããããšèããŠããŸãã
</p>
<p>
ã客ããã®äººæ°ãšã客ãããçä¹³ã泚ãããã®ã«èŠããæéãå
¥åãšããŠäžããããŸããããªãã¯ã客ããã®ãäžäººäžäººã®åŸ
ã¡æéã®åèšã(以äžãåŸ
ã¡æéã®åèšããšãã)ãæå°ã«ããããã®æ³šæã®é åºãéŽæšããã«ä»£ãã£ãŠèª¿ã¹ããã®ãšãã®ãåŸ
ã¡æéã®åèšããåºåããŠçµäºããããã°ã©ã ãäœæããŠãã ããããã ããã客ãã㯠10,000 人以äžã§ 1 人ãããã«èŠããæé㯠60 å以äžãšããŸãã
</p>
<p>
äŸãã°ãã客ããã®äººæ°ã 5 人ã§ãåã客ãããèŠããæéãé ã« 2,6,4,3,9 åã®å Žåããã®ãŸãŸã®é åºã ãšãåŸ
ã¡æéã®åèšã㯠37 åã«ãªããŸãã次ã®äŸã§ã¯ãæåã®åã®é ã® 2 人ç®ãš 3 人ç®ãå
¥ãæ¿ããŠããŸãããã®å ŽåããåŸ
ã¡æéã®åèšã㯠35 åã«ãªããŸããæé©ãªé åºã ãš 31 åã§æžã¿ãŸãã
</p>
<table>
<tr><td width="110"></td><td>åŸ
ã¡æé</td><td></td></tr>
<tr><td>1 äººç® 2 å</td><td> 0 å</td><td></td></tr>
<tr><td>2 äººç® 6 å</td><td> 2 å</td><td></td></tr>
<tr><td>3 äººç® 4 å</td><td> 8 å</td><td></td></tr>
<tr><td>4 äººç® 3 å</td><td> 12 å</td><td></td></tr>
<tr><td>5 äººç® 9 å</td><td> 15 å</td><td></td></tr>
<tr><td></td><td> 37 å</td><td> â ãåŸ
ã¡æéã®åèšã</td></tr>
</table>
<br/>
<p>
2 人ç®ãš 3 人ç®ãå
¥ãæ¿ããäŸ
</p>
<table>
<tr><td width="110"></td><td>åŸ
ã¡æé</td><td></td></tr>
<tr><td>1 äººç® 2 å</td><td align="right"> 0 å</td><td></td></tr>
<tr><td>2 äººç® 4 å</td><td> 2 å</td><td></td></tr>
<tr><td>3 äººç® 6 å</td><td> 6 å</td><td></td></tr>
<tr><td>4 äººç® 3 å</td><td> 12 å</td><td></td></tr>
<tr><td>5 äººç® 9 å</td><td> 15 å</td><td></td></tr>
<tr><td> </td><td> 35 å</td><td> â ãåŸ
ã¡æéã®åèšã</td></tr>
</table>
<br/>
<H2>Input</H2>
<p>
è€æ°ã®ããŒã¿ã»ãããäžããããŸããåããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããŸãã
</p>
<pre>
<var>n</var>
<var>t<sub>1</sub></var>
<var>t<sub>2</sub></var>
:
<var>t<sub>n</sub></var>
</pre>
<p>
1 è¡ç®ã«ã客ããã®äººæ° <var>n</var> (<var>n</var> ≤ 10,000) ãäžããããŸããç¶ã <var>n</var> è¡ã« <var>i</var> 人ç®ã®ã客ãããèŠããæéãè¡šãæŽæ° <var>t<sub>i</sub></var> (0 ≤ <var>t<sub>i</sub></var> ≤ 60) ãããããïŒè¡ã«äžããããŸãã
</p>
<p>
å
¥åã¯ïŒã€ã® 0 ãå«ãè¡ã§çµãããŸããããŒã¿ã»ããã®æ°ã¯ 50 ãè¶
ããŸããã
</p>
<H2>Output</H2>
<p>
åããŒã¿ã»ããããšã«ãåŸ
ã¡æéã®åèš(æŽæ°)ãïŒè¡ã«åºåããŠãã ããã
</p>
<H2>Sample Input</H2>
<pre>
5
2
6
4
3
9
0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
31
</pre>
| [
[
"5\n2\n6\n4\n3\n9\n0\n",
"5\n2\n6\n4\n3\n9\n0\n"
]
] |
p00113 | Period |
<h1>埪ç°å°æ°</h1>
<p>
2 ã€ã®æ£ã®æŽæ° <var>p</var>, <var>q</var> ãå
¥åãã <var>p</var> / <var>q</var> ãå°æ°ãšããŠæ£ç¢ºã«è¡šçŸããããšãèããŸãã(ãã ãã0 < <var>p</var> < <var>q</var> < 10<sup>6</sup>ãšããŸãã)
</p>
<p>
ãã®ãšããçµæã¯
</p>
<ul>
<li> æéã®æ¡ã§æ£ç¢ºã«è¡šçŸã§ããã</li>
<li>ããæ¡ã®ç¯å²ãç¹°ãè¿ã埪ç°å°æ°ãšãªãã</li>
</ul>
<p>
ã®ãããããšãªããŸããçç®ãšåãæé ã§1æ¡ãã€å°æ°éšãæ±ããŠãããšã
</p>
<ul>
<li> å²ãåãã(äœãã 0 ã«ãªã£ã)ãªãããããŸã§ã®æ¡ã§æ£ç¢ºã«è¡šçŸã§ããã</li>
<li> 1床åºãŠããäœãããåã³çŸãããªãã埪ç°ããã</li>
</ul>
<p>
ãšåºå¥ã§ããŸãã
</p>
<p>
2 ã€ã®æŽæ° <var>p</var>, <var>q</var> ãå
¥åãããšã <var>p</var> / <var>q</var> ãå°æ°ã§è¡šããæã®ãå°æ°éšãåºåããããã°ã©ã ãäœæããŠãã ããã ãã ãã
</p>
<ul>
<li> çµæãæéã®æ¡ã§æ£ç¢ºã«è¡šçŸã§ããæã¯ãæ°å€ã ãã 1 è¡ã«åºåããŠãã ããã</li>
<li> çµæã埪ç°å°æ°ã«ãªãæã¯æ¬¡ã®ããã« 2 è¡ã«åºåããŠãã ããã
<ul>
<li>æåã®è¡ã«ã埪ç°ããéšåãŸã§ã®æ°åãåºåããŠãã ããã</li>
<li>次ã®è¡ã«ã¯ã埪ç°ããªãéšåã®äžã«ã¯ç©ºçœãåºåãã埪ç°ããéšåã®äžã«ã¯ã^ããåºåããŠãã ããã</li>
</ul>
</li>
<li> ãããã®å Žåãæ°åå㯠80 æåãè¶
ããããšã¯ãªããã®ãšããŸãã</li>
</ul>
<H2>Input</H2>
<p>
å
¥åã¯è€æ°ã®ããŒã¿ã»ãããããªããŸããåããŒã¿ã»ãããšããŠã<var>p</var>, <var>q</var> ã空çœåºåãã§ïŒè¡ã«äžããããŸããããŒã¿ã»ããã®æ°ã¯ 250 ãè¶
ããŸããã
</p>
<H2>Output</H2>
<p>
ããŒã¿ã»ããããšã«ã埪ç°ããªãå°æ°ã®å Žåã¯æ°å€ã®å°æ°éšåã(ãã®å Žå 1 è¡)ã埪ç°å°æ°ã®å Žåã¯åŸªç°ãããŸã§ã®æ°åãšåŸªç°ããéšåã瀺ãèšå·ã^ã(ãã®å Žå 2 è¡) ãåºåããŠãã ããã
</p>
<H2>Sample Input</H2>
<pre>
1 12
10000 32768
1 11100
1 459550
</pre>
<H2>Output for the Sample Input</H2>
<pre>
083
^
30517578125
00009
^^^
00000217604178
^^^^^^^^^^^^
</pre>
| [
[
"1 12\n10000 32768\n1 11100\n1 459550\n",
"1 12\n10000 32768\n1 11100\n1 459550\n"
]
] |
p00114 | Electro-Fly |
<h1>é»åè¿</h1>
<p>
ããèšç®æ©åŠè
ãé»å空éã«æ£²æ¯ããé»åè¿ãšããå¥åŠãªçåœäœãèŠã€ããŸãããé»åè¿ã®è¡åã芳å¯ããŠãããã¡ã«ããã®ç©ºéã® (<var>x</var>, <var>y</var>, <var>z</var>) å°ç¹ã«ããé»åè¿ã¯ã次ã«ä»¥äžã®èŠåã§ç€ºããã (<var>x'</var>, <var>y'</var>, <var>z'</var>)ã«ç§»åããããšãåãããŸããã
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_electroFly">
</center>
<br/>
<p>
ãã ãã<var>a</var><sub>1</sub>, <var>m</var><sub>1</sub>, <var>a</var><sub>2</sub>, <var>m</var><sub>2</sub>, <var>a</var><sub>3</sub>, <var>m</var><sub>3</sub> ã¯é»åè¿ã®åäœããšã«å®ãŸãæ£ã®æŽæ°ã§ãã<var>A</var> mod <var>B</var> ã¯æ£ã®æŽæ° <var>A</var> ãæ£ã®æŽæ° <var>B</var> ã§å²ã£ããšãã®äœãã§ãã
</p>
<p>
ããã«èŠ³å¯ããããšãããçš®ã®é»åè¿ã¯ (1,1,1) ã«çœ®ããŠãããã°ãããããšãå¿
ã (1,1,1) ã«æ»ã£ãŠããããšãããããŸããããã®ãããªè¿ãæ»ãè¿ãšåä»ããŸãã<sup>(1)</sup> ã
</p>
<p>
æ»ãè¿ã®ããŒã¿ãå
¥åãšãã(1,1,1) ã«æ»ã£ãŠããæå°ã®ç§»ååæ° (>0) ãåºåããããã°ã©ã ãäœæããŠãã ããããªã 1< <var>a</var><sub>1</sub>, <var>m</var><sub>1</sub>, <var>a</var><sub>2</sub>, <var>m</var><sub>2</sub>, <var>a</var><sub>3</sub>, <var>m</var><sub>3</sub> < 2<sup>15</sup> ãšããŸãã
</p>
<p>
<sup>(1)</sup> <var>a</var><sub>1</sub> ãš <var>m</var><sub>1</sub>, <var>a</var><sub>2</sub> ãš <var>m</var><sub>2</sub>, <var>a</var><sub>3</sub> ãš <var>m</var><sub>3</sub> ãããããäºãã«çŽ (å
¬çŽæ°ã 1) ã§ããæã«æ»ããŸãã
</p>
<H2>Input</H2>
<p>
è€æ°ã®ããŒã¿ã»ãããäžããããŸããåããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããŸãã
</p>
<pre>
<var>a</var><sub>1</sub> <var>m</var><sub>1</sub> <var>a</var><sub>2</sub> <var>m</var><sub>2</sub> <var>a</var><sub>3</sub> <var>m</var><sub>3</sub>
</pre>
<p>
å
¥åã¯ïŒã€ã® 0 ãå«ãè¡ã§çµãããŸããããŒã¿ã»ããã®æ°ã¯ 50 ãè¶
ããŸããã
</p>
<H2>Output</H2>
<p>
åããŒã¿ã»ããããšã«ã(1,1,1) ã«æ»ã£ãŠããæå°ã®ç§»ååæ°(æŽæ°)ãïŒè¡ã«åºåããŠãã ããã
</p>
<H2>Sample Input</H2>
<pre>
2 5 3 7 6 13
517 1024 746 6561 4303 3125
0 0 0 0 0 0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
12
116640000
</pre>
| [
[
"2 5 3 7 6 13\n517 1024 746 6561 4303 3125\n0 0 0 0 0 0\n",
"2 5 3 7 6 13\n517 1024 746 6561 4303 3125\n0 0 0 0 0 0\n"
]
] |
p00115 | Starship UAZ Advance |
<h1>å®å®è¹ UAZ ã¢ããã³ã¹å·</h1>
<p>
æææŽ 2005.11.5ãããªãã¯å®å®è¹ UAZ ã¢ããã³ã¹å·ã®èŠé·ãšããŠæµã®å®å®è¹ãšäº€æŠããããšããŠããŸãã 幞ãæµã®å®å®è¹ã¯ãŸã ãã¡ãã«æ°ä»ããã«éæ¢ããŠããŸãããŸãããã§ã«æµã®å®å®åº§æšã¯å€æããŠãã匷åãªçŽç·ã®ããŒã ãæŸã€ããã§ã¶ãŒç ²ãã¯çºå°æºåãå®äºããŠããŸããããšã¯ãçºå°åœä»€ãåºãã°ããã§ãã
</p>
<p>
ãšããããå®å®ç©ºéã«ã¯ãæµã®èšçœ®ãããšãã«ã®ãŒããªã¢ãååšããŠããŸããããªã¢ã¯äžè§åœ¢ãããŠããããã§ã¶ãŒç ²ãã®ããŒã ãã¯ãè¿ããŠããŸããŸãããŸããããŒã ãããªã¢ã«åœããã°æµã«æ°ä»ãããŠéããããŠããŸããŸããäºåã«åœäžãããšå€å®ã§ããªããã°ãçºå°åœä»€ã¯åºããŸããã
</p>
<p>
ããã§ãUAZ ã¢ããã³ã¹å·ãæµãããªã¢ã®äœçœ®ã®å®å®åº§æš(3次å
åº§æš <var>x</var>, <var>y</var>, <var>z</var>) ãå
¥åããŠãããŒã ãããªã¢ããããŠæµã«åœäžããå Žå㯠"HIT"ãããªã¢ã«åœãã£ãŠããŸãå Žå"MISS"ãšåºåããããã°ã©ã ãäœæããŠãã ããã
</p>
<p>
ãã ããããªã¢ã¯ã¢ããã³ã¹å·ãã 3 è§åœ¢ã«èŠãããã®ã ãã察象ã§ãããç·åã«ã€ã¶ããŠèŠãããã®ã¯ãªããã®ãšããŸãããŸããããªã¢ã¯ 3 è§åœ¢ã®é ç¹ãå«ãå¢çã§ãæå¹ã§ãããããŒã ãã¯ãè¿ããã®ãšããŸãããŸããæµãããªã¢å
ã«ããå Žåã¯"MISS"ãšåºåããŠäžããã
</p>
<!--
<p>
æææŽ 2005.11.5ãããªãã¯å®å®è¹ UAZ ã¢ããã³ã¹å·ã®èŠé·ãšããŠæµã®å®å®è¹ãšäº€æŠããããšããŠããŸãã 幞ãæµã®å®å®è¹ã¯ãŸã ãã¡ãã«æ°ä»ããã«éæ¢ããŠããŸãããŸãããã§ã«æµã®å®å®åº§æšã¯å€æããŠãã匷åãªçŽç·ã®ããŒã ãæŸã€ããã§ã¶ãŒç ²ãã¯çºå°æºåãå®äºããŠããŸããããšã¯ãçºå°åœä»€ãåºãã°ããã§ãã
</p>
<p>
ãšãããã1ã€ã ãå°ã£ãããšãå€æããŸãããå®å®ç©ºéã«ã¯ãæµã®èšçœ®ãããšãã«ã®ãŒããªã¢ãååšããŠãã
ã®ã§ããããªã¢ã¯äžè§åœ¢ãããŠããããã§ã¶ãŒç ²ãããŒã ãã¯ãè¿ããŠããŸããŸãããŸããããŒã ãããªã¢ã«åœãã
ã°æµã«æ°ä»ãããŠéããããŠããŸããŸããäºåã«åœäžãããšå€å®ã§ããªããã°ãçºå°åœä»€ã¯åºããŸããã
</p>
<p>
ããã§ãUAZ ã¢ããã³ã¹å·ãæµãããªã¢ã®äœçœ®ã®å®å®åº§æš(3次å
åº§æš <i>x</i>, <i>y</i>, <i>z</i> )ãå
¥åããŠãããã§
ã¶ãŒç ²ããããªã¢ããããŠæµã«åœäžããå Žåã¯âHITâãããªã¢ã«åœäžããŠã¯ãè¿ãããŠããŸãå ŽåâMISSâãšåºåã
ãŠçµäºããããã°ã©ã ãäœæããŠãã ããã
</p>
<p>
ãã ããããªã¢ã¯ã¢ããã³ã¹å·ãã 3 è§åœ¢ã«èŠãããã®ã ãã察象ã§ãããç·åã«ã€ã¶ããŠèŠãããã®ã¯ãªãã
ã®ãšããŸãããŸããããªã¢ã¯ 3 è§åœ¢ã®é ç¹ãå«ãå¢çã§ãæå¹ã§ãããããŒã ãã¯ãè¿ããã®ãšããŸãã
</p>
-->
<H2>Input</H2>
<p>
å
¥åããŒã¿ã®åœ¢åŒã¯ä»¥äžã®ãšããã§ãïŒ<br/>
<br/>
1 è¡ç®ã¯ãUAZ ã¢ããã³ã¹å·ã®åº§æš (<var>x</var>, <var>y</var>, <var>z</var>) (æŽæ°ãåè§ç©ºçœåºåã)<br/>
2 è¡ç®ã¯ãæµã®åº§æš (<var>x</var>, <var>y</var>, <var>z</var>) (æŽæ°ãåè§ç©ºçœåºåã)<br/>
3 è¡ç®ã¯ãããªã¢ã®é ç¹ 1 ã®åº§æš (<var>x</var>, <var>y</var>, <var>z</var>) (æŽæ°ãåè§ç©ºçœåºåã)<br/>
4 è¡ç®ã¯ãããªã¢ã®é ç¹ 2 ã®åº§æš (<var>x</var>, <var>y</var>, <var>z</var> ) (æŽæ°ãåè§ç©ºçœåºåã)<br/>
5 è¡ç®ã¯ãããªã¢ã®é ç¹ 3 ã®åº§æš (<var>x</var>, <var>y</var>, <var>z</var> ) (æŽæ°ãåè§ç©ºçœåºåã)<br/>
</p>
<H2>Output</H2>
<p>
HIT ãŸã㯠MISS ãšïŒè¡ã«åºåããŠãã ããã
</p>
<H2>Constraints</H2>
<ul>
<li>-100 ≤ <var>x</var>, <var>y</var>, <var>z</var> ≤ 100</li>
<li>UAZ ã¢ããã³ã¹å·ãšæµãåãäœçœ®ã«ããããšã¯ãªãã</li>
</ul>
<H2>Sample Input 1</H2>
<pre>
-10 0 0
10 0 0
0 10 0
0 10 10
0 0 10
</pre>
<H2>Output for the Sample Input 1</H2>
<pre>
HIT
</pre>
<br/>
<H2>Sample Input 2</H2>
<pre>
-10 6 6
10 6 6
0 10 0
0 10 10
0 0 10
</pre>
<H2>Output for the Sample Input 2</H2>
<pre>
MISS
</pre>
<br/>
| [
[
"-10 0 0\n10 0 0\n0 10 0\n0 10 10\n0 0 10\n",
"-10 0 0\n10 0 0\n0 10 0\n0 10 10\n0 0 10\n"
]
] |
p00116 | Rectangular Searching |
<H1>é·æ¹åœ¢æ¢çŽ¢</H1>
<p>
瞊㫠<var>H</var> è¡ã暪㫠<var>W</var> å䞊ã¹ããããåèš <var>W × H</var> ã®ãã¹ç®ããããŸããããã€ãã®ãã¹ç®ã«ã¯å°ãã€ããŠããŸããåãã¹ç®ã®å°ã®ç¶æ
ãèªã¿èŸŒã¿ãå°ã®ã€ããŠããªããã¹ç®ã ããããªãæ倧ã®é·æ¹åœ¢ã®é¢ç©ãåºåããããã°ã©ã ãäœæããŠãã ããã
</p>
<p>
å
¥åããŒã¿ã¯ 1 è¡ <var>W</var> æåããæ§æããã<var>H</var> è¡ãäžããããŸããããšãã°ä»¥äžã®ãããªããŒã¿ãäžããããŸãã
</p>
<pre>
..*....**.
..........
**....***.
....*.....
..*.......
...**.....
.*.*......
..........
..**......
.*..*.....
</pre>
<p>
å
¥åããŒã¿ã®äžè¡ããäžè¡ã®ãã¹ç®ãè¡šçŸããŸããå
¥åããŒã¿ã®æååã®ãã¡ã. (ããªãªã) ã¯å°ã®ã€ããŠããªããã¹ç®ã* (ã¢ã¹ã¿ãªã¹ã¯) ã¯å°ã®ã€ããŠãããã¹ç®ã瀺ããŠããŸããå
¥åããŒã¿ã®æååã«ã¯ãããªãªããã¢ã¹ã¿ãªã¹ã¯ãæ¹è¡ä»¥å€ã®æåã¯å«ãŸããŸããã
</p>
<p>
äžèšã®äŸã§ã¯ãäžå³ã® 0 ã§ç€ºãããé·æ¹åœ¢ãæ倧ãšãªããŸãã
</p>
<pre>
..*....**.
..........
**....***.
....*00000
..*..00000
...**00000
.*.*.00000
.....00000
..**.00000
.*..*00000
</pre>
<p>
ãã£ãŠã35 ãšåºåããã°æ£è§£ã«ãªããŸãããªãããã¹ãŠã®ãã¹ç®ã«å°ãã€ããŠããå Žåã«ã¯ã0 ãåºåããŠãã ããã
</p>
<H2>Input</H2>
<p>
è€æ°ã®ããŒã¿ã»ãããäžããããŸããåããŒã¿ã»ããã¯ã¹ããŒã¹ã§åºåããã <var>H</var> ãš <var>W</var> ãããªãè¡ããå§ãŸããã€ã¥ã㊠<var>H × W</var> ã®é·æ¹åœ¢ãäžããããŸãã<var>H, W</var> ã¯ãšãã« 500ã以äžãšããŸãã
</p>
<p>
å
¥åã¯ïŒã€ã® 0 ãå«ãè¡ã§çµãããŸããããŒã¿ã»ããã®æ°ã¯ 20 ãè¶
ããŸããã
</p>
<H2>Output</H2>
<p>
åããŒã¿ã»ããããšã«ãæ倧ã®é·æ¹åœ¢ã®é¢ç©ãïŒè¡ã«åºåããŠãã ããã
</p>
<H2>Sample Input</H2>
<pre>
10 10
...*....**
..........
**....**..
........*.
..*.......
**........
.*........
..........
....*..***
.*....*...
10 10
..*....*..
.*.*...*..
*****..*..
*...*..*..
*...*..*..
..........
****.*...*
..*..*...*
.*...*...*
****..***.
2 3
...
...
0 0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
28
12
6
</pre>
| [
[
"10 10\n...*....**\n..........\n**....**..\n........*.\n..*.......\n**........\n.*........\n..........\n....*..***\n.*....*...\n10 10\n..*....*..\n.*.*...*..\n*****..*..\n*...*..*..\n*...*..*..\n..........\n****.*...*\n..*..*...*\n.*...*...*\n****..***.\n2 3\n...\n...\n0 0\n",
"10 10\n...*....**\n..........\n**....**..\n........*.\n..*.......\n**........\n.*........\n..........\n....*..***\n.*....*...\n10 10\n..*....*..\n.*.*...*..\n*****..*..\n*...*..*..\n*...*..*..\n..........\n****.*...*\n..*..*...*\n.*...*...*\n****..***.\n2 3\n...\n...\n0 0\n"
]
] |
p00117 | A reward for a Carpenter |
<H1>倧工ã®è€çŸ</H1>
<p>
ããæ¥ã殿æ§ã¯äžäººã®å€§å·¥ã«ããå°é¢šãå°éãæ¥ããšãã«çºäººãé¿é£ã§ãããé äžã§å€§ããªå»ºç©ãé ããªãããããšåœããŸããããããããã®é äžã§å€§ããªå»ºç©ãå®æãããã«ã¯ã倧ããªå€ªãæ±ãå¿
èŠã§ããçºã«ãããªå€§ããªæ±ã¯ãããŸãããããã§ã倧工ã¯é ãã®å±±éãŸã§å€§ããªæ±ã調éãã«è¡ãããšã«ãªããŸããïŒå€§å·¥ã¯çºããéå±±ã«è¡ã£ãŠãçºã«æ»ã£ãŠããå¿
èŠããããŸãïŒã
</p>
<p>
倧工ã®è€çŸã¯ã殿æ§ããåãåã£ããéããæ±ã®ä»£éãšäº€éè²»ãå·®ãåŒããäœãã§ããäžã®å°å³ã®ããã«ãå±±éã«è¡ãã«ã¯ããããããªçºãéãããããã®è¡éãããã2ã€ã®çºãã€ãªãè¡éã¯ãããã亀éè²»ãéããŸãã倧工ã®è€çŸãæ倧ã«ããã«ã¯ã©ã®ããã«è¡éããã©ã調éããã°ããã§ãããããæ倧ãšãªã倧工ã®è€çŸãåºåããããã°ã©ã ãäœæããŠãã ããããã ããçºã®æ°ã <var>n</var> ãšããã°ãåçºã¯ 1 ãã <var>n</var> ãŸã§ã®æŽæ°ã§èå¥ãããŸãã2 ã€ã®çºãçŽæ¥ã€ãªãè¡é㯠2 æ¬ä»¥äžãããŸããã
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_carpenter">
</center>
<p>
â» ç¢å°äžã®æ°åã¯ããã®æ¹åã«è¡ãããã®äº€éè²»ã瀺ããŸãã
</p>
<H2>Input</H2>
<p>
å
¥åã¯ä»¥äžã®åœ¢åŒã§äžããããŸãã
</p>
<pre>
<var>n</var>
<var>m</var>
<var>a<sub>1</sub></var>,<var>b<sub>1</sub></var>,<var>c<sub>1</sub></var>, <var>d<sub>1</sub></var>
<var>a<sub>2</sub></var>,<var>b<sub>2</sub></var>,<var>c<sub>2</sub></var>, <var>d<sub>2</sub></var>
:
<var>a<sub>m</sub></var>,<var>b<sub>m</sub></var>,<var>c<sub>m</sub></var>, <var>d<sub>m</sub></var>
<var>s</var>,<var>g</var>,<var>V</var>,<var>P</var>
</pre>
<p>
1 è¡ç®ã«çºã®ç·æ° <var>n</var>ïŒ <var>n</var> ≤ 20ïŒã2 è¡ç®ã«è¡éã®ç·æ° <var>m</var> (<var>m</var> ≤ 100) ãäžããããŸããç¶ã <var>m</var> è¡ã« <var>i</var> çªç®ã®è¡éã®æ
å ± <var>a<sub>i</sub></var>, <var>b<sub>i</sub></var>, <var>c<sub>i</sub></var>, <var>d<sub>i</sub></var> (1 ≤ <var>a<sub>i</sub></var>, <var>b<sub>i</sub></var> ≤ <var>n</var>, 0 ≤ <var>c<sub>i</sub></var>, <var>d<sub>i</sub></var> ≤ 1,000) ãäžããããŸãã<var>a<sub>i</sub></var>, <var>b<sub>i</sub></var> ã¯è¡é <var>i</var> ãã€ãªãã§ããçºã®çªå·ã <var>c<sub>i</sub></var> 㯠<var>a<sub>i</sub></var> ãã <var>b<sub>i</sub></var> ãžã®äº€éè²»ã <var>d<sub>i</sub></var> 㯠<var>b<sub>i</sub></var> ãã <var>a<sub>i</sub></var> ãžã®äº€éè²»ãè¡šããŸãã
</p>
<p>
æçµè¡ã«å€§å·¥ãåºçºããçºã®çªå· <var>s</var>ãæ±ã®ããå±±éã®çªå· <var>g</var>ã殿æ§ãã倧工ãåãåã£ããé <var>V</var>ãæ±ã®ä»£é <var>P</var> ãäžããããŸãã
</p>
<H2>Output</H2>
<p>
倧工ã®è€çŸïŒæŽæ°ïŒãïŒè¡ã«åºåããŠãã ããã
</p>
<H2>Sample Input</H2>
<pre>
6
8
1,2,2,2
1,3,4,3
1,4,4,2
2,5,3,2
3,4,4,2
3,6,1,2
4,6,1,1
5,6,1,2
2,4,50,30
</pre>
<H2>Output for the Sample Input</H2>
<pre>
11
</pre>
| [
[
"6\n8\n1,2,2,2\n1,3,4,3\n1,4,4,2\n2,5,3,2\n3,4,4,2\n3,6,1,2\n4,6,1,1\n5,6,1,2\n2,4,50,30\n",
"6\n8\n1,2,2,2\n1,3,4,3\n1,4,4,2\n2,5,3,2\n3,4,4,2\n3,6,1,2\n4,6,1,1\n5,6,1,2\n2,4,50,30\n"
]
] |
p00118 | Property Distribution |
<H1>Property Distribution</H1>
<p>
ã¿ãã«æ°ã <var>HW</var> ã¢ãŒã«ã®ææš¹åãæ®ããŠäº¡ããªããŸãããææš¹åã¯æ±è¥¿ååæ¹åã« <var>H × W</var> ã®åºç»ã«åããããåºç»ããšã«ãªã³ãŽãã«ãããã«ã³ãæ€ããããŠããŸããã¿ãã«æ°ã¯ãããªéºèšãæ®ããŠããŸããã
</p>
<p>
ææš¹åã¯åºç»åäœã§ã§ããã ãå€ãã®è¡çžè
ã«åããããšããã ããããåºç»ã®æ±è¥¿ååã©ããã®æ¹åã«ãšãªãããåºç»ã«åãçš®é¡ã®æç©ãæ€ããããŠããå Žåã¯ãåºç»ã®å¢çãåãããªãã®ã§ããã㯠1 ã€ã®å€§ããªåºç»ãšããŠæ±ãããšã
</p>
<p>
äŸãã°æ¬¡ã®ãã㪠3 × 10 ã®åºç»ã§ããã° ('ãª'ã¯ãªã³ãŽã'ã«'ã¯ã«ãã'ã'ã¯ãã«ã³ãè¡šã)
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_property1">
</center>
<br/>
<p>
åãæš¹ãããåºç»ã®éã®å¢çãæ¶ããšæ¬¡ã®ããã«ãªãã
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_property2">
</center>
<br/>
<p>
çµå± 10 åã®åºç»ãã€ãŸã 10 人ã§åããããããšã«ãªããŸãã
</p>
<p>
éªãéã£ãŠåºç»ã®å¢çãèŠããªããªãåã«åé
ãçµããªããŠã¯ãªããŸãããããªãã®ä»äºã¯ææš¹åã®å°å³ãããšã«åé
ããåºç»ã®æ°ã決ããããšã§ãã
</p>
<p>
ææš¹åã®å°å³ãèªã¿èŸŒã¿ãåé
ãåããããè¡çžè
ã®äººæ°ãåºåããããã°ã©ã ãäœæããŠãã ããã
</p>
<H2>Input</H2>
<p>
è€æ°ã®ããŒã¿ã»ãããäžããããŸããåããŒã¿ã»ããã¯ç©ºçœã§åºåããã <var>H</var>, <var>W</var> (<var>H, W</var> ≤ 100) ãå«ãè¡ããå§ãŸããç¶ã㊠<var>H × W</var> ã®æåãããªã <var>H</var> è¡ã®æååãäžããããŸãããã®æååã«ã¯ããªã³ãŽãè¡šã '<span>@</span>'ãã«ããè¡šã '<span>#</span>'ããã«ã³ãè¡šã '<span>*</span>'ãã® 3 æåããçŸããŸããã
</p>
<p>
å
¥åã¯ãŒããïŒã€ã®è¡ã§çµãããŸããããŒã¿ã»ããã®æ°ã¯ 20 ãè¶
ããŸããã
</p>
<H2>Output</H2>
<p>
åããŒã¿ã»ããããšã«ãåé
ãåãã人æ°ãïŒè¡ã«åºåããŠãã ããã
</p>
<H2>Sample Input</H2>
<pre>
10 10
####*****@
@#@@@@#*#*
@##***@@@*
#****#*@**
##@*#@@*##
*@@@@*@@@#
***#@*@##*
*@@@*@@##@
*@*#*@##**
@****#@@#@
0 0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
33
</pre>
| [
[
"10 10\n####*****@\n@#@@@@#*#*\n@##***@@@*\n#****#*@**\n##@*#@@*##\n*@@@@*@@@#\n***#@*@##*\n*@@@*@@##@\n*@*#*@##**\n@****#@@#@\n0 0\n",
"10 10\n####*****@\n@#@@@@#*#*\n@##***@@@*\n#****#*@**\n##@*#@@*##\n*@@@@*@@@#\n***#@*@##*\n*@@@*@@##@\n*@*#*@##**\n@****#@@#@\n0 0\n"
]
] |
p00119 | Taro's Obsession |
<H1>倪éåã®å·å¿µ</H1>
<p>
ãŸããã
ã奜ãã®å€ªéããã®å®¶ã§ãããžããªäºä»¶ããããŸãããå宀ã®ä»å£ã«äŸããŠãã£ã3ã€ã®ãŸããã
ãã®ãã¡1ã€ãç¡ããªã£ãŠããã®ã§ãããã€ãã¯ããã€ã«ããã ãããšçã£ãŠãã倪éãããç¯äººãèŠã€ããããææ»ãå§ãããšããã®æ¥ãå宀ã«å
¥ã£ã人ãäœäººãããããšãåãããŸãããããã§ããããã®å®¹çè
ãéšå±ã«å
¥ã£ãé åºã調ã¹ããããå
šå¡ã«æ¬¡ã®ãããªåœ¢åŒã®èšŒèšãããŠãããããšã«ãŸããã
</p>
<p>
容çè
A ã®èšŒèš ãç§ã¯å®¹çè
B ããå
ã«éšå±ã«å
¥ã£ããã
</p>
<p>
容çè
ã®äžäºº(?)ã¯äžæ¯ç«ã®ã¿ããªã®ã§èšŒèšã¯ã§ããŸãããã幞éã«ãæåŸã«éšå±ã«å
¥ã£ããšããã倪éããã¯èŠãŠããŸããã
</p>
<p>
倪éããã¯ãããã®èšŒèšãããéšå±ã«å
¥ã£ãé çªãæšæž¬ããŠææ»ã«åœ¹ç«ãŠãããšã«ããŸããã
</p>
<p>
äŸãã°ã6 人ã®å®¹çè
ãããŠã¿ãã容çè
2 ãšããå Žåã以äžã®ãããªèšŒèšãåŸããããšããŸãã
</p>
<p>
容çè
5 ã®èšŒèš ãç§ã¯ 2 ããå
ã«éšå±ã«å
¥ã£ããã<br>
容çè
1 ã®èšŒèš ãç§ã¯ 4 ããå
ã«éšå±ã«å
¥ã£ããã<br>
容çè
3 ã®èšŒèš ãç§ã¯ 5 ããå
ã«éšå±ã«å
¥ã£ããã<br>
容çè
4 ã®èšŒèš ãç§ã¯ 2 ããå
ã«éšå±ã«å
¥ã£ããã<br>
容çè
1 ã®èšŒèš ãç§ã¯ 6 ããå
ã«éšå±ã«å
¥ã£ããã<br>
容çè
6 ã®èšŒèš ãç§ã¯ 4 ããå
ã«éšå±ã«å
¥ã£ããã<br>
容çè
3 ã®èšŒèš ãç§ã¯ 4 ããå
ã«éšå±ã«å
¥ã£ããã<br>
</p>
<p>
ãã®èšŒèšãã€ãªãåããããšãéšå±ã«å
¥ã£ãé åºã¯
</p>
<ul>
<li>3â5â1â6â4â2</li>
<li>1â6â3â4â5â2</li>
<li>3â1â6â5â4â2</li>
</ul>
<p>
ãªã©ãäœéããã®å¯èœæ§ã«çµã蟌ãããšãã§ããŸãã
</p>
<p>
ã¿ã (容çè
2) 以å€ã®å®¹çè
å
šå¡ã®èšŒèšãããéšå±ã«å
¥ã£ãé çªãæšæž¬ããå¯èœæ§ã®ããé çªã® 1 ã€ãåºåããããã°ã©ã ãäœæããŠãã ããããã ããè€æ°ã®èšŒèšããã容çè
ããããããããŸããããã©ã®èšŒèšãçå®ã§ããççŸããŠããªããã®ãšããŸãã
</p>
<!--
ãã ãã容çè
ã®äººæ°ã m ãšãããš m 㯠20 以äžã§ããã容çè
㯠1 ãã m ãŸã§ã®æŽæ°ã§èå¥ãããŸãã蚌èšã®æ°ã¯ 100 以äžãšããŸãããŸããè€æ°ã®èšŒèšããã容çè
ããããããããŸããããã©ã®èšŒèšãçå®ã§ããççŸããŠããªããã®ãšããŸãã
-->
<H2>Input</H2>
<p>
å
¥åã¯ä»¥äžã®åœ¢åŒã§äžããããŸãã
</p>
<pre>
<var>m</var>
<var>n</var>
<var>x<sub>1</sub></var> <var>y<sub>1</sub></var>
<var>x<sub>2</sub></var> <var>y<sub>2</sub></var>
:
<var>x<sub>n</sub></var> <var>y<sub>n</sub></var>
</pre>
<p>
1 è¡ç®ã«å®¹çè
ã®äººæ° <var>m</var> (<var>m</var> ≤ 20)ã2 è¡ç®ã«èšŒèšã®æ° <var>n</var> (<var>n</var> ≤ 100) ãäžããããŸãã
ç¶ã <var>n</var> è¡ã« <var>i</var> åç®ã®èšŒèšã®å
容 <var>x<sub>i</sub></var>, <var>y<sub>i</sub></var> ãããããïŒè¡ã«äžããããŸãã<var>x<sub>i</sub></var> <var>y<sub>i</sub></var> ã¯ã容çè
<var>x<sub>i</sub></var>(ç§)ã¯å®¹çè
<var>y<sub>i</sub></var> ããå
ã«å
¥ã£ãããšãã蚌èšãè¡šããŸãã
</p>
<H2>Output</H2>
<p>
æåã«éšå±ã«å
¥ã£ã容çè
ã®çªå·ã2 çªç®ã«éšå±ã«å
¥ã£ã容çè
ã®çªå·ã...ã<var>m</var> çªç®ã«éšå±ã«å
¥ã£ã容çè
ã®çªå·ãããããïŒè¡ã«é çªã«åºåããŠãã ããã
</p>
<H2>Sample Input</H2>
<pre>
6
7
5 2
1 4
3 5
4 2
1 6
6 4
3 4
</pre>
<H2>Output for the Sample Input</H2>
<pre>
3
5
1
6
4
2
</pre>
| [
[
"6\n7\n5 2\n1 4\n3 5\n4 2\n1 6\n6 4\n3 4\n",
"6\n7\n5 2\n1 4\n3 5\n4 2\n1 6\n6 4\n3 4\n"
]
] |
p00120 | Patisserie |
<H1>ããã£ã·ãš</H1>
<p>
ã±ãŒãå±ãããããŸã¡ãŸã¡ãªå€§ããã®ããŒã«ã±ãŒããããããäœããŸãããããªãã¯ããã®ã±ãŒããç®±ã«äžŠã¹ãä»äºãä»»ãããŸããã
</p>
<p>
ããŒã«ã±ãŒãã¯ãšãŠããããããã®ã§ãä»ã®ããŒã«ã±ãŒããäžã«ä¹ããšã€ã¶ããŠããŸããŸããã§ããããå³(a) ã®ããã«å
šãŠã®ããŒã«ã±ãŒãã¯å¿
ãç®±ã®åºé¢ã«æ¥ããŠããããã«äžŠã¹ãªããã°ãªããŸããã䞊ã¹æ¿ãããšå¿
èŠãªå¹
ãå€ãããŸãã
</p>
<center>
<table>
<tr><td><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_patisserie1"></td></tr>
<tr><th>å³(a)</th></tr>
<tr><td></td></tr>
<tr><td></td></tr>
<tr><td><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_patisserie2"></td></tr>
<tr><th>å³(b)</th></tr>
</table>
</center>
</br>
<p>
<var>n</var> åã®ããŒã«ã±ãŒãã®ååŸ <var>r<sub>1</sub></var>, <var>r<sub>2</sub></var>, ..., <var>r<sub>n</sub></var> ãšç®±ã®é·ããèªã¿èŸŒã¿ãããããã«ã€ããŠãç®±ã®äžã«ããŸãåãŸããã©ããå€å®ãã䞊ã¹ãé çªã工倫ãããšç®±ã«å
¥ãå Žå㯠"OK"ãã©ã䞊ã¹ãŠãå
¥ããªãå Žåã«ã¯ "NA"ãåºåããããã°ã©ã ãäœæããŠãã ããã
</p>
<p>
ããŒã«ã±ãŒãã®æé¢ã¯åã§ãããç®±ã®å£ã®é«ãã¯ååã«é«ããã®ãšããŸãã ãã ããããŒã«ã±ãŒãã®ååŸã¯ 3 ä»¥äž 10 以äžã®æŽæ°ãšããŸããã€ãŸããã±ãŒãã®ååŸã«æ¥µç«¯ãªå·®ã¯ãªããå³(b) ã®ããã«å€§ããªã±ãŒãã®éã«å°ããªã±ãŒããã¯ãŸã蟌ãã§ããŸãããšã¯ãããŸããã
</p>
<H2>Input</H2>
<p>
å
¥åã¯è€æ°ã®ããŒã¿ã»ãããããªããŸããåããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããŸãã
</p>
<pre>
<var>W</var> <var>r<sub>1</sub></var> <var>r<sub>2</sub></var> ... <var>r<sub>n</sub></var>
</pre>
<p>
æåã«ç®±ã®é·ããè¡šãæŽæ° <var>W</var> (1 ≤ <var>W</var> ≤ 1,000) ãäžããããŸãã ç¶ããŠã空çœåºåãã§åããŒã«ã±ãŒãã®ååŸãè¡šãæŽæ° <var>r<sub>i</sub></var> (3 ≤ <var>r<sub>i</sub></var> ≤ 10) ãäžããããŸããã±ãŒãã®åæ° <var>n</var> 㯠12 以äžã§ãã
</p>
<p>
ããŒã¿ã»ããã®æ°ã¯ 50 ãè¶
ããŸããã
</p>
<H2>Output</H2>
<p>
ããŒã¿ã»ããããšã« OK ãŸã㯠NA ãïŒè¡ã«åºåããŠãã ããã
</p>
<H2>Sample Input</H2>
<pre>
30 4 5 6
30 5 5 5
50 3 3 3 10 10
49 3 3 3 10 10
</pre>
<H2>Output for the Sample Input</H2>
<pre>
OK
OK
OK
NA
</pre>
| [
[
"30 4 5 6\n30 5 5 5\n50 3 3 3 10 10\n49 3 3 3 10 10\n",
"30 4 5 6\n30 5 5 5\n50 3 3 3 10 10\n49 3 3 3 10 10\n"
]
] |
p00121 | Seven Puzzle |
<H1>7 ããºã«</H1>
<p>
7 ããºã«ã¯ 8 ã€ã®æ£æ¹åœ¢ã®ã«ãŒããšãããã®ã«ãŒãããŽãããšåãŸãæ ã§æ§æãããŠããŸããããããã®ã«ãŒãã«ã¯ãäºãã«åºå¥ã§ããããã« 0, 1, 2, ..., 7 ãšçªå·ãã€ããããŠããŸããæ ã«ã¯ã瞊㫠2 åã暪㫠4 åã®ã«ãŒãã䞊ã¹ãããšãã§ããŸãã
</p>
<p>
7 ããºã«ãå§ãããšãã«ã¯ããŸãæ ã«ãã¹ãŠã®ã«ãŒããå
¥ããŸããæ ã®ãªã㧠0 ã®ã«ãŒãã ãã¯ãäžäžå·Šå³ã«é£æ¥ããã«ãŒããšäœçœ®ã亀æããããšãã§ããŸããããšãã°ãæ ã®ç¶æ
ãå³(a) ã®ãšãã«ã0 ã®ã«ãŒãã®å³ã«é£æ¥ããã7 ã®ã«ãŒããšäœçœ®ã亀æããã°ãå³(b) ã®ç¶æ
ã«ãªããŸãããããã¯ãå³(a) ã®ç¶æ
ãã 0 ã®ã«ãŒãã®äžã«é£æ¥ãã 2 ã®ã«ãŒããšäœçœ®ã亀æããã°å³(c) ã®ç¶æ
ã«ãªããŸããå³(a) ã®ç¶æ
㧠0 ã®ã«ãŒããšäžäžå·Šå³ã«é£æ¥ããã«ãŒã㯠7 ãš 2 ã®ã«ãŒãã ããªã®ã§ããã以å€ã®äœçœ®ã®å
¥ãæ¿ãã¯èš±ãããŸããã
</p>
<p>
ã²ãŒã ã®ç®çã¯ãã«ãŒãããããã«æŽåããŠå³(d) ã®ç¶æ
ã«ããããšã§ããæåã®ç¶æ
ãå
¥åãšããã«ãŒãããããã«æŽåãããŸã§ã«ãå¿
èŠãªæå°ææ°ãåºåããããã°ã©ã ãäœæããŠãã ããããã ããå
¥åãããã«ãŒãã®ç¶æ
ããã¯å³(d) ã®ç¶æ
ã«ç§»ãããšã¯å¯èœã§ãããšããŸãã
</p>
<p>
å
¥åããŒã¿ã¯ã1 è¡ã« 8 ã€ã®æ°åã空çœåºåãã§äžããããŸãããããã¯ãæåã®ç¶æ
ã®ã«ãŒãã®äžŠã³ãè¡šããŸããäŸãã°ãå³(a) ã®æ°åè¡šçŸã¯<span>0 7 3 4 2 5 1 6</span> ã«ãå³(c) 㯠<span>2 7 3 4 0 5 1 6</span> ãšãªããŸãã
</p>
<center>
<table>
<tr>
<td width="280"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_sevenpuzzle1" width="240"></td>
<td width="280"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_sevenpuzzle2" width="240"></td>
</tr>
<tr>
<th>å³(a) <span>0 7 3 4 2 5 1 6</span> ã®å Žå</th>
<th>å³(b) <span>7 0 3 4 2 5 1 6</span> ã®å Žå</th>
</tr>
</table>
<br><br>
<table>
<tr>
<td width="280"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_sevenpuzzle3" width="240"></td>
<td width="280"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_sevenpuzzle4" width="240"></td>
</tr>
<tr>
<th>å³(c) <span>2 7 3 4 0 5 1 6</span> ã®å Žå</th>
<th>å³(d) <span>0 1 2 3 4 5 6 7</span> (æçµç¶æ
)</th>
</tr>
</table>
</center>
<br/>
<H2>Input</H2>
<p>
äžèšåœ¢åŒã§è€æ°ã®ããºã«ãäžããããŸããå
¥åã®æåŸãŸã§åŠçããŠãã ããã
äžããããããºã«ã®æ°ã¯ 1,000 以äžã§ãã
</p>
<H2>Output</H2>
<p>
åããºã«ã«ã€ããŠãæçµç¶æ
ãžç§»è¡ããæå°ææ°ãïŒè¡ã«åºåããŠãã ããã
</p>
<H2>Sample Input</H2>
<pre>
0 1 2 3 4 5 6 7
1 0 2 3 4 5 6 7
7 6 5 4 3 2 1 0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
0
1
28
</pre>
| [
[
"0 1 2 3 4 5 6 7\n1 0 2 3 4 5 6 7\n7 6 5 4 3 2 1 0\n",
"0 1 2 3 4 5 6 7\n1 0 2 3 4 5 6 7\n7 6 5 4 3 2 1 0\n"
]
] |
p00122 | Summer of Pyonkichi |
<H1>ãŽããåã®å€</H1>
<p>
äŒæŽ¥å€§åŠã«ã¯äžé¢èçã§èŠãããå
¬åããããæ¥å·®ããé®ãæšã建ç©ããããŸãããæ¥å·®ãã®åŒ·ãå€ã®æ¥ã«ã¯ãå
¬åå
ã«èšçœ®ãããã¹ããªã³ã¯ã©ãŒãäœåããŠèçã«æ£æ°ŽããŠããŸãããã®å
¬åã«ã¯ã«ãšã«ã®ãŽããåãäœã¿çããŠããŸãããŽããåã¯æãã®ãèŠæã§ãæ¥å·®ãã匷ãå€ã®æ¥ã«ã¯åžžã«ã¹ããªã³ã¯ã©ãŒã®æ°Žã«åœãã£ãŠããªããšå¹²ããã³ãŠæ»ãã§ããŸããŸããå
¬åã«èšçœ®ãããã¹ããªã³ã¯ã©ãŒã¯ãç¯æ°Žã®ããäžåºŠã«äžã€ã ãæ£æ°Žããããšã«ãªã£ãŠããã®ã§ããŽããåã¯ã¹ããªã³ã¯ã©ãŒã®äœåã«åãããŠç§»åããªããŠã¯ãªããŸããã
</p>
<center>
<table>
<tr><td>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_phyonkichi1">
</td></tr>
<tr>
<th>(a) å
¬åã®å°å³</th>
</tr>
</table>
<br>
<table>
<tr><td><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_phyonkichi2"></td><td><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_phyonkichi3"></td></tr>
<tr>
<th>(b) ãŽããåã®ãžã£ã³ãç¯å² </th>
<th>(c) ã¹ããªã³ã¯ã©ãŒã®æ£æ°Žç¯å²</th>
</tr>
</table>
</center>
<br/>
<p>
å
¬åã¯äžå³ã®(a)ã®ãšããã§ãå
¬åå
ã®å Žæã¯çžŠæšªãããã 0~9 ã®åº§æšã§è¡šããé»ãâãã¹ããªã³ã¯ã©ãŒã§ããã®çªå·ãäœåããé çªãè¡šããŠããŸããããã¯äžäŸã§åã¹ããªã³ã¯ã©ãŒã®å Žæãšäœåé åºã¯æ¥ã
å€ãããŸãã
</p>
<p>
ãŽããåã¯äžåšçšãªã®ã§ã移åããã«ã決ãŸã£ãè·é¢ããžã£ã³ãããããšããã§ããŸããããŽããåã®ãžã£ã³ãã§ããç¯å²ã¯äžå³(b)ã®ãšããã§ããã以å€ã®å Žæã«ç§»åããããšã¯ã§ããŸãããããããäžåã®ãžã£ã³ãã§çžåœäœåãæ¶èããããããã°ããæ°Žã«åœãã£ãŠäŒãŸãªããŠã¯ãªããŸããã
</p>
<p>
ã¹ããªã³ã¯ã©ãŒãæ£æ°Žã§ããç¯å²ã¯äžå³(c)ã®ãšããã§ãã¹ããªã³ã¯ã©ãŒèªèº«ã®åº§æšãå«ã¿ãŸããåã¹ããªã³ã¯ã©ãŒã¯äžå®æéæ£æ°Žãããšåæ¢ããããã«æ¬¡ã®ã¹ããªã³ã¯ã©ãŒãäœåãéå§ããŸãããŽããåã¯ãã®æã«äžåã ããžã£ã³ããããã®ãšãã次ã«æ£æ°Žãåæ¢ãããŸã§ãžã£ã³ãããªããã®ãšããŸãããŸããå
¬åã®åæ¹ã¯çŒç±ã®ã¢ã¹ãã¡ã«ãã§å²ãŸããŠããã®ã§å
¬åã®å€ã«ã§ãŠããŸããããªæ¹åã«ã¯ãžã£ã³ãããªããã®ãšããŸãã
</p>
<p>
çæãšãªã£ããã®å€ãæãããŠãŽããåã¯çã延ã³ãããšãã§ããã®ã§ãããã? ããæ¥ã®ãŽããåã®åæäœçœ®ãã¹ããªã³ã¯ã©ãŒã®äœçœ®ãšäœåé åºãèªã¿èŸŒã¿ããŽããåãçã延ã³ããã移åçµè·¯ãååšããŠããå Žåã¯âOKâãã©ãé 匵ã£ãŠãæ»ãã§ããŸãå Žåã¯âNAâãåºåããããã°ã©ã ãäœæããŠãã ããããã ããã¹ããªã³ã¯ã©ãŒã®æ°ã¯æ倧 10 åãšãããŽããåã¯äžçªç®ã®ã¹ããªã³ã¯ã©ãŒã®äœåãšåæã«åæäœçœ®ãããžã£ã³ãããããšãšããŸãã
</p>
<H2>Input</H2>
<p>
è€æ°ã®ããŒã¿ã»ãããäžããããŸããåããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããŸãã
</p>
<pre>
<var>px</var> <var>py</var>
<var>n</var>
<var>x<sub>1</sub></var> <var>y<sub>1</sub></var> <var>x<sub>2</sub></var> <var>y<sub>2</sub></var> ... <var>x<sub>n</sub></var> <var>y<sub>n</sub></var>
</pre>
<p>
1 è¡ç®ã«ãŽããåã®åæäœçœ®ã®æšªåº§æš <var>px</var> ãšçžŠåº§æš <var>py</var> ãäžããããŸãã
2 è¡ç®ã«ã¹ããªã³ã¯ã©ãŒã®æ° <var>n</var> ãäžããããŸãã
3 è¡ç®ã« <var>i</var> çªç®ã«åäœããã¹ããªã³ã¯ã©ãŒã®æšªåº§æš <var>x<sub>i</sub></var> ãšçžŠåº§æš <var>y<sub>i</sub></var> ãäžããããŸãã
</p>
<p>
å
¥åã¯ãŒãïŒã€ã®è¡ã§çµãããŸããããŒã¿ã»ããã®æ°ã¯ 20 ãè¶
ããŸããã
</p>
<H2>Output</H2>
<p>
åããŒã¿ã»ããã«ã€ããŠãçåã®å Žå㯠OKãããã§ãªãå Žå㯠NA ãïŒè¡ã«åºåããŠãã ããã
</p>
<H2>Sample Input</H2>
<pre>
6 1
10
6 4 3 3 1 2 0 5 4 6 1 8 5 9 7 7 8 6 8 3
6 1
10
6 4 3 3 1 2 0 5 4 6 1 8 5 9 7 7 8 6 9 0
0 0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
OK
NA
</pre>
| [
[
"6 1\n10\n6 4 3 3 1 2 0 5 4 6 1 8 5 9 7 7 8 6 8 3\n6 1\n10\n6 4 3 3 1 2 0 5 4 6 1 8 5 9 7 7 8 6 9 0\n0 0\n",
"6 1\n10\n6 4 3 3 1 2 0 5 4 6 1 8 5 9 7 7 8 6 8 3\n6 1\n10\n6 4 3 3 1 2 0 5 4 6 1 8 5 9 7 7 8 6 9 0\n0 0\n"
]
] |
p00123 | Speed Skating Badge Test |
<h1>ã¹ããŒãã¹ã±ãŒããããžãã¹ã</h1>
<p>
ã¹ããŒãã¹ã±ãŒããããžãã¹ãã§ã¯ã2 çš®é¡ã®è·é¢ã§èŠå®ãããã¿ã€ã ãäžåã£ãå Žåã«çŽãèªå®ãããŸããäŸãã° A çŽã«ãªãã«ã¯ 500 M 㧠40.0 ç§æªæºãã〠1000 M 㧠1 å 23 ç§æªæºã§ããããšãæ±ããããŸãã
</p>
<p>
ã¹ããŒãã¹ã±ãŒãå€§äŒ (500 M ãš 1000 M) ã§èšé²ããã¿ã€ã ãå
¥åãšããã¹ããŒãã¹ã±ãŒããããžãã¹ãã§äœçŽã«çžåœããããåºåããããã°ã©ã ãäœæããŠäžããã500 M ãš1000 M ã®ãããžãã¹ãèŠå®ã¿ã€ã ã¯äžè¡šã®ãšããã§ãã E çŽã«æºããªãã£ãå Žåã«ã¯ãNA ãšåºåããŠãã ããã
</p>
<center>
<table>
<tr><th width="100"></th><th width="120"> 500 M</th><th width="120">1000 M</th></tr>
<tr><td>AAA çŽ</td><td> 35 ç§ 50</td><td> 1 å 11 ç§ 00</td></tr>
<tr><td> AA çŽ </td><td> 37 ç§ 50</td><td> 1 å 17 ç§ 00</td></tr>
<tr><td> A çŽ </td><td> 40 ç§ 00</td><td> 1 å 23 ç§ 00</td></tr>
<tr><td> B çŽ </td><td> 43 ç§ 00</td><td> 1 å 29 ç§ 00</td></tr>
<tr><td> C çŽ </td><td> 50 ç§ 00</td><td> 1 å 45 ç§ 00</td></tr>
<tr><td> D çŽ </td><td> 55 ç§ 00</td><td> 1 å 56 ç§ 00</td></tr>
<tr><td> E çŽ </td><td>1å10 ç§ 00 </td><td>2 å 28 ç§ 00</td></tr>
</table>
</center>
<br/>
<H2>Input</H2>
<p>
è€æ°ã®ããŒã¿ã»ãããäžããããŸããåããŒã¿ã»ãããšããŠã500 M ã¿ã€ã ãš 1000 M ã¿ã€ã ãããããè¡šãå®æ° <var>t<sub>1</sub></var>, <var>t<sub>2</sub></var> (8.0 ≤ <var>t<sub>1</sub></var>, <var>t<sub>2</sub></var> ≤ 360.0) ã空çœåºåãã§äžããããŸãã<var>t<sub>1</sub></var>, <var>t<sub>2</sub></var> ã¯ç§åäœã§å°æ°ç¹ä»¥äžæ倧 2 æ¡ãŸã§ã®æ°åãå«ãå®æ°ã§äžããããŸãã
<p>
ããŒã¿ã»ããã®æ°ã¯ 100 ãè¶
ããŸããã
</p>
<H2>Output</H2>
<p>
åããŒã¿ã»ããããšã«ãå€å®çµæ AAA ~ E ãŸã㯠NA ãïŒè¡ã«åºåããŠãã ããã
</p>
<H2>Sample Input</H2>
<pre>
40.0 70.0
72.5 140.51
</pre>
<H2>Output for the Sample Input</H2>
<pre>
B
NA
</pre>
| [
[
"40.0 70.0\n72.5 140.51\n",
"40.0 70.0\n72.5 140.51\n"
]
] |
p00124 | League Match Score Sheet |
<h1>ãªãŒã°æŠã®ã¹ã³ã¢ã·ãŒã</h1>
<p>
ã¹ããŒãã®å€§äŒã«ã¯ãªãŒã°æŠãšããŒãã¡ã³ãæŠããããŸãããµãã«ãŒã®ãªãŒã°æŠã§ã¯åã»è² ã»åŒåã«ããããç¹æ°ãä»ãããã®åã¡ç¹ã§é äœã競ããŸããåã¡ç¹ã¯ããããå(3ç¹)ãè² (0ç¹)ãåŒå(1ç¹)ã§ãã
</p>
<p>
ããŒã æ°ãšãªãŒã°æŠã®æ瞟ãå
¥åãšããæ瞟ã®è¯ãé (åã¡ç¹ã®å€ãé )ã«äžŠã¹æ¿ããããŒã åãšåã¡ç¹ãåºåããããã°ã©ã ãäœæããŠãã ãããåã¡ç¹ãåç¹ã®å Žåã¯å
¥åé ã«åºåããŠãã ããã
</p>
<H2>Input</H2>
<p>
è€æ°ã®ããŒã¿ã»ãããäžããããŸããåããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããŸãã
</p>
<pre>
<var>n</var>
<var>name<sub>1</sub></var> <var>w<sub>1</sub></var> <var>l<sub>1</sub></var> <var>d<sub>1</sub></var>
<var>name<sub>2</sub></var> <var>w<sub>2</sub></var> <var>l<sub>2</sub></var> <var>d<sub>2</sub></var>
:
<var>name<sub>n</sub></var> <var>w<sub>n</sub></var> <var>l<sub>n</sub></var> <var>d<sub>n</sub></var>
</pre>
<p>
ïŒè¡ç®ã«ããŒã æ° <var>n</var> (<var>n</var> ≤ 10) ãäžããããŸããç¶ã <var>n</var> è¡ã«ããŒã <var>i</var> ã®åå <var>name<sub>i</sub></var> (20æå以å
ã®ã¢ã«ãã¡ããã)ãåã®æ° <var>w<sub>i</sub></var>ãè² ã®æ° <var>l<sub>i</sub></var>ãåŒåã®æ° <var>d<sub>i</sub></var> (0 ≤ <var>w<sub>i</sub></var>, <var>l<sub>i</sub></var>, <var>d<sub>i</sub></var> ≤ 9) ã空çœåºåãã§äžããããŸãã
</p>
<p>
ããŒã æ°ã 0 ã®ãšããå
¥åã®çµäºãšããŸããããŒã¿ã»ããã®æ°ã¯ 50 ãè¶
ããŸããã
</p>
<H2>Output</H2>
<p>
ããŒã¿ã»ããããšã«ã䞊ã¹æ¿ããããŒã ã®ãªã¹ããåºåããŠãã ããã<var>i</var> è¡ç®ã« <var>i</var> çªç®ã®ããŒã ã®ååãšåã¡ç¹ãã«ã³ãã§åºåã£ãŠåºåããŠãã ããã
</p>
<p>
ããŒã¿ã»ããã®éã«ïŒã€ã®ç©ºè¡ãå
¥ããŠãã ããã
</p>
<H2>Sample Input</H2>
<pre>
4
Japan 1 0 2
Egypt 1 2 0
Canada 0 2 1
Spain 2 0 1
3
India 0 2 0
Poland 1 0 1
Italy 1 0 1
0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
Spain,7
Japan,5
Egypt,3
Canada,1
Poland,4
Italy,4
India,0
</pre>
| [
[
"4\nJapan 1 0 2\nEgypt 1 2 0\nCanada 0 2 1\nSpain 2 0 1\n3\nIndia 0 2 0\nPoland 1 0 1\nItaly 1 0 1\n0\n",
"4\nJapan 1 0 2\nEgypt 1 2 0\nCanada 0 2 1\nSpain 2 0 1\n3\nIndia 0 2 0\nPoland 1 0 1\nItaly 1 0 1\n0\n"
]
] |
p00125 | Day Count |
<h1>æ¥æ°</h1>
<p>
2 ã€ã®æ¥ä»ãå
¥åãšãããã® 2 ã€ã®æ¥ä»ãã®éã®æ¥æ°ãåºåããããã°ã©ã ãäœæããŠãã ããã
</p>
<p>
æ¥ä» 1 (<var>y<sub>1</sub>, m<sub>1</sub>, d<sub>1</sub></var>) ã¯æ¥ä» 2 (<var>y<sub>2</sub>, m<sub>2</sub>, d<sub>2</sub></var>) ãšåããããããã¯ãã以åã®æ¥ä»ãšããŸããæ¥ä» 1 ã¯æ¥æ°ã«å«ããæ¥ä» 2 ã¯å«ããŸããããŸããããã幎ãèæ
®ã«ãããŠèšç®ããŠãã ãããããã幎ã®æ¡ä»¶ã¯æ¬¡ã®ãšãããšããŸãã
</p>
<ul>
<li>西æŠå¹Žã 4 ã§å²ãåãã幎ã§ããããšã</li>
<li>ãã ãã100 ã§å²ãåãã幎ã¯ããã幎ãšããªãã</li>
<li>ãããã400 ã§å²ãåãã幎ã¯ããã幎ã§ããã</li>
</ul>
<H2>Input</H2>
<p>
è€æ°ã®ããŒã¿ã»ãããäžããããŸããåããŒã¿ã»ããã®åœ¢åŒã¯ä»¥äžã®ãšããã§ãïŒ
</p>
<pre>
<var>y<sub>1</sub></var> <var>m<sub>1</sub></var> <var>d<sub>1</sub></var> <var>y<sub>2</sub></var> <var>m<sub>2</sub></var> <var>d<sub>2</sub></var>
</pre>
<p>
<var>y<sub>1</sub></var>, <var>m<sub>1</sub></var>, <var>d<sub>1</sub></var>, <var>y<sub>2</sub></var>, <var>m<sub>2</sub></var>, <var>d<sub>2</sub></var> ã®ãããããè² ã®æ°ã®ãšãå
¥åã®çµãããšããŸãã
</p>
<p>
ããŒã¿ã»ããã®æ°ã¯ 50 ãè¶
ããŸããã
</p>
<H2>Output</H2>
<p>
ããŒã¿ã»ããããšã«ãæ¥æ°ãïŒè¡ã«åºåããŠãã ããã
</p>
<H2>Sample Input</H2>
<pre>
2006 9 2 2006 9 3
2006 9 2 2006 11 11
2004 1 1 2005 1 1
2000 1 1 2006 1 1
2000 1 1 2101 1 1
-1 -1 -1 -1 -1 -1
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1
70
366
2192
36890
</pre>
| [
[
"2006 9 2 2006 9 3\n2006 9 2 2006 11 11\n2004 1 1 2005 1 1\n2000 1 1 2006 1 1\n2000 1 1 2101 1 1\n-1 -1 -1 -1 -1 -1\n",
"2006 9 2 2006 9 3\n2006 9 2 2006 11 11\n2004 1 1 2005 1 1\n2000 1 1 2006 1 1\n2000 1 1 2101 1 1\n-1 -1 -1 -1 -1 -1\n"
]
] |
p00126 | Puzzle |
<h1>ããºã«</h1>
<p>
ãããå㯠9 × 9 ã®ãã¹ç®ã« 1ã9 ã®æ°åãé
眮ããããºã«ã§éãã§ããŸãããã®ããºã«ã§ã¯ä»¥äžã®èŠåã§æ°åãé
眮ããªããã°ãããŸããã
</p>
<ul>
<li>åãåã« 1 ã€ã®æ°åã¯ã¡ããã© 1 åã ãçŸããã</li>
<li>åãè¡ã« 1 ã€ã®æ°åã¯ã¡ããã© 1 åã ãçŸããã</li>
<li>äºéç·ã§åºåããã 3 × 3 ã®åç¯å²ã«ã¯ã1 ã€ã®æ°åã¯ã¡ããã© 1 åã ãçŸããã</li>
</ul>
<p>
äŸãã°ãäžã®å³ 1 ã¯ãã®ãããªèŠåãæºãããé
眮ã®äžã€ã§ããããããããåã¯ãå³ 2 ã®ããã«ããèŠåã«åããé
眮ãäœã£ãŠããŸããŸãã巊端ã®åã«ã2ãã 2 åçŸãããŠãã1ãã 1 åãçŸããããå·Šãã2 çªç®ã®åã«ã1ãã 2 åçŸãããŠãã2ãã 1 åãçŸãããŠããŸããã
</p>
<center>
<table>
<tr>
<td width="280"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_puzzle1"></td>
<td width="280"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_puzzle2"></td>
</tr>
<tr>
<th>å³ 1 </th>
<th>å³ 2 </th>
</tr>
</table>
</center>
<br/>
<p>
ãããåãå©ããããã«ãæ°åã®é
眮ãèªã¿èŸŒãã§ããã®é
眮ãèŠåãæºãããŠãããã©ããã調ã¹ãèŠåã«åããŠããããã®å Žæãåºåããããã°ã©ã ãäœæããŠãã ããã3 ã€ã®èŠåã«ç
§ãããŠèª€ã£ãŠãã (2 å以äžçŸããŠãã) æ°åã®åã«ã¯ * (åè§ã¢ã¹ã¿ãªã¹ã¯)ãã誀ã£ãŠããªãæ°åã®åã«ã¯ç©ºçœã衚瀺ããŠãã ããã
</p>
<H2>Input</H2>
<p>
è€æ°ã®ããŒã¿ã»ãããäžããããŸããæåã®è¡ã«ããŒã¿ã»ããã®æ° <var>n</var> (<var>n</var> ≤ 20) ãäžããããŸããåããŒã¿ã»ãããšããŠãããºã«ã®ç¶æ
ã瀺ã 1 è¡ 9 æåã9 è¡ãããªãæ°ååãäžããããŸãã
</p>
<H2>Output</H2>
<p>
åããŒã¿ã»ããã«ã€ããŠä»¥äžãåºåããŠãã ããã
</p>
<p>
äžããããæ°åãš * (åè§ã¢ã¹ã¿ãªã¹ã¯)ãšç©ºçœã誀ã£ãŠããæ°åã®åã«ã¯ *ã誀ã£ãŠããªãæ°åã®åã«ã¯åè§ç©ºçœãä»å ããã
</p>
<p>
ããŒã¿ã»ããã®éã« 1 è¡ã®ç©ºè¡ãå
¥ããŠãã ããã
</p>
<H2>Sample Input</H2>
<pre>
2
2 1 3 4 5 6 7 8 9
4 5 6 7 8 9 1 2 3
7 8 9 1 2 3 4 5 6
2 3 4 5 6 7 8 9 1
5 6 7 8 9 1 2 3 4
8 9 1 2 3 4 5 6 7
3 4 5 6 7 8 9 1 2
6 7 8 9 1 2 3 4 5
9 1 2 3 4 5 6 7 8
2 1 3 4 5 6 7 8 9
4 5 6 7 8 9 1 2 3
7 8 9 1 2 3 4 5 6
2 3 4 5 6 7 8 9 1
5 6 7 8 9 1 2 3 4
8 9 1 2 3 4 5 6 7
3 4 5 6 7 8 9 1 2
6 7 8 9 1 2 3 4 5
9 1 2 3 4 5 6 7 8
</pre>
<H2>Output for the Sample Input</H2>
<pre>
*2*1 3 4 5 6 7 8 9
4 5 6 7 8 9 1 2 3
7 8 9 1 2 3 4 5 6
*2 3 4 5 6 7 8 9 1
5 6 7 8 9 1 2 3 4
8 9 1 2 3 4 5 6 7
3 4 5 6 7 8 9 1 2
6 7 8 9 1 2 3 4 5
9*1 2 3 4 5 6 7 8
*2*1 3 4 5 6 7 8 9
4 5 6 7 8 9 1 2 3
7 8 9 1 2 3 4 5 6
*2 3 4 5 6 7 8 9 1
5 6 7 8 9 1 2 3 4
8 9 1 2 3 4 5 6 7
3 4 5 6 7 8 9 1 2
6 7 8 9 1 2 3 4 5
9*1 2 3 4 5 6 7 8
</pre>
| [
[
"2\n2 1 3 4 5 6 7 8 9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6\n2 3 4 5 6 7 8 9 1\n5 6 7 8 9 1 2 3 4\n8 9 1 2 3 4 5 6 7\n3 4 5 6 7 8 9 1 2\n6 7 8 9 1 2 3 4 5\n9 1 2 3 4 5 6 7 8\n2 1 3 4 5 6 7 8 9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6\n2 3 4 5 6 7 8 9 1\n5 6 7 8 9 1 2 3 4\n8 9 1 2 3 4 5 6 7\n3 4 5 6 7 8 9 1 2\n6 7 8 9 1 2 3 4 5\n9 1 2 3 4 5 6 7 8\n",
"2\n2 1 3 4 5 6 7 8 9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6\n2 3 4 5 6 7 8 9 1\n5 6 7 8 9 1 2 3 4\n8 9 1 2 3 4 5 6 7\n3 4 5 6 7 8 9 1 2\n6 7 8 9 1 2 3 4 5\n9 1 2 3 4 5 6 7 8\n2 1 3 4 5 6 7 8 9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6\n2 3 4 5 6 7 8 9 1\n5 6 7 8 9 1 2 3 4\n8 9 1 2 3 4 5 6 7\n3 4 5 6 7 8 9 1 2\n6 7 8 9 1 2 3 4 5\n9 1 2 3 4 5 6 7 8\n"
]
] |
p00127 | Pocket Pager Input |
<h1>ãã±ãã«æã¡</h1>
<p>
ããæ¥ããããåã¯ãæ¬æã«ã519345213244ããšããæ°åã ããæžããŠããããããªã¡ãŒã«ãåãåã
ãŸããããã®ã¡ãŒã«ã¯ã10 æ³å¹Žäžã®åŸå§ããã ã£ãã®ã§é»è©±ããŠèããŠã¿ããšããããæ¥ãã§ããã
ãã±ãã«æã¡ã§éã£ã¡ãã£ãã䟿å©ããããããããã£!ããšãã£ãŠåãããŠããŸããŸããããã€ã
ããããªããå°ã匷åŒãªãšããã®ãããã®åŸå§ãããç¥ããããåã¯ãä»æ¹ãªãèªåã§ããã±ãã«æ
ã¡ãã«ã€ããŠèª¿ã¹ãŠã¿ããšã10 幎ãããåã«äžäžã颚é¡ããããªå
¥åã®æ¹æ³ã ãšããããšãåãããŸã
ãã
</p>
<p>
ããã±ãã«æã¡ãã§ã¯ãå³ 1 ã®ãããªå€æè¡šã«åŸãâãâ㯠11ãâãâ㯠15 ãšããå
·åã«ã2 ã€ã®æ°å
ã§äžã€ã®æåãå
¥åããŠãããŸããäŸãã°ããªããšããšããæååãå
¥åããã«ã¯ã519345ããšæã¡ãŸ
ããåŸã£ãŠãã©ã®æåã 2 ã€ã®æ°åã§å
¥åããããšãã§ããã®ã§ãã
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_pocketPager1">
<p>å³1</i>
</center>
<p>
æºåž¯é»è©±ããŸã åºãæ®åããŠããªããããé«æ ¡çã¯ãã®æ¹æ³ã§å
¬è¡é»è©±ããåéã®ãã±ãã«ã«ã¡ãã»ãŒ
ãžãéä¿¡ããŠããã®ã ããã§ããççãªã¹ããŒãã§ãã±ãã«æã¡ãã§ãã女åé«çããããšããæè¿ã
ä»äºãå¿ãããªã£ãŠããåŸå§ã¯ãã¡ãŒã«ãç¡æèã®ãã¡ã«ãã±ãã«æã¡ã§ã¿ã€ãããããã«ãªã£ãŠããŸ
ããŸããã
</p>
<p>
ããã§ãæ¯å解èªã«èŠåŽããŠãããããåãå©ããããã«ããã±ãã«æã¡ã«ããã¡ãã»ãŒãžãæåå
ã«å€æãåºåããããã°ã©ã ãäœæããŠãã ããããã ããå€æã«ã¯å³2ã®å€æè¡šã䜿ããè±
å°æååã³ãã.ããã?ããã!ãã空çœã®ã¿ã察象ãšããŸããå€æåºæ¥ãªãæåãå«ãã¡ãã»ãŒãžã«å¯ŸããŠã¯ NA ãšåºåããŠãã ããã
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_pocketPager2">
<p>å³2</i>
</center>
<H2>Input</H2>
<p>
è€æ°ã®ã¡ãã»ãŒãžãäžããããŸããåè¡ã«ïŒã€ã®ã¡ãã»ãŒãž (200 æå以å
) ãäžããããŸããã¡ãã»ãŒãžã®ç·æ°ã¯ 50 ãè¶
ããŸããã
</p>
<H2>Output</H2>
<p>
åã¡ãã»ãŒãžã«å¯ŸããŠãå€æåŸã®ã¡ãã»ãŒãžãŸã㯠NA ãïŒè¡ã«åºåããŠãã ããã
</p>
<H2>Sample Input</H2>
<pre>
341143514535
314
143565553551655311343411652235654535651124615163
551544654451431564
4
3411
6363636363
153414
</pre>
<H2>Output for the Sample Input</H2>
<pre>
naruto
NA
do you wanna go to aizu?
yes sure!
NA
na
?????
end
</pre>
| [
[
"341143514535\n314\n143565553551655311343411652235654535651124615163\n551544654451431564\n4\n3411\n6363636363\n153414\n",
"341143514535\n314\n143565553551655311343411652235654535651124615163\n551544654451431564\n4\n3411\n6363636363\n153414\n"
]
] |
p00128 | Abacus |
<h1>ããã°ã</h1>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_abacus1">
</center>
<br/>
<p>
ããã°ããç¿ãå§ããå人ããã®ãé¡ãã§ãããªãã¯ããã°ãã®ç ã®äžŠã³
ã衚瀺ããããã°ã©ã ãäœæããããšã«ãªããŸãããããæ°åãå
¥åãšããŠãããã°ãã®ç ã®äžŠã³ãåºåããããã°ã©ã ãäœæããŠãã ããããã ãã衚瀺ããããã°ãã®æ¡æ°ã¯ 5 æ¡ãšãã0 ãã 9 ãŸã§ã®ç ã®é
眮ã¯ãããã '<span>*</span>' (åè§ã¢ã¹ã¿ãªã¹ã¯)ã'<span> </span>' (åè§ç©ºçœ)ã'<span>=</span>' (åè§ã€ã³ãŒã«) ãçšããŠä»¥äžã®ããã«è¡šããã®ãšããŸãã
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_abacus2">
</center>
<br/>
<H2>Input</H2>
<p>
è€æ°ã®ãã¹ãã±ãŒã¹ãäžããããŸããåãã¹ãã±ãŒã¹ãšã㊠5 æ¡ãŸã§ã®æ°åïŒæŽæ°ïŒã ïŒ è¡ã«äžããããŸãã
</p>
<p>
ãã¹ãã±ãŒã¹ã®æ°ã¯ 1024 ãè¶
ããŸããã
</p>
<H2>Output</H2>
<p>
åãã¹ãã±ãŒã¹ã€ããŠããã°ãã®ç ã®é
眮ãåºåããŠãã ããããã¹ãã±ãŒã¹ã®éã«ïŒè¡ã®ç©ºè¡ãå
¥ããŠãã ããã
</p>
<H2>Sample Input</H2>
<pre>
2006
1111
</pre>
<H2>Output for the Sample Input</H2>
<pre>
****
*
=====
* *
****
* ***
*****
*****
*****
=====
****
*
*****
*****
*****
</pre>
| [
[
"2006\n1111\n",
"2006\n1111\n"
]
] |
p00129 | Hide-and-Seek Supporting System |
<h1>ãããããŒã</H1>
<p>
ãããåã¯ãããããŒããèŠæã§ããé ãããšããèŠã€ãã£ã¡ããããé ããŠããåããªããªãèŠã€ããããšãã§ããŸãããèŠããããç¶ããã¯ãè¶
é«æ§èœäœçœ®æ¢çŽ¢ã·ã¹ãã ãäœã£ãŠãããŸãããããã䜿ããšèªåã®äœçœ®ãå«ããŠãåéã®äœçœ®ãæ£ç¢ºã«ç¥ãããšãã§ããŸãã鬌ã«ãªã£ãããé ããŠããåãæ¢ãããšãç°¡åã«ã§ããããã«ãªããŸããã
</p>
<!--
èŠã€ãããåã®äœçœ®ã«è¡ãã°ããã㧠OK ã®ã¯ãã§ããããã䜿ã£ãŠããããšãã°ãããšéãã§ããããªããªãã®ã§å
ç·ã§äœ¿ããŸãã
-->
<p>
ãããåã¯ããã«ãã®ã·ã¹ãã ãé²åããã鬌ããèªåãèŠãããåŠããå€å®ããæ©èœãä»å ããããšãæãã€ããŸããããããã§ããã°ããããããããããšèšãããŠããèŠããäœçœ®ã«ããã°ããŸãã ã ããã ããèŠããªãäœçœ®ã«ããã°ãããããããã§ããããã€ãéãã§ããå
¬åã«ã¯å€§å°ããŸããŸãªåç圢ã®å£ããããŸãããã®å£ã¯å€ããã¯äžã¯èŠããªãããäžããå€ãèŠããŸããã鬌ãšäžç·ã«äžã«å
¥ããšå¥ã®å£ããªããã°èŠãã¡ãããŸãã
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_hideandseek">
</center>
<br/>
<p>
ãããåã¯ã¢ã€ãã¢ã¯ããã®ã§ããããœãããäœãã®ãèŠæã§ããããã§èŠªåã®ããªãã¯ãããåã«ä»£ãã£ãŠãã鬌ããèŠããªãããšç¢ºèªã·ã¹ãã ãã®ãœãããŠã§ã¢ãäœãããšã«ãªããŸãããå
¬åã®å£ã¯åºå®ãããŠããŸããããããåãšé¬Œã®ãããããªäœçœ®æ
å ±ã«å¯ŸããŠèŠãããåŠããå€å®ããå¿
èŠããããŸãã
</p>
<p>
å
¬åã«ããå£ã®æ
å ±(äžå¿ã®åº§æš (<var>wx</var>, <var>wy</var>) ãš ååŸ <var>r</var>) ãšãããåãšé¬Œã®äœçœ®æ
å ±(ãããåã®äœçœ®ã®åº§æš (<var>tx</var>, <var>ty</var>) ãšé¬Œã®äœçœ®ã®åº§æš (<var>sx</var>, <var>sy</var>) ) ãå
¥åãšãããã®äœçœ®ã§é¬ŒãããããåãèŠãããåŠããå€å®ããããã°ã©ã ãäœæããŠãã ããã
</p>
<p>
ãªãã鬌ãããããåãèŠããå Žåã«ã¯ DangerãèŠããªãå Žåã«ã¯ Safe ãšåºåããŠãã ããã鬌ãšãããåã®äœçœ®ãçµãã ç·åäžã«å£ãããå Žåã«ã¯èŠããªããã®ãšãã鬌ããããåãå£ã®äžã«ã¯ããªããã®ãšããŸãã
</p>
<H2>Input</H2>
<p>
è€æ°ã®ããŒã¿ã»ãããäžããããŸããåããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããŸãã
</p>
<pre>
<var>n</var>
<var>wx<sub>1</sub></var> <var>wy<sub>1</sub></var> <var>r<sub>1</sub></var>
<var>wx<sub>2</sub></var> <var>wy<sub>2</sub></var> <var>r<sub>2</sub></var>
:
<var>wx<sub>n</sub></var> <var>wy<sub>n</sub></var> <var>r<sub>n</sub></var>
<var>m</var>
<var>tx<sub>1</sub></var> <var>ty<sub>1</sub></var> <var>sx<sub>1</sub></var> <var>sy<sub>1</sub></var>
<var>tx<sub>2</sub></var> <var>ty<sub>2</sub></var> <var>sx<sub>2</sub></var> <var>sy<sub>2</sub></var>
:
<var>tx<sub>m</sub></var> <var>ty<sub>m</sub></var> <var>sx<sub>m</sub></var> <var>sy<sub>m</sub></var>
</pre>
<p>
1 è¡ç®ã«åç圢ã®å£ã®æ° <var>n</var> (0 ≤ <var>n</var> ≤ 100)ãç¶ã <var>n</var> è¡ã«å£ <var>i</var> ã®äžå¿ã®åº§æšãè¡šãæŽæ° <var>wx<sub>i</sub></var>, <var>wy<sub>i</sub></var> (0 ≤ <var>wx<sub>i</sub></var>, <var>wy<sub>i</sub></var> ≤ 255) ãšååŸãè¡šãæŽæ° <var>r<sub>i</sub></var> (1 ≤ <var>r<sub>i</sub></var> ≤ 255) ãäžããããŸãã
</p>
<p>
ç¶ãè¡ã«ãããåãšé¬Œã®äœçœ®æ
å ±ã®åæ° <var>m</var> (m ≤ 100)ãç¶ã <var>m</var> è¡ã«äœçœ®æ
å ± <var>i</var> ã®ãããåã®äœçœ®ã®åº§æšãè¡šãæŽæ° <var>tx<sub>i</sub></var>, <var>ty<sub>i</sub></var> (0 ≤ <var>tx<sub>i</sub></var>, <var>ty<sub>i</sub></var> ≤ 255) ãšé¬Œã®äœçœ®ã®åº§æšãè¡šãæŽæ° <var>sx<sub>i</sub></var>, <var>sy<sub>i</sub></var> (0 ≤ <var>sx<sub>i</sub></var>, <var>sy<sub>i</sub></var> ≤ 255) ãäžããããŸãã
</p>
<p>
ãŸããåç圢ã®å£ã®äžéšã ããå
¬åã«ãããšããããšã¯ãªããå
šãŠã®å£ã¯åçãšããŠãå
¬åã®å
éšã«å
¥ã£ãŠããŸãã
</p>
<p>
<var>n</var> ã 0 ã®ãšãå
¥åã®çµããã瀺ããŸããããŒã¿ã»ããã®æ°ã¯ 20 ãè¶
ããŸããã
</p>
<H2>Output</H2>
<p>
åããŒã¿ã»ããã«ã€ããŠãäœçœ®æ
å ± <var>i</var> ã®å€å®çµæ Danger ãŸã㯠Safe ã <var>i</var> è¡ç®ã«åºåããŠãã ããã
</p>
<H2>Sample Input</H2>
<pre>
3
6 6 3
19 7 4
21 8 1
6
5 4 2 11
12 4 2 11
11 9 2 11
14 3 20 5
17 9 20 5
20 10 20 5
0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
Safe
Safe
Danger
Safe
Danger
Safe
</pre>
| [
[
"3\n6 6 3\n19 7 4\n21 8 1\n6\n5 4 2 11\n12 4 2 11\n11 9 2 11\n14 3 20 5\n17 9 20 5\n20 10 20 5\n0\n",
"3\n6 6 3\n19 7 4\n21 8 1\n6\n5 4 2 11\n12 4 2 11\n11 9 2 11\n14 3 20 5\n17 9 20 5\n20 10 20 5\n0\n"
]
] |
p00130 | Train |
<h1>åè»</h1>
<p>
26 䞡以äžã®ç·šæã®åè»ããããŸããããããã®è»äž¡ã«ã¯ãè±å°æåã® a ãã z ãŸã§ã®èå¥èšå·ãä»ããŠããŸããåãèšå·ãä»ããŠããè»äž¡ã¯ãããŸããããã ããè»äž¡ãé£çµããé çªã¯èªç±ãšããŸããåè»ã®äžãè»æãå·¡åããŸããè»æã¯ãåè»ã®äžãè¡ã£ããæ¥ããããŠå·¡åããã®ã§ãåãè»äž¡ãäœåºŠãéãããšããããŸãããã ãããã¹ãŠã®è»äž¡ãæäœäžåã¯å·¡åãããã®ãšããŸãããŸããå·¡åãã¯ãããè»äž¡ãå·¡åãçµããè»äž¡ãåè»ã®äžçªç«¯ã®è»äž¡ãšã¯éããŸããã
</p>
<p>
ããè»æãä¹ã£ããã¹ãŠã®åè»ã®å·¡åèšé²ããããŸããããããåããååè»ã®ç·šæãå
é è»äž¡ããåºåããããã°ã©ã ãäœæããŠãã ãããå·¡åèšé²ã¯ 1 è¡ã 1 ã€ã®åè»ã«å¯Ÿå¿ããŸããåè¡ã¯ãè±å°æåã 1 æåã〠<span><-</span> ãŸã㯠<span>-></span> ã§åºåã£ãæååã§ã§ããŠããŸãã<span><-</span> ã¯åæ¹ã®è»äž¡ãžã®ç§»åã<span>-></span> ã¯åŸæ¹ã®è»äž¡ãžã®ç§»åãè¡šããŸãã
</p>
<p>
äŸãã°ã<span>a->b<-a<-c</span> ã¯è»äž¡ a ããåŸæ¹ã®è»äž¡ã§ãã b ã«ç§»ããb ããåæ¹ã® a ã«ç§»ããa ããåæ¹ã® c ãžç§»ã£ãããšãè¡šããŸãããã®å Žåã®åè»ã®ç·šæã¯å
é è»äž¡ãã <span>cab</span> ãšãªããŸãã
</p>
<H2>Input</H2>
<p>
ïŒè¡ç®ã«å·¡åèšé²ã®åæ° <var>n</var> (<var>n</var> ≤ 50)ãç¶ã <var>n</var> è¡ã«å·¡åèšé² <var>i</var> ãè¡šãæåå <var>s<sub>i</sub></var> (1024æåãŸã§ã®åè§æåå) ãäžããããŸãã
</p>
<H2>Output</H2>
<p>
å·¡åèšé² <var>i</var> ã«ã€ããŠãå
é è»äž¡ããã®åè»ã®ç·šæãçŸãæååã <var>i</var> è¡ç®ã«åºåããŠãã ããã
</p>
<H2>Sample Input</H2>
<pre>
4
a->e->c->b->d
b<-c<-a<-d<-e
b->a->c<-a->c->d<-c<-a<-b->a->c->d->e<-d
a->e<-a<-d->a->e<-a<-d<-c->d->a<-d<-c<-b->c->d<-c
</pre>
<H2>Output for the Sample Input</H2>
<pre>
aecbd
edacb
bacde
bcdae
</pre>
| [
[
"4\na->e->c->b->d\nb\n",
"4\na->e->c->b->d\nb\n"
]
] |
p00131 | Doctor's Strange Particles |
<h1>å士ã®å
é»ç®¡</h1>
<p>
å士 : ããŒã¿ãŒåããã£ããã
</p>
<p>
ããŒã¿ãŒ : ãŸãã§ãããä»åºŠã¯ã©ããªãã ããªãçºæã§ããã
</p>
<p>
å士 : ãã®å¹»ã®çŽ ç²åã¢ãã·ãªã³ã®æ€åºåšãçºæãããããã
</p>
<p>
ããŒã¿ãŒ : ã¢ãã·ãªã³ãšããã°ã欧å·ååååæ žç 究æ©æ§ (CERN) ãã¯ãããšããç 究è
ãã¡ãè¡çŒã§è¿œã£ãããŠãããšãããããã§ããããæ¬åœã§ããã?
</p>
<p>
å士 : æ¬åœã ã£ãŠã°ãã现ãã説æã¯çãããéåžžã«åŒ·åãªç£å Žãå
èµããç¹æ®ãªå
é»ç®¡ãå
ãããšã«ãã£ãŠãééããã¢ãã·ãªã³ãæ€åºããã
</p>
<p>
ããŒã¿ãŒ : ä» ã«å
ãããŠæ€åºããã°ãå°æŽå
çã®ãã¥ãŒããªãæ€åºã«å¹æµããããŒãã«è³çŽã®ç 究ã§ããã
ããã§åœ¹ç«ããã®ç 究ã°ããããŠããããã¡ç 究宀ããªã©ãšããæ±åãè¿äžã§ããŸããã
</p>
<p>
å士 : ããã ãšããå°æŽå
çã®ãã¹ãŒããŒã«ããªã«ã³ããã«ãããã£ãŠããã®è£
眮ãã(æªå£èšã£ãã)ãã¿ããžã£ãªã«ã³ãããšåœåããã
</p>
<p>
ããŒã¿ãŒ : ã¡ãã£ãšèŠããã£ãŠèšãããåå±ã£ãŠèšããã»ã»ã»ã
</p>
<p>
å士 : ããã¯ãããšããŠããã®è£
眮ã¡ãã£ãšããçãããããããã
ã¢ãã·ãªã³ç²åãããå
é»ç®¡ãééãããšãæ床ã®é¢ä¿ã§ãã®å
é»ç®¡ãšé£æ¥ããäžäžå·Šå³ã®å
é»ç®¡ãåå¿ããã
</p>
<center>
<table>
<tr><td>å³1</td><td width=80></td><td>å³2</td></tr>
<tr>
<td>
<table>
<tr>
<td>
<table>
<tr><td width="28" align="center">â
</td><td width="28" align="center">â</td><td width="28" align="center">â</td><td width="28" align="center">â</td><td width="28" align="center">â</td></tr>
<tr><td width="28" align="center">â</td><td width="28" align="center">â</td><td width="28" align="center">â</td><td width="28" align="center">â
</td><td width="28" align="center">â</td></tr>
<tr><td width="28" align="center">â</td><td width="28" align="center">â</td><td width="28" align="center">â</td><td width="28" align="center">â</td><td width="28" align="center">â</td></tr>
<tr><td width="28" align="center">â</td><td width="28" align="center">â</td><td width="28" align="center">â</td><td width="28" align="center">â</td><td width="28" align="center">â</td></tr>
<tr><td width="28" align="center">â</td><td width="28" align="center">â</td><td width="28" align="center">â
</td><td width="28" align="center">â</td><td width="28" align="center">â</td></tr>
</table>
</td>
<td>
<table>
<tr><td> </td></tr>
<tr><td> </td></tr>
<tr><td width="40"> → </td></tr>
<tr><td> </td></tr>
<tr><td> </td></tr>
</table>
</td>
<td>
<table>
<tr><td width="28">â</td><td width="28">â</td><td width="28">â</td><td width="28">â</td><td width="28">â</td></tr>
<tr><td>â</td><td>â</td><td>â</td><td>â</td><td>â</td></tr>
<tr><td>â</td><td>â</td><td>â</td><td>â</td><td>â</td></tr>
<tr><td>â</td><td>â</td><td>â</td><td>â</td><td>â</td></tr>
<tr><td>â</td><td>â</td><td>â</td><td>â</td><td>â</td></tr>
</table>
</td>
</tr>
</table>
</td>
<td></td>
<td>
<table>
<tr>
<td>
<table>
<tr><td width="28">â</td><td width="28">â</td><td width="28">â</td><td width="28">â</td><td width="28">â</td></tr>
<tr><td>â</td><td>â
</td><td>â
</td><td>â</td><td>â</td></tr>
<tr><td>â</td><td>â</td><td>â</td><td>â</td><td>â</td></tr>
<tr><td>â</td><td>â</td><td>â</td><td>â</td><td>â</td></tr>
<tr><td>â</td><td>â</td><td>â</td><td>â</td><td>â</td></tr>
</table>
</td>
<td>
<table>
<tr><td> </td></tr>
<tr><td> </td></tr>
<tr><td width="40"> → </td></tr>
<tr><td> </td></tr>
<tr><td> </td></tr>
</table>
</td>
<td>
<table>
<tr><td width="28">â</td><td width="28">â</td><td width="28">â</td><td width="28">â</td><td width="28">â</td></tr>
<tr><td>â</td><td>â</td><td>â</td><td>â</td><td>â</td></tr>
<tr><td>â</td><td>â</td><td>â</td><td>â</td><td>â</td></tr>
<tr><td>â</td><td>â</td><td>â</td><td>â</td><td>â</td></tr>
<tr><td>â</td><td>â</td><td>â</td><td>â</td><td>â</td></tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</center>
<br/>
<p>
ããŒã¿ãŒ : ã€ãŸããå³1ã®å·ŠåŽâ
å°ã®å
é»ç®¡ãç²åãééããå Žåã
å³åŽã®ããã«ç¹ç¯ãããšèšãããšã§ããã
(å³ã¯ 5 × 5 ã®äŸãé»ã¯æ¶ç¯ã»çœã¯ç¹ç¯ç¶æ
ã以äžåãã)
</p>
<p>
å士 : ãŸãåå¿ãšã¯ãå
é»ç®¡ã®ç¶æ
ãå転ãããã€ãŸãæ¶ããŠããå
é»ç®¡ã¯å
ãã
å
ã£ãŠããå
é»ç®¡ã¯æ¶ããã
</p>
<p>
ããŒã¿ãŒ : ã€ãŸããå³2ã®å·ŠåŽã®â
å°ãâå°ãç²åãééããå Žåãå³åŽã®ãããªç¶æ
ã«ãªããšã
</p>
<p>
å士 : ãããæ£æ¹åœ¢ã«ãªããš 100 å (10 × 10) é
眮ããŠåŸ
ã¡åããããã ã
</p>
<p>
ããŒã¿ãŒ : ããã ãã®å€§çºæãããŒãã«è³éžèå§å¡äŒãããããã£ãªã«ã³ãããªããŠã
</p>
<p>
å士 : ããããŒã¿ãŒåãåãæãç 究宀ã®äœé¢šã«ãªããã§ããããã ããããæãã ã
ã§ã¯ãæ©éå®éšãå§ãããããŸãã¯ãã®è£
眮ãçŸåšã©ã³ãã ã«å
é»ç®¡ãç¹ããŠããã®ã§ã
å®éšãå§ããããããã«å
šéšæ¶ããç¶æ
ã«ãªã»ããããŠããããŸãã
ãªãã«ãã©ã®å
é»ç®¡ã«ã¢ãã·ãªã³ç²åãåœãŠãã°å
šéšæ¶ãããèããã°ããã ããããã
ç°¡åã ãã?
</p>
<p>
ããŒã¿ãŒ : èããã®ã¯ãããã§ããå士ãåœãŠãããã«ã¯ã
å¹»ã®ã¢ãã·ãªã³ç²åãçºçãããŠæã¡èŸŒããè£
眮ããªããšãããªãããããªãã§ããã
</p>
<p>
å士 : ã»ã»ã»ã
</p>
<p>
å士ãšããŒã¿ (åæã«)ã³ãªã£ã¢ã«ã³ã!ã ã¯ã¯ã¯ã»ã»ã»ã»ã
ãŒ:
</p>
<p>
ãšããããšã§ãæ¬æ¥ãåæ°ãããããšæ®ããŠããå士ã®ç 究宀ã§ãããäŸã«ãã£ãŠè©±ã¯å
šãé²ã¿ããããããŸããããããããªãã®ã§ãããŒã¿ãŒåã«ä»£ãã£ãŠããã°ã©ã ãäœæããŠãããŠãã ããã
ããã°ã©ã ã¯æ¬¡ã®ãããªãã®ã«ãªããŸãã
</p>
<p>
A. è£
眮ã®å
é»ç®¡ã®ç¶æ
ã 10 × 10 ã®é
åãšããŠå
¥åããŸãã0ã¯æ¶ç¯äžã1ã¯ç¹ç¯äžãè¡šããŸãã
0 ãš 1 以å€ã®ããŒã¿ã¯å«ãŸããŸããã
</p>
<p>
B. å
¥åããè£
眮ã®ç¶æ
ããã¹ãŠæ¶ç¯ã«ããããã«ãã¢ãã·ãªã³ç²åãééãããäœçœ®ãèšç®ããŠåºåããŸããããã¯ãå
¥åãšåã 10 × 10ã®é
åã§å
é»ç®¡ã®äœçœ®ãè¡šããŸããã0 ã¯ééãããªãããã1 ã¯ééããããããšãè¡šããŸãããã¹ãŠãæ¶ç¯ããæ¹æ³ã¯å¿
ã 1 éãã ãååšãããã®ãšããŸãã
</p>
<!--
ãªãã以äžã¯ãã³ãã§ãã
a. ç²åãééãããé çªã¯çµæã«é¢ä¿ãããŸããã
b. ç²åãå¶æ°åééãããããšã¯ééãããªãããšãšåãã§ãã ãŸããå¥æ°åééãããã
ãšã¯1åééãããããšãšåãã§ãã
c. 以äžããããã¹ãŠã®å
é»ç®¡ã«ã€ããŠ0(ééãããªã)ãš 1(ééããã)ã®ã©ã¡ãããéž
æããããšãããªãã¡è§£çã«ãªããŸãã
C. ããã°ã©ã ãçµäºããŸãã
-->
<H2>Input</H2>
<p>
è€æ°ã®ããŒã¿ã»ãããäžããããŸããïŒè¡ç®ã«ããŒã¿ã»ããã®æ° <var>n</var> (<var>n</var> ≤ 20) ãäžããããŸããåããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããŸãã
</p>
<pre>
<var>a<sub>1,1</sub></var> <var>a<sub>1,2</sub></var> ... <var>a<sub>1,10</sub></var>
<var>a<sub>2,1</sub></var> <var>a<sub>2,2</sub></var> ... <var>a<sub>2,10</sub></var>
:
<var>a<sub>10,1</sub></var> <var>a<sub>10,2</sub></var> ... <var>a<sub>10,10</sub></var>
</pre>
<p>
<var>a<sub>i,j</sub></var> ã¯è£
眮㮠<var>i</var> è¡ç® <var>j</var> åç®ã®å
é»ç®¡ã®ç¶æ
ã瀺ãæŽæ° (0 ãŸã㯠1) ãè¡šããŸãã
</p>
<H2>Output</H2>
<p>
åããŒã¿ã»ããã«ã€ããŠãç²åãééãããäœçœ®ã以äžã®åœ¢åŒã§åºåããŠãã ããã
</p>
<pre>
<var>b<sub>1,1</sub></var> <var>b<sub>1,2</sub></var> ... <var>b<sub>1,10</sub></var>
<var>b<sub>2,1</sub></var> <var>b<sub>2,2</sub></var> ... <var>b<sub>2,10</sub></var>
:
<var>b<sub>10,1</sub></var> <var>b<sub>10,2</sub></var> ... <var>b<sub>10,10</sub></var>
</pre>
<p>
<var>b<sub>i,j</sub></var> ã¯è£
眮㮠<var>i</var> è¡ç® <var>j</var> åç®ã®å
é»ç®¡ã«ç²åãééããããããªãã瀺ãæŽæ° (0 ãŸã㯠1) ãè¡šããŸãã
</p>
<H2>Sample Input</H2>
<pre>
1
0 1 0 0 0 0 0 0 0 0
1 1 1 0 0 0 0 0 0 0
0 1 0 0 0 0 0 0 0 0
0 0 0 0 1 1 0 0 0 0
0 0 0 1 0 0 1 0 0 0
0 0 0 0 1 1 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 1 0
0 0 0 0 0 0 0 1 1 1
0 0 0 0 0 0 0 0 1 0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
0 0 0 0 0 0 0 0 0 0
0 1 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 1 1 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 1 0
0 0 0 0 0 0 0 0 0 0
</pre>
| [
[
"1\n0 1 0 0 0 0 0 0 0 0\n1 1 1 0 0 0 0 0 0 0\n0 1 0 0 0 0 0 0 0 0\n0 0 0 0 1 1 0 0 0 0\n0 0 0 1 0 0 1 0 0 0\n0 0 0 0 1 1 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 1 0\n0 0 0 0 0 0 0 1 1 1\n0 0 0 0 0 0 0 0 1 0\n",
"1\n0 1 0 0 0 0 0 0 0 0\n1 1 1 0 0 0 0 0 0 0\n0 1 0 0 0 0 0 0 0 0\n0 0 0 0 1 1 0 0 0 0\n0 0 0 1 0 0 1 0 0 0\n0 0 0 0 1 1 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 1 0\n0 0 0 0 0 0 0 1 1 1\n0 0 0 0 0 0 0 0 1 0\n"
]
] |
p00132 | Jigsaw Puzzle |
<h1>ãžã°ãœãŒããºã«</h1>
<p>
åäŸãã倧人ãŸã§è³ãã¬ç³»ããºã«ã²ãŒã ãæµè¡ããŠããŸããæã
ãé
ããåãã¬ãããããºã«ã²ãŒã ãäœã£ãŠã¿ããªã§éã¶ããšã«ããŸããã
</p>
<p>
æã
ãèããã®ã¯ãžã°ãœãŒããºã«ã®ã²ãŒã ã§ãæªå®æã®éšåãåããã®ã«å¿
èŠãªããŒã¹ãéžã¶ãšãããã®ã§ããå³ 1 (a) ã¯ããºã«ã®æ ã®äŸã§ããé»ãåãŸã£ãŠããéšåãçœãæªå®æã®éšåã§ãããã®ããºã«ãå®æããã®ã«äœ¿ããããŒã¹ãå³ 1 (b) ã®ããã«äžããããŸãããã®äžãããæ ã®çœãéšåãåããããšãã§ããé»ãããŒã¹ã 1 ã€ä»¥äžéžæããŸããäŸãã°ãå³ 2 ã®éžæäŸ 1 ã®ãããªçµã¿åãããªãæ£è§£ãšãªããŸããäžæ¹ãéžæäŸ 2 ã®ãããªçµã¿åããã§ã¯ããºã«ã¯å®æããªãã®ã§äžæ£è§£ãšãªããŸãããŸããéžæããããŒã¹ãäœã£ãŠããŸãå Žåãäžæ£è§£ã§ãããã®ããã«ããã¬ã€ã€ãŒã¯é©åãªããŒã¹ãéžæããããšã§ã²ãŒã ãã¯ãªã¢ããŸãã
</p>
<p>
ããã§ãã®ããºã«ã²ãŒã ã§çšããå€å®ããã°ã©ã ãéçºããããšã«ãªããŸãããæªå®æã®ããºã«ãããŒã¹ã®åè£ããããŠãã¬ã€ã€ãŒãéžãã ããŒã¹ã®çµã¿åãããå
¥åãšãããã¬ã€ã€ãŒãé©åãªããŒã¹ãéžã¶ããšãã§ããŠããã° YES ããããã§ãªããã° NO ãšåºåããããã°ã©ã ãäœæããŠãã ããã
</p>
<p>
ãã®åé¡ã§ã¯ãããºã«ã®æ 㯠<var>H × W</var> ã®é
åã§è¡šããæªå®æã®éšåã . (åè§ããªãªã)ãå®æããŠããéšåã # (åè§ã·ã£ãŒã)ã«ãã£ãŠäžããŸããããºã«ã®æ ã®å€§ããã¯æ倧 <var>20 × 20</var> ãšããŸãããŸããåããŒã¹ã¯ <var>h × w</var> ã®é
åã§è¡šããããŒã¹ãæ§æããéšåã # ãããã§ãªãéšåã . ã«ãã£ãŠäžããŸããäžããããåããŒã¹ã¯ãå
ã®ç¶æ
ãã 90 床ã180 床ã270 床ã ãå転ããããšãã§ããŸãããŸããåããŒã¹ã®å€§ããã¯æ倧 <var>20 × 20</var> ãšããäžããããããŒã¹ã®æ° <var>n</var> ã¯æ倧 10 ãšããŸãã
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_jigsawPuzzle">
</center>
<br>
<H2>Input</H2>
<p>
è€æ°ã®ããŒã¿ã»ãããäžããããŸããåããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããŸãã
</p>
<pre>
<var>H</var> <var>W</var>
<var>g<sub>1,1</sub></var><var>g<sub>1,2</sub></var>...<var>g<sub>1,W</sub></var>
<var>g<sub>2,1</sub></var><var>g<sub>2,2</sub></var>...<var>g<sub>2,W</sub></var>
:
<var>g<sub>H,1</sub></var><var>g<sub>H,2</sub></var>...<var>g<sub>H,W</sub></var>
<var>n</var>
<var>h<sub>1</sub></var> <var>w<sub>1</sub></var>
<var>c1<sub>1,1</sub></var><var>c1<sub>1,2</sub></var>...<var>c1<sub>1,w<sub>1</sub></sub></var>
<var>c1<sub>2,1</sub></var><var>c1<sub>2,2</sub></var>...<var>c1<sub>2,w<sub>1</sub></sub></var>
:
<var>c1<sub>h<sub>1</sub>,1</sub></var><var>c1<sub>h<sub>1</sub>,2</sub></var>...<var>c1<sub>h<sub>1</sub>,w<sub>1</sub></sub></var>
:
:
<var>h<sub>n</sub></var> <var>w<sub>n</sub></var>
<var>cn<sub>1,1</sub></var><var>cn<sub>1,2</sub></var>...<var>cn<sub>1,w<sub>n</sub></sub></var>
<var>cn<sub>2,1</sub></var><var>cn<sub>2,2</sub></var>...<var>cn<sub>2,w<sub>n</sub></sub></var>
:
<var>cn<sub>h<sub>n</sub>,1</sub></var><var>cn<sub>h<sub>n</sub>,2</sub></var>...<var>cn<sub>h<sub>n</sub>,w<sub>n</sub></sub></var>
<var>p</var>
<var>k<sub>1</sub></var> <var>t<sub>1</sub></var> <var>t<sub>2</sub></var> ... <var>t<sub>k<sub>1</sub></sub></var>
<var>k<sub>2</sub></var> <var>t<sub>1</sub></var> <var>t<sub>2</sub></var> ... <var>t<sub>k<sub>2</sub></sub></var>
:
<var>k<sub>p</sub></var> <var>t<sub>1</sub></var> <var>t<sub>2</sub></var> ... <var>t<sub>k<sub>p</sub></sub></var>
</pre>
<p>
1 è¡ç®ã«ãããºã«ã®æ ã®å€§ãã <var>H</var>(瞊) ãš <var>W</var>(暪) ãäžããããŸãã
2 è¡ç®ã«ãæå <var>g<sub>i,j</sub></var> (<span>.</span> ãŸã㯠<span>#</span>) ãããªãããºã«ã®ç€é¢ãè¡šã 1 è¡ <var>W</var> æåã®æååã <var>H</var> è¡äžããããŸãã
</p>
<p>
ç¶ããŠããŒã¹ã®æ° <var>n</var>ã<var>n</var> åã®ããŒã¹ã®æ
å ±ãäžããããŸããåããŒã¹ã®æ
å ±ãšããŠã<var>l</var> çªç®ã®ããŒã¹ã®é
åã®ãµã€ãº <var>h<sub>l</sub></var> (瞊) ãš <var>w<sub>l</sub></var> (暪)ã<var>l</var> çªç®ã®ããŒã¹ã®é
åãäžããããŸãã<var>l</var> çªç®ã®ããŒã¹ã®é
åãšããŠæå <var>cl<sub>i,j</sub></var> (<span>.</span> ãŸã㯠<span>#</span>) ãããªã 1 è¡ <var>w<sub>l</sub></var> æåã®æååã <var>h<sub>l</sub></var> è¡äžããããŸãã
</p>
<p>
ç¶ããŠãã¬ã€ã€ãŒã®äººæ° <var>p</var>ã<var>i</var> çªç®ã®ãã¬ã€ã€ãŒã®éžæããããŒã¹ã®æ° <var>k<sub>i</sub></var> ãšéžæããããŒã¹ã®çªå· <var>t<sub>j</sub></var> ãäžããããŸãã
</p>
<p>
å
¥åã¯ïŒã€ã® 0 ãå«ãè¡ã§çµäºããŸããããŒã¿ã»ããã®æ°ã¯ 10 ãè¶
ããŸããã
</p>
<H2>Output</H2>
<p>
åããŒã¿ã»ããããšã«ã<var>i</var> çªç®ã®ãã¬ã€ã€ãŒãéžæããããŒã¹ã®æ£åŠ YES ãŸã㯠NO ã <var>i</var> è¡ç®ã«åºåããŠãã ããã
</p>
<H2>Sample Input</H2>
<pre>
14 20
####################
###.............####
####..........######
#######.....########
########.....#######
###..###......######
###..####......#####
#########......#####
###########.....####
############.....###
###.########......##
###.#######...###.##
##...###....#####.##
####################
10
12 15
#############..
.##########....
....#####......
.....#####.....
.....######....
......######...
......######...
........#####..
.........#####.
.........######
........###...#
.....####.....#
3 3
#..
###
#..
2 2
##
##
4 10
....#####.
....######
...###...#
####.....#
6 5
....#
..###
#####
##.##
#..##
#..#.
6 4
...#
.###
####
##.#
##.#
#...
2 6
######
.#####
2 7
..#####
#######
2 13
#############
.##########..
6 9
#####....
.######..
.######..
..######.
...#####.
....#####
8
3 1 2 3
4 1 2 3 4
7 2 3 4 5 6 7 8
5 2 3 10 7 8
6 2 3 9 5 6 4
8 2 3 4 6 9 5 4 10
4 4 5 6 9
5 10 2 3 4 9
0 0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
YES
NO
YES
NO
NO
YES
</pre>
| [
[
"14 20\n####################\n###.............####\n####..........######\n#######.....########\n########.....#######\n###..###......######\n###..####......#####\n#########......#####\n###########.....####\n############.....###\n###.########......##\n###.#######...###.##\n##...###....#####.##\n####################\n10\n12 15\n#############..\n.##########....\n....#####......\n.....#####.....\n.....######....\n......######...\n......######...\n........#####..\n.........#####.\n.........######\n........###...#\n.....####.....#\n3 3\n#..\n###\n#..\n2 2\n##\n##\n4 10\n....#####.\n....######\n...###...#\n####.....#\n6 5\n....#\n..###\n#####\n##.##\n#..##\n#..#.\n6 4\n...#\n.###\n####\n##.#\n##.#\n#...\n2 6\n######\n.#####\n2 7\n..#####\n#######\n2 13\n#############\n.##########..\n6 9\n#####....\n.######..\n.######..\n..######.\n...#####.\n....#####\n8\n3 1 2 3\n4 1 2 3 4\n7 2 3 4 5 6 7 8\n5 2 3 10 7 8\n6 2 3 9 5 6 4\n8 2 3 4 6 9 5 4 10\n4 4 5 6 9\n5 10 2 3 4 9\n0 0\n",
"14 20\n####################\n###.............####\n####..........######\n#######.....########\n########.....#######\n###..###......######\n###..####......#####\n#########......#####\n###########.....####\n############.....###\n###.########......##\n###.#######...###.##\n##...###....#####.##\n####################\n10\n12 15\n#############..\n.##########....\n....#####......\n.....#####.....\n.....######....\n......######...\n......######...\n........#####..\n.........#####.\n.........######\n........###...#\n.....####.....#\n3 3\n#..\n###\n#..\n2 2\n##\n##\n4 10\n....#####.\n....######\n...###...#\n####.....#\n6 5\n....#\n..###\n#####\n##.##\n#..##\n#..#.\n6 4\n...#\n.###\n####\n##.#\n##.#\n#...\n2 6\n######\n.#####\n2 7\n..#####\n#######\n2 13\n#############\n.##########..\n6 9\n#####....\n.######..\n.######..\n..######.\n...#####.\n....#####\n8\n3 1 2 3\n4 1 2 3 4\n7 2 3 4 5 6 7 8\n5 2 3 10 7 8\n6 2 3 9 5 6 4\n8 2 3 4 6 9 5 4 10\n4 4 5 6 9\n5 10 2 3 4 9\n0 0\n"
]
] |
p00133 | Rotation of a Pattern |
<H1>ãã¿ãŒã³ã®å転</H1>
<p>
8 æå × 8 è¡ã®ãã¿ãŒã³ãå³åãã« 90 床ã180 床ã270 床å転ãããŠåºåããããã°ã©ã ãäœæããŠãã ããã
</p>
<H2>Input</H2>
<p>
8 æå × 8 è¡ãããªããã¿ãŒã³ãäžããããŸããæåã¯ãè±æ°åãåè§ã·ã£ãŒã '#' ãã¢ã¹ã¿ãªã¹ã¯ '*' ãããªããŸãã
</p>
<H2>Output</H2>
<p>
次ã®åœ¢åŒã§ãå転ããããã¿ãŒã³ãåºåããŠãã ããã
</p>
<pre>
90ïŒåè§æ°ååºå®ïŒ
90床å転ããããã¿ãŒã³
180ïŒåè§æ°ååºå®ïŒ
180床å転ããããã¿ãŒã³
270ïŒåè§æ°ååºå®ïŒ
270床å転ããããã¿ãŒã³
</pre>
<H2>Sample Input</H2>
<pre>
#*******
#*******
#*******
#*******
#*******
#*******
#*******
########
</pre>
<H2>Output for the Sample Input</H2>
<pre>
90
########
#*******
#*******
#*******
#*******
#*******
#*******
#*******
180
########
*******#
*******#
*******#
*******#
*******#
*******#
*******#
270
*******#
*******#
*******#
*******#
*******#
*******#
*******#
########
</pre>
| [
[
"#*******\n#*******\n#*******\n#*******\n#*******\n#*******\n#*******\n########\n",
"#*******\n#*******\n#*******\n#*******\n#*******\n#*******\n#*******\n########\n"
]
] |
p00134 | Exit Survey |
<H1>åºå£èª¿æ»</H1>
<p>
ãããããŒãã§è²·ãç©éé¡ã®åºå£èª¿æ»ãè¡ããŸãããè²·ãç©éé¡ã®ããŒã¿ãå
¥åãšãã1 人ãããã®å¹³åè²·ãç©éé¡ãèšç®ããåºåããããã°ã©ã ãäœæããŠãã ããã調æ»äººæ°ã¯ã10 äžäººä»¥äžãšããäžäººãããã®è²·ãç©éé¡ã¯ 100 äžåãè¶
ããªããã®ãšããŸãã
</p>
<H2>Input</H2>
<p>
å
¥åã¯ä»¥äžã®åœ¢åŒã§äžããããŸãã
</p>
<pre>
<var>n</var>
<var>v<sub>1</sub></var>
<var>v<sub>2</sub></var>
:
<var>v<sub>n</sub></var>
</pre>
<p>
1 è¡ç®ã«èª¿æ»äººæ° <var>n</var>ãç¶ã <var>n</var> è¡ã« <var>i</var> 人ç®ã®è²·ãç©éé¡ãè¡šãæŽæ° <var>v<sub>i</sub></var> ãäžããããŸãã
</p>
<H2>Output</H2>
<p>
å¹³åè²·ãç©éé¡ïŒæŽæ°ïŒå°æ°ç¹ä»¥äžã¯åãæšãŠïŒãïŒè¡ã«åºåããŠãã ããã
</p>
<H2>Sample Input</H2>
<pre>
6
12300
5600
33800
0
26495
52000
</pre>
<H2>Output for the Sample Input</H2>
<pre>
21699
</pre>
| [
[
"6\n12300\n5600\n33800\n0\n26495\n52000\n",
"6\n12300\n5600\n33800\n0\n26495\n52000\n"
]
] |
p00135 | Clock Short Hand and Long Hand |
<H1>æèšã®çãéãšé·ãé</H1>
<p>
åå§ã¹ããŒã©ã€ã䞻矩çµç¹ãã¢ã«ã«ã€ãããããããããã®äºåç¶ãå±ããŸãããã¢ã«ã«ã€ããšããã°ãèŠäººã®é¡é¢ã«ãã€ãæãã€ãããããããããã§æåã§ãããæè¿ã§ã¯ç«è¬ãçšããŠã¬ã»ãã·ã§ã³äŒå Žã«ããºãè±ç«ããŸãæ£ãããªã©ãããéæ¿åããŠããŸãããäºåç¶ã¯æ¬¡ã®æé¢ã§ãã
</p>
<pre>
---ããœã³ã³ ããã®æéã奪ããè¯ããªãã
æèšã®çãéãšé·ãé åºäŒããããã¢ã«ã«ã€ã æ£çŸ©è¡ãã
ã¹ããŒã©ã€ã å倧ãªãã
</pre>
<p>
ãã©ãã©ãããŠãã解ããªãã®ã§ãããæèšã®çéãšé·éãšãéãªã£ãããã«ããããã決è¡ãããšããæå³ã®ããã§ãã
</p>
<p>
ãã®ãããããèŠæãããããæå»ãå
¥åãšããŠãçéãšé·éãè¿ãå Žå㯠"alert"ãé ãå Žå㯠"safe"ããã以å€ã®å Žå㯠"warning" ãšåºåããããã°ã©ã ãäœæããŠãã ããããã ãããè¿ãããšã¯çéãšé·éã®è§åºŠã 0° ä»¥äž 30° æªæºã®å Žåãããããé ãããšã¯ 90° ä»¥äž 180° 以äžã®å ŽåããããŸãããªããæå»ã¯ 00:00 ä»¥äž 11:59 以äžãšããŸãã
</p>
<H2>Input</H2>
<p>
å
¥åã¯ä»¥äžã®åœ¢åŒã§äžããããŸãã
</p>
<pre>
<var>n</var>
<var>hh<sub>1</sub></var>:<var>mm<sub>1</sub></var>
<var>hh<sub>2</sub></var>:<var>mm<sub>2</sub></var>
:
<var>hh<sub>n</sub></var>:<var>mm<sub>n</sub></var>
</pre>
<p>
1 è¡ç®ã«å€å®ããæå»ã®åæ° <var>n</var>ïŒ1 ≤ <var>n</var> ≤ 10000ïŒã2 è¡ç®ä»¥éã« <var>i</var> çªç®ã®æå» <var>hh<sub>i</sub></var>:<var>mm<sub>i</sub></var> ãããããïŒè¡ã«äžããããŸãã
</p>
<H2>Output</H2>
<p>
<var>i</var> çªç®ã®æå»ã®å€å®çµæ safeãwarningããŸã㯠alert ãé çªã«ããããïŒè¡ã«åºåããŠãã ããã
</p>
<H2>Sample Input</H2>
<pre>
4
02:15
06:01
11:55
10:40
</pre>
<H2>Output for the Sample Input</H2>
<pre>
alert
safe
alert
warning
</pre>
| [
[
"4\n02:15\n06:01\n11:55\n10:40\n",
"4\n02:15\n06:01\n11:55\n10:40\n"
]
] |
p00136 | Frequency Distribution of Height |
<H1>床æ°ååž</H1>
<p>
å¥åº·èšºæã§çåŸã®èº«é·ãèšæž¬ããŸããã身é·ã®ããŒã¿ãå
¥åãšãã床æ°ååžãäœæããŠåºåããããã°ã©ã ãäœæããŠãã ããã床æ°ååžã®éçŽã¯ 5 cm å»ã¿ã® 6 ã€ã®éçŽãšãã床æ°ã¯äººæ°ã *ïŒåè§ã¢ã¹ã¿ãªã¹ã¯ïŒã§è¡šç€ºããŸãããã ãããã®éçŽã®åºŠæ°ïŒäººæ°ïŒã 0 ã®å ŽåãéçŽã®èŠåºãã®ã¿ãåºåããŠãã ããã
</p>
<H2>Input</H2>
<p>
å
¥åã¯ä»¥äžã®åœ¢åŒã§äžããããŸãã
</p>
<pre>
<var>n</var>
<var>h<sub>1</sub></var>
<var>h<sub>2</sub></var>
:
<var>h<sub>n</sub></var>
</pre>
<p>
1 è¡ç®ã«çåŸã®æ° <var>n</var> (1 ≤ <var>n</var> ≤ 40)ã2 è¡ç®ä»¥éã« <var>i</var> 人ç®ã®èº«é·ãè¡šãå®æ° <var>h<sub>i</sub></var> (150.0 ≤ <var>h<sub>i</sub></var> ≤ 190.0ãå°æ°ç¬¬ 1 äœãŸã§) ããããã 1 è¡ã«äžããããŸãã
</p>
<H2>Output</H2>
<p>
以äžã®åœ¢åŒã§åºŠæ°ååžã衚瀺ããŠãã ããã
</p>
<pre>
1 è¡ç® èŠåºãã1:ãã«ã€ã¥ã㊠165.0 cm æªæºã®äººæ°åã® *
2 è¡ç® èŠåºãã2:ãã«ã€ã¥ã㊠165.0 cm 以äžã 170.0 cmæªæºã®äººæ°åã® *
3 è¡ç® èŠåºãã3:ãã«ã€ã¥ã㊠170.0 cm 以äžã 175.0 cmæªæºã®äººæ°åã® *
4 è¡ç® èŠåºãã4:ãã«ã€ã¥ã㊠175.0 cm 以äžã 180.0 cmæªæºã®äººæ°åã® *
5 è¡ç® èŠåºãã5:ãã«ã€ã¥ã㊠180.0 cm 以äžã 185.0 cmæªæºã®äººæ°åã® *
6 è¡ç® èŠåºãã6:ãã«ã€ã¥ã㊠185.0 cm 以äžã®äººæ°åã® *
</pre>
<H2>Sample Input 1</H2>
<pre>
4
180.3
168.2
165.5
175.3
</pre>
<H2>Output for the Sample Input 1</H2>
<pre>
1:
2:**
3:
4:*
5:*
6:
</pre>
<H2>Sample Input 2</H2>
<pre>
21
179.4
171.5
156.6
173.0
169.4
181.2
172.4
170.0
163.6
165.9
173.5
168.2
162.5
172.0
175.1
172.3
167.5
175.9
186.2
168.0
178.6
</pre>
<H2>Output for the Sample Input 2</H2>
<pre>
1:***
2:*****
3:*******
4:****
5:*
6:*
</pre>
| [
[
"4\n180.3\n168.2\n165.5\n175.3\n",
"4\n180.3\n168.2\n165.5\n175.3\n"
]
] |
p00137 | Middle-Square Method |
<H1>å¹³æ¹æ¡äžæ³</H1>
<p>
å€å
žçãªä¹±æ°çææ¹æ³ã®äžã€ã§ããå¹³æ¹æ¡äžæ³ã®ããã°ã©ã ãäœæããŸããå¹³æ¹æ¡äžæ³ã¯ããã©ã³ãã€ãã³ã«ãã£ãŠ 1940 幎代åã°ã«ææ¡ãããæ¹æ³ã§ãã
</p>
<p>
å¹³æ¹æ¡äžæ³ã¯ãçæããä¹±æ°ã®æ¡æ°ã <var>n</var> ãšãããšããåæå€ <var>s</var> ã®2ä¹ãèšç®ãããã®æ°å€ã <var>2n</var> æ¡ã®æ°å€ãšã¿ãŠãïŒäžã®äŸã®ããã« 2 ä¹ããæ¡æ°ã足ããªããšãã¯ã0 ãè£ããŸããïŒãã®äžå€®ã«ãã <var>n</var> åã®æ°åãæåã®ä¹±æ°ãšããŸãã次ã«ãã®ä¹±æ°ã 2 ä¹ããŠãåãæ§ã«ãäžå€®ã«ãã <var>n</var> åã®æ°åããšã£ãŠã次ã®ä¹±æ°ãšããŸããäŸãã°ã123 ãåæå€ãšãããš
</p>
<pre>
123<sup>2</sup> = 00015129 â 0151
151<sup>2</sup> = 00022801 â 0228
228<sup>2</sup> = 00051984 â 0519
519<sup>2</sup> = 00269361 â 2693
2693<sup>2</sup> = 07252249 â 2522
</pre>
<p>
ã®æ§ã«ãªããŸãããã®æ¹æ³ãçšããŠãåæå€ <var>s</var>ïŒ10000æªæºã®æ£ã®æŽæ°ïŒãå
¥åãšãã<var>n</var> = 4 ã®å Žåã®ä¹±æ°ã 10 åçæãåºåããããã°ã©ã ãäœæããŠãã ããã
</p>
<H2>Input</H2>
<p>
è€æ°ã®ããŒã¿ã»ãããäžããããŸããïŒè¡ç®ã«ããŒã¿ã»ããã®æ° <var>d</var> (<var>d</var> ≤ 10) ãäžããããŸããåããŒã¿ã»ãããšããŠãïŒè¡ã«åæå€ <var>s</var>ïŒæŽæ°ã1 ≤ <var>s</var> < 10000ïŒãäžããããŸãã
</pre>
<H2>Output</H2>
<p>
åããŒã¿ã»ããã«å¯ŸããŠã
</p>
<pre>
Case <var>x</var>: (<var>x</var> 㯠1 ããå§ãŸãããŒã¿ã»ããçªå·)
ïŒåç®ã®çæããä¹±æ°ïŒæŽæ°ïŒ
ïŒåç®ã®çæããä¹±æ°ïŒæŽæ°ïŒ
ïŒ
ïŒ
ïŒïŒåç®ã®çæããä¹±æ°ïŒæŽæ°ïŒ
</pre>
<p>
ãåºåããŠãã ããã
</p>
<H2>Sample Input</H2>
<pre>
2
123
567
</pre>
<H2>Output for the Sample Input</H2>
<pre>
Case 1:
151
228
519
2693
2522
3604
9888
7725
6756
6435
Case 2:
3214
3297
8702
7248
5335
4622
3628
1623
6341
2082
</pre>
| [
[
"2\n123\n567\n",
"2\n123\n567\n"
]
] |
p00138 | Track and Field Competition |
<H1>éžäžç«¶æ倧äŒ</H1>
<p>
éžäžç«¶æå€§äŒ 200M ã®æºæ±ºå 3 çµã®ã¬ãŒã¹ãè¡ãããŸãããããããã®çµã« 8 åïŒèš 24 åïŒã®éžæãåºå ŽããŸããåçµäžäœ 2 äœãŸã§ã®éžæãšãåçµã® 3 äœä»¥äžã®å
šéžæã®äžããäžäœ 2 åã®èš 8 åã決åã«é²åºããŸãã
</p>
<p>
éžæçªå·ãšã¿ã€ã ãå
¥åãšãã決åé²åºè
8 åã®çªå·ãšãã®ã¿ã€ã ãåºåããããã°ã©ã ãäœæããŠãã ããã
</p>
<!--
<p>
å
¥åããŒã¿ã®1件ç®ãã8件ç®ãŸã§ã1çµç®ã9件ç®ãã16件ç®ãŸã§ã2çµç®ã17件ç®ãã24件ç®ãŸã§ã3çµç®ã®ããŒã¿ãšããŸããã¿ã€ã ã¯ã1/100ãŸã§èšæž¬ããåã¿ã€ã ã®éžæã¯ããªããã®ãšããæ£æš©ã¯ç¡ããã®ãšããŸãã
</p>
-->
<H2>Input</H2>
<p>
å
¥åã¯ä»¥äžã®åœ¢åŒã§äžããããŸãã
</p>
<pre>
<var>p<sub>1</sub></var> <var>t<sub>1</sub></var>
<var>p<sub>2</sub></var> <var>t<sub>2</sub></var>
:
<var>p<sub>24</sub></var> <var>t<sub>24</sub></var>
</pre>
<p>
1 è¡ç®ãã 8 è¡ç®ã«ïŒçµç®ã®éžæçªå· <var>p<sub>i</sub></var> (æŽæ°ã1 ≤ <var>p<sub>i</sub></var> ≤ 10000) ãšã¿ã€ã <var>t<sub>i</sub></var> (1/100 ãŸã§èšæž¬ããå®æ°ã1 ≤ <var>t<sub>i</sub></var> ≤ 100)ã9 è¡ç®ãã 16 è¡ç®ã«ïŒçµç®ã®éžæçªå· <var>p</sub>i</sub></var> ãšã¿ã€ã <var>t<sub>i</sub></var>ã17 è¡ç®ãã 24 è¡ç®ã«ïŒçµç®ã®éžæçªå· <var>p<sub>i</sub></var> ãšã¿ã€ã <var>t<sub>i</sub></var> ãäžããããŸããåãéžæçªå·ã®éžæãåã¿ã€ã ã®éžæã¯ããªããã®ãšããŸãã
</p>
<H2>Output</H2>
<p>
以äžã®é çªã§ã決åé²åºè
ã®éžæçªå·ãšã¿ã€ã ã空çœåºåãã§ããããïŒè¡ã«åºåããŠãã ããã
</p>
<p>
1 çµç®ã® 1 äœã®éžæ<br/>
1 çµç®ã® 2 äœã®éžæ<br/>
2 çµç®ã® 1 äœã®éžæ<br/>
2 çµç®ã® 2 äœã®éžæ<br/>
3 çµç®ã® 1 äœã®éžæ<br/>
3 çµç®ã® 2 äœã®éžæ<br/>
åçµã§ 3 äœä»¥äžã®éžæã®äžã§ã¿ã€ã ã 1 äœã®éžæ<br/>
åçµã§ 3 äœä»¥äžã®éžæã®äžã§ã¿ã€ã ã 2 äœã®éžæ<br/>
</pre>
<H2>Sample Input</H2>
<pre>
18 25.46
16 26.23
3 23.00
10 24.79
5 22.88
11 23.87
19 23.90
1 25.11
23 23.88
4 23.46
7 24.12
12 22.91
13 21.99
14 22.86
21 23.12
9 24.09
17 22.51
22 23.49
6 23.02
20 22.23
24 21.89
15 24.14
8 23.77
2 23.42
</pre>
<H2>Output for the Sample Input</H2>
<pre>
5 22.88
3 23.00
13 21.99
14 22.86
24 21.89
20 22.23
17 22.51
12 22.91
</pre>
| [
[
"18 25.46\n16 26.23\n3 23.00\n10 24.79\n5 22.88\n11 23.87\n19 23.90\n1 25.11\n23 23.88\n4 23.46\n7 24.12\n12 22.91\n13 21.99\n14 22.86\n21 23.12\n9 24.09\n17 22.51\n22 23.49\n6 23.02\n20 22.23\n24 21.89\n15 24.14\n8 23.77\n2 23.42\n",
"18 25.46\n16 26.23\n3 23.00\n10 24.79\n5 22.88\n11 23.87\n19 23.90\n1 25.11\n23 23.88\n4 23.46\n7 24.12\n12 22.91\n13 21.99\n14 22.86\n21 23.12\n9 24.09\n17 22.51\n22 23.49\n6 23.02\n20 22.23\n24 21.89\n15 24.14\n8 23.77\n2 23.42\n"
]
] |
p00139 | Snakes |
<H1>ãã</H1>
<p>
ããäžçã«ã¯ïŒæåã ãã§ã§ããäžæè°ãªãããäœãã§ããŸãããã®ããã«ã¯çŸåšAçš®ãšBçš®ã®2çš®é¡ã確èªãããŠããŸããããã以å€ã®çš®é¡ãããå¯èœæ§ããããŸãã
</p>
<p>
Açš®ã¯ïŒ">'"ã®åŸã«"="ã1å以äžäžŠãã åŸã"#"ãæ¥ãŠãããã«åãšåãåæ°ã®"="ãæ¥ãåŸã"~"ïŒåè§ãã«ãïŒã§çµãããŸãã
</p>
<p>
Bçš®ã¯ïŒ">^"ã®åŸã« "Q="ã1å以äžäžŠãã åŸã"~~"ã§çµãããŸãã
</p>
<pre>
Açš®ã®äŸïŒ >'====#====~ >'==#==~
</pre>
<pre>
Bçš®ã®äŸïŒ >^Q=Q=Q=Q=~~ >^Q=Q=~~
</pre>
<p>
ãããæååããŒã¿ãšããŠåãåãããããã©ããªçš®é¡ã§ããããå€å¥ããŠãAçš®ã®å Žåã¯ãAããBçš®ã®å Žåã¯ãBãããã以å€ã®çš®é¡ã®å Žåã¯ãNAããåºåããããã°ã©ã ãäœæããŠãã ããã
</p>
<H2>Input</H2>
<p>
å
¥åã¯ä»¥äžã®åœ¢åŒã§äžããããŸãã
</p>
<pre>
<var>n</var>
<var>S<sub>1</sub></var>
<var>S<sub>2</sub></var>
:
<var>S<sub>n</sub></var>
</pre>
<p>
1 è¡ç®ã«å€å¥ãããããã®æ° <var>n</var>ïŒ1 ≤ <var>n</var> ≤ 10000ïŒãç¶ã <var>n</var> è¡ã« <var>i</var> å¹ç®ã®ãããè¡šãæåå <var>S<sub>i</sub></var> (200æå以äžã®ã空çœãå«ãŸãªãæåå) ãããããïŒè¡ã«äžããããŸãã
</p>
<H2>Output</H2>
<p>
<var>i</var> è¡ç®ã« <var>i</var> å¹ç®ã®ããã®çš®é¡ AãB ãŸã㯠NA ãåºåããŠãã ããã
</p>
<H2>Sample Input</H2>
<pre>
3
>'======#======~
>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~
>'===#====~
</pre>
<H2>Output for the Sample Input</H2>
<pre>
A
B
NA
</pre>
| [
[
"3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~\n",
"3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~\n"
]
] |
p00140 | Bus Line |
<H1>ãã¹è·¯ç·</H1>
<p>
å³ 1ã®ãããªãã¹è·¯ç·ããããŸããåçæ㯠10 ç®æã§ããããã 0ã9 ã®çªå·ãã€ããŠããŸãããã¹ã¯åçæ 0 ã§ã¯æãè¿ããŸãããå察åŽã¯åŸªç°è·¯ç·ã«ãªã£ãŠãããå³ã®ããã« 5â6â7â8â9â5 ã®é ã§åŸªç°ããŸãã
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_busLine">
</center>
<br/>
<p>
ãã®ãã¹è·¯ç·ã«ã€ããŠãä¹è»ããåçæãšéè»ããåçæãå
¥åãšããä¹è»ããéè»ãŸã§ã«éãåçæã®çªå·ãåºåããããã°ã©ã ãäœæããŠãã ããã
</p>
<p>
ãã ãã1ã5 ã®åçæã§ã¯ 2 æ¹åã®ãã¹ã«ä¹è»ã§ããŸãããããçãçµè·¯ã§éè»åçæã«å°çãããã¹ã«ä¹è»ããããšãšããŸããäŸãã°ãåçæ 4 ããåçæ 2 ãžè¡ãå Žåãå·Šæ¹åã«é²ããã¹ã«ä¹ãã4â3â2ãã®çµè·¯ãéããŸãããŸããäžåºŠãã¹ã«ä¹è»ãããéäžäžè»ã¯ããªããã®ãšããŸããåãåçæãä¹è»åçæãéè»åçæã«æå®ããããšã¯ãããŸããã
</p>
<H2>Input</H2>
<p>
è€æ°ã®ããŒã¿ã»ãããäžããããŸããäžè¡ç®ã«ããŒã¿ã»ããæ° <var>n</var> (<var>n</var> ≤ 20 ) ãäžããããŸããåããŒã¿ã»ãããšããŠãä¹è»ããåçæçªå·ãšéè»ããåçæçªå·ã空çœåºåãã§ïŒè¡ã«äžããããŸãã
</pre>
<H2>Output</H2>
<p>
åããŒã¿ã»ããã«å¯ŸããŠãééããåçæçªå·ã®äžŠã³ã空çœåºåãã§ïŒè¡ã«åºåããŠãã ããã
</p>
<H2>Sample Input</H2>
<pre>
2
2 4
4 2
</pre>
<H2>Output for the Sample Input</H2>
<pre>
2 3 4
4 3 2
</pre>
| [
[
"2\n2 4\n4 2\n",
"2\n2 4\n4 2\n"
]
] |
p00141 | Spiral Pattern |
<H1>ããããæš¡æ§</H1>
<p>
ãããããæš¡æ§ãã衚瀺ããããã°ã©ã ãäœæããããšã«ããŸããããããããæš¡æ§ãã¯ä»¥äžã®ãããªãã®ãšããŸãã
</p>
<ul>
<li>1 蟺ã®é·ãã <var>n</var> ã®å Žåã<var>n</var> è¡ <var>n</var> åã®æååãšããŠè¡šç€ºããã</li>
<li>å·Šäžé
ãåºç¹ãšãïŒæèšåãã«å転ãã枊ç¶ã®æš¡æ§ãšããã</li>
<li>ç·ã®ããéšå㯠#ïŒåè§ã·ã£ãŒãïŒã空çœéšå㯠" "ïŒåè§ç©ºçœïŒã§è¡šçŸããã</li>
<li>ç·ãšç·ã®éã¯ç©ºçœã眮ãã</li>
</ul>
<p>
æŽæ° <var>n</var> ãå
¥åãšãïŒ1 蟺ã®é·ãã <var>n</var> ã®ãããããæš¡æ§ããåºåããããã°ã©ã ãäœæããŠãã ããã
</p>
<H2>Input</H2>
<p>
å
¥åã¯ä»¥äžã®åœ¢åŒã§äžããããŸãã
</p>
<pre>
<var>d</var>
<var>n<sub>1</sub></var>
<var>n<sub>2</sub></var>
:
<var>n<sub>d</sub></var>
</pre>
<p>
ïŒè¡ç®ã«ããŒã¿ã»ããã®æ° <var>d</var> (<var>d</var> ≤ 20)ãç¶ã <var>d</var> è¡ã« <var>i</var> åç®ã®ããããæš¡æ§ã®èŸºã®é·ã <var>n<sub>i</sub></var> (1 ≤ <var>n<sub>i</sub></var> ≤ 100) ãããããïŒè¡ã«äžããããŸãã
</p>
<H2>Output</H2>
<p>
ããŒã¿ã»ããããšã«ãããããæš¡æ§ãåºåããŠãã ãããããŒã¿ã»ããã®éã«ïŒè¡ã®ç©ºè¡ãå
¥ããŠãã ããã
</p>
<H2>Sample Input</H2>
<pre>
2
5
6
</pre>
<H2>Output for the Sample Input </H2>
<pre>
#####
# #
# # #
# # #
# ###
######
# #
# ## #
# # #
# # #
# ####
</pre>
| [
[
"2\n5\n6\n",
"2\n5\n6\n"
]
] |
p00142 | Nature of Prime Numbers |
<h1>çŽ æ°ã®æ§è³ª</h1>
<p>
4 ã§å²ããš 3 ããŸãçŽ æ° <var>n</var> (11ã19ã23 ãªã©) ã«ã¯ãé¢çœãæ§è³ªããããŸãã1 ä»¥äž <var>n</var> æªæºã®èªç¶æ° (1, 2,... , <var>n</var> - 1) ã 2 ä¹ãããã®ã <var>n</var> ã§å²ã£ãããŸããèšç®ããçµæã䞊ã¹ããšãåãæ°ã«ãªããã®ããããããäºãã«ç°ãªã£ãæ°ã®åæ°ã¯ã(<var>n</var> - 1)/2 ã«ãªããŸãã
</p>
<p>
ãã®æ§ã«ããŠåŸãããæ°ã®éåã«ã¯ãç¹å¥ãªæ§è³ªããããŸããåŸãããæ°ã®éåãããäºãã«ç°ãªã 2 〠<var>a</var> ãš <var>b</var> ãéžãã§ãã®å·®ãèšç®ããŸããå·®ãè² ã«ãªã£ããšãã¯ããã®å·®ã« <var>n</var> ã足ããŸããããã«çµæã (<var>n</var> - 1)/2 ãã倧ãããšãã¯ããã®å·®ã <var>n</var> ããåŒããŸãã
</p>
<p>
äŸãã°ã<var>n = 11</var> ã®ãšã 1 ãš 9 ã®å·®ã¯ã<var>1 − 9 = −8</var> â <var>−8 + n = −8 + 11 = 3</var> ã«ãªããŸãã9 ãš 1 ã®å·®ã <var>9 −1 = 8</var> â <var>n − 8 = 11 − 8 = 3</var> ã§ãåãå€ 3 ã«ãªããŸãããã®å·®ã¯ãååšäžã« 0, 1, ã»ã»ã», <var>n</var> - 1 ãæžããŠãäºã€ã®æ°åã®éã®çãæ¹ã®å匧ãèãããšãããããããªããŸãã(äžå³åç
§)
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_natureOfPrimeNumber1">
</center>
<br/>
<p>
ããããŠåŸãããæ°ã®ãå·®ãã¯ã1, 2, . . ., (<var>n</var> - 1)/2 ã®ããããã§ãããåãåæ°åºçŸããŸãã
</p>
<p>
ãäŸã <var>n = 11</var> ã®æã¯ã以äžã®ããã«ãªããŸãã
</p>
<ol>
<li> 1 ãã <var>n</var>-1 ãŸã§ã®æ°ã 2 ä¹ãããã®ã <var>n</var> ã§å²ã£ãäœããèšç®ããŸãã
<pre>
1<sup>2</sup> = 1 â 1
2<sup>2</sup> = 4 â 4
3<sup>2</sup> = 9 â 9
4<sup>2</sup> = 16 â 5
5<sup>2</sup> = 25 â 3
6<sup>2</sup> = 36 â 3
7<sup>2</sup> = 49 â 5
8<sup>2</sup> = 64 â 9
9<sup>2</sup> = 81 â 4
10<sup>2</sup> = 100 â 1
</pre>
</li>
<li> <var>a</var>, <var>b</var> ã®ãå·®ãã®èšç®<br><br>
<ol>
<li> 1 ã§åŸããã 1, 3, 4, 5, 9 ã«ã€ããŠç°ãªãæ°å士ã®å·®ãèšç®ããŸãã</li>
<li> èšç®çµæãè² ã®å Žåã<var>n</var> = 11 ãå ç®ããŸãã</li>
<li> ããã«ãèšç®çµæã (<var>n</var>-1)/2 = 5 ãã倧ããå Žå <var>n</var> = 11 ããæžç®ããŸãã</li>
</ol>
</li>
<li>åºçŸåæ°ãæ±ãã<br>
<p>
èšç®çµæ 1, 2, 3, 4, 5 ã®åºçŸåæ°ãããããæ°ãäžããŸãã
</p>
</li>
</ol>
<p>
ãããã®èšç®çµæãã 1, 2, 3, 4, 5 ã®åºçŸåæ°ã 4 åã§ããããšãããããŸãããã®æ§è³ªã¯ 4 ã§å²ããš 3 ããŸãçŽ æ°ç¹æã®æ§è³ªã§ãã 4 ã§å²ããš 1 ããŸãçŽ æ°ã§ã¯ãã®ãããªããšã¯ãããŸããããã®ããšã確èªããããã10000 以äžã®å¥æ° <var>n</var> ãå
¥åãšããäŸé¡ã«ãããããªèšç® (<var>n</var> ã§å²ã£ãããŸãã® 2 ä¹ã®å·®ã®é »åºŠãæ±ãã)ãå®è¡ãããã®åºçŸåæ°ãåºåããããã°ã©ã ãäœæããŠãã ããã
</p>
<!--
<td><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE_natureOfPrimeNumber2"></td>
-->
<H2>Input</H2>
<p>
è€æ°ã®ããŒã¿ã»ãããäžããããŸããåããŒã¿ã»ãããšããŠïŒã€ã®æŽæ° <var>n</var>ã(<var>n</var> ≤ 10000) ãïŒè¡ã«äžããããŸããå
¥å㯠0 ãïŒã€å«ãè¡ã§ããããŸãã
</p>
<H2>Output</H2>
<p>
åããŒã¿ã»ããã«ã€ããŠãåºçŸé »åºŠã以äžã®åœ¢åŒã§åºåããŠãã ããã
</p>
<pre>
å°äœã®å¹³æ¹ã®å·®ã 1 ã§ãã(<var>a, b</var>)ã®åºçŸåæ°(æŽæ°)
å°äœã®å¹³æ¹ã®å·®ã 2 ã§ãã(<var>a, b</var>)ã®åºçŸåæ°(æŽæ°)
:
:
å°äœã®å¹³æ¹ã®å·®ã (<var>n</var>-1)/2 ã§ãã(<var>a, b</var>)ã®åºçŸåæ°(æŽæ°)
</pre>
<H2>Sample Input</H2>
<pre>
11
15
0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
4
4
4
4
2
2
4
2
4
4
2
</pre>
| [
[
"11\n15\n0\n",
"11\n15\n0\n"
]
] |
p00143 | Altair and Vega |
<h1>çœçãšç¹å¥³</h1>
<p>
ç¹å¥³ã¯å€©åžã®åäŸã§ããããç¶ã®èšãã€ãã§ãããŠããããŠãæ©ãç¹ã£ãŠããŸããã
</p>
<p>
ç¹å¥³ã®ç¹ãé²éŠãšããèŠäºãªåžã§ä»ç«ãŠãæãçãã®ã倩åžã®æ¥œãã¿ã§ãããé²éŠã¯å¯¿åœãçãããã«å£åããŠããŸããŸãããåãè
ã®ç¹å¥³ãæ¯æ¥ç¹ã£ãŠãããã®ã§ãåé¡ã¯ãããŸããã§ãããç¹å¥³ã¯ãç¶ã®èšãã€ããå®ããæ¯æ¥æ¯æ¥é²éŠãç¹ãç¶ããŠããã®ã§ãããŒã€ãã¬ã³ãã¯ããŸããã§ããããããããã«æã£ãç¶ã¯ã倩ã®å·ã®åãã岞ã«äœãçœçãšããåãè
ã玹ä»ããå«å
¥ããããŸããã
</p>
<p>
ãããšãç¹å¥³ã¯ãçµå©ã®æ¥œããã«å€¢äžã«ãªã£ãŠãæ©ç¹ããªã©ãã£ã¡ã®ãã§ãçœçãšéã³åããŠããŸãã倩åžã®ãæ°ã«å
¥ãã®é²éŠã®æãæ°ããä»ç«ãŠãããªãããããããã«ãªã£ãŠããŸããŸããã
</p>
<p>
ããã«ã¯ç¶ãæã£ãŠãç¹å¥³ã宮殿ã«é£ãæ»ããããšæããŸãããããã人éã§ããçœçã®åã«ããããã®æã§å§¿ãçŸãããã«ã¯ãããŸãããéã³åããŠããäºäººã 3 è§åœ¢ã®å£ã§é®æãèªå以å€ã®å
šãŠã®ãã®ãè¡ãæ¥ã§ããªãããããšãèããŸããããããŠãçœçã«èŠã€ãããã«ãç¹å¥³ã«äŒã£ãŠããŸããã«æ©ãç¹ããããããªããã°åŒ·å¶çã«é£ãåž°ããšå®£èšãããšããã®ã§ãã
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_altairAndVega">
</center>
<br/>
<p>
倩åžã¯ãã®äœæŠãéè¡ããããã« 3 è§åœ¢ã®å£çæè£
眮ãéçºããããšã«ããŸããã3 è§åœ¢ã® 3 é ç¹ã®äœçœ® <var>(xp<sub>1</sub>, yp<sub>1</sub>)</var>, <var>(xp<sub>2</sub>, yp<sub>2</sub>)</var>, <var>(xp<sub>3</sub>, yp<sub>3</sub>)</var>ãçœçã®äœçœ® <var>(xk, yk)</var>ãããã³ç¹å¥³ã®äœçœ® <var>(xs, ys)</var>ããå
¥åãšããäžè§åœ¢ãçœçãšç¹å¥³ãé®æããŠãããåŠããå€å®ããé®æã§ããŠããå Žå㯠OKãé®æã§ããŠããªãå Žåã«ã¯ NG ãåºåããããã°ã©ã ãäœæããŠãã ããããã ããé®æããŠãããšã¯ãçœçãšç¹å¥³ã®ãããããäžè§åœ¢ã®å
åŽã«ãããä»æ¹ãå€åŽã«ããå ŽåãèšããŸããçœçãšç¹å¥³ã¯äžè§åœ¢ã®é ç¹ãããã¯èŸºã®äžã«ã¯ããªããã®ãšããŸãã
</p>
<p>
ç¹å¥³ãšçœçã¯æã
å»ã
å Žæãå€ãããããããã°ã©ã ã¯æ§ã
ãªäœçœ®æ
å ±ãå
¥åã質åã«çããªããã°ãªããŸããã
</p>
<!--
<p>
倩åžã¯ãã®äœæŠéè¡ã®ããã« 3 è§åœ¢ã®å£çæè£
眮ã®éçºãéçºéšçœ²ã«åœããŸããã3 ç¹ãäžããŠããã«å£ãäœããšããä»æ§ã§çºæ³šããã€ããã§ããããéçºéšçœ²ã§ã¯äœãééããã®ããã©ã³ãã ã«(ç¡äœçºã«)ã« 3 è§åœ¢ã®å£ãçæãããã® 3 ç¹ãå ±åããã·ã¹ãã ãäœã£ãŠããŸããŸãããçºæ³šè
ãšããŠã倩åžã¯äœãçŽããåœãããã®ã§ãããæããŸããŸãããããã«ãªã£ãã®ã§ãæå°éã®æçŽãã§æãæã€ããšã«ããŸãããã©ã³ãã ã«å£ãã§ããã®ã§ã¯ããŸã£ããããããªãã®ã§ãäœãããšãã 3 è§åœ¢ã決ãŸã£ã段éã§ã3 ç¹ãå ±åããããã§æºè¶³ãããã®ãªãã°(ããªãã¡é®æãã§ããŠããã°)倩åžã OK ãã¿ã³ãæŒããŠå£ã®äœæãæ瀺ãããšããä»æ§ã«ããŸãããé®æã§ããŠããªããã°(é®æäžå
šãªãã°) NG ãã¿ã³ãæŒããããçŽããšãªããŸããç¹å¥³ãšçœçã¯æã
å»ã
å Žæãå€ããŸããå£çæè£
眮ããã¯ç¡äœçºã® 3 ç¹ãã©ãã©ãåºåãããŠããŸãã
</p>
<p>
倩åžã¯äžããããç¶æ³äžã§ãå£ã®äœæãæ瀺ãã¹ããåŠããå€å®ããå¿
èŠã«è¿«ãããŸãããããã§ã倩åžã«ãããã3è§åœ¢ã® 3 é ç¹ã®äœçœ® <var>(xp<sub>1</sub>, yp<sub>1</sub>)</var>, <var>(xp<sub>2</sub>, yp<sub>2</sub>)</var>, <var>(xp<sub>3</sub>, yp<sub>3</sub>)</var>ãçœçã®äœçœ® <var>(xk, yk)</var>ãããã³ç¹å¥³ã®äœçœ® <var>(xs, ys)</var>ããå
¥åãšããäžè§åœ¢ãçœçãšç¹å¥³ãé®æããŠãããåŠããå€å®ããé®æã§ããŠããå Žå㯠OKãé®æã§ããŠããªãå Žåã«ã¯ NG ãåºåããããã°ã©ã ãäœæããŠãã ããããã ããé®æããŠãããšã¯ãçœçãšç¹å¥³ã®ãããããäžè§åœ¢ã®å
åŽã«ãããä»æ¹ãå€åŽã«ããå ŽåãèšããŸããçœçãšç¹å¥³ã¯äžè§åœ¢ã®é ç¹ãããã¯èŸºã®äžã«ã¯ããªããã®ãšããŸãã
</p>
-->
<H2>Input</H2>
<p>
å
¥åã¯ä»¥äžã®åœ¢åŒã§äžããããŸãã
</p>
<pre>
<var>n</var>
<var>query<sub>1</sub></var>
<var>query<sub>2</sub></var>
:
<var>query<sub>n</sub></var>
</pre>
<p>
ïŒè¡ç®ã«å€å¥ãããæ
å ±ã®åæ° <var>n</var> (<var>n</var> ≤ 10000)ãç¶ã <var>n</var> è¡ã« <var>i</var> çªç®ã®è³ªå <var>query<sub>i</sub></var> ãäžããããŸããå質åã¯ä»¥äžã®åœ¢åŒã§äžããããŸãã
</p>
<pre>
<var>xp<sub>1</sub></var> <var>yp<sub>1</sub></var> <var>xp<sub>2</sub></var> <var>yp<sub>2</sub></var> <var>xp<sub>3</sub></var> <var>yp<sub>3</sub></var> <var>xk</var> <var>yk</var> <var>xs</var> <var>ys</var>
</pre>
<p>
å質åãšããŠã3 è§åœ¢ã® 3 é ç¹ã®äœçœ®ãçœçã®äœçœ®ãããã³ç¹å¥³ã®äœçœ® (-1000 ≤ <var>xp<sub>1</sub></var>, <var>yp<sub>1</sub></var>, <var>xp<sub>2</sub></var>, <var>yp<sub>2</sub></var>, <var>xp<sub>3</sub></var>, <var>yp<sub>3</sub></var>, <var>xk</var>, <var>yk</var>, <var>xs</var>, <var>ys</var> ≤ 1000) ãïŒè¡ã«äžããããŸããå
¥åã¯ãã¹ãŠæŽæ°ã§ãã
</p>
<H2>Output</H2>
<p>
質åããšã«ãå€å®çµæ OK ãŸã㯠NG ãïŒè¡ã«åºåããŠãã ããã
</p>
<H2>Sample Input</H2>
<pre>
5
2 5 9 2 8 9 2 11 6 5
2 5 9 2 8 9 2 11 12 6
2 5 9 2 8 9 2 11 11 9
14 1 25 7 17 12 17 9 20 5
14 1 25 7 17 12 22 13 20 5
</pre>
<H2>Output for the Sample Input</H2>
<pre>
OK
NG
NG
NG
OK
</pre>
| [
[
"5\n2 5 9 2 8 9 2 11 6 5\n2 5 9 2 8 9 2 11 12 6\n2 5 9 2 8 9 2 11 11 9\n14 1 25 7 17 12 17 9 20 5\n14 1 25 7 17 12 22 13 20 5\n",
"5\n2 5 9 2 8 9 2 11 6 5\n2 5 9 2 8 9 2 11 12 6\n2 5 9 2 8 9 2 11 11 9\n14 1 25 7 17 12 17 9 20 5\n14 1 25 7 17 12 22 13 20 5\n"
]
] |
p00144 | Packet Transportation |
<H1>ãã±ãã転é</H1>
<p>
ã€ã³ã¿ãŒãããã§ã¯ãããŒã¿ã¯ãã±ããã«åå²ããããã±ããããšã«ã«ãŒã¿ãšåŒã°ããäžç¶æ©åšãä»ããŠå®å
ã«è»¢éãããŸããåã«ãŒã¿ã¯ãã±ããã«èšèŒãããå®å
ãã次ã«è»¢éãã¹ãã«ãŒã¿ãå€æããŸããããã«ãç¡éã«ã«ãŒã¿éã転éããç¶ããããšãé²ãããããã±ããã«ã¯ TTLïŒTime To LiveïŒ ãšããå€ãä»å ãããŠããŸããã«ãŒã¿ã¯åãåã£ããã±ããã® TTL ã 1 æžç®ãããã®çµæã 0 ãªããã®ãã±ãããç Žæ£ãããã以å€ãªã次ã®ã«ãŒã¿ã«è»¢éããŸãã
</p>
<p>
ããã§ããããã¯ãŒã¯ã®èšèšãæå©ãããããã°ã©ã ãäœãããšã«ãªããŸããããããã¯ãŒã¯ã®æ¥ç¶æ
å ±ãšéä¿¡ãã±ããã®æ
å ±ãå
¥åãšããŠãåãã±ãããå®å
ã«ãŒã¿ã«å°çãããŸã§ã«çµç±ããã«ãŒã¿ã®æ°ã®ãã¡æå°ã®å€ã衚瀺ããããã°ã©ã ãäœæããŠãã ããã
</p>
<p>
ãããã¯ãŒã¯ã¯å³ã®ããã«è€æ°ã®ã«ãŒã¿ãšããããçµã¶ã±ãŒãã«ã§æ§æãããŠããŸãããã ããåæ¥ç¶ïŒã±ãŒãã«ïŒã¯åæ¹åã§ããããšã«æ³šæããŠãã ãããåã«ãŒã¿ãçŽæ¥ã€ãªãã£ãŠããã«ãŒã¿ã®çªå·ã®é
åããããã¯ãŒã¯ã®æ¥ç¶ã®æ
å ±ãšããŠäžããããŸããã«ãŒã¿ã®æ°ã <var>n</var> ãšããã°ãåã«ãŒã¿ã¯ 1 ãã <var>n</var> ãŸã§ã®æŽæ°ã§èå¥ãããŸããéä¿¡å
ããå®å
ã«ãŒã¿ãŸã§ã®çµè·¯ãè€æ°ããå Žåã¯ãçµç±ããã«ãŒã¿ã®æ°ãå°ãªãæ¹ã®å€ãåºåããŠãã ããããŸãããã±ãããå®å
ã«å°éããªãå Žå㯠NA ãšåºåããŠãã ããã
</p>
<p>
äŸãã°ã以äžã®å³ã®ãããªãããã¯ãŒã¯ã§ãéä¿¡å
ã«ãŒã¿ã 6ãå®å
ã«ãŒã¿ã 5 ã®å ŽåãèããŸããæççµè·¯ã¯ 6â1â5 ã§ããçµç±ããã«ãŒã¿ã¯ 3 åã§ãããã®å ŽåãTTL ã¯ã«ãŒã¿ 6ã1 ã§ããããæžç®ãããã®ã§ãéä¿¡æã® TTL ã 3 以äžã§ããã°ãã±ããã¯å°éã§ããŸããå®å
ã«ãŒã¿ã§ã¯ TTL ãæžç®ããå¿
èŠã¯ãããŸããããŸããéä¿¡å
ãšå®å
ãåãã«ãŒã¿ã«ãªããããªãã±ããã¯ç¡ããã®ãšããŸãã
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_network">
</center>
<br/>
<H2>Input</H2>
<p>
å
¥åã¯ä»¥äžã®åœ¢åŒã§äžããããŸãã
</p>
<pre>
<var>n</var>
<var>r<sub>1</sub></var> <var>k<sub>1</sub></var> <var>t<sub>11</sub></var> <var>t<sub>12</sub></var> ... <var>t<sub>1k<sub>1</sub></sub></var>
<var>r<sub>2</sub></var> <var>k<sub>2</sub></var> <var>t<sub>21</sub></var> <var>t<sub>22</sub></var> ... <var>t<sub>2k<sub>2</sub></sub></var>
:
<var>r<sub>n</sub></var> <var>k<sub>n</sub></var> <var>t<sub>n1</sub></var> <var>t<sub>n2</sub></var> ... <var>t<sub>nk<sub>n</sub></sub></var>
<var>p</var>
<var>s<sub>1</sub></var> <var>d<sub>1</sub></var> <var>v<sub>1</sub></var>
<var>s<sub>2</sub></var> <var>d<sub>2</sub></var> <var>v<sub>2</sub></var>
:
<var>s<sub>p</sub></var> <var>d<sub>p</sub></var> <var>v<sub>p</sub></var>
</pre>
<p>
1 è¡ç®ã«ã«ãŒã¿ã®ç·æ° <var>n</var>ïŒ<var>n</var> ≤ 100ïŒãç¶ã <var>n</var> è¡ã« <var>i</var> çªç®ã®ã«ãŒã¿ã®æ¥ç¶æ
å ±ãäžããããŸããæ¥ç¶æ
å ±ãšããŠã<var>i</var> çªç®ã®ã«ãŒã¿ã®çªå· <var>r<sub>i</sub></var>ã<var>i</var> çªç®ã®ã«ãŒã¿ãšçŽæ¥æ¥ç¶ããŠããã«ãŒã¿ã®åæ° <var>k<sub>i</sub></var>ã<var>i</var> çªç®ã®ã«ãŒã¿ããéä¿¡ã§ããã«ãŒã¿ã®çªå· <var>t<sub>i1</sub></var>, <var>t<sub>i2</sub></var>, ... <var>t<sub>ik<sub>i</sub></sub></var>ãäžããããŸãã
</p>
<p>
ç¶ãè¡ã«ãã±ããã®åæ° <var>p</var>ïŒ<var>p</var> ≤ 1000ïŒãç¶ã <var>p</var> è¡ã« <var>i</var> çªç®ã®ãã±ããã®æ
å ±ãäžããããŸãããã±ããã®æ
å ±ãšããŠã éä¿¡å
ã«ãŒã¿ã®çªå· <var>s<sub>i</sub></var>, å®å
ã«ãŒã¿ã®çªå· <var>d<sub>i</sub></var>, TTL ã®å€ <var>v<sub>i</sub></var> (0 ≤ <var>v<sub>i</sub></var> ≤ 10000) ãäžããããŸãã
</p>
<H2>Output</H2>
<p>
åãã±ããããšã«ãçµç±ããã«ãŒã¿ã®åæ°ãŸã㯠NA ãïŒè¡ã«åºåããŠãã ããã
</p>
<H2>Sample Input</H2>
<pre>
7
1 4 2 5 4 3
2 1 5
3 1 6
4 1 7
5 2 7 6
6 1 1
7 0
6
1 2 2
1 5 3
1 2 1
5 1 3
6 3 3
1 7 4
</pre>
<H2>Output for the Sample Input</H2>
<pre>
2
2
NA
3
3
3
</pre>
| [
[
"7\n1 4 2 5 4 3\n2 1 5\n3 1 6\n4 1 7\n5 2 7 6\n6 1 1\n7 0\n6\n1 2 2\n1 5 3\n1 2 1\n5 1 3\n6 3 3\n1 7 4\n",
"7\n1 4 2 5 4 3\n2 1 5\n3 1 6\n4 1 7\n5 2 7 6\n6 1 1\n7 0\n6\n1 2 2\n1 5 3\n1 2 1\n5 1 3\n6 3 3\n1 7 4\n"
]
] |
p00145 | Cards |
<H1>ã«ãŒã</H1>
<p>
æ£ã®æŽæ°ãæžãããäžçµã®ã«ãŒãããããŸããã«ãŒããç©ãã§å±±ãããã€ãäœãããããã暪äžåã«äžŠã¹ãŸãããã®äžããé£ãåã£ã 2 ã€ã®ã«ãŒãã®å±±ãéžã³ãå³åŽã®å±±ã®äžã«å·ŠåŽã®å±±ããã®ãŸãŸéããŸãããã®æäœãã«ãŒãã®å±±ãäžã€ã«ãªããŸã§ç¹°ãè¿ããŠãããŸãã
</p>
<p>
2 ã€ã®ã«ãŒãã®å±±ãéããæã«ãããã®äžçªäžãšäžã®ã«ãŒãã«æžãããæ°ããã¹ãŠæãåãããŸããããããŠåŸãããæ°ãã«ãŒãã®éãåããã®ã³ã¹ããšåŒã¶ããšã«ããŸããã«ãŒãã®å±±ãäžã€ã«ããããã®ã³ã¹ãã¯ãã¹ãŠã®éãåããã®ã³ã¹ãã足ãåããããã®ãšããŸãã
</p>
<p>
ã©ã®ãããªé çªã§ã«ãŒãã®å±±ãéãããã§ã³ã¹ãã¯å€ãããŸããããšãã°ã3 ã€ã®ã«ãŒãã®å±±ãããå ŽåãèããŸãããããã®äžçªäžãšäžã®ã«ãŒãã«æžãããæ°ãïŒå·ŠåŽã®å±±ããé ã«ãããã 3 ãš 5, 2 ãš 8, 5 ãš4 ã ã£ããšããŸãããã®ãšãïŒã¯ããã«å·Šãšçãäžã®å±±ãéãããšãã®ã³ã¹ãã¯ã3 à 5 à 2 à 8 = 240 ã§ãããã®éãåããã«ãã£ãŠãäžçªäžã®ã«ãŒãã 3 ã§äžçªäžã®ã«ãŒãã 8 ã§ããå±±ãã§ããŸãã
</p>
<p>
ãã®å±±ãå³ã®å±±ã®äžã«éãããšããã®ã³ã¹ã㯠3 à 8 à 5 à 4 = 480 ã«ãªããŸãããããã£ãŠããã®é çªã§ã«ãŒãã®å±±ãäžã€ã«ãŸãšãããšãã®ã³ã¹ã㯠240 + 480 = 720 ã§ããïŒå³1ïŒ
</p>
<p>
äžæ¹ãã¯ããã«çãäžãšå³ã®å±±ãéããŠããæåŸã«å·Šã®å±±ãéããããšã«ãããšããã®ãšãã®ã³ã¹ã㯠2 à 8 à 5 à 4 + 3 à 5 à 2 à 4 = 440 ã«ãªããŸãããããã£ãŠïŒåŸã®å Žåã®ããã«éããæ¹ãã³ã¹ããå°ãããªããŸããïŒå³2ïŒ
</p>
<center>
<table border=0>
<tr>
<td><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_cards1"></td>
<td><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_cards2"></td>
</tr>
</table>
</center>
<br/>
<p>
ã«ãŒãã®å±±ã®åæ°ãšããããã®å±±ã®äžçªäžãšäžã®ã«ãŒãã«æžãããæ°ãå
¥åãšããã«ãŒãã®å±±ãäžã€ã«ãŸãšããã®ã«å¿
èŠãªæå°ã®ã³ã¹ããåºåããããã°ã©ã ãäœæããŠãã ããããã ããå±±ã®åæ°ã¯ 100 å以äžãšããå
¥åãããããŒã¿ã¯ã©ã®ãããªé çªã§ã³ã¹ããèšç®ããŠã 2<sup>31</sup>-1 ãè¶
ããããšã¯ãããŸããã
</p>
<H2>Input</H2>
<p>
å
¥åã¯ä»¥äžã®åœ¢åŒã§äžããããŸãã
</p>
<pre>
<var>n</var>
<var>a<sub>1</sub></var> <var>b<sub>1</sub></var>
<var>a<sub>2</sub></var> <var>b<sub>2</sub></var>
:
<var>a<sub>n</sub></var> <var>b<sub>n</sub></var>
</pre>
<p>
1 è¡ç®ã«ã«ãŒãã®å±±ã®åæ° <var>n</var>(<var>n</var> ≤ 100)ãç¶ã <var>n</var> è¡ã«å·Šãã <var>i</var> çªç®ã®å±±ã® 1 çªäžã®ã«ãŒãã«æžãããæ° <var>a<sub>i</sub></var> (1 ≤ <var>a<sub>i</sub></var> ≤ 200) ãš 1 çªäžã®ã«ãŒãã«æžãããæ° <var>b<sub>i</sub></var> (1 ≤ <var>b<sub>i</sub></var> ≤ 200) ãäžããããŸãã
</p>
<H2>Output</H2>
<p>
ã«ãŒãã®å±±ãäžã€ã«ãŸãšããã®ã«å¿
èŠãªæå°ã®ã³ã¹ããïŒè¡ã«åºåããŠãã ããã
</p>
<H2>Sample Input</H2>
<pre>
3
3 5
2 8
5 4
</pre>
<H2>Output for the Sample Input</H2>
<pre>
440
</pre>
| [
[
"3\n3 5\n2 8\n5 4\n",
"3\n3 5\n2 8\n5 4\n"
]
] |
p00146 | Lupin The 4th |
<H1>ã«ãã³åäž</H1>
<p>
æªçãã«ãã³åäžãã¯äŒæŽ¥è©å£«ãæ«è£ãšããçŸå¥³ãå¯å£«å³°åããããäŒæŽ¥è¥æŸåžã«äŒæŽ¥è©ãæ®ããè»è³éãç ã£ãŠããããšãèãããããã«ãã³ã®é·å¹Žã®ä»²éã§ãããç³å·è¶ã§éãã®å ±åã«ããã°ãè»è³éã¯åäž¡ç®±ã«åãããããã€ãã®èµã«ä¿ç®¡ãããŠãããèµã«èŠåŒµãã¯ããªããå³éã«æœé ãããŠãããããããè¶ã§éã¯åœŒãç¶ããäŒæãããç§äŒãéŒéæ¬ããã®æãç¹°ãåºãã°ç¬æã«èµãç Žãããšããã
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_lupin">
</center>
<br/>
<p>
æ®ã£ãåé¡ã¯åäž¡ç®±ã®éæ¬ã ãäœåã®ãªãã«ãã³ãšè¶ã§éã¯åäž¡ç®±ãäžã€ãæãŠãªããããã§ãé Œãã«ãªãç·ãç¡é倧ä»ãã«éæ¬ãé Œãã ã<!--倧ä»ã¯ç±³ä¿µã䜿ã£ãèšç·Žãéããè¶
人çãªéæ¬èœåã身ã«ã€ããã-->
ãã¹ãŠã®åäž¡ç®±ãéã³åºãããã«ãã«ãã³ã¯ä»¥äžã®ãããªèšç»ãç«æ¡ããã
</p>
<p>
ãŸããã«ãã³ã®é転ã§æåã®èµãžè¡ããè¶ã§éãšå€§ä»ãéããã
</p>
<ul>
<li>è¶ã§éãèµãç Žã</li>
<li>倧ä»ããã¹ãŠã®åäž¡ç®±ãéã³åºã</li>
<li>ãã®åäž¡ç®±ãæã£ããŸãŸã«ãã³ã決ãã次ã®èµãžåãã</li>
</ul>
<p>
ãããç¹°ãè¿ããæåŸã®èµãŸã§ç Žãåäž¡ç®±ãéã³åºãããã®éã«ã«ãã³ã¯ããªã³ãã¿ãŒãæºåãæåŸã®èµã§äºäººãšåäž¡ç®±ãéã³äžãè±åºããã倧ä»ã¯ã©ããªã«éããã®ãéæ¬ã§ããããè·ç©ã®éãã«å¿ããŠç§»åé床ã¯é
ããªããã«ãã³ã¯ããã®ããšãèæ
®ããŠèµãç Žãé çªã決ããªããã°ãªããªãã
</p>
<p>
ã«ãã³ã«ä»£ãã£ãŠãæåã®èµãç Žã£ãŠããæåŸã®èµã«èŸ¿ãã€ããŸã§ã®ç§»åæéãæå°ãšãªããããªèµãç Žãé çªãåºåããããã°ã©ã ãäœæããŠãã ããããã ãã
</p>
<ul>
<li>èµã¯ãã¹ãŠé¶Žã¶åãããŸã£ããåã«èµ°ãéãã«é¢ããŠãããèµã®æ°ã¯é«ã
15 åã§ãããåããã®è·é¢ã¯é«ã
10000 ã¡ãŒãã«ä»¥äžã§ããã</li>
<li>åäž¡ç®±ã®éãã¯ããããã²ãšã€ 20 ããã°ã©ã ã§ãããããããã®èµã«åããããŠããåäž¡ç®±ã®åæ°ã¯ 10000 å以äžã§ããã</li>
<li>èµããèµãžã®ç§»åã¯ãéãã«æ²¿ã£ãŠå°äžã«èšçœ®ãããŠããå°äžéã䜿ãã</li>
<li>倧ä»ã¯ <var>w</var> ããã°ã©ã ã®è·ç©ãéã¶ã®ã«ãåé 2,000ïŒ(70 + <var>w</var>) ã¡ãŒãã«ã§ç§»åããã</li>
<!--<li>å¯å£«å³°åã¯èšç»ã劚害ããæããããã®ã§äºåã«ç¡ç è¬ã飲ãŸããŠç ãããããã®ã»ãã®åŠšå®³ã«ã€ããŠããéºæŒãªã察åŠããã</li>-->
</ul>
<p>
å
¥åããŒã¿ã¯ãããããã®èµã«ã€ããŠèµã®çªå·ïŒ100 以äžã®æŽæ°ïŒãšåããã®è·é¢ïŒã¡ãŒãã«ïŒãšãã®èµã«ä¿ç®¡ãããŠããåäž¡ç®±ã®åæ°ãäžããããã
</p>
<H2>Input</H2>
<p>
å
¥åã¯ä»¥äžã®åœ¢åŒã§äžããããŸãã
</p>
<pre>
<var>n</var>
<var>s<sub>1</sub></var> <var>d<sub>1</sub></var> <var>v<sub>1</sub></var>
<var>s<sub>2</sub></var> <var>d<sub>2</sub></var> <var>v<sub>2</sub></var>
:
<var>s<sub>n</sub></var> <var>d<sub>n</sub></var> <var>v<sub>n</sub></var>
</pre>
<p>
1 è¡ç®ã«èµã®åæ° <var>n</var>ïŒ<var>n</var> ≤ 15ïŒãç¶ã <var>n</var> è¡ã«ç¬¬ <var>i</var> ã®èµã®æ
å ±ãäžããããŸããèµã®æ
å ±ãšããŠãèµã®çªå· <var>s<sub>i</sub></var> (1 ≤ <var>s<sub>i</sub></var> ≤ 100)ãåããã®è·é¢ <var>d<sub>i</sub></var> (1 ≤ <var>d<sub>i</sub></var> ≤ 10000)ã åäž¡ç®±ã®æ° <var>v<sub>i</sub></var> (1 ≤ <var>v<sub>i</sub></var> ≤ 10000) ãïŒè¡ã«äžããããŸãã
</p>
<H2>Output</H2>
<p>
èµãç Žãé çªãïŒè¡ã«åºåããŠãã ãããèµã®çªå·ã空çœã§åºåã£ãŠãã ããã
</p>
<H2>Sample Input 1</H2>
<pre>
2
1 100 1
2 200 2
</pre>
<H2>Output for the Sample Input 1</H2>
<pre>
1 2
</pre>
<H2>Sample Input 2</H2>
<pre>
3
11 100 1
13 200 20
12 300 3
</pre>
<H2>Output for the Sample Input 2</H2>
<pre>
11 12 13
</pre>
<H2>Sample Input 3</H2>
<pre>
5
13 199 1
51 1000 1
37 350 10
27 300 2
99 200 1000
</pre>
<H2>Output for the Sample Input 3</H2>
<pre>
51 37 27 13 99
</pre>
| [
[
"2\n1 100 1\n2 200 2\n",
"2\n1 100 1\n2 200 2\n"
]
] |
p00147 | Fukushimaken |
<h1>çŠçžè»</h1>
<p>
ãçŠçžè»ãã¯è¡åã®ã§ãã人æ°ã®ã©ãŒã¡ã³å±ã§ããã§ãæè¿ãã客ããã®éãããåŸ
ã¡æéãé·ãã®ã«ãåºã«å
¥ã£ãã空åžãããã®ã¯èš±ããªãããšãã声ãèãããããã«ãªã£ãŠããŸãããã©ãããŠãããªäžæºãåºãã®ã調ã¹ããã®ã§ããããåºãéããŠããããã ã¯å¿ãããŠãå®éã®è¡åã®æ§åã調ã¹ãããšãã§ããŸãããããããé·å¹Žã®çµéšããã客ãããæ¥ãééã人æ°ã¯åãã£ãŠããã®ã§ããããããšã«åŸ
ã¡æéã®åæãããããšã«ããŸããã
</p>
<p>
åºå
ã«ã¯ã«ãŠã³ã¿ãŒã«åãã£ãŠ 17 ã®åžããããŸããéåºæéã¯æ£åã§ãã客ããã¯æ¬¡ã®ããã«ãã£ãŠããŸãã
</p>
<ul>
<li>0 çªãã 99 çªãŸã§ã® 100 çµã®ã°ã«ãŒããæ¥ãŸãã</li>
<li><var>i</var> çªç®ã®ã°ã«ãŒãã¯æ£åãã 5<var>i</var> ååŸã«ãåºã«å°çããŸãã</li>
<li><var>i</var> çªç®ã®ã°ã«ãŒãã®äººæ°ã¯ <var>i</var> % 5 ã 1 ã®ãšã 5 人ããã以å€ã®ãšã㯠2 人ã§ãã<br>
(<var>x</var> % <var>y</var>㯠<var>x</var> ã <var>y</var> ã§å²ã£ããšãã®äœããè¡šãããŸãã)</li>
<li><var>i</var> çªç®ã®ã°ã«ãŒãã¯ãåžã«çããš 17(<var>i</var> % 2) + 3(<var>i</var> % 3) + 19 åéã§é£äºãæžãŸããŸãã</li>
</ul>
<p>
æåã® 10 ã°ã«ãŒãã®å°çæå»ã人æ°ãé£äºæéã¯æ¬¡ã®ããã«ãªããŸãã
</p>
<center>
<table>
<tr><td width="140">ã°ã«ãŒãçªå·</td>
<td width="50">0 </td><td width="50"> 1 </td><td width="50"> 2</td><td width="50"> 3</td><td width="50"> 4</td><td width="50"> 5</td><td width="50"> 6</td><td width="50"> 7</td><td width="50"> 8</td><td width="50"> 9</td></tr>
<tr><td>å°çæå»(ååŸ)</td>
<td>0 </td><td>5</td><td> 10</td><td> 15</td><td> 20</td><td> 25</td><td> 30</td><td> 35</td><td> 40</td><td> 45</td></tr>
<tr><td>人æ°(人)</td>
<td>2 </td><td> 5</td><td> 2</td><td> 2</td><td> 2</td><td> 2</td><td> 5</td><td> 2</td><td> 2</td><td> 2</td></tr>
<tr><td>é£äºæé(å)</td>
<td>19</td><td> 39</td><td> 25</td><td> 36</td><td> 22</td><td> 42</td><td> 19</td><td> 39</td><td> 25</td><td> 36</td></tr>
</table>
</center>
<br/>
<p>
ãŸããã客ãããåžã«æ¡å
ãããšãã«ã¯ã次ã®ããã«ããŠããŸãã
</p>
<ul>
<li>åžã«ã¯ 0 ãã 16 ãŸã§ã®çªå·ãä»ããŠããŸãã</li>
<li><var>x</var> 人ã®ã°ã«ãŒãã¯é£ç¶ã㊠<var>x</var> åãããŠããåžããã£ãæã ãçåžã§ããŸãã</li>
</ul>
<p>
ãŸãã座ããå Žæãè€æ°ãã£ãå Žåã¯ãåžã®çªå·ãæãå°ãããªããšããã«åº§ããŸããäŸãã°ã0ã1ã2ã4ã5çªã®åžã ãã空ããŠããå Žåã5 人ã®ã°ã«ãŒãã¯çåžã§ããŸããã2 人ã®ã°ã«ãŒãã§ããã° 0ã1 çªã«çåžããŸãã
</p>
<ul>
<li>äžåºŠçåžããããåžã移åããŠãããããšã¯ããŸããã</li>
<li>ã客ãã㯠1 ååäœã§åºå
¥ãããŸããåæå»ã«ã¯æ¬¡ã®é åºã§ã客ãããæ¡å
ããŸãã</li>
<ol>
<li>åã®ã°ã«ãŒãã®é¢åžãšåæã«æ¬¡ã®ã°ã«ãŒãã®çåžãå¯èœãšãªããŸãã</li>
<li>ã客ãããçåžãããéã«ã¯ãè¡åã®å
é ã«ããã°ã«ãŒãããé ã«ãã§ããéãå€ãã®ã°ã«ãŒããåãæå»ã«çåžãããŸããè¡åã®é åºãè¿œãè¶ãããšã¯ããŸãããã€ãŸããå
é ã®ã°ã«ãŒããçåžã§ããªããã°ãè¡åå
ã®ä»ã®ã°ã«ãŒããçåžã§ãããšããŠããçåžãããŸããã</li>
<li>ãã®æå»ã«å°çããã°ã«ãŒãã¯ãè¡åãæ®ã£ãŠããå Žåã¯è¡åã®æåŸå°Ÿã«äžŠã³ãŸããè¡åãç¡ããçåžã§ããå Žåã¯çåžããã§ããªãå Žåã¯äžŠãã§åŸ
ã¡ãŸããäŸãšããŠæåã® 10 ã°ã«ãŒããå°çãããŸã§ã®æ§åã瀺ããšä»¥äžã®ããã«ãªããŸããåè¡ã®3ã€ã®æ¬ã¯ãå·Šããæå»ã座åžã®æ§åãè¡åã®æ§åã瀺ããŠããŸãã座åžã¯ã_ãã空åžã§ãçªå·ã¯ãã®åžã«ãã®çªå·ã®ã°ã«ãŒãã座ã£ãŠããããšã瀺ããŠããŸãã</li>
</ol>
</ul>
<pre>
æå»: åº§åž è¡å
0: 00_______________:
5: 0011111__________:
10: 001111122________:
15: 00111112233______:
18: 00111112233______:
19: __111112233______:
20: 44111112233______:
25: 4411111223355____:
30: 4411111223355____: 66666 ã°ã«ãŒã6ãå°ç
34: 4411111223355____: 66666
35: 4411111__3355____: 6666677 ã°ã«ãŒã7ãå°ç
40: 4411111__3355____: 666667788 ã°ã«ãŒã8ãå°ç
41: 4411111__3355____: 666667788
42: __11111__3355____: 666667788
43: __11111__3355____: 666667788
44: 6666677883355____: ã°ã«ãŒã6ã7ã8ãçåž
45: 666667788335599__: ã°ã«ãŒã9ãå°çãçåž
</pre>
<p>
äŸãã°ãæå» 40 ã§ã¯ 8 çªç®ã®ã°ã«ãŒããå°çããŸãããçåžã§ããªãã®ã§è¡åã«å ãããŸãã4 çªç®ã®ã°ã«ãŒãã¯æå» 41 ãŸã§é£äºãããŸããæå» 42 ã§ã¯ã4 çªç®ã®ã°ã«ãŒãã®åžã空ããŸãããé£ç¶ããåžæ°ã足ããªãã®ã§ 6 çªç®ã®ã°ã«ãŒãã¯ãŸã çåžã§ããŸããã1 çªç®ã®ã°ã«ãŒãã¯æå» 43 ãŸã§é£äºãããŸããæå» 44 㧠1 çªç®ã®ã°ã«ãŒãã®åžã空ãã®ã§ã6 çªç®ã®ã°ã«ãŒããçåžããåæã« 7 çªç®ã8 çªç®ã®ã°ã«ãŒããçåžããŸãã9 çªç®ã®ã°ã«ãŒãã¯æå» 45 ã§å°çããåžã空ããŠããã®ã§ãã®ãŸãŸçåžããŸãã
</p>
<p>
ãããã®æ
å ±ãåºã«ããŠã0 ä»¥äž 99 以äžã®æŽæ° <var>n</var> ãå
¥åãšããŠã<var>n</var> çªç®ã°ã«ãŒãã®ã客ãããåŸ
ã€æé(ååäœ)ãåºåããããã°ã©ã ãäœæããŠãã ããã
</p>
<H2>Input</H2>
<p>
è€æ°ã®ããŒã¿ã»ãããäžããããŸããåããŒã¿ã»ããã¯ïŒã€ã®æŽæ° <var>n</var> ãããªããŸãã
</p>
<p>
ããŒã¿ã»ããã®æ°ã¯ 20 ãè¶
ããŸããã
</p>
<H2>Output</H2>
<p>
åããŒã¿ã»ããã«ã€ããŠã<var>n</var> çªç®ã®ã客ã®ååäœã®åŸ
ã¡æé(0 以äžã®æŽæ°)ãïŒè¡ã«åºåããŠãã ããã
</p>
<H2>Sample Input</H2>
<pre>
5
6
7
8
</pre>
<H2>Output for the Sample Input</H2>
<pre>
0
14
9
4
</pre>
| [
[
"5\n6\n7\n8\n",
"5\n6\n7\n8\n"
]
] |
p00148 | Candy and Class Flag |
<H1>ãã£ã³ãã£ãŒãšã¯ã©ã¹æ</H1>
<p>
3幎Cçµã§ã¯ãå¹³æ19幎11æ10æ¥ã®äœè²ç¥ã§äœ¿çšãããã¯ã©ã¹æãããå°æ¥ã®ã¯ã©ã¹äŒã®æã«ã䜿ãããšã«ããŸãããããã§ãã¯ã©ã¹æããä¿ç®¡ããçåŸã決ããããã«ãå
çãå
æ¥å·®ãå
¥ããŠããã倧éã®ãã£ã³ãã£ãŒã䜿ã£ãŠæ¬¡ã®ãããªã²ãŒã ãè¡ãããšã«ããŸããã
</p>
<ul>
<li>åçåŸã¯çåŸçªå·ã®é ã«ïŒåãã€ãã£ã³ãã£ãŒãåããŸãã</li>
<li>äžå·¡ããŠããã£ã³ãã£ãŒãæ®ã£ãŠããããæåã®çåŸçªå·ã®äººããé ã
ã«ãã£ã³ãã£ãŒãåãç¶ããŸãã</li>
<li>æåŸã®ãã£ã³ãã£ãŒãåã£ã人ããã¯ã©ã¹æããä¿ç®¡ããçåŸã«ãªããŸãã</li>
</ul>
<p>
3幎Cçµã®ã¯ã©ã¹ã®äººæ°ã¯ 39 人ã§ãã圌ãã®çåŸçªå·ã¯ 3C01 ãã 3C39 ã§ããäŸãã°ããã£ã³ãã£ãŒã®æ°ã 50 åã®å Žåãã¯ã©ã¹å
šå¡ãïŒåç®ã®ãã£ã³ãã£ãŒãåãçµãããšããã£ã³ãã£ãŒã®æ®ã㯠11 åãšãªããŸãããããåã³çåŸçªå·é ã«åããšãæåŸã® 1 åã¯ã3C11 ã®çåŸãåãããšãšãªããŸããããªãã¡ 3C11 ã®çåŸããã¯ã©ã¹æããä¿ç®¡ããçåŸãšãªããŸãã
</p>
<p>
ãã£ã³ãã£ãŒã®åæ°ãå
¥åãšãããã¯ã©ã¹æããä¿ç®¡ããçåŸã®çåŸçªå·ãåºåããããã°ã©ã ãäœæããŠãã ããã
</p>
<H2>Input</H2>
<p>
è€æ°ã®ãã¹ãã±ãŒã¹ãäžããããŸããåãã¹ãã±ãŒã¹ã¯ä»¥äžã®åœ¢åŒã§äžããããŸããåãã¹ãã±ãŒã¹ãšããŠããã£ã³ãã£ãŒã®åæ°ãè¡šãæŽæ° <var>a</var> (1 ≤ <var>a</var> ≤ 10000) ãïŒè¡ã«äžããããŸããå
¥åã®æåŸ(EOF)ãŸã§åŠçããŠãã ããã
</p>
<p>
ããŒã¿ã»ããã®æ°ã¯ 20 ãè¶
ããŸããã
</p>
<H2>Output</H2>
<p>
åãã¹ãã±ãŒã¹ããšã«ããã¯ã©ã¹æããä¿ç®¡ããçåŸã®çåŸçªå·ïŒåè§è±æ°åïŒãïŒè¡ã«åºåããŠãã ããã
</p>
<H2>Sample Input</H2>
<pre>
50
5576
5577
5578
</pre>
<H2>Output for the Sample Input</H2>
<pre>
3C11
3C38
3C39
3C01
</pre>
| [
[
"50\n5576\n5577\n5578\n",
"50\n5576\n5577\n5578\n"
]
] |
p00149 | Eye Test |
<H1>èŠåæ€æ»</H1>
<p>
èŠåæ€æ»ã®æ€æ»çµæããŒã¿ãå
¥åãšããäžèšã®èŠåå€å®è¡šã«åºã¥ããŠåå€å®ã«åœãŠã¯ãŸã人æ°ããå·Šå³ã®èŠåå¥ã«åºåããããã°ã©ã ãäœæããŠãã ããã
</p>
<center>
<table>
<tr><td width="80">å€å®</td><td>èŠå</td></tr>
<tr><td>A</td><td>1.1 以äž</td></tr>
<tr><td>B</td><td>0.6 ä»¥äž 1.1 æªæº</td></tr>
<tr><td>C</td><td>0.2 ä»¥äž 0.6 æªæº</td></tr>
<tr><td>D</td><td>0.2 æªæº</td></tr>
</table>
</center>
<br/>
<H2>Input</H2>
<p>
å
¥åã¯ä»¥äžã®åœ¢åŒã§äžããããŸãã
</p>
<pre>
<var>l<sub>1</sub></var> <var>r<sub>1</sub></var>
<var>l<sub>2</sub></var> <var>r<sub>2</sub></var>
<var>l<sub>3</sub></var> <var>r<sub>3</sub></var>
:
:
</pre>
<p>
<var>i</var> è¡ç®ã« <var>i</var> 人ç®ã®å·Šã®èŠåãè¡šãå®æ° <var>l<sub>i</sub></var> ãšå³ã®èŠåãè¡šãå®æ° <var>r<sub>i</sub></var> ã空çœåºåãã§äžããããŸãããã ããèŠå㯠0.1 ä»¥äž 2.0 以äžã§ã 0.1 å»ã¿ã§äžããããŸãã
</p>
<p>
å
¥åã®è¡æ°ã¯ 40 ãè¶
ããŸããã
</p>
<H2>Output</H2>
<p>
以äžã®åœ¢åŒã§ãå€å®è¡šãåºåããŠãã ããã
</p>
<p>
1è¡ç® å·Šã®èŠåãAã®äººæ° å³ã®èŠåãAã®äººæ°ïŒç©ºçœåºåãïŒ<br/>
2è¡ç® å·Šã®èŠåãBã®äººæ° å³ã®èŠåãBã®äººæ°ïŒç©ºçœåºåãïŒ<br/>
3è¡ç® å·Šã®èŠåãCã®äººæ° å³ã®èŠåãCã®äººæ°ïŒç©ºçœåºåãïŒ<br/>
4è¡ç® å·Šã®èŠåãDã®äººæ° å³ã®èŠåãDã®äººæ°ïŒç©ºçœåºåãïŒ<br/>
</p>
<H2>Sample Input</H2>
<pre>
1.0 1.2
0.8 1.5
1.2 0.7
2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
2 3
2 1
0 0
0 0
</pre>
| [
[
"1.0 1.2\n0.8 1.5\n1.2 0.7\n2.0 2.0\n",
"1.0 1.2\n0.8 1.5\n1.2 0.7\n2.0 2.0\n"
]
] |
p00150 | Twin Prime |
<H1>Twin Prime</H1>
<p>
Prime numbers are widely applied for cryptographic and communication technology.
A twin prime is a prime number that differs from another prime number by 2.
For example, (5, 7) and (11, 13) are twin prime pairs.
</p>
<p>
In this problem, we call the greater number of a twin prime "size of the twin prime."
</p>
<p>
Your task is to create a program which reads an integer <i>n</i> and prints a twin prime which has the maximum size among twin primes less than or equals to <i>n</i>
</p>
<p>
You may assume that 5 ≤ <i>n</i> ≤ 10000.
</p>
<H2>Input</H2>
<p>
The input is a sequence of datasets. The end of the input is indicated by a line containing one zero. Each dataset is formatted as follows:
</p>
<pre>
<i>n</i> (integer)
</pre>
<H2>Output</H2>
<p>
For each dataset, print the twin prime <i>p</i> and <i>q</i> (<i>p</i> < <i>q</i>). <i>p</i> and <i>q</i> should be separated by a single space.
</p>
<H2>Sample Input</H2>
<pre>
12
100
200
300
0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
5 7
71 73
197 199
281 283
</pre> | [
[
"12\n100\n200\n300\n0\n",
"12\n100\n200\n300\n0\n"
]
] |
p00151 | Grid |
<H1>Grid</H1>
<p>
There is a n × n grid D where each cell contains either 1 or 0.
</p>
<p>
Your task is to create a program that takes the gird data as input and computes the greatest number of consecutive 1s in either vertical, horizontal, or diagonal direction.
</p>
<p>
For example, the consecutive 1s with greatest number in the figure below is circled by the dashed-line.
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_masume">
</center>
<p>
The size of the grid n is an integer where 2 ≤ n ≤ 255.
</p>
<H2>Input</H2>
<p>
The input is a sequence of datasets. The end of the input is indicated by a line containing one zero. Each dataset is formatted as follows:
</p>
<pre>
n
D<sub>11</sub> D<sub>12</sub> ... D<sub>1n</sub>
D<sub>21</sub> D<sub>22</sub> ... D<sub>2n</sub>
.
.
D<sub>n1</sub> D<sub>n2</sub> ... D<sub>nn</sub>
</pre>
<H2>Output</H2>
<p>
For each dataset, print the greatest number of consecutive 1s.
</p>
<H2>Sample Input</H2>
<pre>
5
00011
00101
01000
10101
00010
8
11000001
10110111
01100111
01111010
11111111
01011010
10100010
10000001
2
01
00
3
000
000
000
0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
8
1
0
</pre>
| [
[
"5\n00011\n00101\n01000\n10101\n00010\n8\n11000001\n10110111\n01100111\n01111010\n11111111\n01011010\n10100010\n10000001\n2\n01\n00\n3\n000\n000\n000\n0\n",
"5\n00011\n00101\n01000\n10101\n00010\n8\n11000001\n10110111\n01100111\n01111010\n11111111\n01011010\n10100010\n10000001\n2\n01\n00\n3\n000\n000\n000\n0\n"
]
] |
p00152 | Bowling |
<H1>ããŠãªã³ã°</H1>
<p>
ã¯ã©ã¹ã®ã¬ã¯ãªãšãŒã·ã§ã³ãšããŠããŠãªã³ã°ãè¡ãããšã«ãªããŸãããåå è
ããšã®æçæ
å ±ãå
¥åãšããåŸç¹ã®é«ãé ã«æ瞟æ
å ±ãåºåããããã°ã©ã ãäœæããŠãã ããããªããåç¹ã®å Žåã¯åŠç±çªå·ã®è¥ãé ã«åºåããŠãã ããããã ãåå è
㯠3 åä»¥äž 40 å以äžãšãã1人åœãã1ã²ãŒã ãã€æçããŠãããã®ãšããŸãã
</p>
<p>
ããŠãªã³ã°ãšã¯ããã¬ã€ã€ãŒã«å¯ŸããŠé ç¹ãåããŠæ£äžè§åœ¢ã«äžŠã¹ãããã10 æ¬ã®ãã³ãããããŠããŒã«ã転ããããã³ãåãã¹ããŒãã§ãã 1 åç®ã®æçã§ãã¹ãŠè»¢åããå Žåãã¹ãã©ã€ã¯ãšèšãããã®æçã®ã¿ã§æ¬¡ã®ãã¬ãŒã ã«é²ã¿ãŸããã¹ãã©ã€ã¯ã§ãªãå Žåã¯ãæ®ã£ããã³ããã®ãŸãŸã«ã㊠2 åç®ã®æçãè¡ããŸãã2 åç®ã®æçã§ãã¹ãŠè»¢åããå Žåãã¹ãã¢ãšèšããŸãã2 åç®ã®æççµäºåŸã次ã®ãã¬ãŒã ã«é²ã¿ãŸãã
</p>
<p>
1 ã²ãŒã 㯠10 ã®ãã¬ãŒã ããæ§æããã第 1 ãã第 9 ã®åãã¬ãŒã 㯠2 åæçã§ããŸããåãã¬ãŒã ã®éå§æç¹ã§ã¯ã10 æ¬ã®ãã³ããã¹ãŠç«ã£ãç¶æ
ã§çšæãããŸãã第 10 ãã¬ãŒã ã¯ãã¹ãã©ã€ã¯ãããã¯ã¹ãã¢ãåºãå Žåã«ã¯èš 3 åã®æçãããã以å€ã®å Žå㯠2 åã®æçãè¡ããã²ãŒã çµäºãšãªããŸãã
</p>
<center>
ã¹ã³ã¢äŸïŒ<br>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_bowling1">
<br><br>
ã¹ã³ã¢äŸïŒïŒæé«åŸç¹300ç¹ã®å ŽåïŒ<br>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_bowling2"><br>
</center>
<br/>
<p>ã¹ã³ã¢èšç®ã®æ¹æ³</p>
<ul>
<li> åãã¬ãŒã ã«ãããŠã¹ãã¢ãã¹ãã©ã€ã¯ããªãå Žåã¯ã 2 åã®æçã§åãããã³ã®æ¬æ°ããã®ãã¬ãŒã ã®åŸç¹ãšãªããŸããïŒã¹ã³ã¢äŸïŒã®ç¬¬ 4 ãã¬ãŒã ãšç¬¬ 8 ãã¬ãŒã ïŒ</li>
<li>ã¹ãã¢ãåºããå Žåãåããæ¬æ°ã§ãã 10 ç¹ã«å ãã次ã®æçã§åãããã³ã®æ¬æ°ããã®ãã¬ãŒã ã®åŸç¹ã«å ç®ãããŸããïŒã¹ã³ã¢äŸïŒã®ç¬¬ 1 ãã¬ãŒã ãšç¬¬ 2 ãã¬ãŒã ã®é¢ä¿ãªã©ïŒã¹ã³ã¢äŸïŒã®ç¬¬ 1 ãã¬ãŒã ã§ã¯ç¬¬ 2 ãã¬ãŒã ã® 1 æã§åãã 10 æ¬ïŒç¹ïŒãå ãã 20 ç¹ãåŸç¹ãšãªããŸãã第 3 ãã¬ãŒã ãåæ§ã®èšç®æ¹æ³ã§ãã</li>
<li>ã¹ãã©ã€ã¯ãåºããå Žåãåããæ¬æ°ã§ãã 10 ç¹ã«å ããç¶ã 2 åã®æçã§åãããã³ã®æ¬æ°ãå ç®ãããŸããïŒã¹ã³ã¢äŸïŒã®ç¬¬ 2 ãã¬ãŒã ãšç¬¬ 3 ãã¬ãŒã ã®é¢ä¿ãªã©ïŒãã¡ããç¶ã 2 æäžã«ã¹ãã©ã€ã¯ã®å ŽåããããŸããïŒã¹ã³ã¢äŸïŒã®ç¬¬ 5 ãã¬ãŒã ãšç¬¬ 6ã7 ãã¬ãŒã ã®é¢ä¿ãªã©ïŒ</li>
<li>第 10 ãã¬ãŒã ã®ã¿ãã¹ãã¢ãã¹ãã©ã€ã¯ãåºããå Žåã3 æããŠåãããã³ã®ç·æ°ã第 10 ãã¬ãŒã ã®åŸç¹ãšããŠå ç®ãããŸãã</li>
<li>åãã¬ãŒã ã®åŸç¹ã®åèšã 1 ã²ãŒã ã®åŸç¹ãšãªããæé«åŸç¹ã¯ 300 ç¹ãšãªããŸãã</li>
</ul>
<H2>Input</H2>
<p>
è€æ°ã®ããŒã¿ã»ããã®äžŠã³ãå
¥åãšããŠäžããããŸããå
¥åã®çµããã¯ãŒãã²ãšã€ã®è¡ã§ç€ºãããŸãã
åããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããŸãã</p>
<pre>
<var>m</var>
<var>score<sub>1</sub></var>
<var>score<sub>2</sub></var>
:
<var>score<sub>m</sub></var>
</pre>
<p>
1è¡ç®ã«åå è
æ° <var>m</var> ïŒ3 ≤ <var>m</var> ≤ 40ïŒãç¶ã<var>m</var> è¡ã«<var>i</var> 人ç®ã®åå è
æ
å ± <var>score<sub>i</sub></var> ãäžããããŸããååå è
æ
å ±ã¯ïŒè¡ãã€æ¬¡ã®åœ¢åŒã§äžããããŸãã
</p>
<pre>
<var>id</var> <var>s<sub>1</sub></var> <var>s<sub>2</sub></var> ... <var>s<sub>n</sub></var>
</pre>
<p>
å
é ã«åŠç±çªå·<var>id</var> (0 ≤ <var>id</var> ≤ 9999)ãç¶ããŠç¬¬ <var>j</var> æã®è»¢åãã³æ° <var>s<sub>j</sub></var> (0 ≤ <var>s<sub>j</sub></var> ≤ 10) ãäžããããŸããç·æçæ° <var>n</var> ã¯ã12 ä»¥äž 21 以äžã§ãããåŸç¹èšç®ã«å¿
èŠãªãã³æ°ãéäžè¶³ãªãäžãããããã®ãšããŸãã
</p>
<H2>Output</H2>
<p>
å
¥åããŒã¿ã»ããããšã«ãåŠç±çªå·ãšåŸç¹ããåŸç¹ã®é«ãé ïŒåç¹ã®å Žåã¯åŠç±çªå·ã®è¥ãé ïŒã«åºåããŸããåŠç±çªå·ãšåŸç¹ãïŒã€ã®ç©ºçœã§åºåã£ãŠïŒè¡ã«åºåããŠãã ããã
</p>
<H2>Sample Input</H2>
<pre>
3
1010 6 3 10 7 1 0 7 9 1 10 6 2 4 3 9 1 9 0
1200 5 3 9 1 7 1 0 0 8 1 10 10 4 3 9 1 8 2 9
1101 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
4
3321 8 2 10 9 1 7 0 10 10 10 0 8 10 10 10 10
3332 5 0 10 9 1 4 1 9 0 10 10 7 1 5 2 8 1
3335 10 10 10 10 10 10 10 10 10 10 10 10
3340 8 2 7 3 6 4 8 2 8 2 9 1 7 3 6 4 8 2 9 1 7
0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1200 127
1010 123
1101 60
3335 300
3321 200
3340 175
3332 122
</pre>
| [
[
"3\n1010 6 3 10 7 1 0 7 9 1 10 6 2 4 3 9 1 9 0\n1200 5 3 9 1 7 1 0 0 8 1 10 10 4 3 9 1 8 2 9\n1101 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3\n4\n3321 8 2 10 9 1 7 0 10 10 10 0 8 10 10 10 10\n3332 5 0 10 9 1 4 1 9 0 10 10 7 1 5 2 8 1\n3335 10 10 10 10 10 10 10 10 10 10 10 10\n3340 8 2 7 3 6 4 8 2 8 2 9 1 7 3 6 4 8 2 9 1 7\n0\n",
"3\n1010 6 3 10 7 1 0 7 9 1 10 6 2 4 3 9 1 9 0\n1200 5 3 9 1 7 1 0 0 8 1 10 10 4 3 9 1 8 2 9\n1101 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3\n4\n3321 8 2 10 9 1 7 0 10 10 10 0 8 10 10 10 10\n3332 5 0 10 9 1 4 1 9 0 10 10 7 1 5 2 8 1\n3335 10 10 10 10 10 10 10 10 10 10 10 10\n3340 8 2 7 3 6 4 8 2 8 2 9 1 7 3 6 4 8 2 9 1 7\n0\n"
]
] |
p00153 | Triangle and Circle |
<H1>äžè§åœ¢ãšå</H1>
<p>
å¹³é¢äžã«ããäžè§åœ¢ãšåã®äœçœ®é¢ä¿ãå€å®ããããã°ã©ã ãäœæããŠãã ããã察象ãšãªãå³åœ¢ã¯ããããå¢çãå«ããã®ãšããŸãã
äžè§åœ¢ã¯ 3 é ç¹ã®äœçœ®ãäžããããåã¯äžå¿ã®äœçœ®ãšååŸãäžããããŸããäœçœ®ã¯çŽäº€åº§æšç³»ã«ããïŒã€ã®æŽæ°ã®çµã«ãã£ãŠäžããããŸããååŸãæŽæ°ã§äžããããŸãã
</p>
<H2>Input</H2>
<p>
è€æ°ã®ããŒã¿ã»ããã®äžŠã³ãå
¥åãšããŠäžããããŸããå
¥åã®çµããã¯ãŒããµãã€ã®è¡ã§ç€ºãããŸãã
åããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããŸãã
</p>
<pre>
<var>x<sub>1</sub></var> <var>y<sub>1</sub></var>
<var>x<sub>2</sub></var> <var>y<sub>2</sub></var>
<var>x<sub>3</sub></var> <var>y<sub>3</sub></var>
<var>x<sub>c</sub></var> <var>y<sub>c</sub></var>
<var>r</var>
</pre>
<p>
ïŒè¡ç®ããïŒè¡ç®ã«ãäžè§åœ¢ã®ç¬¬ <var>i</var> ã®é ç¹åº§æš <var>x<sub>i</sub></var>, <var>y<sub>i</sub></var> ãäžããããŸããïŒè¡ç®ã«åã®äžå¿ã®åº§æš <var>x<sub>c</sub></var>, <var>y<sub>c</sub></var>ãïŒè¡ç®ã«åã®ååŸ <var>r</var> ãäžããããŸããäžããããå
¥åã¯ãã¹ãŠã1 ä»¥äž 10,000 以äžã®æŽæ°ãšããŸãã
</p>
<p>
ããŒã¿ã»ããã®æ°ã¯ 100 ãè¶
ããŸããã
</p>
<H2>Output</H2>
<p>
å
¥åããŒã¿ã»ããããšã«ä»¥äžã®åœ¢åŒã§å€å®çµæãïŒè¡ã«åºåããŸãã<br/>
<br/>
åãäžè§åœ¢ã«å«ãŸããå Žå <span>a</span><br/>
äžè§åœ¢ãåã«å«ãŸããå Žå <span>b</span><br/>
ãã以å€ã®å Žåã§ãå
±ééšåãããå Žåã«ã¯ <span>c</span><br/>
å
±ééšåããªãå Žåã«ã¯ <span>d</span><br/>
</p>
<H2>Sample Input</H2>
<pre>
1 1
3 1
3 3
3 2
3
3 12
9 3
11 12
8 7
5
15 3
17 7
22 5
7 6
4
6 11
8 2
16 9
10 8
2
0 0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
b
c
d
a
</pre>
| [
[
"1 1\n3 1\n3 3\n3 2\n3\n3 12\n9 3\n11 12\n8 7\n5\n15 3\n17 7\n22 5\n7 6\n4\n6 11\n8 2\n16 9\n10 8\n2\n0 0\n",
"1 1\n3 1\n3 3\n3 2\n3\n3 12\n9 3\n11 12\n8 7\n5\n15 3\n17 7\n22 5\n7 6\n4\n6 11\n8 2\n16 9\n10 8\n2\n0 0\n"
]
] |
p00154 | Sum of Cards |
<H1>ã«ãŒãã®çµã¿åãã</H1>
<p>
æŽæ°ãæžããŠããã«ãŒããäœæãå
¥ã£ãŠããè¢ã䜿ã£ãŠã²ãŒã ãããŸããããååã®ã²ãŒã ã§åå è
ã¯ãŸãã奜ããªæ° <var>n</var> ãäžã€å®£èšããŸãããããŠãè¢ã®äžããé©åœãªææ°ã ãã«ãŒããäžåºŠã«åãåºããŠããããã®ã«ãŒãã«æžãããæ°ã®ç·åã <var>n</var> ã«çãããã°è±ªè¯è³åãããããŸãããªããããããã®ã²ãŒã çµäºåŸã«ãŒãã¯è¢ã«æ»ãããŸãã
</p>
<p>
è¢ã®äžã® <var>m</var> çš®é¡ã®ã«ãŒãã®æ
å ±ããã³ã<var>g</var> åã®ã²ãŒã ã§åå è
ã宣èšããæ°ãå
¥åãšããããããã®ã²ãŒã ã§è±ªè¯ååãããããã«ãŒãã®çµã¿åãããäœéãããããåºåããããã°ã©ã ãäœæããŠãã ããã
</p>
<H2>Input</H2>
<p>
è€æ°ã®ããŒã¿ã»ããã®äžŠã³ãå
¥åãšããŠäžããããŸããå
¥åã®çµããã¯ãŒãã²ãšã€ã®è¡ã§ç€ºãããŸãã
åããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããŸãã
</p>
<pre>
<var>m</var>
<var>a<sub>1</sub></var> <var>b<sub>1</sub></var>
<var>a<sub>2</sub></var> <var>b<sub>2</sub></var>
:
<var>a<sub>m</sub></var> <var>b<sub>m</sub></var>
<var>g</var>
<var>n<sub>1</sub></var>
<var>n<sub>2</sub></var>
:
<var>n<sub>g</sub></var>
</pre>
<p>
ïŒè¡ç®ã«ã«ãŒãã®çš®é¡æ° <var>m</var> ïŒ1 ≤ <var>m</var> ≤ 7ïŒãç¶ã <var>m</var> è¡ã« <var>i</var> çš®é¡ç®ã®ã«ãŒãã«æžãããæŽæ° <var>a<sub>i</sub></var> (1 ≤ <var>a<sub>i</sub></var> ≤ 100) ãšãã®ææ° <var>b<sub>i</sub></var> (1 ≤ <var>b<sub>i</sub></var> ≤ 10) ã空çœåºåãã§äžããããŸãã
</p>
<p>
ç¶ãè¡ã«ã²ãŒã ã®åæ° <var>g</var> (1 ≤ <var>g</var> ≤ 10)ãç¶ã <var>g</var> è¡ã«ã²ãŒã <var>i</var> ã§å®£èšãããæŽæ° <var>n<sub>i</sub></var> (1 ≤ <var>n<sub>i</sub></var> ≤ 1,000) ãäžããããŸãã
</p>
<p>
ããŒã¿ã»ããã®æ°ã¯ 100 ãè¶
ããªãã
</p>
<H2>Output</H2>
<p>
å
¥åããŒã¿ã»ããããšã«ã<var>i</var> è¡ç®ã«ã²ãŒã <var>i</var> ã§è±ªè¯è³åãããããã«ãŒãã®çµã¿åããæ°ãåºåããŸãã
</p>
<H2>Sample Input</H2>
<pre>
5
1 10
5 3
10 3
25 2
50 2
4
120
500
100
168
7
1 10
3 10
5 10
10 10
25 10
50 10
100 10
3
452
574
787
0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
16
0
12
7
9789
13658
17466
</pre>
| [
[
"5\n1 10\n5 3\n10 3\n25 2\n50 2\n4\n120\n500\n100\n168\n7\n1 10\n3 10\n5 10\n10 10\n25 10\n50 10\n100 10\n3\n452\n574\n787\n0\n",
"5\n1 10\n5 3\n10 3\n25 2\n50 2\n4\n120\n500\n100\n168\n7\n1 10\n3 10\n5 10\n10 10\n25 10\n50 10\n100 10\n3\n452\n574\n787\n0\n"
]
] |
p00155 | Spider Jin |
<H1>ã¹ãã€ããŒäºº</H1>
<p>
æ£çŸ©ã®ããŒããŒãã¹ãã€ããŒäººãã¯ãè
ããããŒããåºããŠãã«ãããã«ãžé£ã³ç§»ãããšãã§ããŸããããããããŒããçãã®ã§èªåããã®è·é¢ã 50 以äžã®ãã«ã«ãã移åã§ããŸãããããããé ãã®ãã«ã«ç§»åããã«ã¯ãäžæŠå¥ã®ãã«ã«é£ã³ç§»ããªããŠã¯ãªããŸããã
</p>
<br>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_spider">
</center>
<br><br>
<p>
ãã«ã®æ° <var>n</var>ã<var>n</var> åã®ãã«ã®æ
å ±ãã¹ãã€ããŒäººã®ç§»åéå§äœçœ®åã³ç®çå°ãå
¥åãšãããã®ç§»åã®æççµè·¯ãåºåããããã°ã©ã ãäœæããŠãã ãããã©ã®ããã«ãã«ãçµç±ããŠãç®æšã®ãã«ã«ç§»åã§ããªãå Žå㯠NA ãšåºåããŠãã ãããåãã«ã¯ç¹ãšããŠæ±ããæçè·é¢ã§ç§»åãããã«ã®çµç±æ¹æ³ãïŒã€ä»¥äžååšããããšã¯ãªããã®ãšããŸãã
</p>
<H2>Input</H2>
<p>
è€æ°ã®ããŒã¿ã»ããã®äžŠã³ãå
¥åãšããŠäžããããŸããå
¥åã®çµããã¯ãŒãã²ãšã€ã®è¡ã§ç€ºãããŸãã
åããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããŸãã
</p>
<pre>
<var>n</var>
<var>b<sub>1</sub></var> <var>x<sub>1</sub></var> <var>y<sub>1</sub></var>
<var>b<sub>2</sub></var> <var>x<sub>2</sub></var> <var>y<sub>2</sub></var>
:
<var>b<sub>n</sub></var> <var>x<sub>n</sub></var> <var>y<sub>n</sub></var>
<var>m</var>
<var>s<sub>1</sub></var> <var>g<sub>1</sub></var>
<var>s<sub>2</sub></var> <var>g<sub>2</sub></var>
:
<var>s<sub>m</sub></var> <var>g<sub>m</sub></var>
</pre>
<p>
ïŒè¡ç®ã«ãã«ã®æ° <var>n</var> (1 ≤ <var>n</var> ≤ 100)ãç¶ã <var>n</var> è¡ã« <var>i</var> çªç®ã®ãã«ã®ãã«çªå· <var>b<sub>i</sub></var> (1 ≤ <var>b<sub>i</sub></var> ≤ <var>n</var>)ããã®ãã«ã®x座æšãšy座æšãè¡šãæŽæ° <var>x<sub>i</sub></var>, <var>y<sub>i</sub></var> (-1000 ≤ <var>x<sub>i</sub></var>, <var>y<sub>i</sub></var> ≤ 1000) ã空çœåºåãã§äžããããŸãã
</p>
<p>
ç¶ãè¡ã«ç§»åæ
å ±ã®åæ° <var>m</var> (1 ≤ <var>m</var> ≤ 100)ãç¶ã <var>m</var> è¡ã«<var>i</var> çªç®ã®ç§»åæ
å ±ãäžããããŸããå移åæ
å ±ãšããŠã移åãéå§ãããã«ã®çªå· <var>s<sub>i</sub></var> ãšç®çå°ãã«ã®çªå· <var>g<sub>i</sub></var> ã空çœåºåãã§äžããããŸãã
</p>
<p>
ããŒã¿ã»ããã®æ°ã¯ 10 ãè¶
ããŸããã
</p>
<H2>Output</H2>
<p>
å
¥åããŒã¿ã»ããããšã«æ¬¡ã®åœ¢åŒã§åºåããŸãã
</p>
<p>
<var>i</var> è¡ç®ã« <var>i</var> çªç®ã®ç§»åæ
å ±ã«å¯Ÿããçµè·¯ãŸã㯠NA ãïŒè¡ã«åºåããŸããåçµè·¯ã¯ä»¥äžã®åœ¢åŒã§åºåããŸãã
</p>
<pre>
<var>s<sub>i</sub></var> <var>br<sub>i1</sub></var> <var>br<sub>i2</sub></var> ... <var>g<sub>i</sub></var>
</pre>
<p>
<var>br<sub>ij</sub></var> 㯠<var>i</var> çªç®ã®ç§»åæ
å ±ã«ãããã<var>j</var> çªç®ã«çµç±ãããã«ã®çªå·ãè¡šããŸãã
</p>
<H2>Sample Input</H2>
<pre>
4
1 0 0
2 30 0
3 60 40
4 0 60
2
1 3
1 4
22
1 0 0
2 150 40
3 30 20
4 180 150
5 40 80
6 130 130
7 72 28
8 172 118
9 50 50
10 160 82
11 90 105
12 144 131
13 130 64
14 80 140
15 38 117
16 190 90
17 60 100
18 100 70
19 130 100
20 71 69
21 200 110
22 120 150
1
1 22
0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1 2 3
NA
1 3 9 20 11 6 22
</pre>
| [
[
"4\n1 0 0\n2 30 0\n3 60 40\n4 0 60\n2\n1 3\n1 4\n22\n1 0 0\n2 150 40\n3 30 20\n4 180 150\n5 40 80\n6 130 130\n7 72 28\n8 172 118\n9 50 50\n10 160 82\n11 90 105\n12 144 131\n13 130 64\n14 80 140\n15 38 117\n16 190 90\n17 60 100\n18 100 70\n19 130 100\n20 71 69\n21 200 110\n22 120 150\n1\n1 22\n0\n",
"4\n1 0 0\n2 30 0\n3 60 40\n4 0 60\n2\n1 3\n1 4\n22\n1 0 0\n2 150 40\n3 30 20\n4 180 150\n5 40 80\n6 130 130\n7 72 28\n8 172 118\n9 50 50\n10 160 82\n11 90 105\n12 144 131\n13 130 64\n14 80 140\n15 38 117\n16 190 90\n17 60 100\n18 100 70\n19 130 100\n20 71 69\n21 200 110\n22 120 150\n1\n1 22\n0\n"
]
] |
p00156 | Moats around the Castle |
<H1>åã®å </H1>
<p>
ããŸãå¿è
ãåå€ãã倩å®é£ã«å¿ã³å
¥ãããšèšç»ãç«ãŠãŠããŸãããã®å¿è
ã¯å°é¢ãèµ°ã£ãããå ã®äžãæ³³ãã ãããããšã¯é£ãªãã§ããŸãããå ããéãäžããããšã¯ãšãŠãèŠæãªã®ã§ãå¿è
ã¯å ã«å
¥ãåæ°ãã§ããã ãå°ãªãããããšèããŠããŸãã
</p>
<p>
ãåã®èŠåå³ãå
¥åãšããåå€ãã倩å®é£ã«è³ããŸã§ã«ãå ããéãäžãããªããŠã¯ãªããªãæå°åæ°ãåºåããããã°ã©ã ãäœæããŠäžããããåã®èŠåå³ã¯äºæ¬¡å
æ ŒåãšããŠäžããããŸããèŠåãå³ã«æãããèšå·ã«ã¯ã倩å®é£ã®äœçœ®ã瀺ãã&ããšå ã®äœçœ®ã瀺ãã#ãã®äœçœ®ãèšããããã®ã»ãã®å°ç¹ã«ã¯ã.ãïŒåè§ããªãªãïŒãèšãããŠããŸãããªãããåã«ã¯å€©å®é£ã¯äžã€ã ããããã®ãšããå¿è
ã¯èµ°ã£ããæ³³ãã ãããŠç§»åãããšãã«æ±è¥¿ååæ¹åã«1ãã¹ãã€ç§»åãããã®ãšããæãã«ã¯ç§»åããŸããã
</p>
<H2>Input</H2>
<p>
è€æ°ã®ããŒã¿ã»ããã®äžŠã³ãå
¥åãšããŠäžããããŸããå
¥åã®çµããã¯ãŒãïŒã€ã®è¡ã§ç€ºãããŸããåããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããŸãã
</p>
<pre>
<var>n</var> <var>m</var>
<var>c<sub>1,1</sub></var><var>c<sub>1,2</sub></var>...<var>c<sub>1,n</sub></var>
<var>c<sub>2,1</sub></var><var>c<sub>2,2</sub></var>...<var>c<sub>2,n</sub></var>
:
<var>c<sub>m,1</sub></var><var>c<sub>m,2</sub></var>...<var>c<sub>m,n</sub></var>
</pre>
<p>
ïŒè¡ç®ã«èŠåå³ã®æ±è¥¿ã®å¹
<var>n</var> ãš ååã®å¹
<var>m</var> (1 ≤ <var>n</var>, <var>m</var> ≤ 100) ãäžãããããç¶ã<var>m</var> è¡ã«èŠåãå³ã® <var>i</var> è¡ç®ã®æ
å ±ãäžãããããåæ
å ±ã¯èšå·ã&ããã#ããã.ããããªãé·ã <var>n</var> ã®æååã§ããã
</p>
<p>
ããŒã¿ã»ããã®æ°ã¯ 50 ãè¶ããªãã
</p>
<H2>Output</H2>
<p>
ããŒã¿ã»ããããšã«å ããéãäžãããªããŠã¯ãªããªãæå°åæ°ïŒæŽæ°ïŒãïŒè¡ã«åºåããŸãã
</p>
<H2>Sample Input</H2>
<pre>
5 5
.###.
#...#
#.&.#
#...#
.###.
18 15
..####....####....
####..####....####
#...............##
.#.############.##
#..#..........#.##
.#.#.########.#.##
#..#.#......#.#.##
.#.#....&...#.#.##
#..#........#.#.##
.#.#.########.#.##
#..#..........#.##
.#.############.##
#...............##
.#################
##################
9 10
#########
........#
#######.#
#.....#.#
#.###.#.#
#.#&#.#.#
#.#...#.#
#.#####.#
#.......#
#########
9 3
###...###
#.#.&.#.#
###...###
0 0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1
2
0
0
</pre>
| [
[
"5 5\n.###.\n#...#\n#.&.#\n#...#\n.###.\n18 15\n..####....####....\n####..####....####\n#...............##\n.#.############.##\n#..#..........#.##\n.#.#.########.#.##\n#..#.#......#.#.##\n.#.#....&...#.#.##\n#..#........#.#.##\n.#.#.########.#.##\n#..#..........#.##\n.#.############.##\n#...............##\n.#################\n##################\n9 10\n#########\n........#\n#######.#\n#.....#.#\n#.###.#.#\n#.#&#.#.#\n#.#...#.#\n#.#####.#\n#.......#\n#########\n9 3\n###...###\n#.#.&.#.#\n###...###\n0 0\n",
"5 5\n.###.\n#...#\n#.&.#\n#...#\n.###.\n18 15\n..####....####....\n####..####....####\n#...............##\n.#.############.##\n#..#..........#.##\n.#.#.########.#.##\n#..#.#......#.#.##\n.#.#....&...#.#.##\n#..#........#.#.##\n.#.#.########.#.##\n#..#..........#.##\n.#.############.##\n#...............##\n.#################\n##################\n9 10\n#########\n........#\n#######.#\n#.....#.#\n#.###.#.#\n#.#&#.#.#\n#.#...#.#\n#.#####.#\n#.......#\n#########\n9 3\n###...###\n#.#.&.#.#\n###...###\n0 0\n"
]
] |
p00157 | Russian Dolls |
<H1>ãããªã§ãŒã·ã«</H1>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_russianDolls">
</center>
<p>
ãããªã§ãŒã·ã«ãšã¯å¥³æ§åãããã©ã£ãæšè£œã®äººåœ¢ã§ããã·ã¢ã®ä»£è¡šçãªæ°èžåã§ãããããªã§ãŒã·ã«ã¯ã倧ããªäººåœ¢ã®äžã«ããããå°ããªäººåœ¢ãå
¥ã£ãŠããå
¥ãåæ§é ã«ãªã£ãŠããã倧ããã®ç°ãªãè€æ°ã®äººåœ¢ã§æ§æãããŠããŸãããã®ãããªå
¥ãåæ§é ã«ãããããå人圢ã®èŽäœã¯äžäžã§åå²ã§ããçç¶ã®æ§é ã«ãªã£ãŠããŸãããããªã§ãŒã·ã«ã¯è·äººã®æã§æäœãããããããäžã€äžã€ã®äººåœ¢ã¯äžçã«äžã€ãããªãéåžžã«è²Žéãªãã®ã«ãªããŸãã
</p>
<p>
å
åŒã§ããäžéåãšæ¬¡éåã¯ããããªã§ãŒã·ã«ã§éã¶ã®ã倧奜ãã§ãåèªããããã1çµã®ãããªã§ãŒã·ã«ãæã£ãŠããŸãããäžéåã®ãããªã§ãŒã·ã«ã¯ <var>n</var> åã®äººåœ¢ããæ§æãããŠããã次éåã®ãããªã§ãŒã·ã«ã¯ <var>m</var> åã®äººåœ¢ããæ§æãããŠããŸãã
</p>
<p>
ããæ¥ã奜å¥å¿ãæºçãªäžéåã¯ãããã2çµã®ãããªã§ãŒã·ã«ã«å«ãŸãã人圢ãã¡ãçµã¿åãããŠãããå€ãã®äººåœ¢ãå«ãæ°ããªãããªã§ãŒã·ã«ãäœããªãããšèããŸãããã€ãŸãã<var>n + m</var> åã®äººåœ¢ã䜿ãã<var>k</var> åã®äººåœ¢ãããªãïŒçµã®ãããªã§ãŒã·ã«ãäœãããšãè©Šã¿ãã®ã§ãã<var>n</var> ãš <var>m</var> ã®å€§ããæ¹ããã <var>k</var> ã倧ããããããšãã§ããã°ãäžéåã®ç®çã¯éæãããŸãã
</p>
<p>
å
åŒã¯2人仲è¯ããã©ã®ããã«äººåœ¢ãçµã¿åãããã° <var>k</var> ã®å€ãæ倧ã«ã§ããããèããŸããããããã幌ã2人ã«ãšã£ãŠãã®åé¡ã¯ããŸãã«ãé£ããã®ã§ã幎äžã®ããªãã¯ããã°ã©ã ãäœæããŠåŒãã¡ãå©ããããšã«ããŸããã
</p>
<p>
äžéåãšæ¬¡éåã®ãããªã§ãŒã·ã«ã®äººåœ¢ã®æ
å ±ãå
¥åãšããæ°ããªãããªã§ãŒã·ã«ãå«ã人圢ã®æ° <var>k</var> ãåºåããããã°ã©ã ãäœæããŠäžãããå
¥åããã人圢ã«å€§ãããåããã®ã¯ååšããŸããããŸãã人圢ãé«ã <var>h</var> ååŸ <var>r</var> ã®åæ±ãšã¿ãªããå Žåãé«ã<var>h</var>ãååŸ <var>r</var> ã®äººåœ¢ãå«ãããšã®ã§ãã人圢㯠<var>x < h </var> ã〠<var>y < r</var> ãæºããé«ã <var>x</var> ååŸ <var>y</var> ã®äººåœ¢ã§ãã
</p>
<H2>Input</H2>
<p>
è€æ°ã®ããŒã¿ã»ããã®äžŠã³ãå
¥åãšããŠäžããããŸããå
¥åã®çµããã¯ãŒãã²ãšã€ã®è¡ã§ç€ºãããŸããåããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããŸãã
</p>
<pre>
<var>n</var>
<var>h<sub>1</sub></var> <var>r<sub>1</sub></var>
<var>h<sub>2</sub></var> <var>r<sub>2</sub></var>
:
<var>h<sub>n</sub></var> <var>r<sub>n</sub></var>
<var>m</var>
<var>h<sub>1</sub></var> <var>r<sub>1</sub></var>
<var>h<sub>2</sub></var> <var>r<sub>2</sub></var>
:
<var>h<sub>m</sub></var> <var>r<sub>m</sub></var>
</pre>
<p>
ïŒè¡ç®ã«äžéåã®ãããªã§ãŒã·ã«ã®äººåœ¢ã®æ° <var>n</var> (<var>n</var> ≤ 100)ãç¶ã <var>n</var> è¡ã«äžéåã®ç¬¬ <var>i</var> ã®äººåœ¢ã®é«ã <var>h<sub>i</sub></var> ãšååŸ <var>r<sub>i</sub></var> (<var>h<sub>i</sub></var>, <var>r<sub>i</sub></var> < 1000) ãäžããããŸãã
</p>
<p>
ç¶ãè¡ã«äºéåã®ãããªã§ãŒã·ã«ã®äººåœ¢ã®æ° <var>m</var> (<var>m</var> ≤ 100)ãç¶ã <var>m</var> è¡ã«äºéåã®ç¬¬ <var>i</var> ã®äººåœ¢ã®é«ã <var>h<sub>i</sub></var> ãšååŸ <var>r<sub>i</sub></var> (<var>h<sub>i</sub></var>, <var>r<sub>i</sub></var> < 1000) ãäžããããŸãã
</p>
<p>
ããŒã¿ã»ããã®æ°ã¯ 20 ãè¶ããªãã
</p>
<H2>Output</H2>
<p>
å
¥åããŒã¿ã»ããããšã«æ°ããªãããªã§ãŒã·ã«ãå«ã人圢ã®æ° <var>k</var> ãåºåããŸãã
</p>
<H2>Sample Input</H2>
<pre>
6
1 1
4 3
6 5
8 6
10 10
14 14
5
2 2
5 4
6 6
9 8
15 10
4
1 1
4 3
6 5
8 6
3
2 2
5 4
6 6
4
1 1
4 3
6 5
8 6
4
10 10
12 11
18 15
24 20
0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
9
6
8
</pre>
| [
[
"6\n1 1\n4 3\n6 5\n8 6\n10 10\n14 14\n5\n2 2\n5 4\n6 6\n9 8\n15 10\n4\n1 1\n4 3\n6 5\n8 6\n3\n2 2\n5 4\n6 6\n4\n1 1\n4 3\n6 5\n8 6\n4\n10 10\n12 11\n18 15\n24 20\n0\n",
"6\n1 1\n4 3\n6 5\n8 6\n10 10\n14 14\n5\n2 2\n5 4\n6 6\n9 8\n15 10\n4\n1 1\n4 3\n6 5\n8 6\n3\n2 2\n5 4\n6 6\n4\n1 1\n4 3\n6 5\n8 6\n4\n10 10\n12 11\n18 15\n24 20\n0\n"
]
] |
p00158 | Collatz's Problem |
<H1>ã³ã©ããã®äºæ³</H1>
<p>
æ£ã®æŽæ° <var>n</var> ã«å¯Ÿãã
</p>
<ul>
<li><var>n</var> ãå¶æ°ã®æ㯠2 ã§å²ãã</li>
<li><var>n</var> ãå¥æ°ã®æ㯠3 åãã1 ã足ãã</li>
</ul>
<p>
ãšããæäœãç¹°ãè¿ããšçµæã 1 ã«ãªããŸããä»»æã®æ£ã®æŽæ° <var>n</var> ã«å¯ŸããŠãã®æäœãç¹°ãè¿ããšå¿
ã 1 ã«ãªãã§ããããšããã®ããã³ã©ããã®äºæ³ããšåŒã°ããåé¡ã§ãããã®åé¡ã¯æ¥æ¬ã§ã¯ããè§è°·ã®åé¡ããšããŠãç¥ãããŠããæªè§£æ±ºã®åé¡ã§ããã³ã³ãã¥ãŒã¿ãå©çšããŠéåžžã«å€§ããªæ° 3 × 2<sup>53</sup> = 27,021,597,764,222,976 以äžã«ã€ããŠã¯åäŸããªãããšãç¥ãããŠããŸãããæ°åŠçã«ã¯èšŒæãããŠããŸããã
</p>
<p>
æŽæ° <var>n</var> ãå
¥åãšããçµæã 1 ã«ãªããŸã§ã«ç¹°ãè¿ãããæäœã®åæ°ãåºåããããã°ã©ã ãäœæããŠãã ãããæŽæ° <var>n</var> 㯠1 以äžã§ãã€äžèšã®èšç®ãç¹°ãè¿ãéäžã®å€ã 1000000 以äžãšãªãçšåºŠã®æŽæ°ãšããŸããããšãã°ãå
¥åãšã㊠3 ãåãåã£ãå Žåã¯ãæäœåã¯
</p>
<pre>
3 â 10 â 5 â 16 â 8 â 4 â 2 â 1
</pre>
<p>
ã«ãªãã®ã§ãæäœã®åæ°ïŒäžã®ç¢å°ã®åæ°ïŒã§ãã 7 ãåºåããŸãã
</p>
<H2>Input</H2>
<p>
è€æ°ã®ããŒã¿ã»ããã®äžŠã³ãå
¥åãšããŠäžããããŸããå
¥åã®çµããã¯ãŒãã²ãšã€ã®è¡ã§ç€ºãããŸãã
åããŒã¿ã»ãããšããŠïŒã€ã®æŽæ° <var>n</var> (<var>n</var> ≤ 1000000) ãïŒè¡ã«äžããããŸãã
</p>
<p>
ããŒã¿ã»ããã®æ°ã¯ 50 ãè¶ããªãã
</p>
<H2>Output</H2>
<p>
ããŒã¿ã»ããããšã«æäœã®åæ°ãïŒè¡ã«åºåããŸãã
</p>
<H2>Sample Input</H2>
<pre>
3
10
0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
7
6
</pre>
| [
[
"3\n10\n0\n",
"3\n10\n0\n"
]
] |
p00159 | The Best Body |
<H1>çæ³ã®äœå</H1>
<p>
è¥æºåºŠãè¡šãææ°ãšããŠBMIïŒBody Mass IndexïŒããããŸããBMIã®å€ã¯ä»¥äžã®åŒã§èšç®ããŸãã
</p>
<center>
<p>
BMI = äœé(kg) / (身é·(m))<sup>2</sup>
</p>
</center>
<p>
BMIã®å€ãæšæºå€ã«è¿ãã»ã©ãçæ³ã®äœåããšèããããŸããããã§ãBMIã®æšæºå€ã 22 ãšããå Žåã察象è
ã®æ
å ±ãå
¥åãšããæããçæ³ã®äœåãã«è¿ã人ã®æ
å ±ãåºåããããã°ã©ã ãäœæããŠãã ããã
</p>
<p>
察象è
ã®æ°ã <var>n</var> ãšãããšãå察象è
ã«ã¯éè€ã®ãªãããã«1 ä»¥äž <var>n</var> 以äžã®æŽæ°å€ã®åä»çªå· <var>p</var> ãæ¯ãããŠããŸãã
</p>
<H2>Input</H2>
<p>
è€æ°ã®ããŒã¿ã»ããã®äžŠã³ãå
¥åãšããŠäžããããŸããå
¥åã®çµããã¯ãŒãã²ãšã€ã®è¡ã§ç€ºãããŸããåããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããŸãã
</p>
<pre>
<var>n</var>
<var>p<sub>1</sub></var> <var>h<sub>1</sub></var> <var>w<sub>1</sub></var>
<var>p<sub>2</sub></var> <var>h<sub>2</sub></var> <var>w<sub>2</sub></var>
:
<var>p<sub>n</sub></var> <var>h<sub>n</sub></var> <var>w<sub>n</sub></var>
</pre>
<p>
ïŒè¡ç®ã«å¯Ÿè±¡è
ã®äººæ° <var>n</var> (<var>n</var> ≤ 1000)ãç¶ã <var>n</var> è¡ã« <var>i</var> 人ç®ã®å¯Ÿè±¡è
ã®åä»çªå· <var>p<sub>i</sub></var> (1 ≤ <var>p<sub>i</sub></var> ≤ <var>n</var>)ãã»ã³ãã¡ãŒãã«åäœã®èº«é· <var>h<sub>i</sub></var> (1 ≤ <var>h<sub>i</sub></var> ≤ 200)ãããã°ã©ã åäœã®äœé <var>w<sub>i</sub></var> (1 ≤ <var>w<sub>i</sub></var> ≤ 200) ãäžããããŸããå
¥åã¯å
šãŠæŽæ°ã§äžããããŸãã
</p>
<H2>Output</H2>
<p>
ããŒã¿ã»ããããšã«ãçæ³ã®äœåãã«æãè¿ã人ã®åä»çªå·ïŒæŽæ°ïŒãïŒè¡ã«åºåããŸããæããçæ³ã®äœåãã«è¿ã人ãäºäººä»¥äžããå Žåã¯ãåä»çªå·ã®å°ããæ¹ãåºåããããšãšããŸãã
</p>
<H2>Sample Input</H2>
<pre>
6
1 165 66
2 178 60
3 180 72
4 160 65
5 185 62
6 182 62
3
3 160 65
2 180 70
1 170 75
0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
3
2
</pre>
| [
[
"6\n1 165 66\n2 178 60\n3 180 72\n4 160 65\n5 185 62\n6 182 62\n3\n3 160 65\n2 180 70\n1 170 75\n0\n",
"6\n1 165 66\n2 178 60\n3 180 72\n4 160 65\n5 185 62\n6 182 62\n3\n3 160 65\n2 180 70\n1 170 75\n0\n"
]
] |
p00160 | Delivery Fee |
<H1>å®
é
æé</H1>
<p>
ããå®
é
æ¥è
ã®å®
é
æéã¯å€§ãããšééã§äžè¡šã®ããã«æéãèšå®ãããŠããŸãã
</p>
<center>
<table>
<tr>
<td width="80"></td>
<td width="100">A ãµã€ãº</td>
<td width="100">B ãµã€ãº</td>
<td width="100">C ãµã€ãº</td>
<td width="100">D ãµã€ãº</td>
<td width="100">E ãµã€ãº</td>
<td width="100">F ãµã€ãº</td>
</tr>
<tr>
<td>倧ãã</td>
<td>60cm以å
</td>
<td>80cm以å
</td>
<td>100cm以å
</td>
<td>120cm以å
</td>
<td>140cm以å
</td>
<td>160cm以å
</td>
</tr>
<td>éã</td>
<td>2kg以å
</td>
<td>5kg以å
</td>
<td>10kg以å
</td>
<td>15kg以å
</td>
<td>20kg以å
</td>
<td>25kg以å
</td>
</tr>
<tr>
<td>æé</td>
<td>600å</td>
<td>800å</td>
<td>1000å</td>
<td>1200å</td>
<td>1400å</td>
<td>1600å</td>
</tr>
</table>
</center>
<br/>
<p>
倧ããã¯äžèŸºïŒçžŠã暪ãé«ãïŒã®åã§ããäŸãã°å€§ããã120cmã§ãéãã15kg以å
ã®è·ç©ã¯ïŒ€ãµã€ãºïŒ1,200åïŒãšãªããŸãã倧ããã120cm以å
ã§ããéãã15kgãè¶
ãã20kg以å
ãªãã°ïŒ¥ãµã€ãºãšãªããŸãã
</p>
<p>
1æ¥ã«æã¡èŸŒãŸããè·ç©ã®æ
å ±ãå
¥åãšããæéã®ç·èšãåºåããããã°ã©ã ãäœæããŠãã ããããªãããµã€ãºãè¶
ããè·ç©ã¯å¯Ÿè±¡å€ãšãæéã®ç·èšã«ã¯å«ã¿ãŸããã
</p>
<H2>Input</H2>
<p>
è€æ°ã®ããŒã¿ã»ããã®äžŠã³ãå
¥åãšããŠäžããããŸããå
¥åã®çµããã¯ãŒãã²ãšã€ã®è¡ã§ç€ºãããŸãã
åããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããŸãã
</p>
<pre>
<var>n</var>
<var>x<sub>1</sub></var> <var>y<sub>1</sub></var> <var>h<sub>1</sub></var> <var>w<sub>1</sub></var>
<var>x<sub>2</sub></var> <var>y<sub>2</sub></var> <var>h<sub>2</sub></var> <var>w<sub>2</sub></var>
:
<var>x<sub>n</sub></var> <var>y<sub>n</sub></var> <var>h<sub>n</sub></var> <var>w<sub>n</sub></var>
</pre>
<p>
ïŒè¡ç®ã«è·ç©ã®åæ°<var>n</var> (1 ≤ <var>n</var> ≤ 10000)ãç¶ã<var>n</var> è¡ã« <var>i</var> çªç®ã®è·ç©ã®çžŠã®é·ã <var>x<sub>i</sub></var>ã暪ã®é·ã <var>y<sub>i</sub></var>ãé«ã <var>h<sub>i</sub></var>ãéã <var>w<sub>i</sub></var> (1 ≤ <var>x<sub>i</sub></var>, <var>y<sub>i</sub></var>, <var>h<sub>i</sub></var>, <var>w<sub>i</sub></var> ≤ 200) ã空çœåºåãã§ïŒè¡ã«äžããããŸãã
</p>
<p>
ããŒã¿ã»ããã®æ°ã¯ 20 ãè¶
ããŸããã
</p>
<H2>Output</H2>
<p>
ããŒã¿ã»ããããšã«è·ç©ã®æéã®ç·èšãïŒè¡ã«åºåããŸãã
</p>
<H2>Sample Input</H2>
<pre>
2
50 25 5 5
80 60 10 30
3
10 15 25 24
5 8 12 5
30 30 30 18
0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
800
3800
</pre>
| [
[
"2\n50 25 5 5\n80 60 10 30\n3\n10 15 25 24\n5 8 12 5\n30 30 30 18\n0\n",
"2\n50 25 5 5\n80 60 10 30\n3\n10 15 25 24\n5 8 12 5\n30 30 30 18\n0\n"
]
] |
p00161 | Sport Meet |
<H1>äœè²ç¥Sport Meet</H1>
<p>
ç§ã®äœè²ç¥ãè¡ãããŸããçš®ç®ã¯åŸç«¶èµ°ãããŒã«éã³ãé害ç©ç«¶èµ°ããªã¬ãŒã®4çš®ç®ã§ããåå ããŒã 㯠<var>n</var> ããŒã ã§ããã®4çš®ç®ã®åèšã¿ã€ã ãæãå°ããããŒã ããåªåãã次ã«å°ããããŒã ããæºåªåãããããŠãæäžäœãã2çªç®ã®ããŒã ããããŒããŒè³ããšããŠè¡šåœ°ããããšæããŸãã
</p>
<p>
åããŒã ã®æ瞟ãå
¥åãšããŠããåªåãããæºåªåãããããŒããŒè³ãã®ããŒã ãåºåããããã°ã©ã ãäœæããŠãã ããã
ãã ããããŒã ã«ã¯ãããã 1 ãã <var>n</var> ã®ããŒã çªå·ãå²ãåœãŠãããŠããŸãã
</p>
<H2>Input</H2>
<p>
è€æ°ã®ããŒã¿ã»ããã®äžŠã³ãå
¥åãšããŠäžããããŸããå
¥åã®çµããã¯ãŒãã²ãšã€ã®è¡ã§ç€ºãããŸãã
åããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããŸãã
</p>
<pre>
<var>n</var>
<var>record<sub>1</sub></var>
<var>record<sub>2</sub></var>
:
<var>record<sub>n</sub></var>
</pre>
<p>
ïŒè¡ç®ã«å¯Ÿè±¡ãšãªãããŒã ã®æ° <var>n</var> (4 ≤ <var>n</var> ≤ 100000)ãç¶ã <var>n</var> è¡ã« <var>i</var> çªç®ã®ããŒã ã®æ
å ±ãäžããããŸããåããŒã ã®æ
å ±ã¯ä»¥äžã®åœ¢åŒã§äžããããŸãã
</p>
<pre>
<var>id</var> <var>m1</var> <var>s1</var> <var>m2</var> <var>s2</var> <var>m3</var> <var>s3</var> <var>m4</var> <var>s4</var>
</pre>
<p>
<var>id</var> (1 ≤ <var>id</var> ≤ <var>n</var>)ã¯ããŒã çªå·ã<var>m1</var>, <var>s1</var> ã¯ããããåŸç«¶èµ°ã®ã¿ã€ã ã®åãšç§ã<var>m2</var>, <var>s2</var> ã¯ããããããŒã«éã³ã®ã¿ã€ã ã®åãšç§ã<var>m3</var>, <var>s3</var> ã¯ããããé害ç©ç«¶èµ°ã®ã¿ã€ã ã®åãšç§ã<var>m4</var>, <var>s4</var> ã¯ãããããªã¬ãŒã®ã¿ã€ã ã®åãšç§ãè¡šããŸããåãšç§ã¯ãšãã«0 ä»¥äž 59 以äžã®æŽæ°ã§ãããŸããåèšã¿ã€ã ãè€æ°ã®ããŒã ã§åãã«ãªããããªå
¥åã¯ãªããã®ãšããŸãã
</p>
<H2>Output</H2>
<p>
å
¥åããŒã¿ã»ããããšã«ä»¥äžã®åœ¢åŒã§ããŒã çªå·ãåºåããŸãã<br/>
<br/>
1 è¡ç® åªåã®ããŒã çªå·<br/>
2 è¡ç® æºåªåã®ããŒã çªå·<br/>
3 è¡ç® ããŒããŒè³ã®ããŒã çªå·<br/>
</p>
<H2>Sample Input</H2>
<pre>
8
34001 3 20 3 8 6 27 2 25
20941 3 5 2 41 7 19 2 42
90585 4 8 3 12 6 46 2 34
92201 3 28 2 47 6 37 2 58
10001 3 50 2 42 7 12 2 54
63812 4 11 3 11 6 53 2 22
54092 3 33 2 54 6 18 2 19
25012 3 44 2 58 6 45 2 46
4
1 3 23 1 23 1 34 4 44
2 5 12 2 12 3 41 2 29
3 5 24 1 24 2 0 3 35
4 4 49 2 22 4 41 4 23
0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
54092
34001
10001
1
3
2
</pre>
| [
[
"8\n34001 3 20 3 8 6 27 2 25\n20941 3 5 2 41 7 19 2 42\n90585 4 8 3 12 6 46 2 34\n92201 3 28 2 47 6 37 2 58\n10001 3 50 2 42 7 12 2 54\n63812 4 11 3 11 6 53 2 22\n54092 3 33 2 54 6 18 2 19\n25012 3 44 2 58 6 45 2 46\n4\n1 3 23 1 23 1 34 4 44\n2 5 12 2 12 3 41 2 29\n3 5 24 1 24 2 0 3 35\n4 4 49 2 22 4 41 4 23\n0\n",
"8\n34001 3 20 3 8 6 27 2 25\n20941 3 5 2 41 7 19 2 42\n90585 4 8 3 12 6 46 2 34\n92201 3 28 2 47 6 37 2 58\n10001 3 50 2 42 7 12 2 54\n63812 4 11 3 11 6 53 2 22\n54092 3 33 2 54 6 18 2 19\n25012 3 44 2 58 6 45 2 46\n4\n1 3 23 1 23 1 34 4 44\n2 5 12 2 12 3 41 2 29\n3 5 24 1 24 2 0 3 35\n4 4 49 2 22 4 41 4 23\n0\n"
]
] |
p00162 | Hamming Numbers |
<H1>ããã³ã°æ°</H1>
<p>
1 ã« 2, 3, 5 ãäœåã (0 å以äž) ããç®ããŠåŸãããæ°ãããã³ã°æ° (Hamming numbers) ãšåŒã³ãŸããäŸãã°ã
</p>
<ul>
<li>1</li>
<li>1 Ã 2 Ã 2 = 4</li>
<li>1 Ã 2 Ã 2 Ã 3 Ã 5 Ã 5 = 300</li>
</ul>
<p>
ãªã©ã¯ããã³ã°æ°ã§ããã11, 13, 14 ãªã©ã¯ããã³ã°æ°ã§ã¯ãããŸããã
</p>
<p>
ããã³ã°æ°ã¯ã©ãã 60 ã®ã¹ãä¹ãå²ãåã(äŸãã°ã54 㯠60<sup>3</sup> = 21600 ãå²ãåã) ã®ã§ãæå»ãªã© 60 é²æ³ã®èšç®ã«ã¯éœåã®è¯ãæ°ãšããŠæããç¥ãããŠããŸããããŸãã楜åšã®èª¿åŸã«çšããé³éã®äžã€ã§ããçŽæ£åŸã§ã¯ãé³ã®åšæ³¢æ°ã®æ¯ã 24, 27, 30, 32, 36, 40, 45, 48 ãšããããã³ã°æ°ãããªãæ°åã«ãªããŸãã
</p>
<p>
æŽæ° <var>m</var>ã<var>n</var> ãå
¥åãšãã<var>m</var> ä»¥äž <var>n</var> 以äžã®ããã³ã°æ°ã®åæ°ãåºåããããã°ã©ã ãäœæããŠãã ããã
</p>
<H2>Input</H2>
<p>
è€æ°ã®ããŒã¿ã»ããã®äžŠã³ãå
¥åãšããŠäžããããŸããå
¥åã®çµããã¯ãŒãã²ãšã€ã®è¡ã§ç€ºãããŸãã
</p>
<p>
åããŒã¿ã»ãããšããŠãïŒã€ã®æŽæ° <var>m</var> ãš <var>n</var> (1 ≤ <var>m</var>, <var>n</var> ≤ 1000000, <var>m</var> ≤ <var>n</var>) ã空çœåºåãã§ïŒè¡ã«äžããããŸãã
</p>
<p>
ããŒã¿ã»ããã®æ°ã¯ 20 ãè¶
ããŸããã
</p>
<H2>Output</H2>
<p>
ããŒã¿ã»ããããšã« <var>m</var> ä»¥äž <var>n</var> 以äžã®ããã³ã°æ°ã®åæ°ãïŒè¡ã«åºåããŸãã
</p>
<H2>Sample Input</H2>
<pre>
3 8
1 27
1 86
0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
5
17
31
</pre>
| [
[
"3 8\n1 27\n1 86\n0\n",
"3 8\n1 27\n1 86\n0\n"
]
] |
p00163 | Highway Toll |
<H1>ææéè·¯éè¡æ</H1>
<p>
20XX幎ã«åå€æ¹åžç±å¡©å çŽçºããåäŒæŽ¥çºãŸã§ã®6åºéãç·è·é¢58kmã®äŒæŽ¥äžå€®éè·¯ãå®æãééããäºå®ã§ãã
</p>
<p>
ééåŸãå幎éã¯å©çšä¿é²ã®ãã17æ30åã19æ30åãŸã§ã«åºçºICãå°çICãééãããªããã€èµ°è¡è·é¢ã40km以äžã®è»ã«å¯Ÿããéè¡æéã¯åé¡ã«ãªããŸãããã ãæéã¯50ååäœãšãã端æ°ã¯åãäžããŸããäžèšã®è¡šã¯æéãšè·é¢ã®äžèŠ§è¡šã§ãã
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_highwayToll1"><br><br>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_highwayToll2">
</center><br>
<p>
äŸãã°åå€æ¹ïŒïŒïŒããäŒæŽ¥è¥æŸïŒïŒïŒãŸã§ã¯æéã450åãè·é¢ã12kmãšãªããŸããåé¡æé垯ã§ããã°250åã«ãªããŸãã
</p>
<p>
åºçºICãåºçºICééæå»ãå°çICãå°çICééæå»ãå
¥åãšããæéãèšç®ããŠåºåããããã°ã©ã ãäœæããŠãã ããããã ããå
¥åãããæå»ã¯24 æéè¡šèšã®å€ãšããŸãããªãã17æ30åããã³19æ30åã¡ããã©ã«ééããå Žåãåé¡æé垯ã«å«ããŸãã
</p>
<H2>Input</H2>
<p>
è€æ°ã®ããŒã¿ã»ããã®äžŠã³ãå
¥åãšããŠäžããããŸããå
¥åã®çµããã¯ãŒãã²ãšã€ã®è¡ã§ç€ºãããŸãã
åããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããŸãã
</p>
<pre>
<var>d</var>
<var>h<sub>d</sub></var> <var>m<sub>d</sub></var>
<var>a</var>
<var>h<sub>a</sub></var> <var>m<sub>a</sub></var>
</pre>
<p>
ïŒè¡ç®ã«åºçºICã®çªå· <var>d</var> (1 ≤ <var>d</var> ≤ 7)ãïŒè¡ç®ã«åºçºICã®ééæå»ã®æé <var>h<sub>d</sub></var> (0 ≤ <var>h<sub>d</sub></var> ≤ 23) ãšå <var>m<sub>d</sub></var> (0 ≤ <var>m<sub>d</sub></var> ≤ 59) ãäžããããŸãã
</p>
<p>
3è¡ç®ã«å°çICã®çªå· <var>a</var> (1 ≤ <var>a</var> ≤ 7)ãïŒè¡ç®ã«å°çICã®ééæå»ã®æé <var>h<sub>a</sub></var> (0 ≤ <var>h<sub>a</sub></var> ≤ 23) ãšå <var>m<sub>a</sub></var> (0 ≤ <var>m<sub>a</sub></var> ≤ 59) ãäžããããŸãã
</p>
<H2>Output</H2>
<p>
ããŒã¿ã»ããããšã«éè¡æéïŒæŽæ°ïŒãïŒè¡ã«åºåããŸãã
</p>
<H2>Sample Input</H2>
<pre>
2
17 25
4
17 45
4
17 25
7
19 35
0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
250
1300
</pre>
| [
[
"2\n17 25\n4\n17 45\n4\n17 25\n7\n19 35\n0\n",
"2\n17 25\n4\n17 45\n4\n17 25\n7\n19 35\n0\n"
]
] |
p00164 | Ohajiki Game |
<H1>ãã¯ããåã</H1>
<p>
äžéåãšæ¬¡éåã®å
åŒã¯å®¶ã§ãããã¯ããåããããŠéã³ãŸãããã¯ããåãã¯ãäžã«æã«ç©ãŸããè€æ°ã®ãã¯ãããäºäººã亀äºã«ãšã£ãŠããã²ãŒã ã§ããäžåºŠã«1ã4åã®ãã¯ããã奜ããªæ°ã ãé ã«åããçžæã«æåŸã®1åãåãããæ¹ãåã¡ã«ãªããŸããäºäººã¯ãã€ã 32 åã®ãã¯ããã䜿ããå
ã§ããäžéåã®çªããã²ãŒã ãå§ããŸãã
</p>
<p>
ãããŸã§ã«äœåºŠãæŠã£ãŠããäºäººã§ããã次éåã¯å
ã®äžéåã«ã©ãããŠãåã€ããšãã§ããŸãããããããã®ã¯ããäžéåã¯ãã®ã²ãŒã ã®å¿
åæ³ãç¥ã£ãŠããããã§ããäžéåã¯ãæ®ãã®ãã¯ããã®æ°ã <var>n</var> ãšãããšãå¿
ã (<var>n</var> - 1) % 5 åã®ãã¯ãããåããŸãããã㧠<var>x</var> % <var>y</var> ã¯ã<var>x</var> ã <var>y</var> ã§å²ã£ãäœãã瀺ããŸãã
</p>
<p>
äžæ¹ã次éåã¯ãæ®ãã®ãã¯ããã®æ°ã«ããããããã²ãŒã ã®ã¯ããã«ååã§åããã¯ããã®æ°ãæ°åãšããŠæ±ºããŠããŸãã®ã§ããäŸãã°ã次éåã決ããæ°åã{ 3, 1, 4, 2 } ã§ãããªãã°ã圌ã®åããã¯ããã®æ°ã¯é ã« 3 -> 1 -> 4 -> 2 -> 3 -> 1 -> 4 -> ⊠ãšãªããŸãïŒåããšæ±ºããæ°ãããã¯ããã®æ®ãã®æ°ä»¥äžã«ãªã£ãå Žåã¯ãæ®ãã®ãã¯ããå
šãŠãåããŸãïŒã
</p>
<p>
ãªãã©è² ããŠãããæ¹ãå€ããããšããªãé åºãªæ¬¡éåã®å°æ¥ãå¿é
ã«ãªã£ããæ¯ããã¯ã次éåããããªãæ°åãéžãã ãšããŠãäžéåã«ã¯åãŠãªããšããããšã瀺ãããã«ãã²ãŒã ãã·ã¥ãã¬ãŒãããããã°ã©ã ãæžãããšã«ããŸããã
</p>
<p>
次éåã®èããæ°å <var>a</var> ãå
¥åãšããäžéåãšæ¬¡éåãé 次ãã¯ãããåã£ãåŸã®æ®ãã®ãã¯ããã®åæ°ãåºåããããã°ã©ã ãäœæããŠãã ããã
</p>
<H2>Input</H2>
<p>
è€æ°ã®ããŒã¿ã»ããã®äžŠã³ãå
¥åãšããŠäžããããŸããå
¥åã®çµããã¯ãŒãã²ãšã€ã®è¡ã§ç€ºãããŸãã
åããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããŸãã
</p>
<pre>
<var>n</var>
<var>a<sub>1</sub></var> <var>a<sub>2</sub></var> ... <var>a<sub>n</sub></var>
</pre>
<p>
ïŒè¡ç®ã«æ¬¡éåã®æ±ºããæ°åã®é·ã <var>n</var> (1 ≤ <var>n</var> ≤ 25)ãïŒè¡ç®ã«æ°åã® <var>i</var> çªç®ã®èŠçŽ <var>a<sub>i</sub></var> (1 ≤ <var>a<sub>i</sub></var> ≤ 4) ã空çœåºåãã§äžããããŸããå
¥åã¯ãã¹ãŠæŽæ°ã§äžããããŸãã
</p>
<p>
ããŒã¿ã»ããã®æ°ã¯ 100 ãè¶
ããŸããã
</p>
<H2>Output</H2>
<p>
ããŒã¿ã»ããããšã«ãã²ãŒã ã®ååã§ã®ãã¯ãããåãããçŽåŸã®ãã¯ããã®æ°ïŒæŽæ°ïŒãåºåããŸãã
</p>
<H2>Sample Input</H2>
<pre>
4
3 1 4 2
3
4 3 2
0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
31
28
26
25
21
17
16
14
11
8
6
5
1
0
31
27
26
23
21
19
16
12
11
8
6
4
1
0
</pre>
| [
[
"4\n3 1 4 2\n3\n4 3 2\n0\n",
"4\n3 1 4 2\n3\n4 3 2\n0\n"
]
] |
p00165 | Lottery |
<H1>å®ãã</H1>
<p>
ããåœã®çæ§ã¯çŽ æ°ãšã®ã£ã³ãã«ã倧奜ãã§ãããã®åœã®é貚ã®åäœã¯ãã©ã€ã ãšãããŸãã2007 幎 11 æ 1 æ¥çŸåšã®ãã©ã€ã ã®ã¯ãã¹åã¬ãŒã㯠9973 ãšã¡ããã©çŽ æ°ã«ãªã£ãŠããã®ã§ãçæ§ã¯å€§åã³ã§ãããã®åœã§ã¯ 1/101 ãã©ã€ã ã1ãµããã©ã€ã ãšããè£å©è²šå¹£ã䜿ãããŠããŸãã
</p>
<p>
ãã®åœã®æ¿åºã¯ãåœå®¶è²¡æ¿ã®å®å®ãåœæ°ã®åš¯æ¥œãçæ§ã®è¶£å³ãåæã«æºè¶³ãããããšãç®çã«å®ããæ¯èå
¬ç€Ÿãèšç«ããå®ããäºæ¥ãå§ããããšã«ããŸãããçŽ æ°ã倧奜ããªçæ§ã¯ãçŽ æ°ã話é¡ã«ãªãã°ããã ãã§æºè¶³ããŠãè³éããããããªããŸããããã§æ¯èå
¬ç€Ÿã¯æ¬¡ã®ãããªå®ãããèããŸããã
</p>
<ul>
<li>ããã«ã¯ 0 ãã <var>MP</var> ãŸã§ã®äžé£ã®çªå·ãã€ããããŠããã<var>MP</var> ã¯ãã®åœã§ç¥ãããŠããæ倧ã®çŽ æ°ã§ãæ¯æäžæ¥ã«å®å ±ã§å瀺ããããåæã«ã<var>MP</var> 以äžã®ãã¹ãŠã®çŽ æ°ãçºè¡šãããããã以äžå€§ããªçŽ æ°ãçºèŠãããŠãããã®æã®éã¯ãå®ããæ¯èå
¬ç€Ÿãå«ãå
šãŠã®å
¬çãªæ©é¢ã§ã¯ãäžæ¥ã«çºè¡šããã<var>MP</var> ãæ倧ã®çŽ æ°ãšããŠæ±ãã2007 幎 11 æ 1 æ¥ ã«ã¯<var>MP</var> = 999983 (1000000 以äžã®æ倧ã®çŽ æ°) ãçºè¡šãããã</li>
<li>å®ããã®è²©å£²äŸ¡æ Œã¯ 1 ãµããã©ã€ã ã</li>
<li>å®ããã®æœéžã§ã¯ãåœããããã®çªå· <var>p</var> ãšè³éç®åºã®ããã®æ° <var>m</var> ã®çµ(<var>p</var>, <var>m</var>) ãäœçµãéžã°ããã<var>p</var>, <var>m</var> ã¯ãããã0 ä»¥äž <var>MP</var> 以äžã®æŽæ°ã</li>
<li>ãã®åœã§ç¥ãããŠããçŽ æ°ã®äžã§ <var>p</var> - <var>m</var> ä»¥äž <var>p</var> + <var>m</var> 以äžã®ãã®ã <var>X</var> åãããšãããšãæœéžçµæ(<var>p</var>, <var>m</var>) ã®è³éã¯ã<var>X</var> ãã©ã€ã ãšãªãã</li>
<li>æœéžçµæ (<var>p</var>, <var>m</var>) ã®è³é <var>X</var> ãã©ã€ã ã¯çªå· <var>p</var> ã®å®ãããæã£ãŠããåœéžè
ã«æ¯æããããã<var>X</var> = 0 ã®å Žåãããããã®å Žåã«ã¯åœéžè
ã«ã¯è³éã¯æ¯æãããªãã</li>
<li>è³éã®ãã¡ 1 ãã©ã€ã ã¯å®ããã®å£²ãäžãããæ¯åºããã<var>X</var> - 1 ãã©ã€ã ã¯çæ§ã®å
å»·è²»ããæ¯åºãããïŒçæ§ãæã£ãŠãããïŒã<var>X</var> = 0 ãªãã°å®ããã®å£²ãäžããã 1 ãã©ã€ã ãå
å»·è²»ã«ç¹°ãå
¥ãããããïŒçæ§ã«å¯Ÿãæ¯æãããïŒ</li>
<li>ã²ãšã€ã®çªå· <var>p</var> ãè€æ°ã®åœããããã«ãªãããšãããããã®å Žåã«ã¯ããããã®æœéžçµæ(<var>p</var>, <var>m</var>) ããç®åºãããè³éã®åèšãåœéžè
ã«æ¯æãããã</li>
</ul>
<p>
ãã®ããã§ã¯åœãããããè²·ã£ã人ã¯æœéžçµæããé¢ä¿ããçŽ æ°ãæ¢ãããã®åæ°ãæ°ããã®ã§ãåœæ°ã®è©±é¡ã«çŽ æ°ãããåºãŠããŠçæ§ã¯ãšãŠããæºæŠã§ããå®ããæ¯èå
¬ç€ŸãšããŠã¯åœãããã1æ¬åœããå
¬ç€Ÿè² æ
ã 1 ãã©ã€ã ãè²©å£²äŸ¡æ Œã 1 ãµããã©ã€ã ã ãããåœããããã®æ¬æ° <var>n</var> ãã販売ããå®ãã 101 æ¬ããã 1 æ¬ä»¥äžãšãªãããã«ããã° (ããªãã¡ã<var>n</var> ≤ (販売ããæ¬æ°)/101 ãšããã°) èµ€åã«ã¯ãªããŸããã
</p>
<!--
<p>
åé¡ã¯å
å»·è²»ããã®æ¯åºé¡ã§ããå®ããæ¯èå
¬ç€Ÿã®æŽä»£ã®ç·è£ã¯çæ§ã®ãåŠåã§ãã¿ããªçæ§ãšåæ§ã«çŽ æ°ã倧奜ãã§ãããåœããããã«å¯Ÿããå
å»·è²»ããã®æ¯åºé¡ã決ããäŒè°ã楜ããã§ããŸããããšããã2007幎ã®äººäºç°åã§ãåŠåã§ã¯ãªãã圹人ãç·è£ã«å°±ä»»ããŸãããäžå¹žãªããšã«ãã®ç·è£ã¯çæ§ã®ããšã¯ååã«å°æ¬ããŠããŸãããæ°åŠãèŠæã§ãçŽ æ°ã®è©±ãèããšããã«é³¥èãç«ã¡ãŸããããã§ããªãã¯ãã®äžå¹žãªæ°ç·è£ã®ã¢ã·ã¹ã¿ã³ããšãªã£ãŠãæœéžçµæãå
¥åãšããŠã2007幎11æã«ãããå®ããæ¯èå
¬ç€Ÿãçæ§ã«è«æ±ããè³éã®é¡ãåºåããããã°ã©ã ãäœæããŠãã ããããã ããæœéžçµæã®æ° n ã¯1以äž1000000以äžã§ãããè«
æ±ããè³éã®é¡ãè² ã«ãªãããšã¯ãªããã®ãšããŸãã
</p>
-->
<p>
åé¡ã¯å
å»·è²»ããã®æ¯åºé¡ã§ããããªãã®ä»äºã¯ãæœéžçµæãå
¥åãšããŠã2007 幎 11 æã«ãããå®ããæ¯èå
¬ç€Ÿãçæ§ã«è«æ±ããè³éã®é¡ãåºåããããã°ã©ã ãäœæããããšã§ãããã ããè«æ±ããè³éã®é¡ãè² ã«ãªãããšã¯ãªããã®ãšããŸãã
</p>
<p>泚æ</p>
<ul>
<li>ãã®åœã«ãããçŽ æ°ã®å®çŸ©ãæ¥æ¬ã®åŠæ ¡æè²ã§åŠç¿ããå
容ãšåãã§ããå³ã¡ãçŽ æ°ãšã¯ 1 ãšèªåèªèº«ä»¥å€ã®çŽæ°ãæããªãèªç¶æ°ããããŸãïŒãªãã1 ã¯çŽ æ°ã§ã¯ãããŸããïŒã</li>
<li>æã
㯠1000003 ãçŽ æ°ã§ããããšãç¥ã£ãŠããŸããããã®åœã§ã¯ 2007 幎 11 æ段éã§ã¯ç¥ãããŠããŸããããã®ããã999963 ä»¥äž 1000003 以äžã®ç¯å²ã«ãããã®åœã§ç¥ãããŠããçŽ æ°ã¯ 999983 ãš 999979 ã® 2 åãããããŸããã</li>
</ul>
<H2>Input</H2>
<p>
è€æ°ã®ããŒã¿ã»ããã®äžŠã³ãå
¥åãšããŠäžããããŸããå
¥åã®çµããã¯ãŒãã²ãšã€ã®è¡ã§ç€ºãããŸãã
åããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããŸãã
</p>
<pre>
<var>n</var>
<var>p<sub>1</sub></var> <var>m<sub>1</sub></var>
<var>p<sub>2</sub></var> <var>m<sub>2</sub></var>
:
<var>p<sub>n</sub></var> <var>m<sub>n</sub></var>
</pre>
<p>
ïŒè¡ç®ã«æœéžçµæã®æ° <var>n</var> (1 ≤ <var>n</var> ≤ 1000000)ãç¶ã <var>n</var> è¡ã« <var>i</var> çªç®ã®æœéžçµæã®æ
å ± <var>p<sub>i</sub></var>, <var>m<sub>i</sub></var> ã空çœåºåãã§äžããããŸãã
</p>
<p>
ããŒã¿ã»ããã®æ°ã¯ 20 ãè¶
ããŸããã
</p>
<H2>Output</H2>
<p>
ããŒã¿ã»ããããšã«çæ§ãžã®è«æ±é¡ããã©ã€ã åäœïŒæŽæ°ïŒã§ïŒè¡ã«åºåããŸãã
</p>
<H2>Sample Input</H2>
<pre>
4
5 0
9 1
3 10
11 3
1
999983 20
0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
5
1
</pre>
| [
[
"4\n5 0\n9 1\n3 10\n11 3\n1\n999983 20\n0\n",
"4\n5 0\n9 1\n3 10\n11 3\n1\n999983 20\n0\n"
]
] |
p00166 | Area of Polygon |
<H1>å€è§åœ¢ã®é¢ç©</H1>
<p>
ïŒã€ã®åã«å
æ¥ããïŒã€ã®å€è§åœ¢ã®é ç¹æ
å ±ãå
¥åãšãããããã®é¢ç©ã®å€§å°é¢ä¿ãåºåããããã°ã©ã ãäœæããŠãã ããã
</p>
<p>
<var>X</var> è§åœ¢ã®åé ç¹ã«ã¯åæèšåãã« 1 ãã <var>X</var> ãŸã§çªå·ãæ¯ã£ãŠãããã®ãšããŸãïŒå³ã¯ã<var>X</var> = 4 ã®å Žåã®äŸã瀺ããŠããŸãïŒããã ããäžããããå€è§åœ¢ã¯åã®äžå¿ãå
éšã«å«ããã®ãšããé ç¹ <var>i</var> ã®äœçœ®ã«é¢ããããŒã¿ã¯ãé ç¹ <var>i</var> ããé ç¹ <var>i+1</var> ãŸã§åæèšåãã«èšã£ãäžå¿è§ã®è§åºŠ <var>v</var> (1 ≤ <var>v</var> < 180 ã®æŽæ°) ã§äžããããŸãããŸããåºåãã倧å°é¢ä¿ã«ã€ããŠã¯ã第ïŒã®å€è§åœ¢ã®é¢ç©ã倧ããå Žå㯠1 (åè§æ°å)ã第ïŒã®å€è§åœ¢ã®é¢ç©ã倧ããå Žå㯠2 (åè§æ°å)ãããããã®é¢ç©ãçããå Žå㯠0 (åè§æ°å) ãšåºåããŠãã ããã
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_areaOfPolygon">
</center>
<!--
<p>
ããã°ã©ã ã¯ä»¥äžã«å®çŸ©ããå
¥åãç¶ãéãåŠçãç¹°ãè¿ããå
¥åãçµãã£ããçµäºããããã«äœæã
ãŠãã ããã
</p>
-->
<H2>Input</H2>
<p>
è€æ°ã®ããŒã¿ã»ããã®äžŠã³ãå
¥åãšããŠäžããããŸããå
¥åã®çµããã¯ãŒãã²ãšã€ã®è¡ã§ç€ºãããŸãã
åããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããŸãã
</p>
<pre>
<var>m</var>
<var>v<sub>1</sub></var>
<var>v<sub>2</sub></var>
:
<var>v<sub>m −1</sub></var>
<var>n</var>
<var>v<sub>1</sub></var>
<var>v<sub>2</sub></var>
:
<var>v<sub>n − 1</sub></var>
</pre>
<p>
ïŒè¡ç®ã«ç¬¬ïŒã®å€è§åœ¢ã®é ç¹ã®æ° <var>m</var> (3 ≤ <var>m</var> ≤ 50)ãç¶ã <var>m − 1</var> è¡ã«ç¬¬ïŒã®å€è§åœ¢ã®é ç¹ <var>i</var> ã®æ
å ± <var>v<sub>i</sub></var> (1 ≤ <var>v<sub>i</sub></var> < 180) ãäžããããŸãã
</p>
<p>
ç¶ãè¡ã«ç¬¬ïŒã®å€è§åœ¢ã®é ç¹ã®æ° <var>n</var> (3 ≤ <var>n</var> ≤ 50)ãç¶ã <var>n − 1</var> è¡ã«ç¬¬ïŒã®å€è§åœ¢ã®é ç¹ <var>i</var> ã®æ
å ± <var>v<sub>i</sub></var> (1 ≤ <var>v<sub>i</sub></var> < 180) ãäžããããŸãã
</p>
<p>
ããŒã¿ã»ããã®æ°ã¯ 200 ãè¶
ããŸããã
</p>
<H2>Output</H2>
<p>
ããŒã¿ã»ããããšã«å€§å°é¢ä¿ïŒåè§æ°åïŒãïŒè¡ã«åºåããŸãã
</p>
<H2>Sample Input</H2>
<pre>
4
30
125
75
4
30
125
75
5
30
125
75
65
4
30
125
75
4
30
125
75
6
30
50
50
25
75
0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
0
1
2
</pre>
| [
[
"4\n30\n125\n75\n4\n30\n125\n75\n5\n30\n125\n75\n65\n4\n30\n125\n75\n4\n30\n125\n75\n6\n30\n50\n50\n25\n75\n0\n",
"4\n30\n125\n75\n4\n30\n125\n75\n5\n30\n125\n75\n65\n4\n30\n125\n75\n4\n30\n125\n75\n6\n30\n50\n50\n25\n75\n0\n"
]
] |
p00167 | Bubble Sort |
<H1>ããã«ãœãŒã</H1>
<p>
ããŒã¿ã䞊ã¹æ¿ããããã®æŽåïŒãœãŒãïŒã¢ã«ãŽãªãºã ã¯ã³ã³ãã¥ãŒã¿ç§åŠã«ã¯æ¬ ãããªãåºæ¬çãªã¢ã«ãŽãªãºã ã§ããäŸãã°ãäžå³ã®ããã«ãæŽæ°å€ã®é
åã®èŠçŽ ãæé ã«äžŠã¹æ¿ããããšããæäœãæŽåã§ãã
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_bubbleSort1"><br>
</center>
<p>
å€ãã®æŽåã¢ã«ãŽãªãºã ãèæ¡ãããŠããŸãããããã®äžã§ãåºæ¬çãªã¢ã«ãŽãªãºã ã®ïŒã€ãããã«ãœãŒãã§ããäŸãšããŠãäžããããæŽæ°å€ã®é
åãããã«ãœãŒãã§æé ã«äžŠã¹ãŠã¿ãŸãã
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_bubbleSort2"><br/>
</center>
<br/>
<p>
ããã«ãœãŒãã§ã¯ãåèšç®ã¹ãããã«ãããŠãé
åãããœãŒããããéšåããšããœãŒããããŠããªãéšåãã«åããŠèããŸããæåã¯é
åå
šäœããœãŒããããŠããªãéšåã«ãªããŸãã
</p>
<p>
ãœãŒããããŠããªãéšåã®å
é ãããé£å士ã®èŠçŽ ãæ¯èŒããŠïŒå³ã§ã¯ç·è²ã®èŠçŽ ïŒã倧ããå€ãå³ã«ããããã«ãããã亀æããŸããäºã€ã®å€ãçããå Žåã¯äº€æããŸããã
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_bubbleSort3"><br/>
<br/>
</center>
<p>
ãã®åŠçããœãŒããããŠããªãéšåïŒå³ã§ã¯çœè²ã®èŠçŽ ïŒã®æ«å°ŸãŸã§ç¹°ãè¿ããŸããæåŸã«ãæ«å°ŸããœãŒããããŠããéšåïŒå³ã§ã¯éè²ã®èŠçŽ ïŒã«è¿œå ããŠ1ã¹ããããå®äºããŸãã
</p>
<p>
ãã®ã¹ãããããœãŒããããŠããªãéšåã®é·ãã1ã«ãªããŸã§ç¹°ãè¿ããŸãã
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_bubbleSort4"><br/>
<br/>
<br/>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_bubbleSort5"><br/>
<br/>
<br/>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_bubbleSort6"><br/>
<br/>
</center>
<p>
ãã®ããã«ãœãŒããããŠããªãéšåã®é·ãã 1 ã«ãªã£ããããœãŒãã®åŠçãçµäºããŸãã
</p>
<p>
ããã§ã¯ã<var>n</var> åã®æ°å€ã®é
åãå
¥åãšããæ°å€ãé
åã®å
é ããæé ã«äžŠã¶ããã«äžèšã®ããã«ãœãŒãã®æé ã§äžŠã¹æ¿ããè¡ããèŠããé
åèŠçŽ ã®äº€æåæ°ãåºåããããã°ã©ã ãäœæããŠãã ããã
</p>
<H2>Input</H2>
<p>
è€æ°ã®ããŒã¿ã»ããã®äžŠã³ãå
¥åãšããŠäžããããŸããå
¥åã®çµããã¯ãŒãã²ãšã€ã®è¡ã§ç€ºãããŸãã
åããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããŸãã
</p>
<pre>
<var>n</var>
<var>a<sub>1</sub></var>
<var>a<sub>2</sub></var>
:
<var>a<sub>n</sub></var>
</pre>
<p>
ïŒè¡ç®ã«æ°å€ã®æ° <var>n</var> (1 ≤ <var>n</var> ≤ 100)ãç¶ã <var>n</var> è¡ã«<var>i</var> çªç®ã®æ°å€ <var>a<sub>i</sub></var> (1 ≤ <var>a<sub>i</sub></var> ≤ 1000000) ãäžããããŸãã
</p>
<p>
ããŒã¿ã»ããã®æ°ã¯ 20 ãè¶
ããŸããã
</p>
<H2>Output</H2>
<p>
ããŒã¿ã»ããããšã«ããŒã¿èŠçŽ ã®äº€æåæ°ïŒæŽæ°ïŒãïŒè¡ã«åºåããŸãã
</p>
<H2>Sample Input</H2>
<pre>
5
5
3
2
1
4
6
1
2
3
4
5
6
3
3
2
1
0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
7
0
3
</pre>
| [
[
"5\n5\n3\n2\n1\n4\n6\n1\n2\n3\n4\n5\n6\n3\n3\n2\n1\n0\n",
"5\n5\n3\n2\n1\n4\n6\n1\n2\n3\n4\n5\n6\n3\n3\n2\n1\n0\n"
]
] |
p00168 | Kannondou |
<H1>芳é³å </H1>
<p>
äžéåã®å®¶ã®è£å±±ã«ã¯èŠ³é³å ããããŸãããã®èŠ³é³å ãŸã§ã¯ãµããšãã 30 段ã®é段ããããäžéåã¯ãæ¯æ¥ã®ããã«èŠ³é³å ãŸã§éã³ã«è¡ããŸããäžéåã¯é段ãïŒè¶³ã§ïŒæ®µãŸã§äžããããšãã§ããŸããéãã§ãããã¡ã«é段ã®äžãæ¹ã®çš®é¡ïŒæ®µã®é£ã°ãæ¹ã®åæ°ïŒãéåžžã«ããããããããšã«æ°ãã€ããŸããã
</p>
<p>
ããã§ãäžæ¥ã« 10 çš®é¡ã®äžãæ¹ããããã¹ãŠã®äžãæ¹ãè©ŠãããšèããŸããããããæ°åŠãçç¥ããŠããããªãã¯ãããªããšã§ã¯äžéåã®å¯¿åœãå°œããŠããŸãããšãç¥ã£ãŠããã¯ãã§ãã
</p>
<p>
äžéåã®èšç»ãå®çŸäžå¯èœã§ããããšãäžéåã«çŽåŸãããããã«ãé段ã®æ®µæ° <var>n</var> ãå
¥åãšããäžæ¥ã« 10 çš®é¡ã®äžãæ¹ããããšããŠãäžéåããã¹ãŠã®äžãæ¹ãå®è¡ããã®ã«èŠãã幎æ°ãåºåããããã°ã©ã ãäœæããŠãã ãããäžå¹Žã¯ 365 æ¥ãšããŠèšç®ããŠãã ãããäžæ¥ã§ãå¿
èŠãªãäžå¹ŽãšããŸãã365 æ¥ãªã 1 幎ã§ããã366 æ¥ãªã 2 幎ãšãªããŸãã
</p>
<H2>Input</H2>
<p>
è€æ°ã®ããŒã¿ã»ããã®äžŠã³ãå
¥åãšããŠäžããããŸããå
¥åã®çµããã¯ãŒãã²ãšã€ã®è¡ã§ç€ºãããŸãã
åããŒã¿ã»ãããšããŠã段æ°ãè¡šãïŒã€ã®æŽæ° <var>n</var> (1 ≤ <var>n</var> ≤ 30) ãïŒè¡ã«äžããããŸãã
</p>
<p>
ããŒã¿ã»ããã®æ°ã¯ 30 ãè¶
ããŸããã
</p>
<H2>Output</H2>
<p>
ããŒã¿ã»ããããšã«äžéåããã¹ãŠã®äžãæ¹ãå®è¡ããã®ã«å¿
èŠãªå¹Žæ°ïŒæŽæ°ïŒãïŒè¡ã«åºåããŸãã
</p>
<H2>Sample Input</H2>
<pre>
1
10
20
25
0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1
1
34
701
</pre>
| [
[
"1\n10\n20\n25\n0\n",
"1\n10\n20\n25\n0\n"
]
] |
p00169 | Blackjack |
<H1>ãã©ãã¯ãžã£ãã¯</H1>
<p>
ãã©ãã¯ãžã£ãã¯ã¯ã«ãžãã§è¡ãããã«ãŒãã²ãŒã ã®äžçš®ã§ã1 ã 13 ãŸã§ã®æ°ãæžãããã«ãŒãã䜿ã£ãŠã²ãŒã ãè¡ãããŸããåã«ãŒãã®ç¹æ°ã¯æ¬¡ã®ããã«æ±ºãŸã£ãŠããŸãã
</p>
<ul>
<li>1 㯠1 ç¹ããã㯠11 ç¹</li>
<li>2 ãã 9 ãŸã§ã¯ãæžãããŠããæ°ã®éãã®ç¹æ°</li>
<li>10 ãã 13 ãŸã§ã¯ã10 ç¹</li>
</ul>
<p>
ãã®ã²ãŒã ã«ã¯èŠªãå«ããäœäººãã®åå è
ãããããããããäœæãã®ã«ãŒãã®çµãæã£ãŠããŸãããã®ã«ãŒãã®çµã®ããšãæãšåŒã³ãŸããæã®ç¹æ°ã¯ã«ãŒãã®ç¹æ°ã®åèšã§ãããã®èšç®ã¯æ¬¡ã®ããã«è¡ããã®ãšããŸãã
</p>
<ul>
<li>ã«ãŒãã®ç¹æ°ã®åèšã 21 ãã倧ãããªããšãã¯ãæã®ç¹æ°ã 0 ç¹ãšãã</li>
<li>ã«ãŒãã®ç¹æ°ãšããŠã1 㯠1 ç¹ãšèšç®ããŠã 11 ç¹ãšèšç®ããŠãããããæã®ç¹æ°ãæ倧ãšãªãæ¹ãéžã¶ããšãšãã</li>
</ul>
<p>
é
ãããã«ãŒãã®æ
å ±ãå
¥åãšããæã®ç¹æ°ãåºåããããã°ã©ã ãäœæããŠãã ããã
</p>
<!--
ãã ãã1ã€ã®æã«å«ãŸããã«ãŒãã®ææ° n ã¯1以äž21以äžãšããåãæ°ãæžãããã«ãŒããäœæã§ã
å«ãããšãã§ãããã®ãšããŸãã-->
<H2>Input</H2>
<p>
è€æ°ã®ããŒã¿ã»ããã®äžŠã³ãå
¥åãšããŠäžããããŸããå
¥åã®çµããã¯ãŒãã²ãšã€ã®è¡ã§ç€ºãããŸãã
åããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããŸãã
</p>
<pre>
<var>c<sub>1</sub></var> <var>c<sub>2</sub></var> ... <var>c<sub>n</sub></var>
</pre>
<p>
ïŒè¡ã« <var>i</var> çªç®ã®ã«ãŒãã«æžãããŠããæŽæ° <var>c<sub>i</sub></var> (1 ≤ <var>c<sub>i</sub></var> ≤ 13) ã空çœåºåãã§ïŒè¡ã«äžããããŸããã«ãŒãã®æ° <var>n</var> 㯠100 ãè¶
ããŸããã
</p>
<p>
ããŒã¿ã»ããã®æ°ã¯ 200 ãè¶
ããŸããã
</p>
<H2>Output</H2>
<p>
ããŒã¿ã»ããããšã«æã®ç¹æ°ãïŒè¡ã«åºåããŸãã
</p>
<H2>Sample Input</H2>
<pre>
1
7 7 7
7 7 8
12 1
10 1 1
0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
11
21
0
21
12
</pre>
| [
[
"1\n7 7 7\n7 7 8\n12 1\n10 1 1\n0\n",
"1\n7 7 7\n7 7 8\n12 1\n10 1 1\n0\n"
]
] |
p00170 | Lunch |
<H1>ã©ã³ã</H1>
<p>
ãæŒã«é£ã¹ããåŒåœãäœãããã«ããåºã§é£ã¹ç©ãè²·ããŸããããåºã§ã¯ãé£ã¹ç©ãå
¥ããã®ã«çŽ°é·ãè¢ããããããªãã£ãã®ã§ããã¹ãŠã®é£ã¹ç©ã瞊ã«ç©ãã§è¢ã«å
¥ããå¿
èŠããããŸããè¢ãåãã«ããããã«ãã§ããã ãéãç©ãäžã«ããŠè©°ãããã®ã§ãããé£ã¹ç©ã®äžã«ã¯ãããããç©ããã£ãŠãäžã«éãç©ãä¹ãããšã€ã¶ããŠããŸããŸãã
</p>
<!--
ããã§ãããããã®é£ã¹ç©ãã€ã¶ããªãããã«ããã€åºæ¥ãã ãéãç©ãäžã«ãªãããã«é£ã¹ç©ãç©ã¿ãããšæããŸãã
-->
<p>
ããã§ãé£ã¹ç©ã®æ
å ±ãå
¥åãšããå
šãŠã®é£ã¹ç©ãã€ã¶ããããã€å
šäœã®éå¿ãæãäœããªããããªç©ã¿æ¹ãåºåããããã°ã©ã ãäœæããŠãã ãããããããã®é£ã¹ç©ããšã«ãåå <var>f</var>ãéã <var>w</var>ãäžã«èŒããŠèããããéã <var>s</var> ãæå®ãããŸãã
ãå
šãŠã®é£ã¹ç©ãã€ã¶ããªãããšããã®ã¯ãäžããé ã«ãïŒ<var>f<sub>1</sub></var>ã<var>f<sub>2</sub></var>ã... ã<var>f<sub>n</sub></var>ïŒãš <var>n</var> åã®é£ã¹ç©ãç©ãã æããã¹ãŠã® <var>f</var> ã«ã€ããŠã<br/>
<br/>
<var>s<sub>f<sub>i</sub></sub> ≥ w<sub>f<sub>i+1</sub></sub> + w<sub>f<sub>i+2</sub></sub> + </var> ... <var> + w<sub>f<sub>n</sub></sub></var>
<br/>
<br/>
ã§ããããšãæå³ããŸãããŸããå
šäœã®éå¿ <var>G</var> ã¯ã<br/>
<br/>
<var>G = (1 × w<sub>f<sub>1</sub></sub> + 2 × w<sub>f<sub>2</sub></sub> + </var> ... <var> + n × w<sub>f<sub>n</sub></sub>)</var> / <var>(w<sub>f<sub>1</sub></sub> + w<sub>f<sub>2</sub></sub>+</var> ... <var>+w<sub>f<sub>n</sub></sub></var>)
<br/>
<br/>
ãšããŸãããã ãã解ã¯ã¡ããã©1ã€ã ãååšãããã®ãšããŸãã
</p>
<H2>Input</H2>
<p>
è€æ°ã®ããŒã¿ã»ããã®äžŠã³ãå
¥åãšããŠäžããããŸããå
¥åã®çµããã¯ãŒãã²ãšã€ã®è¡ã§ç€ºãããŸããåããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããŸãã
</p>
<pre>
<var>n</var>
<var>f<sub>1</sub></var> <var>w<sub>1</sub></var> <var>s<sub>1</sub></var>
<var>f<sub>2</sub></var> <var>w<sub>2</sub></var> <var>s<sub>2</sub></var>
:
<var>f<sub>n</sub></var> <var>w<sub>n</sub></var> <var>s<sub>n</sub></var>
</pre>
<p>
ïŒè¡ç®ã«é£ã¹ç©ã®åæ° <var>n</var> (1 ≤ <var>n</var> ≤ 10)ãç¶ã <var>n</var> è¡ã« <var>i</var> çªç®ã®é£ã¹ç©ã®åå <var>f<sub>i</sub></var> (20 æå以å
ã®åè§è±æåå)ãéã <var>w<sub>i</sub></var> (1 ≤ <var>w<sub>i</sub></var> ≤ 1000)ãèããããéã <var>s<sub>i</sub></var> (1 ≤ <var>s<sub>i</sub></var> ≤ 1000) ã空çœåºåãã§äžããããŸãã
</p>
<p>
ããŒã¿ã»ããã®æ°ã¯ 20 ãè¶
ããŸããã
</p>
<H2>Output</H2>
<p>
ããŒã¿ã»ããããšã«ã次ã®åœ¢åŒã§é£ã¹ç©ã®ååãäžããç©ã¿äžããé ã«åºåããŸãã<br/>
<br/>
1 è¡ç®: 1 çªäžã®é£ã¹ç©ã®ååïŒåè§è±æååïŒ <br/>
2 è¡ç®: äžãã2 çªç®ã®é£ã¹ç©ã®åå<br/>
ïŒ<br/>
<var>n</var> è¡ç®: 1 çªäžã®é£ã¹ç©ã®åå<br/>
</p>
<H2>Sample Input</H2>
<pre>
4
sandwich 80 120
apple 50 200
cheese 20 40
cake 100 100
9
onigiri 80 300
onigiri 80 300
anpan 70 280
mikan 50 80
kanzume 100 500
chocolate 50 350
cookie 30 80
purin 40 400
cracker 40 160
0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
apple
cake
sandwich
cheese
kanzume
purin
chocolate
onigiri
onigiri
anpan
mikan
cracker
cookie
</pre>
| [
[
"4\nsandwich 80 120\napple 50 200\ncheese 20 40\ncake 100 100\n9\nonigiri 80 300\nonigiri 80 300\nanpan 70 280\nmikan 50 80\nkanzume 100 500\nchocolate 50 350\ncookie 30 80\npurin 40 400\ncracker 40 160\n0\n",
"4\nsandwich 80 120\napple 50 200\ncheese 20 40\ncake 100 100\n9\nonigiri 80 300\nonigiri 80 300\nanpan 70 280\nmikan 50 80\nkanzume 100 500\nchocolate 50 350\ncookie 30 80\npurin 40 400\ncracker 40 160\n0\n"
]
] |
p00171 | Dice Puzzle |
<H1>ãµã€ã³ãããºã«</H1>
<p>
åé¢ã«ã¢ã«ãã¡ãããäžæå(a ã zãA ã Z)ãæããããµã€ã³ãããããŸãã
</p>
<br><center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/dice22Puzzle1"></center><br>
<p>
ãã®ãããªãµã€ã³ãã8ã€çµã¿åãã㊠2 à 2 à 2 ã®ç«æ¹äœãäœãããšãèããŸãã
</p>
<br><center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/dice22Puzzle2"></center><br>
<p>
çµã¿åããæ¹ã«ã¯æ¡ä»¶ããããåãµã€ã³ãã®åãåãé¢ã¯åãã¢ã«ãã¡ãããã§ãã€äžæ¹ãå°æåãã
ãäžæ¹ã倧æåã§ãªããã°ãªããŸãããäŸãã°ãa ãšæãããé¢ã«æ¥ããããšãã§ããã®ã¯ A ãšæã
ããé¢ã§ãããã ããæ¥ãããšãã®æåã®åãã¯åããŸããã
</p>
<br><center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/dice22Puzzle3"></center><br>
<p>
ãã®ã«ãŒã«ã«åŸããïŒã€ã®ãµã€ã³ãã®æ
å ±ãå
¥åãšããç«æ¹äœãäœãããåŠããå€å®ããããã°ã©ã ãäœæããŠãã ãããç«æ¹äœãäœããå Žå㯠YESïŒåè§è±å€§æåïŒãäœããªãå Žå㯠NOïŒåè§è±å€§æåïŒãšåºåããŠãã ããã
</p>
<p>
ãªãããµã€ã³ãã®åé¢ã®æåã次ã®å³ã«ããããã« <var>c1</var> ã <var>c6</var> ãšè¡šãããšã«ããŸãã
ãŸãã1ã€ã®ãµã€ã³ãã«åãæåãè€æ°åæãããŠããããšã¯ç¡ããã®ãšããŸãïŒåãã¢ã«ãã¡ãããã®å€§æåãšå°æåã¯ãã®éãã§ã¯ãããŸããïŒã
</p>
<br><center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/dice22Puzzle4"></center><br>
<H2>Input</H2>
<p>
è€æ°ã®ããŒã¿ã»ããã®äžŠã³ãå
¥åãšããŠäžããããŸããå
¥åã®çµããã¯ãŒãã²ãšã€ã®è¡ã§ç€ºãããŸãã
åããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããŸãã
</p>
<pre>
<var>s<sub>1</sub></var>
<var>s<sub>2</sub></var>
:
<var>s<sub>8</sub></var>
</pre>
<p>
<var>i</var> è¡ç®ã« <var>i</var> åç®ã®ãµã€ã³ãã®æ
å ± <var>s<sub>i</sub></var> ãäžããããŸãã<var>s<sub>i</sub></var> ã¯é·ã 6 ã®æååã§ãã <var>j</var> æåç®ããµã€ã³ãã®åé¢ <var>cj</var> ã«å¯Ÿå¿ããŸãã
</p>
<p>
ããŒã¿ã»ããã®æ°ã¯ 50 ãè¶
ããŸããã
</p>
<H2>Output</H2>
<p>
ããŒã¿ã»ããããšã«å€å®çµæïŒåè§è±å€§æåïŒãïŒè¡ã«åºåããŸãã
</p>
<H2>Sample Input</H2>
<pre>
zabZNq
BCxmAi
ZcbBCj
aizXCm
QgmABC
JHzMop
ImoXGz
MZTOhp
zabZnQ
BCxmAi
ZcbBCj
aizXCm
QgmABC
JHzMop
ImoXGz
MZTOhp
abcdef
ABDCFE
FBDCAE
abcdef
BEACDF
bfcaed
fabcde
DEABCF
UnivOf
AizuaH
zTXZYW
piglIt
GRULNP
higGtH
uAzIXZ
FizmKZ
UnivOf
AizuaH
piglIt
higGtH
GRULNP
uAzIXZ
FizmKZ
ZTXzYW
0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
YES
YES
NO
</pre>
| [
[
"zabZNq\nBCxmAi\nZcbBCj\naizXCm\nQgmABC\nJHzMop\nImoXGz\nMZTOhp\nzabZnQ\nBCxmAi\nZcbBCj\naizXCm\nQgmABC\nJHzMop\nImoXGz\nMZTOhp\nabcdef\nABDCFE\nFBDCAE\nabcdef\nBEACDF\nbfcaed\nfabcde\nDEABCF\nUnivOf\nAizuaH\nzTXZYW\npiglIt\nGRULNP\nhigGtH\nuAzIXZ\nFizmKZ\nUnivOf\nAizuaH\npiglIt\nhigGtH\nGRULNP\nuAzIXZ\nFizmKZ\nZTXzYW\n0\n",
"zabZNq\nBCxmAi\nZcbBCj\naizXCm\nQgmABC\nJHzMop\nImoXGz\nMZTOhp\nzabZnQ\nBCxmAi\nZcbBCj\naizXCm\nQgmABC\nJHzMop\nImoXGz\nMZTOhp\nabcdef\nABDCFE\nFBDCAE\nabcdef\nBEACDF\nbfcaed\nfabcde\nDEABCF\nUnivOf\nAizuaH\nzTXZYW\npiglIt\nGRULNP\nhigGtH\nuAzIXZ\nFizmKZ\nUnivOf\nAizuaH\npiglIt\nhigGtH\nGRULNP\nuAzIXZ\nFizmKZ\nZTXzYW\n0\n"
]
] |
p00172 | Doctor's Research Rooms |
<H1>å士ã®ç 究宀</H1>
<p>
äŒæŽ¥å€§åŠã®é¶Žè³å士ã¯ãšãŠãç 究ç±å¿ãªããšã§æåã§ãã圌ã®ç 究宀ã«ã¯è€æ°ã®åŠçãããŸããã圌ã¯æ¯æ¥å€é
ããŸã§ç 究ãããã®ã§å¿
ãæåŸã«åž°å®
ããŸãã圌ã®ç 究宀ã«ã¯ãã¢ã§ã€ãªãã£ãè€æ°ã®éšå±ããããæåŸã«ç 究宀ãåºã人ããã¹ãŠã®éšå±ã®æãããæ¶ããŠåž°å®
ããããšã«ãªã£ãŠããŸãã
</p>
<p>
æè¿ã倧åŠã§ã¯çãšãã«åãå
¥ããŠããããããã¹ãŠã®æãããæ¶ããŠãããå³ãããã§ãã¯ãããŸããå°ã£ãããšã«åœŒã¯èª°ããèªãã極床ã®èç
è
ã§ãæããã®æ¶ããéšå±ã«ã¯æ±ºããŠå
¥ãããšãã§ããŸãããããã§ã圌ã¯ããéšå±ã®ç
§æã®ON/OFFãä»ã®éšå±ããæäœã§ããããã«ç 究宀ã®ç
§æèšåãæ¹é ããŸããã
</p>
<p>
ãšããããäºç®ã®éœåã§ïŒã€ã®éšå±ããã³ã³ãããŒã«ã§ããéšå±ãéãããŠããŸãããã®äžãåž°å®
æã®åéšå±ã®æããã®ç¶æ
ãæ¥ã«ãã£ãŠç°ãªããããå
šãŠã®æãããæ¶ããŠåºå£ãŸã§ãã©ãã€ãã®ã«æ¯æ¥ããªãã®æéãæãã£ãŠããŸããããã§ãç 究å¡ã®ããªããå士ãå©ããããã«ããã°ã©ã ãäœæããããšã«ãªããŸããã
</p>
<p>
ç 究宀ã®éšå±æ
å ±ãåéšå±ã®æããã®ç¹ç¯æ
å ±ãåéšå±ã®ç
§æã¹ã€ããã®æ
å ±ãå
¥åãšããå士ããã¹ãŠã®æãããæ¶ããŠåž°å®
ã§ãããã©ãããåºåããããã°ã©ã ãäœæããŠãã ããããã ããéšå±ã®æ° <var>n</var> 㯠1 ä»¥äž 15 以äžã®æŽæ°ããã¢ã®æ° <var>m</var> 㯠1 ä»¥äž 30 以äžã®æŽæ°ãç
§æã®ç¹ç¯æ
å ± <var>l</var> 㯠0 ãŸã㯠1 ã®æŽæ°ã§ããããæ¶ç¯ãšç¹ç¯ãè¡šããåéšå±ã«ã¯ 1 ä»¥äž <var>n</var> 以äžã®æŽæ°ã§çªå·ãä»äžãããŠãããã®ãšããŸããåºå£ã¯çªå· <var>n</var> ã®éšå±ã«ååšããå士ã¯åžžã«éšå± 1 ããã¹ã¿ãŒããããã®ãšããŸãã
</p>
<p>
ãªããåºåã¯ãå士ã®åãã¹ãè¡åã«å¿ããŠä»¥äžã® 3 éãã«åããŠåºåããŸãã
</p>
<p><b>ã±ãŒã¹ïŒ</b>.
åºå£ä»¥å€ã®å
šãŠã®æãããæ¶ããŠåºå£ã«ãã©ãã€ããå ŽåïŒçµè·¯ã®éçšã§åºå£ãéã£ãŠãããïŒã
</p>
<pre>
You can go home in X steps.
</pre>
<p>
ãšåºåããŸãããã㧠X ã¯éšå±ã®ç§»åãã¹ã€ããã®ON/OFF ãããããïŒã¹ããããšããå Žåã®ãå士ã®éšå±ããåºå£ã«ãã©ãçããŸã§ã®æçã®ã¹ãããæ°ã§ããããã«ã以äžã®æååã«åŸãå士ã®éšå±ããåºå£ãŸã§ã®çµè·¯ïŒå士ã®ãšãã¹ãè¡åïŒã X è¡ã§åºåããŸãã
</p>
<ul>
<li>éšå± R ãžç§»åããå Žå
<pre>
Move to room R.
</pre>
</li>
<li>éšå± R ã®ç
§æãæ¶ãå Žå
<pre>
Switch off room R.
</pre>
</li>
<li>éšå± R ã®ç
§æãç¹ç¯ããå Žå
<pre>
Switch on room R.
</pre>
</li>
</ul>
<p>
ããã§ãR ã¯éšå±ã®çªå·ãè¡šããŸããå士ãããéšå±ã«ç§»åããçŽåŸãè€æ°ã®ã¹ã€ãããæäœããŠæ¬¡ã®éšå±ã«ç§»åããå Žåã¯æäœããéšå±çªå·ãå°ããã»ãããåºåããŠãã ããããã®æ¡ä»¶ãæºããéããè€æ°ã®è§£ãããå Žåã¯ãã©ããåºåããŠãããŸããŸããããã®æ
å ±ãããšã«ãå士ã¯ç¡äºåž°å®
ããããšãã§ããŸãã
</p>
<p>
<b>ã±ãŒã¹2</b>. åºå£ã«ãã©ãçãããšã¯ã§ããããåºå£ã®ããéšå±ä»¥å€ã®å
šãŠã®æãããæ¶ãããšã
ã§ããªãå Žåã
</p>
<pre>
You can not switch off all lights.
</pre>
<p>
ãšåºåããããã®å Žåãå士ã¯çãšããå®ããªãã£ããšããŠå€§åŠã«çœ°ããããŸãã
</p>
<p>
<b>ã±ãŒã¹3</b>. ã©ãããããŠãåºå£ã«ãã©ãçããªãå Žåã
<pre>
Help me!
</pre>
<p>
ãšåºåããããã®å Žåãå士ã¯èŠåå¡ã«ç·æ¥æå©ãæ±ããŸãã
</p>
<p>
ç°¡åãªäŸã瀺ããŸãããã®äŸã§ã¯ãç 究宀㯠4 ã€ã®éšå±ã§æ§æãããéšå± 1 ãš 2ã2 ãš 3ã2 ãš 4 ãããããç¹ãã£ãŠããŸãããŸããéšå± 1 åã³ 4 ããéšå± 2ã3 ã®ç
§æãæäœããããšãã§ããéšå± 3 ããéšå± 1ã2ã4 ã®ç
§æãæäœããããšãã§ããŸããæåãéšå± 2ã3ã4 ã®ç
§æãæ¶ããç¶æ
ã§ãå士ãéšå± 1 ã«ããŸãã
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_researchRoom"><br/>
<br/>
</center>
<p>
ãã®ç¶æ³ã§ã¯ãå士ãåãã¹ãè¡åã¯æ¬¡ã®ããã«ãªããŸãã
</p>
<pre>
éšå±2ãš3ã®ç
§æãonã«ããã
éšå±2ã«ç§»åããã
éšå±3ã«ç§»åããã
éšå±1ã®ç
§æãoffã«ããéšå±4ã®ç
§æãonã«ããã
éšå±2ã«ç§»åããã
éšå±4ã«ç§»åããã
éšå±2ãš3ã®ç
§æãoffã«ããã
</pre>
<p>
ããã§å士ã¯éšå± 4 以å€ã®ç
§æãæ¶ãããšãã§ããåž°å®
ããããšãã§ããŸãã
</p>
<H2>Input</H2>
<p>
è€æ°ã®ããŒã¿ã»ããã®äžŠã³ãå
¥åãšããŠäžããããŸããå
¥åã®çµããã¯ãŒã2ã€ã®è¡ã§ç€ºãããŸãã
åããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããŸãã
</p>
<pre>
<var>n</var> <var>m</var>
<var>s<sub>1</sub></var> <var>t<sub>1<sub></var>
<var>s<sub>2</sub></var> <var>t<sub>2<sub></var>
:
<var>s<sub>m</sub></var> <var>t<sub>m<sub></var>
<var>l<sub>1</sub></var> <var>l<sub>2</sub></var> ... <var>l<sub>n</sub></var>
<var>k<sub>1</sub></var> <var>r<sub>1</sub></var> <var>r<sub>2</sub></var> ... <var>r<sub>k<sub>1</sub></sub></var>
<var>k<sub>2</sub></var> <var>r<sub>1</sub></var> <var>r<sub>2</sub></var> ... <var>r<sub>k<sub>2</sub></sub></var>
:
<var>k<sub>n</sub></var> <var>r<sub>1</sub></var> <var>r<sub>2</sub></var> ... <var>r<sub>k<sub>n</sub></sub></var>
</pre>
<p>
ïŒè¡ç®ã«éšå±ã®æ° <var>n</var> (1 ≤ <var>n</var> ≤ 15) ãšãã¢ã®æ° <var>m</var> (1 ≤ <var>m</var> ≤ 30) ã空çœåºåãã§äžããããŸããç¶ã <var>m</var> è¡ã« <var>i</var> åç®ã®ãã¢ã®æ
å ±ãäžããããŸãã<var>s<sub>i</sub></var> <var>t<sub>i</sub></var> ã¯éšå± <var>s<sub>i</sub></var> ãšéšå± <var>t<sub>i</sub></var> ããã¢ã§ç¹ãã£ãŠããããšãè¡šããŸãã
</p>
<p>
ç¶ãïŒè¡ã«ãéšå± <var>i</var> ã®ç
§æã®ç¹ç¯æ
å ± <var>l<sub>i</sub></var> (0 ãŸã㯠1) ã空çœåºåãã§äžããããŸãã
</p>
<p>
ç¶ã <var>n</var> è¡ã«éšå± <var>i</var> ã®ã¹ã€ããæ
å ±ãäžããããŸãã<var>k<sub>i</sub></var> (0 ≤ <var>k<sub>i</sub></var> ≤ 12) ã¯éšå± <var>i</var> ã®ã¹ã€ããã®æ°ã<var>r<sub>1</sub></var> ... <var>r<sub>k<sub>i</sub></sub></var> ã¯ç
§æãæäœã§ããéšå±ã®çªå·ãè¡šããŸãã
</p>
<p>
ããŒã¿ã»ããã®æ°ã¯100 ãè¶
ããŸããã
</p>
<H2>Output</H2>
<p>
ããŒã¿ã»ããããšã«ãäžèšã® 3 éãã®çµæã«å¿ããŠä»¥äžã®åœ¢åŒã§åºåããŸãã
</p>
<p>ã±ãŒã¹ 1 ã®å Žå<br/>
<br/>
1è¡ç®: You can go home in X steps.<br/>
2è¡ç®: 1ã€ç®ã®å士ãåãã¹ãè¡å<br/>
3è¡ç®: 2ã€ç®ã®å士ãåãã¹ãè¡å<br/>
:<br/>
X+1 è¡ç®: X åç®ã®å士ãåãã¹ãè¡å<br/>
</p>
<p>ã±ãŒã¹ 2 ã®å Žå<br/>
<br/>
1 è¡ç®: You can not switch off all lights.<br/>
</p>
<p>ã±ãŒã¹ 3 ã®å Žå<br/>
<br/>
1 è¡ç®: Help me!<br/>
</pre>
<H2>Sample Input</H2>
<pre>
4 3
1 2
2 3
2 4
1 0 0 0
2 2 3
0
3 1 2 4
2 2 3
4 3
1 2
2 3
2 4
1 0 0 0
2 2 3
0
3 1 2 4
1 3
4 3
1 2
2 3
2 4
1 0 0 0
2 2 3
0
2 1 2
2 2 3
0 0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
You can go home in 10 steps.
Switch on room 2.
Switch on room 3.
Move to room 2.
Move to room 3.
Switch off room 1.
Switch on room 4.
Move to room 2.
Move to room 4.
Switch off room 2.
Switch off room 3.
You can not switch off all lights.
Help me!
</pre>
| [
[
"4 3\n1 2\n2 3\n2 4\n1 0 0 0\n2 2 3\n0\n3 1 2 4\n2 2 3\n4 3\n1 2\n2 3\n2 4\n1 0 0 0\n2 2 3\n0\n3 1 2 4\n1 3\n4 3\n1 2\n2 3\n2 4\n1 0 0 0\n2 2 3\n0\n2 1 2\n2 2 3\n0 0\n",
"4 3\n1 2\n2 3\n2 4\n1 0 0 0\n2 2 3\n0\n3 1 2 4\n2 2 3\n4 3\n1 2\n2 3\n2 4\n1 0 0 0\n2 2 3\n0\n3 1 2 4\n1 3\n4 3\n1 2\n2 3\n2 4\n1 0 0 0\n2 2 3\n0\n2 1 2\n2 2 3\n0 0\n"
]
] |
p00173 | Haunted House |
<H1>ãåãå±æ·</H1>
<p>
äŒæŽ¥åŠåé«çåŠæ ¡ã§ã¯ãæ¯å¹ŽåŠåç¥ããããªã£ãŠããŸãããã®äžã§ãäžçªäººæ°ã¯ãåãå±æ·ã§ããäžçªäººæ°ã®çç±ã¯ããåãå±æ·ããããªãã¯ã©ã¹ã 1ã¯ã©ã¹ã 2ã¯ã©ã¹ã§ã¯ãªãã9ã¯ã©ã¹ããåãå±æ·ããããªãããšã§ããããããã工倫ããããšããããããããåæ§çãªãåãå±æ·ã«ãªã£ãŠããŸãããã®ãããæè¿ã§ã¯è¿é£ããå€ãã®æ¥å Žè
ã蚪ããŸãã
</p>
<p>
ããã§ãåŠåç¥å®è¡å§å¡äŒã§ã¯ããåãå±æ·ã®å
¥å Žæéãäžè¡šã®ããã«æ ¡å
ã§çµ±äžããããã«ããšã¥ãåã¯ã©ã¹ããšã«å
¥å Žè
ç·æ°ãšåå
¥ã®éèšããããªãããšã«ããŸããã
</p>
<p>
å
¥å Žæéè¡š(å
¥å Žè
1人ãããã®å
¥å Žæ)
</p>
<pre>
åå ååŸ
200å 300å
</pre>
<p>
åã¯ã©ã¹æ¯ã®ååãšååŸã®å
¥å Žè
æ°ãå
¥åãšããåã¯ã©ã¹æ¯ã®å
¥å Žè
ç·æ°åã³åå
¥ã®äžèŠ§è¡šãäœæããããã°ã©ã ãäœæããŠãã ããã
</p>
<H2>Input</H2>
<p>
å
¥åã¯ä»¥äžã®åœ¢åŒã§äžããããŸãã
</p>
<pre>
<var>name<sub>1</sub></var> <var>a<sub>1</sub></var> <var>b<sub>1</sub></var>
<var>name<sub>2</sub></var> <var>a<sub>2</sub></var> <var>b<sub>2</sub></var>
:
<var>name<sub>9</sub></var> <var>a<sub>9</sub></var> <var>b<sub>9</sub></var>
</pre>
<p>
å
¥åã¯ïŒè¡ãããªãã<var>i</var> è¡ç®ã«ç¬¬ <var>i</var> ã®ã¯ã©ã¹ã®ã¯ã©ã¹å <var>name<sub>i</sub></var> (æ°åãšã¢ã«ãã¡ããããå«ã 1 æåä»¥äž 15 æå以äžã®åè§æåå)ãååã®å
¥å Žè
æ° <var>a<sub>i</sub></var> (0 ≤ <var>a<sub>i</sub></var> ≤ 400)ã ååŸã®å
¥å Žè
æ° <var>b<sub>i</sub></var> (0 ≤ <var>b<sub>i</sub></var> ≤ 400) ãäžããããŸãã
</p>
<H2>Output</H2>
<p>
<var>i</var> è¡ç®ã«ç¬¬ <var>i</var> ã®ã¯ã©ã¹ã®ã¯ã©ã¹åã å
¥å Žè
ç·æ°ã æéåå
¥ã空çœåºåãã§ïŒè¡ã«åºåããŠãã ããã
</p>
<H2>Sample Input</H2>
<pre>
1a 132 243
1c 324 183
1f 93 199
2b 372 163
2c 229 293
2e 391 206
3a 118 168
3b 263 293
3d 281 102
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1a 375 99300
1c 507 119700
1f 292 78300
2b 535 123300
2c 522 133700
2e 597 140000
3a 286 74000
3b 556 140500
3d 383 86800
</pre>
| [
[
"1a 132 243\n1c 324 183\n1f 93 199\n2b 372 163\n2c 229 293\n2e 391 206\n3a 118 168\n3b 263 293\n3d 281 102\n",
"1a 132 243\n1c 324 183\n1f 93 199\n2b 372 163\n2c 229 293\n2e 391 206\n3a 118 168\n3b 263 293\n3d 281 102\n"
]
] |
p00174 | Badminton |
<H1>ãããã³ãã³</H1>
<p>
AåãBãããCåã§ä¹
ãã¶ãã«éã¶ããšã«ãªããŸããã AåãšBããããã¬ã€ã€ãŒãCåã審å€ã«ãªããããã³ãã³ã®ã·ã³ã°ã«ã¹ã®ã²ãŒã ãããŸããã3人ã§æ±ºããã«ãŒã«ã¯ä»¥äžã®éãã§ãã
</p>
<ul>
<li>3 ã²ãŒã ãè¡ããŸãã</li>
<li>11 ç¹ãå
åãã人ãããã®ã²ãŒã ã®åè
ãšãªããŸãã</li>
<li>第 1 ã²ãŒã ã®æåã®ãµãŒãã¯Aåããå§ãŸããŸããã次ã®ãµãŒãã¯çŽåã®ãã€ã³ããåã£ã人ãè¡ããŸãã</li>
<li>第 2 ã²ãŒã ã第 3 ã²ãŒã ã¯åã®ã²ãŒã ãåã£ã人ãæåã®ãµãŒããè¡ããŸãã</li>
<li>10 - 10 ã«ãªã£ãŠä»¥é㯠2 ç¹å·®ãã€ãã人ãåè
ãšãªããŸãã</li>
</ul>
<p>
å
šãŠã®ã²ãŒã ãçµãããåŸç¹ãèŠãããšããã®ã§ããã審å€ã®CåãåŸç¹ãèšé²ããã®ãå¿ããŠããŸããããããããµãŒããæã£ã人ããã¡ããšèšé²ããŠããŸããããµãŒãé ã®èšé²ããåŸç¹ãèšç®ããããã°ã©ã ãäœæããŠãã ããããã ããäºäººãæã£ããµãŒãã®åæ°ã®åèšã¯ 100 以äžãšãããµãŒãé ã®èšé²ã¯ããµãŒããæã£ã人ãè¡šã "A" ãŸã㯠"B" ã®æååã§è¡šãããŸãã
</p>
<H2>Input</H2>
<p>
è€æ°ã®ããŒã¿ã»ããã®äžŠã³ãå
¥åãšããŠäžããããŸããå
¥åã®çµããã¯ãŒãã²ãšã€ã®è¡ã§ç€ºãããŸ
ããåããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããŸãã
</p>
<pre>
<var>record<sub>1</sub></var>
<var>record<sub>2</sub></var>
<var>record<sub>3</sub></var>
</pre>
<p>
<var>i</var> è¡ç®ã«ç¬¬ <var>i</var> ã²ãŒã ã®ãµãŒãé ãè¡šãæååãäžããããŸãã
</p>
<p>
ããŒã¿ã»ããã®æ°ã¯ 20 ãè¶
ããŸããã
</p>
<H2>Output</H2>
<p>
ããŒã¿ã»ããæ¯ã«ã<var>i</var> è¡ç®ã«ç¬¬ <var>i</var> ã²ãŒã ã®Aåã®åŸç¹ãšBããã®åŸç¹ã空çœåºåãã§åºåããŠãã ããã
</p>
<H2>Sample Input</H2>
<pre>
ABAABBBAABABAAABBAA
AABBBABBABBAAABABABAAB
BABAABAABABABBAAAB
AABABAAABBAABBBABAA
AAAAAAAAAAA
ABBBBBBBBBB
0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
11 8
10 12
11 7
11 8
11 0
0 11
</pre>
| [
[
"ABAABBBAABABAAABBAA\nAABBBABBABBAAABABABAAB\nBABAABAABABABBAAAB\nAABABAAABBAABBBABAA\nAAAAAAAAAAA\nABBBBBBBBBB\n0\n",
"ABAABBBAABABAAABBAA\nAABBBABBABBAAABABABAAB\nBABAABAABABABBAAAB\nAABABAAABBAABBBABAA\nAAAAAAAAAAA\nABBBBBBBBBB\n0\n"
]
] |
p00175 | Quaternary Notation |
<H1>ïŒé²æ°</H1>
<p>
10 é²æ°ã¯çŸåšäœ¿ãããŠããäžè¬çãªèšæ°æ³ã§ã0ã1ã2ã3ã4ã5ã6ã7ã8ã9 ã®10 åã®èšå·ãçšããŠå
šãŠã®æ°åãè¡šããŸãã
</p>
<p>
2 é²æ°ã¯ã³ã³ãã¥ãŒã¿ã®äžçã§ãã䜿ãããèšæ°æ³ã§ã0 ãš1 ã®äºã€ã®èšå·ãçšããŠå
šãŠã®æ°åãè¡šããŸãã
</p>
<p>
4 é²æ°ã§çšããããã®ã¯ 0ã1ã2ã3 ã® 4 ã€ã®æ°åã ãã§ãã4 é²æ°ã§ã¯ 0 ããé ã«æ°ãå¢ãããŠãã£ããšãã« 4 ãŸã§æ¥ãã次ã®äœã«æ¡äžããããŸãããã®ããã10 é²æ°ã® 4 ã¯æ¡äžããããŠã10ããšããè¡šçŸã«ãªããŸãã
</p>
<center>
<table>
<tr>
<td width="80">10 é²æ°</td>
<td width="40">0</td>
<td width="40">1</td>
<td width="40">2</td>
<td width="40">3</td>
<td width="40">4</td>
<td width="40">5</td>
<td width="40">6</td>
<td width="40">7</td>
<td width="40">8</td>
<td width="40">9</td>
<td width="40">10</td>
<td>...</td>
</tr>
<tr>
<td>2 é²æ°</td>
<td>0</td>
<td>1</td>
<td>10</td>
<td>11</td>
<td>100</td>
<td>101</td>
<td>110</td>
<td>111</td>
<td>1000</td>
<td>101</td>
<td>1010</td>
<td>...</td>
</tr>
<tr>
<td>4 é²æ°</td>
<td>0</td>
<td>1</td>
<td>2</td>
<td>3</td>
<td>10</td>
<td>11</td>
<td>12</td>
<td>13</td>
<td>20</td>
<td>21</td>
<td>22</td>
<td>...</td>
</tr>
</table>
<br>
</center>
<p>
æãã¯ã€ã§ã¯éãã¿ãã€ã¢ãæã«ã¯ããã§æ°ããŠããã®ã§ã10 é²æ°ã§ã¯ãªã4 é²æ°ã䜿ã£ãŠããããã§ãã
</p>
<p>
10 é²æ°ã§å
¥åãããæŽæ° <var>n</var> ã 4 é²æ°ã«å€æãåºåããããã°ã©ã ãäœæããŠãã ããã
</p>
<H2>Input</H2>
<p>
è€æ°ã®ããŒã¿ã»ããã®äžŠã³ãå
¥åãšããŠäžããããŸããå
¥åã®çµãã㯠-1 ã²ãšã€ã®è¡ã§ç€ºãããŸããåããŒã¿ã»ãããšããŠïŒã€ã®æŽæ° <var>n</var> (0 ≤ <var>n</var> ≤ 1000000) ãïŒè¡ã«äžããããŸãã
</p>
<p>
ããŒã¿ã»ããã®æ°ã¯ 2000 ãè¶
ããŸããã
</p>
<H2>Output</H2>
<p>
å
¥åããŒã¿ã»ããæ¯ã« 4 é²æ°ã«å€æããçµæãïŒè¡ã«åºåããŸãã
</p>
<H2>Sample Input</H2>
<pre>
7
4
0
12
10
10000
-1
</pre>
<H2>Output for the Sample Input</H2>
<pre>
13
10
0
30
22
2130100
</pre>
| [
[
"7\n4\n0\n12\n10\n10000\n-1\n",
"7\n4\n0\n12\n10\n10000\n-1\n"
]
] |
p00176 | What Color? |
<H1>äœè²ïŒ</H1>
<p>
ãŠã§ããã¶ã€ããŒãç®æã倪éåã¯ãã ããŸä¿®è¡äžãäºåæã®å
茩ããããã®ããŒãžã®èæ¯è²ã¯#ffe085ã§ããšããŠã§ããã¶ã€ã³ç¹æã®è²çªå·ã§æ瀺ãããã®ã§ããããããã©ããªè²ããããšæãæµ®ãã¹ãããšãã§ããŸããã
</p>
<p>
ãã®è²çªå·ã¯å
ã®äžåè²ã§ããèµ€ãç·ãéããããã®åŒ·ããè¡šãããŠããŸããå
·äœçã«ã¯2 æ¡ã® 16 é²æ°ã3 ã€çµã¿åããããã®ã§ãè²çªå·ãâ#RGBâãšãããšããR ã¯èµ€ã®åŒ·ããG ã¯ç·ã®åŒ·ããã¯éã®åŒ·ããè¡šããŸãããããã 00 ãã ff ãŸã§ã®å€ã«ãªããŸãã
</p>
<p>
è²çªå·ã«ãŸã äžæ
£ããªå€ªéåã®ããã«ãè²çªå·ãå
¥åãšããè²ã®è¡šã®äžãããã£ãšãè¿ãè²ã®åå
ãåºåããããã°ã©ã ãäœæããŠãã ããã䜿çšããè²ã®è¡šã¯ä»¥äžã®éãã§ãã
</p>
<center>
<table>
<tr><td width="20"> </td><td width="100"> è²ã®åå</td><td width="80">èµ€ã®åŒ·ã</td><td width="80"> ç·ã®åŒ·ã</td><td width="80"> éã®åŒ·ã</td></tr>
<tr><td bgcolor="#000000"></td><td>black</td><td> 00</td><td> 00</td><td> 00</td></tr>
<tr><td bgcolor="#0000ff"></td><td>blue</td><td> 00</td><td> 00</td><td> ff</td></tr>
<tr><td bgcolor="#00ff00"></td><td> lime</td><td> 00</td><td> ff</td><td> 00</td></tr>
<tr><td bgcolor="#00ffff"></td><td> aqua</td><td> 00</td><td> ff</td><td> ff</td></tr>
<tr><td bgcolor="#ff0000"></td><td> red</td><td> ff</td><td> 00</td><td> 00</td></tr>
<tr><td bgcolor="#ff00ff"></td><td> fuchsia</td><td> ff</td><td> 00</td><td> ff</td></tr>
<tr><td bgcolor="#ffff00"></td><td> yellow</td><td> ff</td><td> ff</td><td> 00</td></tr>
<tr><td bgcolor="#ffffff"></td><td> white</td><td> ff</td><td> ff</td><td> ff</td></tr>
</table>
</center>
<br/>
<br/>
<p>
ããã£ãšãè¿ãè²ããšã¯ã以äžã®ããã«å®çŸ©ããŸããäžããããè²çªå·ã§ã®èµ€ãç·ãéã®åŒ·ãããããã <var>R</var>ã<var>G</var>ã<var>B</var> ãšããè¡šã® <var>k</var> çªç®ã®è²ã®èµ€ãç·ãéã®åŒ·ãããããã <var>R<sub>k</sub></var>ã<var>G<sub>k</sub></var>ã<var>B<sub>k</sub></var> ãšãããšãã次ã®åŒã§èšç®ãã <var>d<sub>k</sub></var> ã®å€ãæãå°ããè²ããã£ãšãè¿ãè²ãšããŸãã
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_pck2008_04">
</center>
<br/>
<br/>
<p>
ãªãã<var>d<sub>k</sub></var> ã®å€ãåãã«ãªãè²ãè€æ°ååšããå Žåã¯è¡šã®äžã§ããäžã«ããè²ããã£ãšãè¿ãè²ã«ãªã
ãŸãã
</p>
<H2>Input</H2>
<p>
è€æ°ã®ããŒã¿ã»ããã®äžŠã³ãå
¥åãšããŠäžããããŸããå
¥åã®çµããã¯ãŒãã²ãšã€ã®è¡ã§ç€ºãããŸããåããŒã¿ã»ãããšããŠãè²çªå·ãè¡šãæååãã<span>#</span><var>RGB</var> 圢åŒã§ïŒè¡ã«äžããããŸãã
</p>
<p>
ããŒã¿ã»ããã®æ°ã¯ 1000 ãè¶
ããŸããã
</p>
<H2>Output</H2>
<p>
ããŒã¿ã»ããæ¯ã«æãè¿ãè²ã®ååãïŒè¡ã«åºåããŸãã
</p>
<H2>Sample Input</H2>
<pre>
#ffe085
#787878
#decade
#ff55ff
0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
white
black
white
fuchsia
</pre>
| [
[
"#ffe085\n#787878\n#decade\n#ff55ff\n0\n",
"#ffe085\n#787878\n#decade\n#ff55ff\n0\n"
]
] |
p00177 | Distance Between Two Cities |
<H1>ïŒéœåžéã®è·é¢</H1>
<p>
å°çäžã®2 éœåžã®åç·¯ãšæ±çµãå
¥åãšããå°è¡šè·é¢ãèšç®ããŠåºåããããã°ã©ã ãäœæããŠãã ããããã ããå°çã¯ååŸ 6,378.1 km ã®çãšãã2 ç¹éã®å°è¡šè·é¢ãšã¯ãã®çé¢ã«æ²¿ã£ãæçè·é¢ã§ãããŸããååçã§ãåç·¯ã¯çšããã«åç·¯ 0 ~ -90 床ãçšããã°ãªãããžååç·ã®è¥¿ã§ã西çµã¯çšããã«æ±çµ 180 ~ 360 床ãçšããããšãšããŸããå°è¡šè·é¢ã¯ km åäœã§æ±ããå°æ°ç¹ä»¥äžã¯åæšäºå
¥ããæŽæ°å€ãšããŠåºåããŠãã ããã
</p>
<p>
以äžã«äž»èŠéœåžã®åç·¯ãæ±çµã®äŸã瀺ããŸãã
</p>
<center>
<table>
<tr><th width="120">å°å</th><th width="100"> åç·¯(床)</th><th width="100"> æ±çµ(床)</th></tr>
<tr><th>æ±äº¬</th><th> 35.68</th><th> 139.77</th></tr>
<tr><th> ã·ã³ã¬ããŒã«</th><th> 1.37</th><th> 103.92</th></tr>
<tr><th> ã·ãããŒ</th><th> -33.95 </th><th>151.18</th></tr>
<tr><th> ã·ã«ãŽ </th><th> 41.78</th><th> 272.25</th></tr>
<tr><th>ããšãã¹ã¢ã€ã¬ã¹ </th><th> -34.58</th><th> 301.52</th></tr>
<tr><th> ãã³ãã³ </th><th> 51.15</th><th> 359.82</th></tr>
</table>
</center>
<br/>
<br/>
<H2>Input</H2>
<p>
è€æ°ã®ããŒã¿ã»ããã®äžŠã³ãå
¥åãšããŠäžããããŸããå
¥åã®çµããã¯-1 åã€ã®è¡ã§ç€ºãããŸããåããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããŸãã
</p>
<pre>
<var>a</var> <var>b</var> <var>c</var> <var>d</var>
</pre>
<p>
1 è¡ã«ç¬¬ 1 ã®éœåžã®åç·¯ <var>a</var>ã第 1 ã®éœåžã®æ±çµ <var>b</var>ã第 2 ã®éœåžã®åç·¯ <var>c</var>ã第 2 ã®éœåžã®æ±çµ <var>d</var> ã空çœåºåãã§äžããããŸããå
¥åã¯ãã¹ãŠå®æ°ã§äžããããŸãã
</p>
<p>
ããŒã¿ã»ããã®æ°ã¯ 30 ãè¶
ããŸããã
</p>
<H2>Output</H2>
<p>
ããŒã¿ã»ããæ¯ã« 2 éœåžã®å°è¡šè·é¢ãïŒè¡ã«åºåããŸãã
</p>
<H2>Sample Input</H2>
<pre>
35.68 139.77 51.15 359.82
1.37 103.92 41.78 272.25
51.15 359.82 -34.58 301.52
-1 -1 -1 -1
</pre>
<H2>Output for the Sample Input</H2>
<pre>
9609
15092
11112
</pre>
| [
[
"35.68 139.77 51.15 359.82\n1.37 103.92 41.78 272.25\n51.15 359.82 -34.58 301.52\n-1 -1 -1 -1\n",
"35.68 139.77 51.15 359.82\n1.37 103.92 41.78 272.25\n51.15 359.82 -34.58 301.52\n-1 -1 -1 -1\n"
]
] |
p00178 | TETORIS |
<H1>ãããªã¹</H1>
<p>
ãããªã¹ã¯ãèœã¡ãŠãããããã¯ãç€é¢äžã«äžŠã¹ãŠæ¶ãã²ãŒã ã§ããããã§ã¯ããããå°ãã¢ã¬ã³ãžããã²ãŒã ãèããŸãããã
</p>
<p>
ãã®ã²ãŒã ã®ç€é¢ã®å€§ããã¯æšª 5 ã³ãã§ãåºçŸãããããã¯ããã¹ãŠå
¥ãã ãã®é«ãããããŸããèœã¡ãŠãããããã¯ã¯çŽç·ç¶ã§ã暪åãã瞊åãã® 2 çš®é¡ããããé·ã㯠1 ãã 5 ãŸã§ã® 5 çš®é¡ã§ãã
</p>
<p>
以äžã«äŸã瀺ããŸããStep(ã€) ããStep(ã)ãŸã§ã®å³ã¯ãããã¯ãèœã¡ãŠæ¶ããŠããæ§åãè¡šãããã®ã§ãã
Step(ã€)ããé ã«Step(ã)ãStep(ã)ãšé ã«é²ãã§ãããŸãã
</p>
<p>
ãããã¯ãèœãšããšãã«ãStep(ã€)ã®ããã«ãããã¯ã®ã©ãããäžã«ç©ãã§ãããããã¯ã«åŒã£ããã£ããšãã«ã¯ãStep(ã)ã®ããã«èœã¡ããããã¯ã¯ãã®å Žæã§æ¢ãŸããŸãããŸãããããã¯ãèœãšããçµæãç€é¢ã®æšªäžè¡ã®å
šãŠã®ã³ãã«ãããã¯ãè©°ãŸã£ãå Žåã«ã¯ãStep(ã)ã§ç€ºãããããã«ããã®è¡ã®ãããã¯ãæ¶ããŸãããã®åŸãæ¶ããè¡ã®äžã«ãããããã¯ãããã®ãŸãŸã®åœ¢ã§1è¡äžã«ããã¿ãŸã(Step(ã))ã
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_pck200806_1">
<br/><br/>
</center>
<p>
1 ã²ãŒã 㯠1000 å以å
ã®ãããã¯ãé ã«èœã¡ãŠããããšãšããŸããäŸãã°ãèœã¡ããããã¯ã®é·ããé çªã«æšªåã 4 ã³ã, 暪åã 3 ã³ã, 瞊åã 2 ã³ã, 瞊åã 3 ã³ãã§ãèœã¡ãå Žæã巊端ãã 1 ã³ãç®ã1 ã³ãç®ã4 ã³ãç®ã5 ã³ãç®ã§ãã£ãå Žåã«ã¯ãäžå³ã®Step(ã€)~(ã)ã®ããã«èœã¡ãæåŸã«æ®ããããã¯ã¯ 2 ã³ãã«ãªããŸãã
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_pck200806_2">
<br/><br/>
</center>
<p>
é çªã«èœã¡ãŠãããããã¯ã®æ
å ±ãå
¥åãšããå
šãŠã®ãããã¯ãèœã¡ãæã«æ®ãã³ãæ°ãåºåããããã°ã©ã ãäœæããŠãã ããã
</p>
<H2>Input</H2>
<p>
è€æ°ã®ããŒã¿ã»ããã®äžŠã³ãå
¥åãšããŠäžããããŸããå
¥åã®çµããã¯ãŒãã²ãšã€ã®è¡ã§ç€ºãããŸããåããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããŸãã
</p>
<pre>
<var>n</var>
<var>d<sub>1</sub></var> <var>p<sub>1</sub></var> <var>q<sub>1</sub></var>
<var>d<sub>2</sub></var> <var>p<sub>2</sub></var> <var>q<sub>2</sub></var>
:
<var>d<sub>n</sub></var> <var>p<sub>n</sub></var> <var>q<sub>n</sub></var>
</pre>
<p>
ïŒè¡ç®ã«ãããã¯ã®æ° <var>n</var> (1 ≤ <var>n</var> ≤ 1000) ãäžããããŸããç¶ã <var>n</var> è¡ã« <var>i</var> åç®ã®ãããã¯ã®åã <var>d<sub>i</sub></var> (1 ãŸãã¯2)ããããã¯ã®é·ã <var>p<sub>i</sub></var> (1 ≤ <var>p<sub>i</sub></var> ≤ 5)ããããã¯ã®äœçœ® <var>q<sub>i</sub></var> ãäžããããŸãããããã¯ã®åã <var>d<sub>i</sub></var> 㯠1 ã暪åããã2 ã瞊åããè¡šããŸãããããã¯ã®äœçœ® <var>q<sub>i</sub></var> ã¯ç€é¢äžã®å·Šç«¯ãã1 ~ 5 ãŸã§ã®æŽæ°ãšãã暪åãã®ãããã¯ã®å Žåã¯å·Šç«¯ã®ã³ãã®èœã¡ãäœçœ®ãšããŸãã
</p>
<p>
ããŒã¿ã»ããã®æ°ã¯ 20 ãè¶
ããŸããã
</p>
<H2>Output</H2>
<p>
ããŒã¿ã»ããæ¯ã«æåŸã«æ®ããããã¯ã®å ããã³ãæ°ãïŒè¡ã«åºåããŸãã
</p>
<H2>Sample Input</H2>
<pre>
4
1 4 1
1 3 1
2 2 4
2 3 5
1
1 5 1
7
2 2 2
1 4 1
2 1 3
1 4 1
1 1 1
2 5 5
1 4 2
0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
2
0
6
</pre>
| [
[
"4\n1 4 1\n1 3 1\n2 2 4\n2 3 5\n1\n1 5 1\n7\n2 2 2\n1 4 1\n2 1 3\n1 4 1\n1 1 1\n2 5 5\n1 4 2\n0\n",
"4\n1 4 1\n1 3 1\n2 2 4\n2 3 5\n1\n1 5 1\n7\n2 2 2\n1 4 1\n2 1 3\n1 4 1\n1 1 1\n2 5 5\n1 4 2\n0\n"
]
] |
p00179 | Mysterious Worm |
<H1>ãµãããªè«</H1>
<p>
äŒæŽ¥çç©åŠç 究æã®Aå士ã¯ããšããåã®å³¶ã§ãµãããªè«ãçºèŠããŸããã圢ã¯èè«ã®ããã«çŽ°é·ãã®ã§ãããã²ãšã€ã®äœç¯ãçã®ãããªåœ¢ãããŠããã®ã§ã糞ã§ã€ãªãã ããŒãºçã®ããã«èŠããŸãããµãããªã®ã¯äœã®è²ã«æ§ã
ãªããªãšãŒã·ã§ã³ãããããšãšããªãã«ã¯æéããã€ã«ã€ããŠäœã®è²ãå€ã£ãŠããè«ãããããšã§ãããã©ã®è«ã®äœç¯ã®è²ãèµ€ãç·ãéã®ã©ããã«éãããããã§ããã1 ç§ããšã«äœç¯ã®è²ãå€ãã£ãŠãããæåŸã«ã¯ãã¹ãŠã®äœç¯ãåãè²ã«ãªã£ãŠèœã¡çãå Žåãããã°ããã€ãŸã§åŸ
ã£ãŠããã£ãšè²ãå€ããã€ã¥ããå Žåãããããã§ããã
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_pck200807_1">
<br/><br/>
</center>
<p>
調ã¹ãŠãããã¡ã«ããµã ãã¯ãã¹ãŠã®äœç¯ãåãè²ãããŠããã®ã§ãããäœãã«é©ãããããŠè奮ããåŸã¯äœç¯ã®è²ãåæã«å€ãã£ãŠããŸãããšãããããŸãããäžåºŠäœç¯ã®è²ãå€ãã£ãŠããŸããšããµããã³ãã¹ãŠã®äœç¯ãåãè²ã«ãªããŸã§ã¯ãã£ãšè²ãå€ããç¶ããããšãããããŸããã
</p>
<p>
Aå士ã¯ãã®è«ãäœå¹ãæãŸããŠè奮ãããŠã¿ãŠã¯ãè²ãå€ããæ§åãèå³æ·±ã芳å¯ããŠããŸãããããããŠè²ãå€åããŠããæäžã®è²ã®å€ããæ¹ã«ã¯æ¬¡ã®ãããªèŠåæ§ãããããšã«æ°ãã€ããŸããã
</p>
<ul>
<li>è²ãå€ããã®ã¯ãé£ãåã£ãŠããè²éãã® 2ã€ã®äœç¯ã®ã㢠1çµã ããå€ãããä»ã®äœç¯ã®è²ã¯å€ãããªãããã ãããã®ãããªãã¢ãè€æ°ãããšãã«ãã©ã®ãã¢ã®è²ãå€ãããã¯ãããããäºæž¬ã§ããªãã</li>
<li>ãã®ãããªãã¢ã¯ã2ã€ã®äœç¯ã®è²ã®ã©ã¡ãã§ããªãè²ã«åæã«å€ãã(ããšãã°ãç·ãšèµ€ã®äœç¯ãé£ãåã£ãŠãããšãã¯ãããããåæã«éã«å€ãã)ã</li>
</ul>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_pck200807_2">
<br/><br/>
</center>
<p>
è«ã®è²ã®å€åãã2ç§åŸãŸã§ãã¹ãŠæžãããã®ãäžã®å³ã§ããå³ã®äžæ®µã®ãããªè²ãããè«ããããšããŸãããã®ãšããé£ãåã£ãè²éãã®äœç¯ã®ãã¢ã¯ 3çµããã®ã§ã1ç§åŸã«ã¯äžæ®µã«äžŠã¹ãŠæãã 3éãã®è²ã®ã©ããã«å€ãããŸãã1ç§åŸã«äžæ®µå·ŠåŽã® 2ã€ã®ããã«å€ãã£ããšãã«ã¯ã2ç§åŸã«ãã¹ãŠã®äœç¯ãç·è²ã«ãªãããšãã§ããŸã(å³ã®äžæ®µã®å·ŠåŽãã 2çªç®)ã ããã«å¯ŸããŠã1ç§åŸã«äžæ®µã®1çªå³ã®ããã«å€ãã£ããšãã«ã¯ã2ç§åŸã«ãã¹ãŠã®äœç¯ãåãè²ã«å€ããããšã¯ãããŸããã
</p>
<p>
å士ã¯ãç®ã®åã«ããè«ã®äœç¯ããã¹ãŠåãè²ã«ãªãå¯èœæ§ãããã®ãããããšããããããªãã®ã¯æçã§äœç§åŸãªã®ããäºæž¬ããããšã«ããŸããã
</p>
<p>
ç®ã®åã«ããè«ã®äœç¯ã®è²ã®äžŠã³ãå
¥åãšãããã®è«ã®äœç¯ããã¹ãŠåãè²ã«ãªãã®ã«èŠããæçã®æéãç§åäœã§åºåããããã°ã©ã ãäœæããŠãã ããããã ããåãè²ã«ãªãå¯èœæ§ããªããšãã¯ãNA(åè§è±å€§æå)ããšåºåããŠãã ããããŸããè«ã®äœç¯ã®è²ã®äžŠã³ã¯2 ä»¥äž 10 以äžã®r(èµ€)ãg(ç·)ãb(é)ãããªãæååã§è¡šãããŸãã
</p>
<H2>Input</H2>
<p>
è€æ°ã®ããŒã¿ã»ããã®äžŠã³ãå
¥åãšããŠäžããããŸããå
¥åã®çµããã¯ãŒãã²ãšã€ã®è¡ã§ç€ºãããŸ
ããåããŒã¿ã»ãããšããŠã è«ã®äœç¯ã®æ
å ±ãè¡šãïŒã€ã®æååãïŒè¡ã«äžããããŸãã
</p>
<p>
ããŒã¿ã»ããã®æ°ã¯ 100 ãè¶
ããŸããã
</p>
<H2>Output</H2>
<p>
ããŒã¿ã»ããæ¯ã«ããã¹ãŠã®äœç¯ã®è²ãåãã«ãªããŸã§ã«èŠããæå°æé (ç§åäœã®æŽæ°) ãŸã㯠NA ãïŒè¡ã«åºåããŸãã
</pre>
<H2>Sample Input</H2>
<pre>
rbgrg
rbbgbbr
bgr
bgrbrgbr
bggrgbgrr
gbrggrbggr
rrrrr
bgbr
0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
5
7
1
6
NA
8
0
4
</pre>
| [
[
"rbgrg\nrbbgbbr\nbgr\nbgrbrgbr\nbggrgbgrr\ngbrggrbggr\nrrrrr\nbgbr\n0\n",
"rbgrg\nrbbgbbr\nbgr\nbgrbrgbr\nbggrgbgrr\ngbrggrbggr\nrrrrr\nbgbr\n0\n"
]
] |
p00180 | Demolition of Bridges |
<H1>æ©ã®åãå£ã</H1>
<p>
æ°Žã®åœãŠã©ãŒã¿ãŒããã³ã«ã¯ <var>n</var> åã®éœåžããããŸããåéœåžã¯æ°Žã«å²ãŸããŠããã島åœã®ããã«ãªã£ãŠããŸãããŠã©ãŒã¿ãŒããã³ã«ã¯ <var>m</var> æ¬ã®æ©ããããéœåžéã®äº€éã¯ãããã®æ©ã«ãã£ãŠè¡ãããå
šãŠã®éœåžã«è¡ãæ¥ããããšãã§ããŸãã
</p>
<p>
æè¿ãéè·¯ç¹å®è²¡æºã®èŠçŽãã«ããæ©ã®ç¶æè²»ã®åæžã決å®ãããŸãããå
šéšã®æ©ãç¶æããããšãã§ããªããªã£ãŠããŸããããã€ãã®æ©ãåãå£ãããšã«ãªããŸãããããã§ããŠã©ãŒã¿ãŒããã³ã¯ã©ã®éœåžã«ã§ãè¡ãããšãã§ããããã«æ©ãæ®ãã€ã€ãæ©ã®ç¶æè²»ãæå°åããããšã課é¡ãšãªããŸããã
</p>
<p>
éœåžã®æ°ãæ©ã®æ°ãåæ©ã®ç¶æè²»ãå
¥åãšããæ©ãå©çšããŠã©ã®éœåžã«ãè¡ããããã«ãã€ã€ãæ©ãåãå£ããå Žåã®ç¶æè²»ã®æå°å€ãåºåããããã°ã©ã ãäœæããŠãã ããããªããæ©ã®åãå£ãã«ã¯è²»çšãæãããªããã®ãšããŸãããã ããåéœåžã¯ 0 ãã <var>n</var> - 1 ãŸã§é çªã«çªå·ãä»ããããŠãããã®ãšããŸãã
</p>
<H2>Input</H2>
<p>
è€æ°ã®ããŒã¿ã»ããã®äžŠã³ãå
¥åãšããŠäžããããŸããå
¥åã®çµããã¯ãŒããµãã€ã®è¡ã§ç€ºãããŸããåããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããŸãã
</p>
<pre>
<var>n</var> <var>m</var>
<var>a<sub>1</sub></var> <var>b<sub>1</sub></var> <var>cost<sub>1</sub></var>
<var>a<sub>2</sub></var> <var>b<sub>2</sub></var> <var>cost<sub>2</sub></var>
:
<var>a<sub>m</sub></var> <var>b<sub>m</sub></var> <var>cost<sub>m</sub></var>
</pre>
<p>
ïŒè¡ç®ã«éœåžã®æ° <var>n</var> (2 ≤ <var>n</var> ≤ 100)ã æ©ã®æ° <var>m</var> (1 ≤ <var>m</var> ≤ 500) ãäžããããŸããç¶ã <var>m</var> è¡ã«ç¬¬ <var>i</var> ã®æ©ã®æ
å ±ãäžããããŸãã<var>a<sub>i</sub></var>, <var>b<sub>i</sub></var> ã¯æ©ãã€ãªãã§ããéœåžã®çªå·ã<var>cost<sub>i</sub></var> (1 ≤ <var>cost<sub>i</sub></var> ≤ 1000) ã¯æ©ã«ãããç¶æè²»ãè¡šããŸãã
</p>
<H2>Output</H2>
<p>
ããŒã¿ã»ããæ¯ã«æ©ã®ç¶æè²»ã®åèšãïŒè¡ã«åºåããŸãã
</p>
<H2>Sample Input</H2>
<pre>
5 6
0 2 1
2 1 3
2 3 8
1 3 2
3 4 5
1 4 4
3 3
1 2 3
2 0 3
0 1 3
0 0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
10
6
</pre>
| [
[
"5 6\n0 2 1\n2 1 3\n2 3 8\n1 3 2\n3 4 5\n1 4 4\n3 3\n1 2 3\n2 0 3\n0 1 3\n0 0\n",
"5 6\n0 2 1\n2 1 3\n2 3 8\n1 3 2\n3 4 5\n1 4 4\n3 3\n1 2 3\n2 0 3\n0 1 3\n0 0\n"
]
] |
p00181 | Bookshelf |
<H1>æ¬æ£</H1>
<p>
倪éåã¯ãšããå°èª¬ã«ã¯ãŸã£ãŠããŸãããã®å°èª¬ã¯å
šéšã§ <var>n</var> å·»ãããåå·»ã§æ¬ã®åããç°ãªããŸãã倪éåã¯ãã®å°èª¬ã倧å€æ°ã«å
¥ã£ãã®ã§ããã®å°èª¬å°çšã®æ¬æ£ãè²·ãããšæã£ãŠããŸããããããéšå±ã«å€§ããªæ¬æ£ã眮ããšããªãçããªã£ãŠããŸãã®ã§ãåºæ¥ãã ãæ¬æ£ã®å¹
ãå°ãããªãããã«å·¥å€«ããªããã°ãªããŸãããåºãã倩äºã®é«ãã枬ã£ããšãããã©ããã <var>m</var> 段ã®æ¬æ£ãªã眮ããããšãåãããŸãããããã§ãå°èª¬ <var>n</var> å·»ãã©ã®ããã«åããã° <var>m</var> 段ã®æ¬æ£ã®å¹
ãæå°ã«åºæ¥ãã§ãããã?
倪éåã«ã¯ãã ããããããå段ã«çŽããå°èª¬ã¯å·»ã®çªå·é ã«äžŠãã§ããªããã°ãªããŸããã
</p>
<p>
æ¬æ£ã®æ®µæ°ãå°èª¬ã®å·»æ°ãåæ¬ã®åããå
¥åãšããŠãå
šå·»ã 1å·»ããé ã«åããããšãã§ããæ¬æ£ã®äžã§å¹
ãæå°ãšãªããã®ã®å¹
ãæ±ããããã°ã©ã ãäœæããŠãã ããããã ããæ¬æ£ã®æ ã®å€§ããã¯å¹
ã«å«ããªãããšãšããŸãã
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_pck200809">
</center>
<br/>
<H2>Input</H2>
<p>
è€æ°ã®ããŒã¿ã»ããã®äžŠã³ãå
¥åãšããŠäžããããŸããå
¥åã®çµããã¯ãŒããµãã€ã®è¡ã§ç€ºãããŸããåããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããŸãã
</p>
<pre>
<var>m</var> <var>n</var>
<var>w<sub>1</sub></var>
<var>w<sub>2</sub></var>
:
<var>w<sub>n</sub></var>
</pre>
<p>
ïŒè¡ç®ã«éšå±ã«çœ®ãããšãã§ããæ¬æ£ã®æ®µæ° <var>m</var> (1 ≤ <var>m</var> ≤ 20)ã å°èª¬ã®å·»æ° <var>n</var> (1 ≤ <var>n</var> ≤ 100) ãäžããããŸããç¶ã <var>n</var> è¡ã«ç¬¬ <var>i</var> å·»ã®æ¬ã®åããè¡šãæŽæ° <var>w<sub>i</sub></var> (1 ≤ <var>w<sub>i</sub></var> ≤ 1000000) ãäžããããŸãã
</p>
<p>
ãã ããæ¬æ£ã®å¹
㯠1500000 ãè¶
ããªããã®ãšããŸãã
</p>
<p>
ããŒã¿ã»ããã®æ°ã¯ 50 ãè¶
ããŸããã
</p>
<H2>Output</H2>
<p>
ããŒã¿ã»ããæ¯ã«æå°ãšãªãæ¬æ£ã®å¹
ãïŒè¡ã«åºåããŸãã
</p>
<H2>Sample Input</H2>
<pre>
3 9
500
300
800
200
100
600
900
700
400
4 3
1000
1000
1000
0 0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1800
1000
</pre>
| [
[
"3 9\n500\n300\n800\n200\n100\n600\n900\n700\n400\n4 3\n1000\n1000\n1000\n0 0\n",
"3 9\n500\n300\n800\n200\n100\n600\n900\n700\n400\n4 3\n1000\n1000\n1000\n0 0\n"
]
] |
p00182 | Beaker |
<H1>ããŒã«ãŒ</H1>
<p>
ãããããªå®¹éã®ããŒã«ãŒãäžããããŠããŸããã¯ããã«ããã®äžã®äžçªå®¹éã®å€§ããªããŒã«ãŒãäžåéžã³ãèå£ããæ°Žããã£ã±ãã«ãªããŸã§æ³šããŸããã€ãã«ã次ã®ã«ãŒã«ã«ãããããªãããããŒã«ãŒã®æ°Žãä»ã®ããŒã«ãŒã«ç§»ãæ¿ããŠãããŸãã
</p>
<ul>
<li>ããŒã«ãŒã«å
¥ã£ãŠããæ°Žã¯,æ®ããã«ãã¹ãŠä»ã®ããŒã«ãŒã«ç§»ããªããã°ãªããªãããã ããäžåã®ããŒã«ãŒã«æ°Žãå
šéšç§»ããªããšãã¯ãè€æ°ã®ããŒã«ãŒã«åããŠç§»ããŠãããã</li>
<li>ããŒã«ãŒã«æ°Žãå
¥ãããšãããã£ã±ãã«ãªããŸã§æ°Žã泚ããªããã°ãªããªãããŸããæ°ŽãããŒããŠã¯ãªããªãã</li>
<li>è€æ°ã®ããŒã«ãŒããåãããŒã«ãŒã«äžåºŠã«æ°Žã泚ãã§ã¯ãªããªãã</li>
<li>åãããŒã«ãŒã«ã¯äžåºŠããæ°Žã泚ãã§ã¯ãªããªãã</li>
</ul>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_pck200810">
<br/><br/>
</center>
<p>
ãã®ã«ãŒã«ã«ãããã£ããšããããŒã«ãŒã®åæ° <var>n</var> ãšåããŒã«ãŒã®å®¹éãå
¥åãšãããã¹ãŠã®ããŒã«ãŒã«æ°Žã泚ãããšãã§ãããã©ãããå€å®ããŠåºåããããã°ã©ã ãäœæããŠãã ããããã¹ãŠã®ããŒã«ãŒã«æ°Žã泚ãããšãã§ãããšã㯠YES (åè§è±å€§æå)ãã§ããªããšã㯠NO (åè§è±å€§æå) ãåºåããŠãã ããã
</p>
<H2>Input</H2>
<p>
è€æ°ã®ããŒã¿ã»ããã®äžŠã³ãå
¥åãšããŠäžããããŸããå
¥åã®çµããã¯ãŒãã²ãšã€ã®è¡ã§ç€ºãããŸããåããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããŸãã
</p>
<pre>
<var>n</var>
<var>c<sub>1</sub></var> <var>c<sub>2</sub></var> ... <var>c<sub>n</sub></var>
</pre>
<p>
1 è¡ç®ã«ããŒã«ãŒã®åæ° <var>n</var> (1 ≤ <var>n</var> ≤ 50) ãäžããããŸããïŒè¡ç®ã« <var>i</var> çªç®ã®ããŒã«ãŒã®å®¹éãè¡šãæŽæ° <var>c<sub>i</sub></var> (1 ≤ <var>c<sub>i</sub></var> ≤ 100) ãäžããããŸãã
</p>
<p>
ããŒã¿ã»ããã®æ°ã¯ 105 ãè¶
ããŸããã
</p>
<H2>Output</H2>
<p>
ããŒã¿ã»ããæ¯ã«å€å®çµæãïŒè¡ã«åºåããŸãã
</p>
<H2>Sample Input</H2>
<pre>
10
11 2 23 4 2 12 8 5 2 10
8
2 1 3 11 2 3 1 4
9
5 9 1 2 4 8 17 1 8
8
3 38 9 4 18 14 19 5
1
1
0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
YES
YES
NO
YES
</pre>
| [
[
"10\n11 2 23 4 2 12 8 5 2 10\n8\n2 1 3 11 2 3 1 4\n9\n5 9 1 2 4 8 17 1 8\n8\n3 38 9 4 18 14 19 5\n1\n1\n0\n",
"10\n11 2 23 4 2 12 8 5 2 10\n8\n2 1 3 11 2 3 1 4\n9\n5 9 1 2 4 8 17 1 8\n8\n3 38 9 4 18 14 19 5\n1\n1\n0\n"
]
] |
p00183 | Black-and-White |
<H1>äžç®äžŠã¹</H1>
<p>
3 × 3 ã®ç€é¢ã®äžç®äžŠã¹ãèããŸããããäžç®äžŠã¹ã¯ 2 人ã§è¡ã察æŠã²ãŒã ã§ããå
æ»åŸæ»ã決ããäžäººã¯é»ç³ãäžäººã¯çœç³ãæã¡ãŸããç€é¢ã«ç³ã亀äºã«äžã€ãã€çœ®ããŠããã瞊暪æãã®ããããã®æ¹åã«å
ã« 3 ã€èªåã®ç³ã䞊ã¹ã人ãåã¡ãšãªããŸãã
</p>
<p>
ç€é¢ã®æ
å ±ãå
¥åãšããåæã®å€å®ãè¡ããé»ãåã¡ã®å Žåã¯ãbããçœãåã¡ã®å Žåã¯ãwããã©ã¡ããããã£ãŠããªãå Žåã¯ãNAããšåºåããããã°ã©ã ãäœæããŠãã ããã ç€é¢ã®æ
å ±ã¯ã3è¡3åã®æååã§æ§æãããŸãããbãã¯é»ç³ããwãã¯çœç³ãã+ã(åè§ãã©
ã¹)ã¯äœã眮ãããŠããªãç¶æ³ãè¡šããŸãããã ããåæã«é»ã3ã€ãçœã3ã€äžŠã¶ããšã¯ãããŸã
ãã
</p>
<!--<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ticktacktoe">-->
<H2>Input</H2>
<p>
è€æ°ã®ããŒã¿ã»ããã®äžŠã³ãå
¥åãšããŠäžããããŸããå
¥åã®çµããã¯ãŒãã²ãšã€ã®è¡ã§ç€ºãããŸãã
åããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããŸãã
</p>
<pre>
<var>board<sub>1</sub></var>
<var>board<sub>2</sub></var>
<var>board<sub>3</sub></var>
</pre>
<p>
<var>i</var> è¡ç®ã«ç€é¢ã® <var>i</var> è¡ç®ã®æ
å ±ãè¡šãæåå <var>board<sub>i</sub></var> ãäžããããŸãã
</p>
<p>
ããŒã¿ã»ããã®æ°ã¯ 50 ãè¶
ããŸããã
</p>
<H2>Output</H2>
<p>
ããŒã¿ã»ããæ¯ã«ããbãããwãããNAãã®ãããããïŒè¡ã«åºåããŸãã
</p>
<H2>Sample Input</H2>
<pre>
bbw
wbw
+b+
bwb
wbw
wbw
0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
b
NA
</pre>
| [
[
"bbw\nwbw\n+b+\nbwb\nwbw\nwbw\n0\n",
"bbw\nwbw\n+b+\nbwb\nwbw\nwbw\n0\n"
]
] |
p00184 | Tsuruga Castle |
<H1>鶎ã¶å</H1>
<p>
äŒæŽ¥è¥æŸåžã®ã·ã³ãã«ã§ãã鶎ã¶åã¯ãè²çæ°é·ãæ¬æ Œçãªå€©å®é£ãç¯åããã鶎ã¶åããšåä»ããŸããã倩å®é£ããã¯äŒæŽ¥çå°ãäžæã§ããŸãããŸããæŽããæ¥ã«ã¯ãçœèéã§æåãªé£¯çå±±ã®å±±é ãã鶎ã¶åãèŠãããšãã§ããŸãã
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tsuruga"><br/>
<br/>
</center>
<p>
äŒæŽ¥è¥æŸåžã®ä»åŸã®åºå ±æŽ»åã®åèã«ããããã鶎ã¶åã«èšªããæ¥å Žè
ã«ã€ããŠã幎代調æ»ãããããšã«ããŸãããæ¥å Žè
ã®å¹Žéœ¢ãå
¥åãšããäžèšã®å¹Žéœ¢åºåå¥ã«äººæ°ãåºåããããã°ã©ã ãäœæããŠãã ããã
</p>
<center>
<table>
<tr><th width="100"> åºå</th><th width="100"> 幎霢</th></tr>
<tr><td>10æ³æªæº</td><td> 0 ~ 9</td></tr>
<tr><td> 10代</td><td> 10 ~ 19</td></tr>
<tr><td> 20代</td><td> 20 ~ 29</td></tr>
<tr><td> 30代</td><td> 30 ~ 39</td></tr>
<tr><td> 40代 </td><td> 40 ~ 49</td></tr>
<tr><td> 50代</td><td> 50 ~ 59</td></tr>
<tr><td>60æ³ä»¥äž</td><td> 60 ~</td></tr>
</table>
</center>
<H2>Input</H2>
<p>
è€æ°ã®ããŒã¿ã»ããã®äžŠã³ãå
¥åãšããŠäžããããŸããå
¥åã®çµããã¯ãŒãã²ãšã€ã®è¡ã§ç€ºãããŸãã
åããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããŸãã
</p>
<pre>
<var>n</var>
<var>a<sub>1</sub></var>
<var>a<sub>2</sub></var>
:
<var>a<sub>n</sub></var>
</pre>
<p>
1 è¡ç®ã«æ¥å Žè
ã®äººæ° <var>n</var> (1 ≤ <var>n</var> ≤ 1000000)ãç¶ã <var>n</var> è¡ã« <var>i</var> 人ç®ã®æ¥å Žè
ã®å¹Žéœ¢ <var>a<sub>i</sub></var> ( 0 ≤ <var>a<sub>i</sub></var> ≤ 120 ) ãäžããããŸãã
</p>
<H2>Output</H2>
<p>
ããŒã¿ã»ããæ¯ã«ä»¥äžã®åœ¢åŒã§äººæ°ãåºåããŸãã<br/>
<br/>
1 è¡ç®: 10 æ³æªæºã®äººæ°<br/>
2 è¡ç®: 10 代ã®äººæ°<br/>
3 è¡ç®: 20 代ã®äººæ°<br/>
4 è¡ç®: 30 代ã®äººæ°<br/>
5 è¡ç®: 40 代ã®äººæ°<br/>
6 è¡ç®: 50 代ã®äººæ°<br/>
7 è¡ç®: 60 æ³ä»¥äžã®äººæ°<br/>
</pre>
<H2>Sample Input</H2>
<pre>
8
71
34
65
11
41
39
6
5
4
67
81
78
65
0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
2
1
0
2
1
0
2
0
0
0
0
0
0
4
</pre>
| [
[
"8\n71\n34\n65\n11\n41\n39\n6\n5\n4\n67\n81\n78\n65\n0\n",
"8\n71\n34\n65\n11\n41\n39\n6\n5\n4\n67\n81\n78\n65\n0\n"
]
] |
p00185 | Goldbach's Conjecture II |
<H1> ãŽãŒã«ããããäºæ³</H1>
<p>
ãŽãŒã«ããããäºæ³ãšã¯ã6 以äžã®ã©ããªå¶æ°ãã2 ã€ã®çŽ æ° (*1) ã®åãšããŠè¡šããããšãã§ããããšãããã®ã§ãã
</p>
<p>
ããšãã°ãå¶æ°ã® 12 㯠<var>12 = 5 + 7</var> ã18 㯠<var>18 = 5 + 13 = 7 + 11</var> ãªã©ãšè¡šãããšãã§ããŸãã
</p>
<p>
åã 134 ãšãªã 2 ã€ã®çŽ æ°ã®çµã¿åãããã¹ãŠæžãåºããšã以äžã®éããšãªããŸãã<br/>
<br/>
<var>134 = 3+131 = 7+127 = 31+103 = 37+97 = 61+73 = 67+67 </var><br/>
<var> = 131+3 = 127+7 = 103+31 = 97+37 = 73+61</var>
</p>
<p>
äžããããæ°ã倧ãããªããšããããã§ãçŽ æ°ã®çµã¿åããèŠã€ãããããªæ°ãããŸããããããçŸä»£æ°åŠããã£ãŠããŠããã®äºæ³ã蚌æããããšããåäŸãäœãããšãã§ããŸãã(*2)ãã¡ãã£ãšäžæè°ãªæããããŸããã
</p>
<p>
ããã§ããŽãŒã«ããããäºæ³ãéè³ããããã«ãå¶æ° <var>n</var> ãå
¥åãšããåã <var>n</var> ãšãªã 2 ã€ã®çŽ æ°ã®çµã¿åãã®æ°ãæ±ããããã°ã©ã ãäœæããŠãã ããã
</p>
<p>
åã <var>n</var> ãšãªãçŽ æ°ã®çµã¿åãã®æ°ãšã¯ <var>n = p + q</var> ã〠<var>p ≤ q</var> ã§ãããããªæ£ã®çŽ æ° <var>p</var>, <var>q</var> ã®çµã¿åãã®æ°ã§ããäžã®äŸãããããããã«åã 134 ãšãªãçŽ æ°ã®çµã¿åãã¯6 åã§ãã
</p>
<p>
(*1) çŽ æ°ãšã¯ã1 ãŸãã¯èªåèªèº«ä»¥å€ã«çŽæ°ãæããªãæŽæ°ã®ããšã§ããããªãã1 ã¯çŽ æ°ã§ã¯ãªãã<br/>
(*2) 2007 幎 2 æçŸåšã5×10<sup>17</sup> ãŸã§ã®å
šãŠã®å¶æ°ã«ã€ããŠæãç«ã€ããšã確ãããããŠããã(Wikipedia)
</p>
<H2>Input</H2>
<p>
è€æ°ã®ããŒã¿ã»ããã®äžŠã³ãå
¥åãšããŠäžããããŸããå
¥åã®çµããã¯ãŒãã²ãšã€ã®è¡ã§ç€ºãããŸãã åããŒã¿ã»ãããšããŠãïŒã€ã®å¶æ° <var>n</var> (6 ≤ <var>n</var> ≤ 1000000) ãïŒè¡ã«äžããããŸãã
</p>
<p>
ããŒã¿ã»ããã®æ°ã¯ 500 ãè¶
ããŸããã
</p>
<H2>Output</H2>
<p>
ããŒã¿ã»ããæ¯ã«çŽ æ°ã®çµã¿åãã®æ°ãïŒè¡ã«åºåããŸãã
</p>
<H2>Sample Input</H2>
<pre>
134
4330
34808
98792
0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
6
72
274
607
</pre>
| [
[
"134\n4330\n34808\n98792\n0\n",
"134\n4330\n34808\n98792\n0\n"
]
] |
p00186 | Aizu Chicken |
<H1>äŒæŽ¥å°é¶</H1>
<p>
2008 幎 4 æã«ãäŒæŽ¥è¥æŸåžã¯é·ã20 m 85 cm ã®ãããšãäœãã«ææŠããŠæåããŸããããã®ãšã䜿ãããé¶èããäŒæŽ¥ç¹ç£ã®äŒæŽ¥å°é¶ã§ããäŒæŽ¥å°é¶ã¯ãšãŠãããããã®ã§ããã飌è²ããããããã®ã§çç£éãå°ãªããå€æ®µãé«ãã®ãé£ç¹ã§ãã<!--çŸåšãçç£æ¡å€§ã®ããã®åªåãé²ããããŠããã®ã§ããã®ãã¡ã¿ãªããã®äœãçºã§ãç®ã«ããæ¥ãæ¥ããããããŸããã-->
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_chicken"><br/>
<br/>
</center>
<p>
ä»æ¥ã¯äžéåã®å®¶ã«ãé ããã芪æãéã³ã«æ¥ãŸãããæ¯ããã¯é¶èã®æ°Žçããäœã£ãŠèŠªæãããŠãªãããšã«ããŸãããè¿ãã®ãèå±ããã§ã¯äŒæŽ¥å°é¶ãšãµã€ãã®é¶èã® 2 çš®é¡ã®é¶èã売ã£ãŠããŸãããæ¯ããã¯ã以äžã®ãããªæ瀺ãäžéåã«äžããŠããèå±ããã«è¡ã£ãŠé¶èãè²·ã£ãŠããããã«
é Œã¿ãŸããã
</p>
<ul>
<li>é¶èã足ããªããªããšå°ãã®ã§ã決ããããé以äžã®é¶èãè²·ãã</li>
<li>äºç®ã®èš±ãç¯å²ã§äŒæŽ¥å°é¶ãã§ããã ãå€ãè²·ã(äŒæŽ¥å°é¶ã¯å¿
ãè²·ãããš)ã</li>
<li>äŒæŽ¥å°é¶ãè²·ã£ãæ®ãã§ãµã€ãã®é¶èãã§ããã ãå€ãè²·ã(äºç®ã足ããªããã°è²·ããªã)ã</li>
</ul>
<p>
äžéåããèå±ããã«è¡ããšãäŒæŽ¥å°é¶ãåèã®ããäžäººãè²·ããéãå¶éããŠããŸãããäžéåãããæ¯ããããäžãããããã¹ãŠã®æ瀺ãå®ã£ãŠè²·ãç©ããããšããäžéåãè²·ãäŒæŽ¥å°é¶ãšæ®éã®é¶èã®éã¯ããããäœã°ã©ã ã«ãªãã§ããã?
</p>
<p>
è²·ãã¹ãé¶èã®éã®äžé <var>q<sub>1</sub></var>ãäºç® <var>b</var>ããã®ãèå±ããã§ã®äŒæŽ¥å°é¶ 100 ã°ã©ã ã®å€æ®µ <var>c<sub>1</sub></var>ããµã€ãã®é¶è 100 ã°ã©ã ã®å€æ®µ <var>c<sub>2</sub></var>ãäŒæŽ¥å°é¶ãäžäººãè²·ããéã®äžé <var>q<sub>2</sub></var> ãå
¥åãšããäžéåãè²·ãäŒæŽ¥å°é¶ãšãµã€ãã®é¶èã®éã 100 ã°ã©ã åäœã§åºåããããã°ã©ã ãäœæããŠãã ããããã ãããã®ãèå±ããã§ã¯ãæ¯ããã®æ瀺éãã«è²·ããªãå Žåã«ã¯ããNAããšåºåããŠãã ããã
</p>
<H2>Input</H2>
<p>
è€æ°ã®ããŒã¿ã»ããã®äžŠã³ãå
¥åãšããŠäžããããŸããå
¥åã®çµããã¯ãŒãã²ãšã€ã®è¡ã§ç€ºãããŸãã åããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããŸãã
</p>
<pre>
<var>q<sub>1</sub></var> <var>b</var> <var>c<sub>1</sub></var> <var>c<sub>2</sub></var> <var>q<sub>2</sub></var>
</pre>
<p>
é¶èã®éãè¡šãããŒã¿ <var>q<sub>1</sub></var> ãš <var>q<sub>2</sub></var> ã¯100 ã°ã©ã åäœã§æå®ãããŸãããŸãã<var>b</var>ã<var>c<sub>1</sub></var>ã<var>c<sub>2</sub></var>ã<var>q<sub>1</sub></var>ã<var>q<sub>2</sub></var> 㯠1 ä»¥äž 1,000,000 以äžã®æŽæ°ãšããŸãã
</p>
<p>
ããŒã¿ã»ããã®æ°ã¯ 50 ãè¶
ããŸããã
</p>
<H2>Output</H2>
<p>
ããŒã¿ã»ããæ¯ã«ãäžéåã賌å
¥ããäŒæŽ¥å°é¶ã®éãšãµã€ãã®é¶èã®é(åè§ç©ºçœåºåã) ãŸãã¯ãNAããïŒè¡ã«åºåããŸãã
</p>
<H2>Sample Input</H2>
<pre>
48 9297 240 126 32
20 3010 157 141 7
30 117002 5680 962 15
8 1673 1712 190 22
64 8478 87 54 307
23 5477 117 92 12
50 7558 1396 187 17
279 88677 4522 514 14
0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
28 20
7 13
15 33
NA
97 0
12 44
NA
NA
</pre>
| [
[
"48 9297 240 126 32\n20 3010 157 141 7\n30 117002 5680 962 15\n8 1673 1712 190 22\n64 8478 87 54 307\n23 5477 117 92 12\n50 7558 1396 187 17\n279 88677 4522 514 14\n0\n",
"48 9297 240 126 32\n20 3010 157 141 7\n30 117002 5680 962 15\n8 1673 1712 190 22\n64 8478 87 54 307\n23 5477 117 92 12\n50 7558 1396 187 17\n279 88677 4522 514 14\n0\n"
]
] |
p00187 | Stoning Fortune |
<H1>æç³ãã¿ãã</H1>
<p>
ãèªåã®éã¯èªåã§åãéãããã¢ãããŒã«ãããç¥ç€Ÿãèªåèªèº«ã®æã§éå¢ã決ãããã¿ãããäœããŸããããã®ãã¿ãããåŒã人ã«ã¯ãŸã6ã€ã®ç³ãæããŠãããããã®æããç³ã®äžã€ç®ãšäºã€ç®ãçµã¶ ç·åãäžã€ç®ãšåã€ç®ãçµã¶ ç·åãäºã€ç®ãšå
ã€ç®ãçµã¶ ç·åã®3æ¬ã®ç·åã®äº€ç¹ãé ç¹ãšãã äžè§åœ¢ã®é¢ç©ããéå¢ã決ãããšãããã®ã§ããåéå¢ãšäžè§åœ¢ã®é¢ç©ãšã®é¢ä¿ã¯ä»¥äžã®ãšããã§ãã
</p>
<center>
<table>
<tr><th width="300">ç·åã®äº€ç¹ãé ç¹ãšããäžè§åœ¢ã®é¢ç©</th><th> éå¢</th></tr>
<tr><td> 1,900,000ä»¥äž </td><td>倧å (dai-kichi)</td></tr>
<tr><td> 1,000,000以äž1,900,000æªæº </td><td>äžå (chu-kichi)</td></tr>
<tr><td> 100,000以äž1,000,000æªæº </td><td> å (kichi)</td></tr>
<tr><td> 0ãã倧ãã 100,000æªæº </td><td> å°å (syo-kichi)</td></tr>
<tr><td> äžè§åœ¢ãªã </td><td> å¶ (kyo)</td></tr>
</table>
</center>
<br/>
<p>
ããããäžè§åœ¢ã®é¢ç©ã®å€§ããã®å€å®ã¯ç¥äž»ãããæèšç®ã§ãã£ãŠããã®ã§æ£ç¢ºãšã¯ããããæéãããã£ãŠããŸããŸããããã§è¿æã«äœãåªç§ãªããã°ã©ãã§ããããªãã¯ãäžå»ã§ãæ©ãããã°ã©ã ãæžããŠç¥äž»ãããå©ããŠãããããšã«ããŸããã
</p>
<p>
3 æ¬ã®ç·åã®æ
å ±ãå
¥åãšããç·åã®äº€ç¹ãé ç¹ãšãã äžè§åœ¢ã®é¢ç©ããéå¢ãåºåããããã°ã©ã ãäœæããŠãã ãããç·åã®æ
å ±ã¯å§ç¹ã®åº§æš (<var>x<sub>1</sub></var>, <var>y<sub>1</sub></var>) ãšãçµç¹ã®åº§æš (<var>x<sub>2</sub></var>, <var>y<sub>2</sub></var>) ãäžããããå§ç¹ãšçµç¹ã®åº§æšã¯å¿
ãç°ãªãããšãšããŸãããŸãã2 ã€ä»¥äžã®ç·åãåäžçŽç·äžã«ããå Žåã亀ç¹ãæããªã 2 ã€ã®ç·åãããå Žåã3 ã€ã®ç·åã 1 ç¹ã§äº€ããå Žåã¯ããäžè§åœ¢ãªãããšãªããŸãã
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_stoning">
</center>
<br/><br/>
<H2>Input</H2>
<p>
è€æ°ã®ããŒã¿ã»ããã®äžŠã³ãå
¥åãšããŠäžããããŸããå
¥åã®çµããã¯ãŒã4ã€ã®è¡ã§ç€ºãããŸãã
åããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããŸãã
</p>
<pre>
<var>line<sub>1</sub></var>
<var>line<sub>2</sub></var>
<var>line<sub>3</sub></var>
</pre>
<p>
<var>i</var> è¡ç®ã« <var>i</var> çªç®ã®ç·åã®æ
å ±ãäžããããŸããåç·åã®æ
å ±ã¯ä»¥äžã®åœ¢åŒã§äžããããŸãã
</p>
<pre>
<var>x<sub>1</sub></var> <var>y<sub>1</sub></var> <var>x<sub>2</sub></var> <var>y<sub>2</sub></var>
</pre>
<p>
ç·åã®ç«¯ç¹ã®åº§æšãè¡šãæŽæ° (<var>x<sub>1</sub></var>, <var>y<sub>1</sub></var>), (<var>x<sub>2</sub></var>, <var>y<sub>2</sub></var>) (-1000 ≤ <var>x<sub>1</sub></var>, <var>y<sub>1</sub></var>, <var>x<sub>2</sub></var>, <var>y<sub>2</sub></var> ≤ 1000 ) ã空çœåºåãã§äžããããŸãã
</p>
<H2>Output</H2>
<p>
ããŒã¿ã»ããæ¯ã«ããã¿ããã®çµæãïŒè¡ã«åºåããŸãã
</p>
<H2>Sample Input</H2>
<pre>
-3 -2 9 6
3 -2 7 6
-1 0 5 0
2 2 -1 -1
0 1 2 1
-3 -1 3 1
0 0 0 0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
syo-kichi
kyo
</pre>
| [
[
"-3 -2 9 6\n3 -2 7 6\n-1 0 5 0\n2 2 -1 -1\n0 1 2 1\n-3 -1 3 1\n0 0 0 0\n",
"-3 -2 9 6\n3 -2 7 6\n-1 0 5 0\n2 2 -1 -1\n0 1 2 1\n-3 -1 3 1\n0 0 0 0\n"
]
] |
p00188 | Search |
<H1>æ¢çŽ¢</H1>
<p>
ãæ¢çŽ¢ããšã¯ãããããã®æ
å ±ã®äžããæã¿ã®æ
å ±ãåŸãæäœã®ããšã§ãã身è¿ãªäŸã§ã¯ãåæ Œçºè¡šã®æã®ãããããã®åéšçªå·ããèªåã®åéšçªå·ãèŠã€ãããããšããé»è©±åž³ãããäŒæŽ¥å€ªéããã®é»è©±çªå·ãèŠã€ããããšããªã©ããããŸãããã®æ¢çŽ¢ãšããæäœã¯ã³ã³ãã¥ãŒã¿ã®åéã§ãåºãçšããããŠããŸãã
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_search">
</center>
<br/>
<p>
æ¢çŽ¢ã®æ¹æ³ã¯æ²¢å±±ãããŸããæ¢çŽ¢ã®å¯Ÿè±¡ãšãªãããŒã¿ããå°ããé (ãŸãã¯å€§ããé )ã«äžŠã¹ãããŠããå Žåã«äœ¿ãããšãã§ããæ¢çŽ¢ã®æ¹æ³ãèããŸãã
</p>
<p>
å°ããé (ãŸãã¯å€§ããé )ã«äžŠã¹ãããŠããããŒã¿åã®äžå€®ã«äœçœ®ããå€ãšç®çã®å€ãšã®å€§å°é¢ä¿ãçšããŠãäžå€®ã«äœçœ®ããå€ããååéšåãæ¢çŽ¢ç¯å²ã«ãããåŸåéšåãæ¢çŽ¢ç¯å²ã«ãããã決ããããšã§ãæ¢çŽ¢ã®ç¯å²ãçµã£ãŠããæ¹æ³ããããŸããæé ã¯ä»¥äžã®ããã«ãªããŸãã
</p>
<ol>
<li>ããŒã¿ã®åã®å
šäœãæ¢çŽ¢ã®ç¯å²ãšããŸãã</li>
<li>æ¢çŽ¢ã®ç¯å²ã®äžå€®ã«äœçœ®ããå€ã調ã¹ãŸãã</li>
<li>ç®çã®å€ãšäžå€®ã«äœçœ®ããå€ãäžèŽããã°æ¢çŽ¢ãçµäºããŸãã</li>
<li>ç®çã®å€ãšäžå€®ã«äœçœ®ããå€ãããå°ãããã°ååéšåãæ¢çŽ¢ã®ç¯å²ãšãã倧ãããã°åŸåéšåãæ¢çŽ¢ã®ç¯å²ãšããŠ2.ãžæ»ããŸãã</li>
</ol>
<p>
以äžã¯äžè¿°ããæ¢çŽ¢ã®æ¹æ³ã®äŸã§ãããã®äŸã§ã®ç®çã®å€ã¯51ã§ããããããã®ããŒã¿ã«ã¯çªå·
(index)ãæ¯ãããŠããããã®çªå·ã¯0ããå§ãŸã£ãŠããŸãã
</p>
<center>
<table>
<tr>
<td valign="top" style="vertical-align:top">
<br/><br/><br/>
<p>
ã¹ããã1: æåã¯çªå·0~6å
šäœãæ¢çŽ¢ã®ç¯å²ãšããŸãã
</p>
<p>
ã¹ããã2: æ¢çŽ¢ã®ç¯å²ã®äžå€®ã«äœçœ®ããå€ã調ã¹ãŸãããã ãããäžå€®ã«äœçœ®ããå€ããšã¯ã(å·ŠåŽã®çªå·+å³åŽã®çªå·)ã2ã§å²ã£ãçªå·ã®äœçœ®ã«ããå€ãšããŸããã€ãŸãããã®å Žåã(0 + 6) ÷ 2 ãèšç®ããçªå·3ã«ããå€(36)ãäžå€®ã«äœçœ®ããå€ãšãªããŸãã
</p>
<p>
ã¹ããã3:ç®çã®å€(51)ãšäžå€®ã«äœçœ®ããå€(36)ãæ¯èŒããŸãã
</p>
<p>
ã¹ããã4:ã¹ããã3ã®çµæãããç®çã®å€ã¯äžå€®ã«äœçœ®ããå€ãã倧ããã®ã§ãåŸåéšåã«ãããçªå·4 (äžå€®ã«äœçœ®ããå€ã®é£)以éãæ¢çŽ¢ã®ç¯å²ãšããŸããåæ§ã®æé ã§æ¢çŽ¢ã®ç¯å²ã®äžå€®ã«äœçœ®ããå€ã調ã¹ãç®çã®å€ãäžå€®ã«äœçœ®ããå€ããå°ãããã°ååéšåãæ¢çŽ¢ã®ç¯å²ãšãã倧ãããã°åŸåéšåãæ¢çŽ¢ã®ç¯å²ãšããŠãæ¢çŽ¢ã®ç¯å²ãå°ããããŠãããŸãã(ã¹ããã2~ã¹ããã4ã®ç¹°ãè¿ã)ç®çã®å€ãäžå€®ã«äœçœ®ããå€ãšäžèŽããããæ¢çŽ¢ã®ç¯å²ãã€ããŠããŸã£ãæã«æ¢çŽ¢ãçµäºããŸãã
</p>
</td>
<td>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_searchFlow">
</td>
</tr>
</table>
</center>
<br/>
<p>
<var>n</var> åã®æ°å€ã®é
åãå
¥åãšããç®çã®å€ãšäžå€®ã«äœçœ®ããå€ãæ¯èŒããåæ°ãåºåããããã°ã©ã ãäœæããŠãã ããããã ããäžå€®ã«äœçœ®ããå€ã®çªå·ãèšç®ãããšããå²ãåããªãå Žåã¯ãå°æ°ç¹ä»¥äžãåãæšãŠãå€ããã®çªå·ãšããããšãšããŸãã
äžããããããŒã¿åã¯å°ããé ã«æŽåãããŠãããã®ãšããŸãã
</p>
<H2>Input</H2>
<p>
è€æ°ã®ããŒã¿ã»ããã®äžŠã³ãå
¥åãšããŠäžããããŸããå
¥åã®çµããã¯ãŒãã²ãšã€ã®è¡ã§ç€ºãããŸãã åããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããŸãã
</p>
<pre>
<var>n</var>
<var>a<sub>1</sub></var>
<var>a<sub>2</sub></var>
:
<var>a<sub>n</sub></var>
<var>k</var>
</pre>
<p>
1 è¡ç®ã«æ°å€ã®æ° <var>n</var> (1 ≤ <var>n</var> ≤ 100) ãç¶ã <var>n</var> è¡ã« <var>i</var> åç®ã®æ°å€ <var>a<sub>i</sub></var> (1 ≤ <var>a<sub>i</sub></var> ≤ 100000, æŽæ°) ãäžããããŸãã
</p>
<p>
ç¶ãè¡ã«æ¢çŽ¢ããå€ <var>k</var> (1 ≤ <var>k</var> ≤ 100000) ãäžããããŸãã
</pre>
<H2>Output</H2>
<p>
ããŒã¿ã»ããæ¯ã«æ¢çŽ¢ãçµãããŸã§ã®æ¯èŒåæ°ãïŒè¡ã«åºåããŸãã
</p>
<H2>Sample Input</H2>
<pre>
7
11
15
23
36
51
61
86
51
4
1
2
3
5
4
0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
3
3
</pre>
| [
[
"7\n11\n15\n23\n36\n51\n61\n86\n51\n4\n1\n2\n3\n5\n4\n0\n",
"7\n11\n15\n23\n36\n51\n61\n86\n51\n4\n1\n2\n3\n5\n4\n0\n"
]
] |
p00189 | Convenient Location |
<H1>䟿å©ãªçº</H1>
<p>
æ¥æ¥åæ¥ããAããã¯ãå°±è·ãæ©ã«åŒè¶ããããããšã«ããŸãããå°±è·ããäŒç€Ÿã¯ããªãã£ã¹ãããã€ãã®çºã«ãã£ãŠãæ¥ã«ãã£ãŠåºå€ãããªãã£ã¹ãéããŸããããã§Aããã¯,ã©ãã®ãªãã£ã¹ã«
è¡ãã«ãæéã®çãçºã«äœãããšèããŸããã
</p>
<p>
ããã§ããªãã¯ãAãããå©ãããããäœãã®ã«äžçªäŸ¿å©ãªçºãæ¢ãããšã«ãªããŸããã
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_location">
</center>
<br/>
<p>
çºã«ã¯ 0 ããå§ãŸãçªå·ãæ¯ãããŠãããçºãšçºã®éã«ã¯éããããŸããããããã®éã«å¯ŸããŠéå€æéã決ãŸã£ãŠããŸããAãããããçºã«äœãã§ããå Žåã«ãèªåã®çºã®ãªãã£ã¹ãŸã§ã®éå€æé㯠0 ãšããŸãããã®ãšãã«å
šãŠã®çºãŸã§ã®éå€æéã®ç·åãèããŸããäŸãã°ãçºãšéã®é
眮ãäžã®å³ã®ããã«ãªã£ãŠããŠãAãããçº1ã«äœãã å Žåã«ã¯ãããããã®çºãŸã§ã®éå€æéã¯
<br/>
<br/>
çº 0 ãŸã§ 80<br/>
çº 1 ãŸã§ 0<br/>
çº 2 ãŸã§ 20<br/>
çº 3 ãŸã§ 70<br/>
çº 4 ãŸã§ 90<br/>
<br/>
ãšãªããç·å㯠260 ãšãªããŸãã
</p>
<p>
éã®æ°ãšãå
šãŠã®éã®æ
å ±ãå
¥åãšããããããã®çºã«äœãã å Žåã®éå€æéã®ç·åãèšç®ãããããæå°ãšãªãçºã®çªå·ãšããã®ãšãã®éå€æéã®ç·åãåºåããããã°ã©ã ãäœæããŠãã ããããã ããéå€æéã®ç·åãæå°ãšãªãçºãè€æ°ããå Žåã¯ãäžçªå°ããçºã®çªå·åã³ãã®æã®éå€æéã®ç·åãåºåããŠãã ãããçºã®ç·æ°ã¯ 10 以äžãéã®ç·æ°ã¯ 45 以äžãšããå
šãŠã®éã¯åæ¹åã«ç§»åã§ããéå€æéã¯æ¹åã«ãã£ãŠå€ãããªããã®ãšããŸãããŸããã©ã®çºããã§ããã®ä»å
šãŠã®çºãžã® çµè·¯ããããã®ãšããŸãã
</p>
<H2>Input</H2>
<p>
è€æ°ã®ããŒã¿ã»ããã®äžŠã³ãå
¥åãšããŠäžããããŸããå
¥åã®çµããã¯ãŒãã²ãšã€ã®è¡ã§ç€ºãããŸãã åããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããŸãã
</p>
<pre>
<var>n</var>
<var>a<sub>1</sub></var> <var>b<sub>1</sub></var> <var>c<sub>1</sub></var>
<var>a<sub>2</sub></var> <var>b<sub>2</sub></var> <var>c<sub>2</sub></var>
:
<var>a<sub>n</sub></var> <var>b<sub>n</sub></var> <var>c<sub>n</sub></var>
</pre>
<p>
ïŒè¡ç®ã«éã®æ° <var>n</var> (1 ≤ <var>n</var> ≤ 45) ãäžããããŸããç¶ã <var>n</var> è¡ã« <var>i</var> çªç®ã®éã®æ
å ±ãäžããããŸãã
<var>a<sub>i</sub></var>, <var>b<sub>i</sub></var> (0 ≤ <var>a<sub>i</sub></var>, <var>b<sub>i</sub></var> ≤ 9) 㯠<var>i</var> çªç®ã®éãã€ãªãã§ããçºã®çªå·ã<var>c<sub>i</sub></var> (0 ≤ <var>c<sub>i</sub></var> ≤ 100) ã¯ãã®éã®éå€æéãè¡šããŸãã
</p>
<H2>Output</H2>
<p>
ããŒã¿ã»ããæ¯ã«ãéå€æéã®ç·åãæå°ã«ãªãçºã®çªå·åã³ãã®æã®éå€æéã®ç·åã空çœåºåãã§ïŒè¡ã«åºåããŸãã
</p>
<H2>Sample Input</H2>
<pre>
6
0 1 80
1 2 20
0 2 60
2 3 50
3 4 60
1 4 90
2
0 1 1
1 2 1
0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
2 240
1 2
</pre>
| [
[
"6\n0 1 80\n1 2 20\n0 2 60\n2 3 50\n3 4 60\n1 4 90\n2\n0 1 1\n1 2 1\n0\n",
"6\n0 1 80\n1 2 20\n0 2 60\n2 3 50\n3 4 60\n1 4 90\n2\n0 1 1\n1 2 1\n0\n"
]
] |
p00190 | Eleven Puzzle |
<H1>11 ããºã«</H1>
<p>
倪éå㯠8 ããºã«ã倧åŸæã§äŒã¿æéãªã©ã«ãã€ãåéã«äžŠã³æ¿ããŠããã£ãŠéãã§ããŸãããããªãšããåéããããã£ãšè€éãªããºã«ã¯è§£ãã?ããšèãããã®ã§ãããä»ã®ããºã«ã¯ãã£ãããšã¯ãããŸãããã©ããããã®åéã¯èªäœã§ 11 ããºã«ãäœã£ãŠããã¿ããã§ãããã®ããºã«ã¯ä»¥äžã®ãããªåœ¢ãããŠããŸãã
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_elevenPuzzle">
</center>
<br/>
<p>
11 ããºã«ã¯ 11 æã®æ£æ¹åœ¢ã®ã«ãŒããšãå³ 1 ã®ãããªåœ¢ã®æ ã䜿ã£ãŠè¡ããŸããæåã« 11 æã®ã«ãŒããæ ã«å
¥ããŸãããããš 2 ã«æã®ç©ºãã¹ããŒã¹ãã§ããŸãã®ã§ããã®ç©ºãã¹ããŒã¹ã«é£æ¥ããã«ãŒããåããããšãã§ããŸãããããç¹°ãè¿ããã«ãŒãããããã«æŽåããŠãå³ 2 ã®å®æåã«ããããšã 11 ããºã«ã®ç®çã§ãã
</p>
<p>
倪éåã¯ãã®ããºã«ã«ææŠããããšã«ããŸããããšããã倪éåã¯ãã® 11 ããºã«ãããšãç°¡åã«è§£ããŠããŸããŸãããããã§åéã¯ãåããæ°ãäžçªå°ãªãããŠè§£ããŠã!ããšç¡è¶ãªããšãèšã£ãŠããŸããã倪éåã¯çããããããªãã®ã§ãããã°ã©ã ã®ã§ããããªãã« 11 ããºã«ã解ããšãã®æå°ã¹ãããæ°ãåºãããã°ã©ã ãäœæããŠããã£ãŠããææŠããããšã«ããŸããããã®ãšãã2 ã«æåããããšãããããã®ã§ãããäžã€ã®æ°åã 1 ã¹ããŒã¹å移åãããããšã1ã¹ããããšããŠèããããšãšããŸãã
</p>
<p>
11 ããºã«ã®åæç¶æ
ãå
¥åãšãã11 ããºã«ã解ããšãã®æå°ã¹ãããæ°ãåºåããããã°ã©ã ãäœæããŠãã ããããã ããããºã«ã解ããšãã®æå°ã¹ãããæ°ã 20 ã¹ãããããå€ãããã£ãŠããŸãå Žåã¯ããNAããšåºåããŠãã ãããããºã«ã®ç¶æ
ã¯ãäžè¡ç®ã®æ
å ±ããé ã«å
¥åããããã®ãšããæ°åã® 0 ã¯ç©ºãã¹ããŒã¹ãè¡šããŸããäŸãã°ãå³ 1 ã®ç¶æ
ãè¡šãå
¥åã¯ä»¥äžã®ããã«ãªããŸãã
</p>
<pre>
6
2 1 3
10 5 7 0 8
9 4 11
0
</pre>
<H2>Input</H2>
<p>
è€æ°ã®ããŒã¿ã»ããã®äžŠã³ãå
¥åãšããŠäžããããŸããå
¥åã®çµããã¯-1ã²ãšã€ã®è¡ã§ç€ºãããŸãã åããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããŸãã
</p>
<pre>
<var>p<sub>1</sub></var>
<var>p<sub>2</sub></var> <var>p<sub>3</sub></var> <var>p<sub>4</sub></var>
<var>p<sub>5</sub></var> <var>p<sub>6</sub></var> <var>p<sub>7</sub></var> <var>p<sub>8</sub></var> <var>p<sub>9</sub></var>
<var>p<sub>10</sub></var> <var>p<sub>11</sub></var> <var>p<sub>12</sub></var>
<var>p<sub>13</sub></var>
</pre>
<p>
<var>i</var> è¡ç®ã«ããºã«ã® <var>i</var> è¡ç®ã®æ
å ± <var>p<sub>i</sub></var> (0 ≤ <var>p<sub>i</sub></var> ≤ 11) ã空çœåºåãã§äžããããŸãã
</p>
<p>
ããŒã¿ã»ããã®æ°ã¯ 100 ãè¶
ããŸããã
</p>
<H2>Output</H2>
<p>
ããŒã¿ã»ããæ¯ã«ãæå°ã¹ãããæ°ãŸã㯠NA ãïŒè¡ã«åºåããŸãã
</p>
<H2>Sample Input</H2>
<pre>
2
1 0 3
4 5 6 7 8
9 0 11
10
0
1 2 3
4 5 6 7 8
9 10 11
0
0
11 10 9
8 7 6 5 4
3 2 1
0
-1
</pre>
<H2>Output for the Sample Input</H2>
<pre>
2
0
NA
</pre>
| [
[
"2\n1 0 3\n4 5 6 7 8\n9 0 11\n10\n0\n1 2 3\n4 5 6 7 8\n9 10 11\n0\n0\n11 10 9\n8 7 6 5 4\n3 2 1\n0\n-1\n",
"2\n1 0 3\n4 5 6 7 8\n9 0 11\n10\n0\n1 2 3\n4 5 6 7 8\n9 10 11\n0\n0\n11 10 9\n8 7 6 5 4\n3 2 1\n0\n-1\n"
]
] |
p00191 | Baby Tree |
<H1>èæš</H1>
<p>
æ€ç©åŠè
ã®ãµããŒå士ã¯èæšçšã®ç¹æ®è¥æãäœçš®é¡ãçºæããŸããããã®è¥æãèæšã«äžãããšãç¬ãéã«èæšã®å€§ãããå€ãããŸãã
äœããè¥æã«ä»¥äžã®ããã«å¯äœçšãããããšãå€æããŸããã
</p>
<ul>
<li>1 åç®ã«äžããè¥æã ãã§ã¯ãèæšã®å€§ãããå€ãããŸããã</li>
<li>2 åç®ä»¥éã¯ããã®åã«äžããè¥æãšããã®çŽåã«äžããè¥æãšã®çµã¿åããã«ãã£ãŠèæšã«åœ±é¿ãäžããŸããè¯ã圱é¿ãäžãããšèæšã䌞ã³ãæªã圱é¿ãäžãããšèæšãçž®ãã§ããŸãããšããããŸãã</li>
</ul>
<p>
è©Šãã«ããµããŒå士㯠3 çš®é¡ã®è¥æ (è¥æ 1ã2ã3) ã«å¯Ÿããããæç¹ã§äžããè¥æ (ä»åã®è¥æ) ãšãã®çŽåã«äžããè¥æ (çŽåã®è¥æ) ã®çµã¿åããã«ããèæšã®æé·åºŠåãã調ã¹ã以äžã®ãæé·åºŠè¡šããäœæããŸããã
</p>
<table>
<tr>
<td style="vertical-align:top">
<p>
å³è¡šã® 1 è¡ç®ã¯ä»åäžããè¥æã®çªå·ã§ã1 åç®ã¯ãã®çŽåã«äžããè¥æã®çªå·ã§ããä»ã®æ°åã¯çŽåã«äžããè¥æãšä»åäžããè¥æã®çµã¿åããã«ããèæšã®æé·åºŠ (æé·åŸå¯Ÿæé·åã®å€§ããã®æ¯ç) ã瀺ããŸããæé·åºŠ > 1.0 ã®å Žåã¯èæšã䌞ã³ããæé·åºŠ < 1.0 ã®å Žåã¯èæšãçž®ãããšã瀺ããŸããäŸãã°è¥æ 1 ã®åŸã«è¥æ 2 ãäžãããšèæšã®å€§ããã 3 åã«ãªãããè¥æ 1 ã®åŸã«è¥æ 3 ãäžãããšèæšã®å€§ãããååã«çž®ãã§ããŸããŸãã
</p>
</td>
<td>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_babyTree1">
</td>
</tr>
</table>
<br/>
<p>
èæšã«äžããè¥æã®åæ°ãå¶éãããå Žåãèæšãã§ããã ã倧ããè²ãŠãã«ã¯ã©ã®è¥æãã©ã®ãããªé ã§äžããã°ããã§ãããã?ãæé·åºŠè¡šãããã®çãæããŠãããŸããäŸãšããŠäžã®è¡šã«ããè¥æã 3 åã ãäžããå Žåã以äžã®ããã«è¥æ 3 â è¥æ 1 â è¥æ 2 ã®é ã«ããããšæãèæšãæé·ããŸãã
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_babyTree2">
</center>
<br/>
<ul>
<li> 1 åç®ã®è¥æ (è¥æ 3) ã§ã¯èæšã®å€§ããã¯å€ãããŸããã</li>
<li> 2 åç®ã®è¥æ (è¥æ 1) ã§ã¯ãè¡šããè¥æ 3 åŸã®è¥æ 1 ã§ã®æé·åºŠã 3.0 ãªã®ã§ãèæšã®å€§ããã¯ååã® 3.0 åã«ãªããŸãã</li>
<li> 3 åç®ã®è¥æ (è¥æ 2) ã§ã¯ãè¡šããè¥æ 1 åŸã®è¥æ 2 ã§ã®æé·åºŠã 3.0 ãªã®ã§ãèæšã®å€§ããã¯ããã«ååã® 3.0 åã§ãæåã® 3.0 × 3.0 ã® 9.0 åã«ãªããŸãã</li>
</ul>
<p>
ä»åºŠã¯ããµããŒå士ã¯çºæãã <var>n</var> çš®é¡ã®è¥æãå
šéšèª¿ã¹ãŠãäžã®ãããªãæé·åºŠè¡šããäœããããŸããããéåžžã«å€§ããªè¡šã«ãªã£ãŠããŸããè¥æã®çš®é¡ãšäžããé çªã決ããã®ã«å€§å€èŠåŽããŠããŸãã
</p>
<p>
ããã§å士ã«ä»£ããã<var>n</var> çš®é¡ã®è¥æã®çµã¿åããã«ããèæšã®ãæé·åºŠè¡šãäžã®æé·åºŠå€éšåãå
¥åãšããè¥æã <var>m</var> åäžããåŸã®æ倧ã®èæšã®å€§ãããæ±ããããã°ã©ã ãäœæããŠãã ããããã ããåãã®èæšã®å€§ããã 1 ãšãã1 åç®ã«äžããè¥æã®æé·åºŠã¯ã©ã®è¥æã§ã 1.0 ãšããŸãããªããè¥æ㯠1 ãã <var>n</var> ãŸã§çªå·ä»ããããŠããŸãã
<!--åºåããèæšã®å€§ããã¯ãå°æ°ç¹ç¬¬ 3 äœãåæšäºå
¥ããŠãå°æ°ç¹ç¬¬ 2 äœãŸã§æ±ããŠãã ããã-->
</p>
<H2>Input</H2>
<p>
è€æ°ã®ããŒã¿ã»ããã®äžŠã³ãå
¥åãšããŠäžããããŸããå
¥åã®çµããã¯ãŒããµãã€ã®è¡ã§ç€ºãããŸãã åããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããŸãã
</p>
<pre>
<var>n</var> <var>m</var>
<var>g<sub>11</sub></var> <var>g<sub>12</sub></var> ... <var>g<sub>1n</sub></var>
<var>g<sub>21</sub></var> <var>g<sub>22</sub></var> ... <var>g<sub>2n</sub></var>
:
<var>g<sub>n1</sub></var> <var>g<sub>n2</sub></var> ... <var>g<sub>nn</sub></var>
</pre>
<p>
1 è¡ç®ã«è¥æã®çš®é¡æ° <var>n</var> (2 ≤ <var>n</var> ≤ 100)ã è¥æãäžããåæ° <var>m</var> (1 ≤ <var>m</var> ≤ 100) ãäžããããŸãã
</p>
<p>
ç¶ã<var>n</var> è¡ã«ãè¥æ <var>i</var> ã®åŸã«è¥æ <var>j</var> ãäžããæã®èæšã®æé·åºŠ <var>g<sub>ij</sub></var> (0.0 ≤ <var>g<sub>ij</sub></var> ≤ 10.0, å®æ°) ãäžããããŸãã
</p>
<p>
ããŒã¿ã»ããã®æ°ã¯ 20 ãè¶
ããŸããã
</p>
<H2>Output</H2>
<p>
ããŒã¿ã»ããæ¯ã«ãæ倧ã®èæšã®å€§ãããïŒè¡ã«åºåããŸããåºåããèæšã®å€§ããã¯ãå°æ°ç¹ç¬¬ 3 äœãåæšäºå
¥ããŠãå°æ°ç¹ç¬¬ 2 äœãŸã§æ±ããŠãã ããã
</p>
<H2>Sample Input</H2>
<pre>
3 3
1.3 3.0 0.5
2.4 2.1 1.0
3.0 0.8 1.2
2 2
1.0 1.0
1.0 1.0
0 0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
9.00
1.00
</pre>
| [
[
"3 3\n1.3 3.0 0.5\n2.4 2.1 1.0\n3.0 0.8 1.2\n2 2\n1.0 1.0\n1.0 1.0\n0 0\n",
"3 3\n1.3 3.0 0.5\n2.4 2.1 1.0\n3.0 0.8 1.2\n2 2\n1.0 1.0\n1.0 1.0\n0 0\n"
]
] |
p00192 | Multistory Parking Lot |
<H1>ç«äœé§è»å Ž</H1>
<table>
<tr>
<td style="vertical-align:top">
<p>
è¡äžã«ã¯é§è»å Žã®å©çšå¹çãäžãããããç«äœåŒãã¿ã¯ãŒåŒãªã©ã®æ§ã
ãªé§è»å ŽããããŸãããã®äžã«ã¯ãã²ãšã€ã®é§è»ã¹ããŒã¹ã«å³ã®ãããªã2段åŒé§è»è£
眮ããèšçœ®ãã2å°åã®é§è»ã¹ããŒã¹ã確ä¿ããŠããé§è»å ŽããããŸãããã®2段åŒé§è»è£
眮ã¯1å°ãæéåŒã®ãã¬ãã(è»ãä¹ããå¹³ããªéæ¿)ã«ä¹ããŠäžæ®µã«é§è»ããããã1å°ãäžæ®µã«é§è»ããããšãã§ããŸãã
</p>
<p>
ãã®ãããª2段åŒé§è»è£
眮ãçšããŠããé§è»å Žã§ã¯ãäžæ®µã®è»ãåºãå
¥ãããã®ã«ããã®éœåºŠãäžæ®µã«é§è»ãããŠããè»ãåºããŠãéããå¿
èŠãããã®ã§ãå¿
ã管ç人ãããé§è»ããŠããè»ã®ã«ã®ãé ãã£ãŠãå¿
èŠã«å¿ããŠè»ã®åºãå
¥ããè¡ããŸãã
</p>
</td>
<td>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tsurugaParking1">
</td>
</tr>
</table>
<p>
鶎ã¶é§è»å Žããã®ãããª2段åŒé§è»è£
眮ãèšçœ®ããŠããé§è»å Žã®ã²ãšã€ã§ããã人æäžè¶³ã®ãããè»ã®é転ãã§ããªã人ã管ç人ã«ãªã£ãŠããŸããŸããããã®ãããäžåºŠé§è»ããè»ã¯ã客ãããæ»ããŸã§åããããšãã§ãããäžæ®µã«ãªã£ãè»ã¯äžæ®µã®è»ã®æã¡äž»ãæ»ã£ãŠããã§ãªããšè»ãåºãããšãã§ããªãç¶æ
ã«ãªã£ãŠããŸããŸããã
</p>
<p>
次ãã次ãžãšé§è»ãã«æ¥ãè»ãæéãããã°ããªããã°ãªããªã管ç人ãããæäŒãããã鶎ã¶é§è»å Žã®ã«ãŒã«ãæºããããã°ã©ã ãäœæããŠãã ããã
</p>
<p><b>鶎ã¶é§è»å Žã®èšå</b></p>
<ul>
<li> é§è»ã¹ããŒã¹ã¯1ã€ä»¥äžãããå
šãŠ2段åŒé§è»è£
眮ãèšçœ®ãããŠããŸãã</li>
<li> åé§è»ã¹ããŒã¹ã«ã¯1ããé ã«çªå·ãå²ãæ¯ãããŠããŸãã</li>
<li> åãã¯é§è»å Žã«1å°ãé§è»ããŠããªããã®ãšããŸãã</li>
</ul>
<p>鶎ã¶é§è»å Žã¯ä»¥äžã®ãããªã«ãŒã«ãæ¡çšããŠããŸãã</p>
<p><b>è»ãæ¢ããæ</b></p>
<ul>
<li>é§è»ããè»ã®é§è»æéã管ç人ã«ç¥ããããŸãã</li>
<li>1å°ãé§è»ãããŠããªãé§è»ã¹ããŒã¹ããå
ã«é§è»ããŠãããŸãã</li>
<li>1å°ãé§è»ãããŠããªãé§è»ã¹ããŒã¹ããªãå Žåã«ã¯ã空ããŠããé§è»ã¹ããŒã¹ã«é§è»ããŸãã
ãã ãããã®ãããªé§è»ã¹ããŒã¹ãè€æ°ãããšãã¯ä»¥äžã®æé ã§é§è»ããŸãã</li>
<ol>
<li> é§è»ããŠããè»ã®æ®ãé§è»æéãé§è»ããããšããŠããè»ã®é§è»æé以äžã®ãã®ãããå Žåããã®å·®ãäžçªå°ããé§è»ã¹ããŒã¹ã«é§è»ããŸãã</li>
<li> é§è»ããŠããã©ã®è»ã®æ®ãé§è»æéãé§è»ããããšããŠããè»ã®é§è»æéæªæºã§ããå Žåããã®å·®ãäžçªå°ããé§è»ã¹ããŒã¹ã«é§è»ããŸãã</li>
</ol>
<li>æºè»(空ããŠããé§è»ã¹ããŒã¹ããªã)ã®å Žåãé§è»ããããšããè»ã¯é§è»ã¹ããŒã¹ã空ããŸã§é çªã«åŸ
ã¡ãŸãã空ãããšåæã«ãæåã«åŸ
ã£ãŠããè»ããé ã«é§è»ããŸãã
</li>
</ul>
<p>
â»åæ¡ä»¶ã«ãããŠã該åœããé§è»ã¹ããŒã¹ãè€æ°ããå Žåã¯é§è»ã¹ããŒã¹çªå·ã®æãå°ãããšããã«é§è»ããããšãšããŸãããŸããåæå»ã«åºåº«ããè»ãããå Žåã¯ãåºåº«ããè»ããã¹ãŠåºãŠããé§è»ãå§ããåŸ
ã£ãŠããè»ãããéããé§è»ã§ããã ãã®è»ãåæå»ã«é§è»ããããšãšããŸãã
</p>
<p><b>è»ãåºãæ</b></p>
<ul>
<li>管ç人ã«ç¥ããããé§è»æéãéããè»ã¯åºåº«ããŸãã</li>
<li>è€æ°ã®é§è»ã¹ããŒã¹ã§åæã«é§è»æéãéããè»ããã£ãå Žåãé§è»ã¹ããŒã¹çªå·ã®å°ããè»ããå
ã«åºåº«ããŸãã</li>
<li>äžæ®µã«é§è»ããè»ã®é§è»æéãéããå Žåãäžæ®µã®è»ãåºåº«ãããŸã§åŸ
ããªããã°ãªããŸãããäžæ®µã®è»ã¯äžæ®µã®è»ãåºåº«ããåŸãåæå»ã«åºåº«ããŸãã</li>
</ul>
<p>
äžå³ã§é¶Žã¶é§è»å Žã®é§è»æ¹æ³ã®äŸã瀺ããŸãããã®äŸã§ã¯ãé§è»ã¹ããŒã¹ã®æ°ã¯3ã§ãè» B ~è» Eããã§ã«é§è»ããŠãããšããŸããããã«é§è»æé70åã®è» A ãæ¥ãããšãèããŸããé§è»ã¹ããŒã¹3ã«ã¯ãã§ã«2å°é§è»ãããŠããã®ã§é§è»ã§ããããŸã 空ããŠããé§è»ã¹ããŒã¹1ãé§è»ã¹ããŒã¹2ã®ã©ã¡ããã«é§è»ããããšã«ãªããŸããé§è»ã¹ããŒã¹1ã«é§è»äžã®è» B ã®æ®ãé§è»æéã¯50åãé§è»ã¹ããŒã¹2ã«é§è»äžã®è»Cã®æ®ãé§è»æéã¯22åã§ãã©ã¡ããè» A ã®é§è»æéããå°ãªãã®ã§ãè» A ã®é§è»æéãšã®å·®ãããå°ããè» B ãé§è»ããŠããé§è»ã¹ããŒã¹1ã«é§è»ããŸãããã®çµæãå
ã«é§è»ããŠããè» B ã¯äžæ®µã«ãªããŸãã
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tsurugaParking2">
</center>
<br/>
<p>
é§è»ã¹ããŒã¹ã®æ° <var>m</var>ãé§è»ããè»ã®å°æ° <var>n</var>ãåè»ã®é§è»æé <var>t</var> ãå
¥åãšããé§è»å ŽããåºãŠããé çªã«è»ã®æŽççªå·ãåºåããããã°ã©ã ãäœæããŠãã ããããã ããè»ã«ã¯å
¥åã®é ã«1ããã¯ããŸãæŽæ°ã®æŽççªå·ãå²ãæ¯ãããŠãããè»ã¯10åããã«1å°ãã€æŽççªå·é ã«é§è»ãã«ãããã®ãšããŸãã
</p>
<H2>Input</H2>
<p>
è€æ°ã®ããŒã¿ã»ããã®äžŠã³ãå
¥åãšããŠäžããããŸããå
¥åã®çµããã¯ãŒããµãã€ã®è¡ã§ç€ºãããŸããåããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããŸãã
</p>
<pre>
<var>m</var> <var>n</var>
<var>t<sub>1</sub></var>
<var>t<sub>2</sub></var>
:
<var>t<sub>n</sub></var>
</pre>
<p>
1 è¡ç®ã«2段åŒã®é§è»è£
眮ã®æ° <var>m</var> (1 ≤ <var>m</var> ≤ 10) ãšé§è»ããè»ã®å°æ° <var>n</var> (1 ≤ <var>n</var> ≤ 100) ãäžããããŸããç¶ã <var>n</var> è¡ã«<var>i</var> å°ç®ã®è»ã®é§è»æé <var>t<sub>i</sub></var> (1 ≤ <var>t<sub>i</sub></var> ≤ 120) ãäžããããŸãã
</p>
<p>
ããŒã¿ã»ããã®æ°ã¯ 20 ãè¶
ããŸããã
</p>
<H2>Output</H2>
<p>
ããŒã¿ã»ããæ¯ã«é§è»å ŽããåºãŠããé çªã«è»ã®æŽççªå·ãïŒè¡ã«åºåããŸããæŽççªå·ã¯ç©ºçœåºåãã§åºåããŠãã ããã
</p>
<H2>Sample Input</H2>
<pre>
3 5
90
52
82
84
70
2 4
10
30
40
60
0 0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
2 5 1 4 3
1 2 4 3
</pre>
| [
[
"3 5\n90\n52\n82\n84\n70\n2 4\n10\n30\n40\n60\n0 0\n",
"3 5\n90\n52\n82\n84\n70\n2 4\n10\n30\n40\n60\n0 0\n"
]
] |
p00193 | Convenience Store |
<H1>ã³ã³ãã</H1>
<table>
<tr>
<td style="vertical-align:top">
<p>
ã³ã³ãããšã³ã¹ã¹ãã¢ã»ããã³ã€ã¬ãã³ã¯äºæ¥ãåºããããè¥æŸåžã«äžåºèç®ããªãŒãã³ããããšèããŠããŸããè¥æŸåžã«ã¯æ¢ã«ä»ã®ããããã®ã³ã³ãããšã³ã¹ã¹ãã¢ãããã®ã§ãæ°åºèããªãŒãã³ããå Žæãæåã®éµãæ¡ãããšã«ãªãããã§ããããã³ã€ã¬ãã³ã¯ãã客ããã¯èªåã®äœãã§ããå°åããæãè¿ãã³ã³ãããå©çšããããšããåæã®äžããå€ãã®ã客ãããå©çšããã§ãããå°ç¹ãã«åºåºããããšã«ããŠããŸãã
</p>
</td>
<td>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_devenEleven1">
</td>
</tr>
</table>
<p>
ããã³ã€ã¬ãã³ã¯ãæ¢èšã®åã³ã³ãããã«ããŒããŠããç¯å²ãææ¡ãããããè¥æŸåžã®å°å³ãååãªæ£å
è§åœ¢(以åŸããããã¯ã)ãçšããŠåºåããŸããããã®ãšããåãããã¯ã«ã¯æ¢èšã®ã³ã³ãããå€ããšãäžã€ã ãå
¥ãããã«åºåããŸããããã®å°å³äžã§ãåãããã¯ããããã³ã³ãããžè¡ãã®ã«çµç±ãããããã¯ã®æ°ãããšã«ã³ã³ãããšã®è·é¢ãæ±ããŸããåãããã¯ã¯ãã®è·é¢ãæãå°ããã³ã³ããã«ãã£ãŠã«ããŒãããŠãããšèããŸããåé¡ã¯ããã®å°å³ãããšã«ãã§ããã ãå€ãã®ãããã¯ãã«ããŒããæ¢èšã®ã³ã³ããããªããããã¯ããæ¢ãããšã§ãã
</p>
<p>
ããã³ã€ã¬ãã³ã®ããã°ã©ãã§ããããªãã¯ããããã¯åããããå°å³æ
å ±ãšæ°åºèã®åè£å°ã®æ
å ±ãããæãåºãã«ããŒã§ãããããã¯æ°ãèšç®ããããã°ã©ã ãéçºããããšã«ãªããŸããã
</p>
<p>
<var>m × n</var> ã«åºåããå°å³ã¯å³1ã®ããã«è¡šããŸããå
è§åœ¢ã®ãããã¯ã暪㫠<var>m</var> åã瞊㫠<var>n</var> å䞊ã³ãããããã¯äžã€ã®åº§æš(<var>x, y</var>)ã§ç€ºãããŸããå¥æ°è¡ã®å·Šç«¯ã¯ãã®äžã®è¡ã®å·Šç«¯ã®å·Šäžã«ãå¶æ°è¡ã®å·Šç«¯ã¯ãã®äžã®è¡ã®å·Šç«¯ã®å³äžã«ãããããäœçœ®ããŸããäŸãã°ã座æš(1, 1)ã¯å³1ã®äžçªå·Šäžã®ãããã¯ã瀺ããŸãããŸãã座æš(1, 2)ã¯åº§æš(1, 1)ã®å³äžã«äœçœ®ãã座æš(1, 3)ã¯åº§æš(1, 2)ã®å·Šäžã«äœçœ®ããŸãã
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_devenEleven2">
</center>
<br/>
<p>
å³2ã¯æ¢èšã®ã³ã³ããã6åãã£ãå Žåã®äŸã§ã6 × 6 ã«åºåãããŠããŸããåã³ã³ããã¯1ããé ã«çªå·ãæ¯ãããŠããŸãããã®ãšããåã³ã³ãããã«ããŒãããããã¯ãçªå·æ¯ã«å¡ãåãããšå³3ã®ããã«ãªããŸãã座æš(1, 4)ã(2, 5)ã®ããã«å¡ãããŠããªããããã¯ã¯æãè¿ãã³ã³ãããäºã€ä»¥äžãããã©ã¡ããšãå€æãã€ããªããããã¯ã«ãªã£ãŠããŸããäŸãã°ã座æš(1, 4)ã®ãããã¯ã®å Žåãçªå·4ã®ã³ã³ãããšçªå·5ã®ã³ã³ãããžã®è·é¢ãçããããã®ãããã¯ãã«ããŒããŠããã³ã³ããã¯ãªããã®ãšããŠèããŸããçªå·4ã®ã³ã³ãããã«ããŒããŠãããããã¯æ°ã¯5ãšãªããŸãã
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_devenEleven3">
</center>
<br/>
<p>
ããã§ãããã³ã€ã¬ãã³ã座æš(1, 3)ãšåº§æš(5, 3)ãæ°åºèã®åè£å°ãšããŠèããŠãããšããŸãã座æš(1, 3)ã«åºèãæ§ããå Žåãã«ããŒã§ãããããã¯æ°ã¯3ãšãªããŸã(å³4)ãäžæ¹ã座æš(5, 3)ã«åºèãæ§ããå Žåã«ã«ããŒã§ãããããã¯æ°ã¯4ãšãªããŸã(å³5)ããããã£ãŠãæãåºãã«ããŒã§ãããããã¯æ°ã¯4ãšãªããŸãã
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_devenEleven4">
</center>
<br/>
<p>
å°å³æ
å ± <var>m × n</var>ãæ¢èšã®ã³ã³ããã®æ° <var>s</var> ãšãã®åº§æš(<var>x, y</var>)ãåè£å°ã®æ° <var>t</var> ãšãã®åº§æš(<var>p, q</var>)ãå
¥åãšããå
šåè£å°ã®äžã§æãåºãã«ããŒã§ãããããã¯æ°ãåºåããããã°ã©ã ãäœæããŠãã ããã
</p>
<H2>Input</H2>
<p>
è€æ°ã®ããŒã¿ã»ããã®äžŠã³ãå
¥åãšããŠäžããããŸããå
¥åã®çµããã¯ãŒããµãã€ã®è¡ã§ç€ºãããŸãã åããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããŸãã
</p>
<pre>
<var>m</var> <var>n</var>
<var>s</var>
<var>x<sub>1</sub></var> <var>y<sub>1</sub></var>
<var>x<sub>2</sub></var> <var>y<sub>2</sub></var>
:
<var>x<sub>s</sub></var> <var>y<sub>s</sub></var>
<var>t</var>
<var>p<sub>1</sub></var> <var>q<sub>1</sub></var>
<var>p<sub>2</sub></var> <var>q<sub>2</sub></var>
:
<var>p<sub>t</sub></var> <var>q<sub>t</sub></var>
</pre>
<p>
1 è¡ç®ã«åºåããå°å³ã®å€§ãã(暪ã瞊)ãè¡šãæŽæ° <var>m</var>, <var>n</var> (2 ≤ <var>m, n</var> ≤ 100) ãäžããããŸãã
</p>
<p>
2è¡ç®ã«æ¢èšã®ã³ã³ããã®æ° <var>s</var> (1 ≤ <var>s</var> ≤ 10) ãäžããããŸããç¶ã<var>s</var> è¡ã«ã <var>i</var> åç®ã®æ¢èšã®ã³ã³ããã®åº§æš <var>x<sub>i</sub></var>, <var>y<sub>1</sub></var> ãäžããããŸãã
</p>
<p>
ç¶ãè¡ã«ãæ°åºèã®åè£å°ã®æ° <var>t</var> (1 ≤ <var>t</var> ≤ 10 ) ãäžããããŸããç¶ã <var>t</var> è¡ã«ã<var>i</var> åç®ã®åè£å°ã®åº§æš <var>p<sub>i</sub></var>, <var>q<sub>i</sub></var> ãäžããããŸãã
</p>
<p>
ããŒã¿ã»ããã®æ°ã¯ 20 ãè¶
ããŸããã
</p>
<H2>Output</H2>
<p>
ããŒã¿ã»ããæ¯ã«ãå
šåè£å°ã®äžã§æãåºãã«ããŒã§ãããããã¯æ°ãïŒè¡ã«åºåããŸãã
</p>
<H2>Sample Input</H2>
<pre>
6 6
6
1 1
6 1
3 2
3 5
1 6
5 6
2
1 3
5 3
6 6
6
3 2
3 5
6 1
1 1
1 6
5 6
2
2 3
5 3
0 0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
4
</pre>
| [
[
"6 6\n6\n1 1\n6 1\n3 2\n3 5\n1 6\n5 6\n2\n1 3\n5 3\n6 6\n6\n3 2\n3 5\n6 1\n1 1\n1 6\n5 6\n2\n2 3\n5 3\n0 0\n",
"6 6\n6\n1 1\n6 1\n3 2\n3 5\n1 6\n5 6\n2\n1 3\n5 3\n6 6\n6\n3 2\n3 5\n6 1\n1 1\n1 6\n5 6\n2\n2 3\n5 3\n0 0\n"
]
] |
p00194 | Delivery Company |
<H1>ééäŒç€Ÿ</H1>
<table>
<tr>
<td style="vertical-align:top">
<p>
çœèééã¯äŒæŽ¥è¥æŸåžã代衚ããééäŒç€Ÿã§ããæšä»ã®åæ²¹äŸ¡æ Œã®é«éš°ã¯ééäŒç€Ÿã«ãå€å€§ãªãã¡ãŒãžãäžããééäŒç€Ÿå瀟ã§ã¯ãã§ããã ãå°ãªãã¬ãœãªã³ã§è·ç©ãéã¶ããšã課é¡ãšãªã£ãŠããŸãã
</p>
</td>
<td>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_byakkoDelivery1">
</td>
</tr>
</table>
<p>
çœèééã§ã¯ãéãè·ç©ãç©ãã ãã©ãã¯ã¯ããã®èµ°ãã ãã«å€ãã®ãšãã«ã®ãŒãå¿
èŠãšããããšã«çç®ããŸããããã©ãã¯ãå庫ãåºçºããŠããäžåºŠãåæ¢ããããšãªãç®çå°ãŸã§å°éããçµè·¯ã®äžã§æçæéã®çµè·¯ãéãããšã§ãã¬ãœãªã³ã®ç¯çŽãã§ãããšèããŸããã
</p>
<p>
ããªãã®ä»äºã¯ããã®ãããªæççµè·¯ãèšç®ã§ããã«ãŒãããéçºããããšã§ããäœæããã«ãŒããçšããã°ã©ã ã®ä»æ§ã¯ä»¥äžã®ãšããã§ãã
</p>
<ul>
<li>åžå
ã¯ãäžå³ã®ããã«ãæ±è¥¿æ¹åã®éè·¯ <var>M</var> æ¬ãååæ¹åã®éè·¯ <var>N</var> æ¬ ãããªãæ Œåã§è¡šããæ Œåã®å亀ç¹ã¯äº€å·®ç¹ãè¡šããŸãã</li>
<li>亀差ç¹ã®ããã€ãã«ã¯æ±è¥¿ - ååã®æ¹åã«ä¿¡å·æ©ãèšçœ®ãããŠãããäžå®ã®åšæã§éãèµ€ã®ã·ã°ãã«ãç¹ç¯ããŠããŸãã</li>
<li>åžå
ã®äº€å·®ç¹éãçµã¶éè·¯ã«ã¯å·¥äºäžã§ééã§ããªãåæãããã€ããããŸãã</li>
<li>ãã©ãã¯ã亀差ç¹ãã亀差ç¹ãžç§»åããã®ã«å¿
èŠãªæéã¯äžå®ã§ãããæžæ»ããŠããéè·¯ã§ã¯ããã«é·ãæéãããããŸãã</li>
</ul>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_byakkoDelivery2">
</center>
<br/>
<p>
åžå
ã®éè·¯æ
å ±ããã©ãã¯ã亀差ç¹éã移åããã®ã«å¿
èŠãªæéãä¿¡å·æ©ããã亀差ç¹ãšåä¿¡å·æ©ã®åšæãå·¥äºäžã®éè·¯ãæžæ»ããŠããéè·¯ãšæžæ»åºŠãçœèééã®å庫(å§ç¹)ãšç®çå°(çµç¹)ã®äœçœ®ãå
¥åãšããå§ç¹ããçµç¹ãŸã§ã®æçã®æéãåºåããããã°ã©ã ãäœæããŠäžããã
</p>
<p>
å³ã®ããã«ãæ±è¥¿ã®æ¹åã®éè·¯ã¯aãbãcã... ãšè±å°æåã§ååãä»ããã ãååã®æ¹åã®é路㯠1ã2ã3ã... ãšæŽæ°ã§ååãä»ããããŠããŸããåžå
ã®äº€å·®ç¹ã¯ããããã®è±å°æåãšæŽæ°ã®çµã¿åãã <var>H</var>-<var>V</var> ã§æå®ãããŸãã
</p>
<p>
äŸãã°ãåžå
ã®æå西ã®äº€å·®ç¹ã¯ a-1 ã§æå®ãããŸããåä¿¡å·ã¯åšæ <var>k</var> ããã¡ã<var>k</var> åããšã«åãæ¿ãããŸããæ±è¥¿ãéãªãã°ååãèµ€ã§ãååãéãªãã°æ±è¥¿ãèµ€ã§ããé»è²ã®ã·ã°ãã«ã¯ååšããŸããããã©ãã¯ã¯äºã€ã®äº€å·®ç¹ãçµã¶éè·¯ã移åããã®ã« <var>D</var> åèŠããŸããããã®éè·¯ãæžæ»ããŠããå Žåã¯ããã« <var>d</var> åã®æéãèŠããŸãããã©ãã¯ã¯éè·¯ãå·¥äºäžã®å Žåã¯ç§»åã§ããŸããã
</p>
<p>
ãŸãã亀差ç¹ã«å°éããæå»ã«ãä¿¡å·ãèµ€ã®å Žåã«ã¯é²å
¥ã§ããŸããããã©ãã¯ã¯äº€å·®ç¹ã§ã®ã¿ãæ±ã西ãåãåã«æ¹åãå€ããããšãã§ããŸãããæ¥ãæ¹åãžã¯ç§»å(Uã¿ãŒã³)ã§ããŸãããéè·¯ã¯2æ¹éè¡ã§ããããã©ãã¯ãè¡ãæ¥ããæéãå·¥äºç¶æ³ãæžæ»åºŠã¯2æ¹åå
±éã§ãã
</p>
<p>
åæç¶æ
ãšããŠããã©ãã¯ã¯æ±ãåããŠããŠããã©ãã¯ãå庫ãåºçºããç¬éãã¹ãŠã®ä¿¡å·æ©ãååã®æ¹åã«éã«åãæ¿ãããã®ãšããŸãããŸãããã©ãã¯ã¯ 100å以å
ã§ç®çå°ã«å°éã§ãããã®ãšããŸãã
</p>
<H2>Input</H2>
<p>
è€æ°ã®ããŒã¿ã»ããã®äžŠã³ãå
¥åãšããŠäžããããŸããå
¥åã®çµããã¯ãŒããµãã€ã®è¡ã§ç€ºãããŸããåããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããŸãã
</p>
<pre>
<var>M</var> <var>N</var>
<var>D</var>
<var>ns</var>
<var>H<sub>1</sub></var>-<var>V<sub>1</sub></var> <var>k<sub>1</sub></var>
<var>H<sub>2</sub></var>-<var>V<sub>2</sub></var> <var>k<sub>2</sub></var>
:
<var>H<sub>ns</sub></var>-<var>V<sub>ns</sub></var> <var>k<sub>ns</sub></var>
<var>nc</var>
<var>H<sub>11</sub></var>-<var>V<sub>11</sub></var> <var>H<sub>12</sub></var>-<var>V<sub>12</sub></var>
<var>H<sub>21</sub></var>-<var>V<sub>21</sub></var> <var>H<sub>22</sub></var>-<var>V<sub>22</sub></var>
:
<var>H<sub>nc1</sub></var>-<var>V<sub>nc1</sub></var> <var>H<sub>nc2</sub></var>-<var>V<sub>nc2</sub></var>
<var>nj</var>
<var>H<sub>11</sub></var>-<var>V<sub>11</sub></var> <var>H<sub>12</sub></var>-<var>V<sub>12</sub></var> <var>d<sub>1</sub></var>
<var>H<sub>21</sub></var>-<var>V<sub>21</sub></var> <var>H<sub>22</sub></var>-<var>V<sub>22</sub></var> <var>d<sub>2</sub></var>
:
<var>H<sub>nj1</sub></var>-<var>V<sub>nj1</sub></var> <var>H<sub>nj2</sub></var>-<var>V<sub>nj2</sub></var> <var>d<sub>nj</sub></var>
<var>H<sub>s</sub></var>-<var>V<sub>s</sub></var> <var>H<sub>d</sub></var>-<var>V<sub>d</sub></var>
</pre>
<p>
ïŒè¡ç®ã«éè·¯ã®æ¬æ° <var>M</var>, <var>N</var> (2 ≤ <var>M, N</var> ≤ 20) ãäžããããŸããïŒè¡ç®ã«ãäºã€ã®äº€å·®ç¹ãçµã¶éè·¯ã移åããã®ã«èŠããæé <var>D</var> (1 ≤ <var>D</var> ≤ D, æŽæ°) ãäžããããŸãã
</p>
<p>
ïŒè¡ç®ã«ä¿¡å·æ©ã®æ° <var>ns</var> ãäžããããŸããç¶ã <var>ns</var> è¡ã«ã<var>i</var> åç®ã®ä¿¡å·æ©ã®äœçœ®ãè¡šãè±å°æåãšæŽæ°ã®çµ <var>H<sub>i</sub></var>-<var>V<sub>i</sub></var> ãšåšæ <var>k</var> (1 ≤ <var>k</var> ≤ 100) ãäžããããŸãã
</p>
<p>
ç¶ãè¡ã«ãå·¥äºäžã®éè·¯ã®æ° <var>nc</var> ãäžããããŸããç¶ã <var>nc</var> è¡ã«ã<var>i</var> åç®ã®å·¥äºäžã®éè·¯ã®ïŒã€ã®ç«¯ç¹ïŒäº€å·®ç¹ïŒãè¡šãè±å°æåãšæŽæ°ã®çµ <var>H<sub>i1</sub></var>-<var>V<sub>i1</sub></var> <var>H<sub>i2</sub></var>-<var>V<sub>i2</sub></var> ãäžããããŸãã
</p>
<p>
ç¶ãè¡ã«ãæžæ»éè·¯ã®æ° <var>nj</var> ãäžããããŸããç¶ã <var>nj</var> è¡ã«ã<var>i</var> åç®ã®æžæ»éè·¯ã®ïŒã€ã®ç«¯ç¹ïŒäº€å·®ç¹ïŒãè¡šãè±å°æåãšæŽæ°ã®çµ <var>H<sub>i1</sub></var>-<var>V<sub>i1</sub></var> <var>H<sub>i2</sub></var>-<var>V<sub>i2</sub></var> ãšæé <var>d<sub>i</sub></var> (1 ≤ <var>d<sub>i</sub></var> ≤ 100) ãäžããããŸãã
</p>
<p>
æåŸã®è¡ã«ãå§ç¹ã®äº€å·®ç¹ <var>H<sub>s</sub></var>-<var>V<sub>d</sub></var> ãšçµç¹ã®äº€å·®ç¹ <var>H<sub>d</sub></var>-<var>V<sub>d</sub></var> ãäžããããŸãã
</p>
<p>
ããŒã¿ã»ããã®æ°ã¯ 20 ãè¶
ããŸããã
</p>
<H2>Output</H2>
<p>
ããŒã¿ã»ããæ¯ã«æçæéãïŒè¡ã«åºåããŸãã
</p>
<H2>Sample Input</H2>
<pre>
4 5
1
3
b-2 3
c-3 2
c-4 1
3
a-2 b-2
b-3 c-3
d-3 d-4
2
b-3 b-4 1
c-1 d-1 1
d-1 b-4
4 5
1
3
b-2 3
c-3 2
c-4 1
3
a-2 b-2
b-3 c-3
d-3 d-4
2
b-3 b-4 1
c-1 d-1 1
d-2 b-4
4 5
1
3
b-2 3
c-3 2
c-4 1
3
a-2 b-2
b-3 c-3
d-3 d-4
2
b-3 b-4 1
c-1 d-1 1
d-3 b-4
0 0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
7
4
8
</pre>
| [
[
"4 5\n1\n3\nb-2 3\nc-3 2\nc-4 1\n3\na-2 b-2\nb-3 c-3\nd-3 d-4\n2\nb-3 b-4 1\nc-1 d-1 1\nd-1 b-4\n4 5\n1\n3\nb-2 3\nc-3 2\nc-4 1\n3\na-2 b-2\nb-3 c-3\nd-3 d-4\n2\nb-3 b-4 1\nc-1 d-1 1\nd-2 b-4\n4 5\n1\n3\nb-2 3\nc-3 2\nc-4 1\n3\na-2 b-2\nb-3 c-3\nd-3 d-4\n2\nb-3 b-4 1\nc-1 d-1 1\nd-3 b-4\n0 0\n",
"4 5\n1\n3\nb-2 3\nc-3 2\nc-4 1\n3\na-2 b-2\nb-3 c-3\nd-3 d-4\n2\nb-3 b-4 1\nc-1 d-1 1\nd-1 b-4\n4 5\n1\n3\nb-2 3\nc-3 2\nc-4 1\n3\na-2 b-2\nb-3 c-3\nd-3 d-4\n2\nb-3 b-4 1\nc-1 d-1 1\nd-2 b-4\n4 5\n1\n3\nb-2 3\nc-3 2\nc-4 1\n3\na-2 b-2\nb-3 c-3\nd-3 d-4\n2\nb-3 b-4 1\nc-1 d-1 1\nd-3 b-4\n0 0\n"
]
] |
p00195 | What is the Most Popular Shop in Tokaichi? |
<h1>人æ°ã®åºåºã¯?</h1>
<table>
<tr>
<td valign="top" style="vertical-align:top">
<p>
äŒæŽ¥è¥æŸåžã§ã¯ãæ¯å¹Ž1æ10æ¥ã«ãåæ¥åžããšããååžããããŸãããã®åæ¥åžã¯ãçŽ600幎ã®æŽå²ãããäŒæŽ¥å°æ¹æ倧ã®ååžã§ããäŒæŽ¥å°æ¹ã§ã¯ã銎æã¿ã®çžèµ·ç©ã§ãããèµ·ãäžããå°æ³åž«(ãããããããŒã)ã売ãããŠããããšã§ãããç¥ãããŠããŸããèµ·ãäžããå°æ³åž«ã¯ã倧ãã3cm çšåºŠã®éå¿ãåºã«ãã匵ãåã§ã転ãããŠãããã«èµ·ããããããšãããã®ååãä»ããŸãããå家åºã§ã¯ãå¿
ã家æããäžåå€ãè²·ã£ãŠç¥æ£ã«äŸããŸãããã®äžåã¯ã ã家æãå¢ããããã«ãããåãèè² ã£ãŠãããããšã®æå³ããããŸãã
</p>
</td>
<td valign="top" style="vertical-align:top">
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_tokaichi">
</td>
</tr>
</table>
<br/>
<p>
åæ¥åžå®è¡å§å¡äŒã§ã¯ã次åã®åæ¥åžã«åããŠãèµ·ãäžããå°æ³åž«ã®è²©å£²åæ°ãäžçªå€ãåºåºã調ã¹ãããšã«ãªããŸãããä»å¹Žã®åºåºã®æ°ã¯5åº(AãBãCãDãE:åè§è±å)ã§ã販売åæ°ã¯ãååãšååŸã«åããŠåæ¥åžå®è¡å§å¡äŒã«å ±åãããŠããŸãã
</p>
<p>
ååºåºã®æ
å ±ãå
¥åãšããäžæ¥ã®è²©å£²åæ°ãäžçªå€ãåºåºã®ååãšãã®åæ°ãåºåããããã°ã©ã ãäœæããŠãã ããã
</p>
<H2>Input</H2>
<p>
è€æ°ã®ããŒã¿ã»ããã®äžŠã³ãå
¥åãšããŠäžããããŸããå
¥åã®çµããã¯ãŒããµãã€ã®è¡ã§ç€ºãããŸãã
åããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããŸãã
</p>
<pre>
<var>s1<sub>A</sub></var> <var>s2<sub>A</sub></var>
<var>s1<sub>B</sub></var> <var>s2<sub>B</sub></var>
<var>s1<sub>C</sub></var> <var>s2<sub>C</sub></var>
<var>s1<sub>D</sub></var> <var>s2<sub>D</sub></var>
<var>s1<sub>E</sub></var> <var>s2<sub>E</sub></var>
</pre>
<p>
<var>i</var> è¡ç®ã«ãããããA, B, C, D, E ã®ååã®è²©å£²åæ° <var>s1<sub>i</sub></var> ãšååŸã®è²©å£²åæ° <var>s2<sub>i</sub></var> (1 ≤ <var>s1<sub>i</sub></var>, <var>s2<sub>i</sub></var> ≤ 10000) ãäžããããŸãããã ããäžæ¥ã®è²©å£²åæ°ãåãåºåºã¯ç¡ããã®ãšããŸãã
</p>
<p>
ããŒã¿ã»ããã®æ°ã¯ 100 ãè¶
ããŸããã
</p>
<H2>Output</H2>
<p>
ããŒã¿ã»ããããšã«ãäžæ¥ã®è²©å£²åæ°ã®äžçªå€ãåºåºã®ååãšãã®åæ°ãïŒè¡ã«åºåããŸãã
</p>
<H2>Sample Input</H2>
<pre>
1593 4311
4321 2155
1256 6421
5310 1455
2152 5421
1549 3386
4528 3719
1234 4321
3330 3109
2739 2199
0 0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
C 7677
B 8247
</pre>
| [
[
"1593 4311\n4321 2155\n1256 6421\n5310 1455\n2152 5421\n1549 3386\n4528 3719\n1234 4321\n3330 3109\n2739 2199\n0 0\n",
"1593 4311\n4321 2155\n1256 6421\n5310 1455\n2152 5421\n1549 3386\n4528 3719\n1234 4321\n3330 3109\n2739 2199\n0 0\n"
]
] |
p00196 | Baseball Championship |
<H1>éç倧äŒ</H1>
<p>
éçã®åœå¥å¯ŸææŠ WBC ã§ãæ¥æ¬ã2é£èŠéæ!! éç人æ°ãé«ãŸãäžãäŒæŽ¥åŠåé«æ ¡ãäŒå Žã«éç倧äŒãè¡ãããŸããããã®å€§äŒã§ã¯ãç·åœãã®ãªãŒã°æŠãè¡ãã以äžã®ãããªæ¹æ³ã§é äœã決ããããšã«ãªããŸããã
</p>
<ol>
<li> åã¡æ°ã®å€ãããŒã ãäžäœãšãã</li>
<li> åã¡æ°ãåæ°ã®å Žåã¯è² ãæ°ã®å°ãªãããŒã ãäžäœãšãã</li>
</ol>
<p>
åããŒã ã®æ瞟ãå
¥åãšããããŒã åãäžäœã®ããŒã ããé ã«åºåããããã°ã©ã ãäœæããŠãã ãããåé äœã®ããŒã ãååšããå Žåã¯ãå
¥åé ã«åºåããŠãã ããããã ããããŒã æ° <var>n</var> 㯠2 ä»¥äž 10 以äžã®æŽæ°ãããŒã å <var>t</var> 㯠1 æåã®åè§è±åãè©Šåæ¯ã®æ瞟 <var>r</var> 㯠<var>n</var> - 1 åã®æ°åã§è¡šãããåã¡ã®å Žå㯠0 ãè² ãã®å Žå㯠1 ãåŒãåãã®å Žå㯠2 ãšããŸãããŸããããŒã åã«éè€ã¯ãªããã®ãšããŸãã
</p>
<H2>Input</H2>
<p>
è€æ°ã®ããŒã¿ã»ããã®äžŠã³ãå
¥åãšããŠäžããããŸããå
¥åã®çµããã¯ãŒãã²ãšã€ã®è¡ã§ç€ºãããŸãã
åããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããŸãã
</p>
<pre>
<var>n</var>
<var>score<sub>1</sub></var>
<var>score<sub>2</sub></var>
:
<var>score<sub>n</sub></var>
</pre>
<p>
1 è¡ç®ã«ããŒã ã®æ° <var>n</var> (2 ≤ <var>n</var> ≤ 10) ãç¶ã <var>n</var> è¡ã«ç¬¬ <var>i</var> ã®ããŒã ã®æ瞟 <var>score<sub>i</sub></var> ãäžããããŸããåæ瞟ã¯æ¬¡ã®åœ¢åŒã§äžããããŸãã
</p>
<pre>
<var>t</var> <var>r<sub>1</sub></var> <var>r<sub>2</sub></var> ... <var>r<sub>n−1</sub></var>
</pre>
<p>
ããŒã å <var>t</var> (ïŒæåã®åè§è±å)ã<var>t</var> ã®è©Šåæ¯ã®æ瞟 <var>r<sub>i</sub></var> (0, 1, ãŸã㯠2) ã空çœåºåãã§äžããããŸãã
</p>
<p>
ããŒã¿ã»ããã®æ°ã¯ 50 ãè¶
ããŸããã
</p>
<H2>Output</H2>
<p>
ããŒã¿ã»ããããšã«ãããŒã åãäžäœã®ããŒã ããé ã«åºåããŸãã
</p>
<H2>Sample Input</H2>
<pre>
6
A 1 0 0 2 0
B 0 0 1 1 0
C 1 1 1 1 1
D 1 0 0 1 2
E 2 0 0 0 0
F 1 1 0 2 1
4
g 1 1 1
h 0 1 2
w 0 0 0
b 0 2 1
0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
E
A
B
D
F
C
w
h
b
g
</pre>
| [
[
"6\nA 1 0 0 2 0\nB 0 0 1 1 0\nC 1 1 1 1 1\nD 1 0 0 1 2\nE 2 0 0 0 0\nF 1 1 0 2 1\n4\ng 1 1 1\nh 0 1 2\nw 0 0 0\nb 0 2 1\n0\n",
"6\nA 1 0 0 2 0\nB 0 0 1 1 0\nC 1 1 1 1 1\nD 1 0 0 1 2\nE 2 0 0 0 0\nF 1 1 0 2 1\n4\ng 1 1 1\nh 0 1 2\nw 0 0 0\nb 0 2 1\n0\n"
]
] |
p00197 | Greatest Common Divisor: Euclidean Algorithm |
<h1>æ倧å
¬çŽæ°-ãŠãŒã¯ãªããã®äºé€æ³</h1>
<p>
æ倧å
¬çŽæ°ã¯ãã³ã³ãã¥ãŒã¿äžã§æ±ãæ°åŠã«ã¯æ¬ ãããªãèŠçŽ ã§ããæ倧å
¬çŽ æ°ã䜿ãããšã§ãèšç®ã®å¹çã倧ããå€åããããšããããŸããæ倧å
¬çŽæ°ãæ±ããã¢ã«ãŽãªãºã ã®ã²ãšã€ãããŠãŒã¯ãªããã®äºé€æ³ãã§ãããã®åŠç ã®æµãã以äžã«ç€ºããŸãã
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_gcd"><br/>
</center>
<br/>
<p>
äŸãã° 1071 ãš 1029 ã®å Žåã1071 ã <var>X</var> ã1029 ã <var>Y</var> ã«ä»£å
¥ããŠã<br>
1071 ÷ 1029 ã®äœã㯠42 ã<var>X</var> ã« 42 ã代å
¥ã㊠<var>X</var> ãš <var>Y</var> ãå
¥ãæ¿ããã (1 ã¹ããã)<br>
1029 ÷ 42 ã®äœã㯠21 ã<var>X</var> ã« 21 ã代å
¥ã㊠<var>X</var> ãš <var>Y</var> ãå
¥ãæ¿ããã (2 ã¹ããã)<br>
42 ÷ 21 ã®äœã㯠0 ã<var>X</var> ã« 0 ã代å
¥ã㊠<var>X</var> ãš <var>Y</var> ãå
¥ãæ¿ããã (3 ã¹ããã)<br>
<var>Y</var> ã 0 ã«ãªã£ãã®ã§ããã®æã® <var>X</var> ãæ倧å
¬çŽæ°ãšãªãããã£ãŠæ倧å
¬çŽæ°ã¯ 21 ã
</p>
<p>
ãã®ããã«ããã£ãã® 3 ã¹ããã㧠1071 ãš 1029 ã®æ倧å
¬çŽæ°ãæ±ããããšãåºæ¥ãŸããããŠãŒã¯ãªããã®äºé€æ³ã¯çŽæ°ãåºããŠæ¯èŒããŠããæ¹æ³ã«æ¯ã¹ãå§åçã«æ©ãçµæãåºããŠãããŸãã
</p>
<p>
ïŒã€ã®æŽæ°ãå
¥åãšãããŠãŒã¯ãªããã®äºé€æ³ãçšããŠæ倧å
¬çŽæ°ãæ±ãããã®æ倧å
¬çŽæ°ãšèšç®ã«ããã£ãã¹ãããæ°ãåºåããããã°ã©ã ãäœæããŠãã ããã
</p>
<H2>Input</H2>
<p>
è€æ°ã®ããŒã¿ã»ããã®äžŠã³ãå
¥åãšããŠäžããããŸããå
¥åã®çµããã¯ãŒããµãã€ã®è¡ã§ç€ºãããŸãã
åããŒã¿ã»ãããšããŠïŒã€ã®æŽæ° <var>a, b</var> (2 ≤ <var>a, b</var> ≤ 2<sup>31</sup>-1) ãïŒè¡ã«äžããããŸãã
</p>
<p>
ããŒã¿ã»ããã®æ°ã¯ 1000 ãè¶
ããŸããã
</p>
<H2>Output</H2>
<p>
ããŒã¿ã»ããããšã«ãå
¥åãããïŒã€ã®æŽæ°ã®æ倧å
¬çŽæ°ãšãèšç®ã«ããã£ããŠãŒã¯ãªããã®äºé€æ³ã®ã¹ãããæ°ã空çœåºåãã§ïŒè¡ã«åºåããŸãã
</p>
<H2>Sample Input</H2>
<pre>
1071 1029
5 5
0 0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
21 3
5 1
</pre>
| [
[
"1071 1029\n5 5\n0 0\n",
"1071 1029\n5 5\n0 0\n"
]
] |
p00198 | Trouble in Shinagawa's Artifacts |
<h1>ç«æ¹äœã®äœå</h1>
<p>
èžè¡å®¶åå·ã¯ <var>n</var> ç¹ã®äœåãåºå±ããããã«äŸé ŒãããŸãããããã§ãç«æ¹äœã® 6 é¢ããã³ãã§è²ä»ããããã®ãäœåãšããŠåºå±ããããšã«ããŸãããäœåã¯ãRedãYellowãBlueãMagentaãGreenãCyan ã® 6 è²å
šãŠã䜿ãããŠããŠãåé¢ã¯ 1 è²ã§å¡ãã€ã¶ãããŠããŸããåå·ã¯åœ¢ãåãç«æ¹äœã®äœåã§ãè²ã®é
眮ã®ä»æ¹ãå€ããç°ãªãäœåãšã㊠<var>n</var> ç¹äœæããŸããã
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_shinagawa1"><br/>
</center>
<br/>
<p>
圌ã®å人ã§ããããªãã¯ãå人ã®ããã¿ã§äœåãåºå±åã«é²èŠ§ãããŠããããŸããããããã§ããããšã«æ°ãä»ããŸããããããã®äœåã®äžã«ç°ãªãè²ä»ãããããŠããããã«èŠããŠããå®ã¯åãè²ã®çµã¿åãããããç«æ¹äœãååšããŠããã®ã§ãããã®ãŸãŸã§ã¯ã <var>n</var> ç¹ã®äœåãåºå±ããããšã§ããªããªã£ãŠããŸããŸãã
</p>
<p>
äœæããäœåã®æ°ãšåäœåã®è²ã®æ
å ±ãå
¥åãšããåºå±ããããã«ããšäœç¹å¿
èŠããåºåããããã°ã©ã ãäœæããŠãã ããã
</p>
<p>
ç«æ¹äœã®åé¢ã®è²ã¯ c1 ãã c6 ãŸã§ã®èšå·ã§è¡šããã 以äžã®ãããªé
眮ãšãªã£ãŠããŸãããŸããc1 ãã c6 ã®ãããã㯠RedãYellowãBlueãMagentaãGreenãCyan ã®ãããã 1 è²ãšãªããŸãã
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_shinagawa2"><br/>
</center>
<br/>
<H2>Input</H2>
<p>
è€æ°ã®ããŒã¿ã»ããã®äžŠã³ãå
¥åãšããŠäžããããŸãã å
¥åã®çµããã¯ãŒãã²ãšã€ã®è¡ã§ç€ºãããŸãã
åããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããŸãã
</p>
<pre>
<var>n</var>
<var>cube<sub>1</sub></var>
<var>cube<sub>2</sub></var>
:
<var>cube<sub>n</sub></var>
</pre>
<p>
ïŒè¡ç®ã«äœåã®æ° <var>n</var> (1 ≤ <var>n</var> ≤ 30)ãç¶ã <var>n</var> è¡ã« <var>i</var> çªç®ã®äœåã®æ
å ±ãäžããããŸããåäœåã®æ
å ±ã¯æ¬¡ã®åœ¢åŒã§äžããããŸãã
</p>
<pre>
c1 c2 c3 c4 c5 c6
</pre>
<p>
äœåã®è²ã®é
眮 c<sub><var>i</var></sub> ã空çœåºåãã§äžããããŸãã
</p>
<p>
ããŒã¿ã»ããã®æ°ã¯ 100 ãè¶
ããŸããã
</p>
<H2>Output</H2>
<p>
ããŒã¿ã»ããããšã«ãåºå±ããã®ã«ããšäœç¹ã®äœåãå¿
èŠããïŒè¡ã«åºåããŸãã
</p>
<H2>Sample Input</H2>
<pre>
3
Cyan Yellow Red Magenta Green Blue
Cyan Yellow Red Magenta Green Blue
Red Yellow Magenta Blue Green Cyan
4
Red Magenta Blue Green Yellow Cyan
Red Yellow Magenta Blue Green Cyan
Magenta Green Red Cyan Yellow Blue
Cyan Green Yellow Blue Magenta Red
0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1
1
</pre>
| [
[
"3\nCyan Yellow Red Magenta Green Blue\nCyan Yellow Red Magenta Green Blue\nRed Yellow Magenta Blue Green Cyan\n4\nRed Magenta Blue Green Yellow Cyan\nRed Yellow Magenta Blue Green Cyan\nMagenta Green Red Cyan Yellow Blue\nCyan Green Yellow Blue Magenta Red\n0\n",
"3\nCyan Yellow Red Magenta Green Blue\nCyan Yellow Red Magenta Green Blue\nRed Yellow Magenta Blue Green Cyan\n4\nRed Magenta Blue Green Yellow Cyan\nRed Yellow Magenta Blue Green Cyan\nMagenta Green Red Cyan Yellow Blue\nCyan Green Yellow Blue Magenta Red\n0\n"
]
] |
p00199 | Chairs Where Demanding People Sit |
<h1>é£åãªäººãã¡ã座ãæ€
å</h1>
<p>
4ã€ã®åœã®äžå¿ã«ããäžç«éœåžã¢ã€ãºã·ãã£ã«ã¯ã倧éžæšªæåè»ãã³ãã€å·ã®ããŒã ããããŸãã ããŒã ã«ã¯ããã³ãã€å·ãåŸ
ã€ä¹å®¢çšã®æ€
åãäžåã«çšæãããŠãããããŒã ã«å
¥ã£ãŠãã人ã¯èªç±ã«æ€
åãå©çšããããšãã§ããŸãã
</p>
<p>
ãã®ãã³ãã€å·ãå®ããæ©ããå¿«é©ãšããããšã§ãåšå²ã®4ã€ã®åœããã®å©çšè
ã絶ããŸãããä»æ¥ã¯ééèšå¿µæ¥ãšããããšã§ãããŒã ã«åº§ã£ãŠãã人ãã¡ã«ç¹å¥ãªããšãããŠãããããšæã£ãŠããŸãããã®ããã«ã¯ãæ¹æãéã£ã人ãã¡ãã©ãã«åº§ã£ãŠãããææ¡ããªããã°ãªããŸããã4ã€ã®åœã®äººãã¡ã®é£åãªæ§æ Œãèæ
®ããŠãæ€
åãã©ã®ããã«åãŸã£ãŠããããã·ãã¥ã¬ãŒãããããã°ã©ã ãäœæããŠãã ãããæ¹æãéã£ã人ãã¡ã¯ã次ã
ã«äžåã«äžŠãã æ€
åã«åº§ã£ãŠãããŸãã4ã€ã®åœã®äººãã¡ã¯ãåœããšã«æ±ºãŸã£ãæ§æ Œãšåº§ãæ¹ããããŸããããããã®åº§ãæ¹ã¯ä»¥äžã®éãã§ãã
</p>
<table border=1 cellpadding=8 cellspacing=1>
<tr>
<td width=120>Aåœäººã®æ§æ Œ</td>
<td> A åœäººã¯åº§ããã°ããã巊端ããèŠãŠãã空ããŠããæ€
åã«åº§ãã</td>
</tr>
</table>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_chair1">
</center>
<br/>
<br/>
<table border=1 cellpadding=8 cellspacing=1>
<tr>
<td width=120 rowspan="2">Båœäººã®æ§æ Œ</td>
<td colspan="2"> B åœäººã¯ A åœäººãèŠæã A åœäººã®é£ä»¥å€ã§ãå³ç«¯ãã空ããŠããæ€
åã«åº§ãããã ãã Aåœäººã®é£ãã空ããŠããªãå Žåãææ
¢ããŠå·Šç«¯ãã空ããŠããæ€
åã«åº§ãã</td>
</tr>
</table>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_chair2">
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_chair3">
<br/>
<br/>
</center>
<table border=1 cellpadding=8 cellspacing=1>
<tr>
<td width=120 rowspan="2">Cåœäººã®æ§æ Œ</td>
<td colspan="2">
C åœäººã¯äººã®é£ã«åº§ããããå·ŠåŽããé ã«åº§ã£ãŠãã人ãèŠãŠãããäžçªå·ŠåŽã«åº§ã£ãŠãã人 ã®å³é£ã«åº§ãããšãããããããåãŸã£ãŠãããªããã®äººã®å·Šé£ã«åº§ãããšããããããåãŸã£ ãŠãããªã次ã®äººã®é£ã«åæ¡ä»¶ã§åº§ãããšãããã©ã®æ€
åã«ã人ã座ã£ãŠããªããã°çãäž(æ€
åã®æ° <var>n</var> ãå¥æ°ã®å Žå (<var>n</var>+1)/2 ãå¶æ°ã®å Žå <var>n</var>/2+1 )ã®æ€
åã«åº§ãã
</td>
</tr>
</table>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_chair4">
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_chair5">
<br/>
<br/>
</center>
<table border=1 cellpadding=8 cellspacing=1>
<tr>
<td width=120 rowspan="2">Dåœäººã®æ§æ Œ</td>
<td colspan="2">
D åœäººã¯äººã®é£ã«åº§ããããªããäžçªè¿ã人ãšã®è·é¢ããäžçªå€§ãããªãæ€
åã«åº§ãããšãããåæ¡ä»¶ã®æ€
åãè€æ°ããå Žåããã©ãããŠã誰ãã®é£ã«åº§ããªããã°ãªããªãå Žåããã®äžã§äžçªå·ŠåŽã«ããæ€
åã«åº§ãã誰ã座ã£ãŠããªãå Žåã¯å·Šç«¯ã®æ€
åã«åº§ãã
</td>
</tr>
</table>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_chair6">
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_chair7">
<br/>
<br/>
</center>
<p>
ãã³ãã€å·ã«ä¹ãããšããŠããä¹å®¢ã®æ
å ±ãå
¥åãšãã æ€
åã«ã©ã®ããã«åº§ã£ãŠããããåºåããããã°ã©ã ãäœæããŠãã ãããå·Šããé çªã«åº§ã£ãŠãã人ã®åœç±ãåºåããŸãããã ãã空åžã®å Žå㯠# (åè§ã·ã£ãŒã)ãåºåããŠãã ããã
</p>
<H2>Input</H2>
<p>
è€æ°ã®ããŒã¿ã»ããã®äžŠã³ãå
¥åãšããŠäžããããŸãã å
¥åã®çµããã¯ãŒããµãã€ã®è¡ã§ç€ºãããŸãã
åããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããŸãã
</p>
<pre>
<var>n</var> <var>m</var>
<var>a<sub>1</sub></var>
<var>a<sub>2</sub></var>
:
<var>a<sub>m</sub></var>
</pre>
<p>
1 è¡ç®ã«æ€
åã®æ° <var>n</var> (1 ≤ <var>n</var> ≤ 100) ãšä¹å®¢ã®æ° <var>m</var> (<var>m</var> ≤ <var>n</var>) ãäžããããŸããç¶ã <var>m</var> è¡ã« <var>i</var> 人ç®ã®æ
å ± <var>a<sub>i</sub></var> ãäžããããŸãã<var>a<sub>i</sub></var> ã¯ïŒã€ã®æåã§ã'A' ãªãã° A åœäººã'B' ãªãã° B åœäººã'C' ãªãã° C åœäººã'D' ãªãã° D åœäººãè¡šããŸãã
</p>
<p>
ããŒã¿ã»ããã®æ°ã¯ 100 ãè¶
ããŸããã
</p>
<H2>Output</H2>
<p>
ããŒã¿ã»ããããšã«ãæçµçãªæ€
åã®ç¶æ
ãïŒè¡ã«åºåããŸãã
</p>
<H2>Sample Input</H2>
<pre>
5 4
A
B
C
D
5 4
D
C
B
A
0 0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
ACD#B
DCA#B
</pre>
| [
[
"5 4\nA\nB\nC\nD\n5 4\nD\nC\nB\nA\n0 0\n",
"5 4\nA\nB\nC\nD\n5 4\nD\nC\nB\nA\n0 0\n"
]
] |