question_id
stringlengths
6
6
content
stringlengths
1
27.2k
p03522
<span class="lang-en"> <p>Score : <var>1500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a sequence <var>A</var> of length <var>N</var>.</p> <p>On this sequence, we can perform the following two kinds of operations:</p> <ul> <li> <p>Swap two adjacent elements.</p> </li> <li> <p>Sel...
p03488
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>A robot is put at the origin in a two-dimensional plane. Initially, the robot is facing in the positive <var>x</var>-axis direction.</p> <p>This robot will be given an instruction sequence <var>s</var>....
p03172
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There are <var>N</var> children, numbered <var>1, 2, \ldots, N</var>.</p> <p>They have decided to share <var>K</var> candies among themselves. Here, for each <var>i</var> (<var>1 \leq i \leq N</var>), C...
p02011
<h1>Problem H. Enlarge Circles</h1> <!-- Time Limit: 2 sec Memory Limit: 512 MB --> <p> You are given $N$ distinct points on the 2-D plane. For each point, you are going to make a single circle whose center is located at the point. Your task is to maximize the sum of perimeters of these $N$ circles so that circles ...
p00186
<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> ...
p02441
<h1>Count</h1> <p> For a given sequence of integers $A = \{a_0, a_1, ..., a_{n-1}\}$, perform the following operations. </p> <ul> <li>count($b, e, k$): print the number of the specific values $k$ in $a_b, a_{b+1}, ..., a_{e-1}$. </ul> <h2>Input</h2> <p> The input is given in the following format. </p> <pre>...
p03600
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>In Takahashi Kingdom, which once existed, there are <var>N</var> cities, and some pairs of cities are connected bidirectionally by roads. The following are known about the road network:</p> <ul> <li>Peo...
p02912
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Takahashi is going to buy <var>N</var> items one by one.</p> <p>The price of the <var>i</var>-th item he buys is <var>A_i</var> yen (the currency of Japan).</p> <p>He has <var>M</var> discount tickets, ...
p01797
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type='text/javascript' src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script> </script> <h2>Problem H Kimagure Cleaner</h2...
p00885
<H1><font color="#000">Problem B:</font> Balloon Collecting</H1> <p> "Balloons should be captured efficiently", the game designer says. He is designing an oldfashioned game with two dimensional graphics. In the game, balloons fall onto the ground one after another, and the player manipulates a robot vehicle on the gr...
p03250
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You have decided to give an allowance to your child depending on the outcome of the game that he will play now.</p> <p>The game is played as follows:</p> <ul> <li>There are three "integer panels", each ...
p01778
<h2>G: Dungeon of Cards / カードの迷宮</h2> <h3>物語</h3> <p>ここは不思議の国あじふらい.あじふらい辺境の地に位置するカードの迷宮には,金銀財宝が眠ると伝えられている.好奇心旺盛なあいずにゃんは,この言い伝えを聞くやいなや,友人のウィを連れてカードの迷宮を目指す旅に出ることにした.</p> <p>翌日,旅の計画を立てるためにあいずにゃんがウィの家を訪れると,ウィは何やら考え込んでいるようだった.どうやら用意周到なウィはカードの迷宮に関する重要な情報を入手したようだ.それは,カードの迷宮には <var>N</var> 枚の扉があり,それぞれの扉を開けるためにカードが必要になるとい...
p03745
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You are given an array <var>A</var> of length <var>N</var>. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-incre...
p02857
<span class="lang-en"> <p>Score: <var>800</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3> <p><font color="red"><strong>This is an interactive task.</strong></font></p> <p>We have <var>2N</var> balls arranged in a row, numbered <var>1, 2, 3, ..., 2N</var> from left to right, where <var>N</var> i...
p01282
<H1><font color="#000">Problem J:</font> Revenge of the Round Table</H1> <p> Two contries A and B have decided to make a meeting to get acquainted with each other. <i>n</i> ambassadors from A and B will attend the meeting in total. </p> <p> A round table is prepared for in the meeting. The ambassadors are getting se...
p01328
<h1><font color="#000">Problem H:</font> 迷い猫、走った</h1> <p>洋菓子専門店ストレイキャッツではたくさんの猫が飼われている。猫の数があまりにも多いため、この店のスタッフである希は餌やりに困っていた。 いくつかの場所に餌を置いても、猫は貪欲なので最も近い餌に向かってしまい、一つの餌入れにたくさんの猫が集中してしまう。 あなたは希のために、できるだけ猫が集中しない餌の配置を求める問題を解くことにした。</p> <p>問題を簡単にするため、猫は平面上の y&gt;0 の部分にいて餌を置くまで動かないとする。 猫は N 個の集団に分かれていて、一箇所に何匹もいるかもしれない。 餌入...
p03315
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There is always an integer in Takahashi's mind.</p> <p>Initially, the integer in Takahashi's mind is <var>0</var>. Takahashi is now going to eat four symbols, each of which is <code>+</code> or <code>-<...
p02154
<h1>Problem F: Equilateral Triangle</h1> <h2>Problem</h2> <p>$N$個の頂点からなる凸多角形が与えられる。</p> <p>その凸多角形の全ての頂点を含む正三角形を考えるとき、その正三角形の一辺の長さの最小値を求めよ。</p> <p></p> <h2>Input</h2> <p>入力は以下の形式ですべて整数で与えられる。</p> <pre> $N$ $px_1$ $py_1$ $px_2$ $py_2$ $\vdots$ $px_N$ $py_N$ </pre> <p> $1$行目には凸多角形の頂点数を表す整数$N$が与えられる。<br> 続く$N$行には凸多角形...
p00169
<H1>ブラックジャック</H1> <p> ブラックジャックはカジノで行われるカードゲームの一種で、1 〜 13 までの数が書かれたカードを使ってゲームが行われます。各カードの点数は次のように決まっています。 </p> <ul> <li>1 は 1 点あるいは 11 点</li> <li>2 から 9 までは、書かれている数の通りの点数</li> <li>10 から 13 までは、10 点</li> </ul> <p> このゲームには親を含めた何人かの参加者がおり、それぞれが何枚かのカードの組を持っています。このカードの組のことを手と呼びます。手の点数はカードの点数の合計です。その計算は次のように行うものとします。 ...
p00493
<H1>ジグザグ数 (Zig-Zag Numbers) </H1> <h2> 問題</h2> <p> 正の整数を (先頭に 0 をつけずに) 10 進法で書いて桁の数字を順番に見ていくと増加と減少を交互に繰り返しているとき,その数は「ジグザグ数」であると呼ぶことにしよう.たとえば,2947 は桁の数字が 2 → 9 → 4 → 7 と,増加 → 減少 → 増加 の順になっているのでジグザグ数である.また,71946 は 減少 → 増加 → 減少 → 増加 の順なのでジグザグ数である.一方,123 や 71446 や 71442 や 88 はジグザグ数ではない.なお,1 桁の正の整数はジグザグ数であると考えることとする...
p00539
<h2>JOI 公園 (JOI Park)</h2> <p> 20XX 年に IOI 国で行われるオリンピックに備え,IOI 国にある JOI 公園を整備することになった.JOI公園には <var>N</var> 個の広場があり,広場には 1 から <var>N</var> の番号がついている.広場を繋ぐ <var>M</var> 本の道があり,道には 1 から <var>M</var> の番号がついている.道 <var>i</var> (1 &le; <var>i</var> &le; <var>M</var>) は広場 <var>A<sub>i</sub></var> と広場 <var>B<sub>i</sub></v...
p01001
<h1>Problem C: General of Taiko</h1> <h2>Problem</h2> <p> とあるゲームセンターには、曲に合わせて流れてくる譜面通りに和太鼓を叩くゲームがあります。 譜面は長さ<var> L </var>のセルからなり、各セルには何もない、またはノートと呼ばれるプレイヤーがとるべき行動を表した記号があります。 ノートは2種類ありそれぞれ、和太鼓の面を叩く「トン」、和太鼓の縁を叩く「コツ」があります。 これらのノートに合わせて和太鼓を叩くと得点を得ることができます。 この得点の合計が10000点以上であればクリアとなります。 </p> <p> このとき、プレイヤーが曲をクリアできる確率...
p01451
<H1>Problem E: 街を駆ける道</H1> <p> ネーヴァ王国には、トタタ族とツテテ族、2種類の民族が暮らしている。トタタ族の最大の特徴は、 酢豚にパイナップルを入れて食べることである。だがツテテ族は、パイナップルに酢豚を入れて食べ る。こんな2つの民族がお互いに仲良くやっていけるはずもなく、トタタ族とツテテ族は、何百年も の昔からずっといがみ合いを続けてきた。 </p> <p> そんなある日、ネーヴァ王のもとに、2つの民族から嘆願書が届いた。それによるとトタタ族は、自 分たちが暮らす街Aと街Bのあいだを結ぶ道を建設してほしいらしい。一方でツテテ族も、自分たち が暮らす街Cと街Dのあいだを結ぶ道を建設してほしい...
p03196
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There are <var>N</var> integers <var>a_1, a_2, ..., a_N</var> not less than <var>1</var>. The values of <var>a_1, a_2, ..., a_N</var> are not known, but it is known that <var>a_1 \times a_2 \times ... \...
p01902
<link rel="stylesheet" href="css/description.css" type="text/css" /> <script language="JavaScript" type="text/javascript" src="js/varmath.js" charset="UTF-8"></script> <h2>E: 鬼畜ババ抜き - Unbalanced Old Maid -</h2> <h3>物語</h3> <p>高坂さんと園田さんと南さんは子供の頃からの仲良し3人組だ。3人は沖縄に修学旅行に行くも、台風が来てしまい、海で遊ぶことができないのでババ抜きをすることにした。</p> <p>...
p00610
<H1><font color="#000000">Problem F:</font> Cleaning Robot 2.0</H1> <p> Dr. Asimov, a robotics researcher, released cleaning robots he developed (see Problem B). His robots soon became very popular and he got much income. Now he is pretty rich. Wonderful. </p> <p> First, he renovated his house. Once his house had...
p00240
<H1>金利計算</H1> <p> 金利は銀行に預けているお金に付き、その計算方法や利率は銀行によって様々です。利息と元金を合わせたものを元利と呼びますが、元利の計算方法として、利息を元金に組み入れずに計算する「単利」と利息を元金に組み入れて計算する「複利」というものがあり、より多くの元利を得るためにはこの差異を理解していなければなりません。元利の計算方法は以下のようになります。 </p> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_0240_1"><br> <br> <img src="https://judgeapi....
p03895
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Takahashi recorded his daily life for the last few days as a integer sequence of length <var>2N</var>, as follows:</p> <ul> <li><var>a_1, b_1, a_2, b_2, ... , a_N, b_N</var></li> </ul> <p>This means tha...
p02787
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Ibis is fighting with a monster.</p> <p>The <em>health</em> of the monster is <var>H</var>.</p> <p>Ibis can cast <var>N</var> kinds of spells. Casting the <var>i</var>-th spell decreases the monster's h...
p02292
<H1>Counter-Clockwise</H1> <br/> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_CGL_CGL_1_C"> </center> <p> For given three points <var>p0, p1, p2</var>, print </p> <pre> COUNTER_CLOCKWISE </pre> <p> if <var>p0, p1, p2</var> make a counterclockwise turn (1), </p> <pre> CLOCKWISE </pre> <p...
p01847
<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-AMS_HTML"> </script> <h3>カーテン</h3> <p>もうすぐ夏がやってくる.あなたは夏に向けて部屋の模様替えをするこ...
p00755
<h3><U>Identically Colored Panels Connection</U></h3> <!-- end en only --> <div> <!-- please enclose each h3 level section with div --> <!-- begin en only --> <p> Dr. Fukuoka has invented fancy panels. Each panel has a square shape of a unit size and has one of the six colors, namely, yellow, pink, red, purple,...
p02768
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Akari has <var>n</var> kinds of flowers, one of each kind.</p> <p>She is going to choose one or more of these flowers to make a bouquet.</p> <p>However, she hates two numbers <var>a</var> and <var>b</va...
p00305
<h1>枠</h1> <p> 画像の中から有益な情報を抽出する画像認識はコンピュータサイエンスの中でも重要な研究テーマのひとつです。デジタルカメラ、運転支援システム、防犯システムなどに幅広く応用されています。 </p> <p> このような研究のおかげで、私たちは画像解析を行うための多くのソフトウェアやプログラム集を使い様々な処理を行うことができます。一方、自力でプログラムを書いて解析することで、その仕組みを知り、楽しい時間を過ごすことができます。ここでは、一風変わった画像認識をしてみましょう。 </p> <p> 画像として次のような各ピクセルが整数の値を持つ <var>N</var> &times; <var>N</v...
p02338
<!--<h1>写像12相 その8:ボールに区別あり・箱に区別なし・箱の中身は1つ以下</h1>--> <h1>Balls and Boxes 8</h1> <table border=""> <tr><th>Balls</th><th>Boxes</th><th>Any way</th><th>At most one ball</th><th>At least one ball</th></tr> <tr><th>Distinguishable</th><th>Distinguishable</th><td>1</td><td>2</td><td>3</td></tr> <tr><th>Indistinguishab...
p03483
<span class="lang-en"> <p>Score : <var>800</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You are given a string <var>S</var> consisting of lowercase English letters. Determine whether we can turn <var>S</var> into a palindrome by repeating the operation of swapping two adjacent characters. ...
p03179
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Let <var>N</var> be a positive integer. You are given a string <var>s</var> of length <var>N - 1</var>, consisting of <code>&lt;</code> and <code>&gt;</code>.</p> <p>Find the number of permutations <var...
p01144
<!-- begin en only --> <h3><U> Princess' Marriage </U></h3> <!-- end en only --> <!-- begin ja only --> <h3><U> お姫様の嫁入り </U></h3> <!-- end ja only --> <!-- begin en only --> <p> English text is not available in this practice contest. </p> <!-- end en only --> <!-- begin ja only --> <p> ある貧乏な国のおてんばで勇敢なお姫様は,ギャンブルの配...
p03529
<span class="lang-en"> <p>Score : <var>1000</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Consider the following game:</p> <ul> <li>The game is played using a row of <var>N</var> squares and many stones.</li> <li>First, <var>a_i</var> stones are put in Square <var>i\ (1 \leq i \leq N)</var>...
p01514
<!-- begin en only --> <h3><u>You Are the Judge </u></h3> <!-- end en only --> <!-- begin ja only --> <h3><u>審判は君だ! </u></h3> <!-- end ja only --> <div> <!-- begin en only --> <p> English text is not available in this practice contest. </p> <!-- end en only --> <!-- begin ja only --> <p> あなたはプログラミングコンテスト iCPC の審判だ。今日...
p03207
<span class="lang-en"> <p>Score : <var>200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>In some other world, today is the day before Christmas Eve.</p> <p>Mr. Takaha is buying <var>N</var> items at a department store. The regular price of the <var>i</var>-th item <var>(1 \leq i \leq N)</va...
p04038
<span class="lang-en"> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke loves colorful balls. He has a total of <var>N×K</var> balls, <var>K</var> in each of his favorite <var>N</var> colors. The colors are numbered <var>1</var> through <var>N</var>.</p> <p>He will arrange all of the balls in a row from ...
p03657
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is giving cookies to his three goats.</p> <p>He has two cookie tins. One contains <var>A</var> cookies, and the other contains <var>B</var> cookies. He can thus give <var>A</var> cookies, <var>B</...
p02945
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have two integers: <var>A</var> and <var>B</var>.</p> <p>Print the largest number among <var>A + B</var>, <var>A - B</var>, and <var>A \times B</var>.</p> </section> </div> <div class="part"> <sectio...
p00978
<h2>Sixth Sense</h2> <p> Ms. Future is gifted with precognition. Naturally, she is excellent at some card games since she can correctly foresee every player's actions, except her own. Today, she accepted a challenge from a reckless gambler Mr. Past. They agreed to play a simple two-player trick-taking card game. </p...
p01390
<script src="./IMAGE/varmath.js" charset="UTF-8"></script> <h1><font color="#000">問題 C </font> しりとり</h1> <h2>問題文</h2> <p>なんとなく暇だったのでしりとりの AI を作って AI としりとりをすることにした.しりとりとは <var>2</var> 人で遊ぶゲームで,両者の間でまだ一度も発言されておらず,(最初の手番を除いて) 先頭の文字が直前の単語の最後の文字となっている単語を交互に言い合うゲームである.</p> <p>今回 AI に単語の判定を実装するのが面倒だったので,単語の定義はアルファベットの小文字か...
p02416
<H1>Sum of Numbers</H1><br> <p> Write a program which reads an integer and prints sum of its digits. </p> <H2>Input</H2> <p> The input consists of multiple datasets. For each dataset, an integer <var>x</var> is given in a line. The number of digits in <var>x</var> does not exceed 1000. </p> <p> The input ends...
p02046
<h3>避けるべし</h3> <!-- begin ja only --> <p>あなたはいま,上下左右に広大に広がるマス目の原点に当たる位置 <i>(0, 0)</i> にいる.マスの位置は<i>x</i>座標と<i>y</i>座標で表され,右に1マス動くことが<i>x</i>座標が1つ増えることに対応し,上に1マス動くことが<i>y</i>座標が1つ増えることに対応する.あなたはこれから目的地であるマス <i>(x, y)</i> を目指して出発するところだ.あなたは 1 歩で上下左右斜めの 8 方向に隣接するマスに移動することができる.</p> <p>さあ,目的地に向かって移動開始だ!とあなたは意気込んでいるところかもしれ...
p00581
<h1>勇者ビ太郎(Bitaro the Brave)</h1> <p> 勇者のビ太郎は,魔王と対峙することとなった. </p> <p> ビ太郎は,縦$H$ 行,横$W$ 列のマス目上に宝石(Jewel),オーブ(Orb),金塊(Ingot) を配置し,魔法を発動することによって魔王に攻撃をしようとしている.以下,マス目のうち上から$i$ 行目($1 \leq i \leq H$),左から$j$ 列目($1 \leq j \leq W$) のマスを,マス($i, j$) と表す. </p> <p> ビ太郎は今,それぞれのマスにこれら3 種類のうち1 個を配置した.今から魔法を発動しようとしているが,この魔法の威力はマ...
p00094
<H1>坪面積の計算</H1> <p> 土地の面積を表現する「○○坪」という単位を聞いたことはないでしょうか? 古来、1人の武士が1日に食べるお米を作る面積を言いました。 </p> <p> <var>a</var>[m]&times; <var>b</var>[m]の土地があります。<var>a</var> と <var>b</var> を入力し、その土地の坪面積 <var>S</var>[坪]を出力するプログラムを作成してください。 1 坪 = 3.305785 [m<sup>2</sup>] とし、<var>a</var> と <var>b</var> は 100 以下の整数とします。 </p> <H2>入力</...
p02553
<span class="lang-en"> <p>Score : <var>200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Given are integers <var>a,b,c</var> and <var>d</var>. If <var>x</var> and <var>y</var> are integers and <var>a \leq x \leq b</var> and <var>c\leq y \leq d</var> hold, what is the maximum possible value ...
p02103
<h1>Problem F: Great Devil Sakanikia</h1> <h2>Problem</h2> <p> 大悪魔サカーニャは今日も天敵の猫に襲われていた。<br> いつもやられている訳にはいかないので、秘密兵器を購入した。<br> この秘密兵器は、巨大な岩を生成することで猫の移動経路を塞ぎ、猫がこちらに近づけないようにすることができる。<br> </p> <p> 今、サカーニャと一匹の猫がマス(0,0),(<var>n</var>&minus;1,0),(<var>n</var>&minus;1,<var>m</var>&minus;1),(0,<var>m</var>&minus;1)で囲まれた長方形の...
p01685
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script> <h3>Problem Statement</h3> <p>...
p00997
<h1>Problem H : Dungeon (II)</h1> <p> あなたはとあるゲームの開発に携わっている。 そのゲームはランダムに生成されたダンジョンをプレイヤーが探索するというものである。 ゲームの仕様として、プレイヤーに予めダンジョンの危険度を提示し、生成されたダンジョンを探索するのか、それとも新しくダンジョンを生成しなおすかを、選択できるようにしたい。 </p> <p> このゲームで生成されるダンジョンには<i>n</i> 個の部屋が存在しており、0から <i>n-1</i> までの番号が割り振られている。 部屋と部屋は通路で結ばれている。部屋と部屋を結ぶ通路は、合計で <i>n-1</i> 本存在している...
p03342
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There is an integer sequence <var>A</var> of length <var>N</var>.</p> <p>Find the number of the pairs of integers <var>l</var> and <var>r</var> (<var>1 \leq l \leq r \leq N</var>) that satisfy the follo...
p03712
<span class="lang-en"> <p>Score : <var>200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You are given a image with a height of <var>H</var> pixels and a width of <var>W</var> pixels. Each pixel is represented by a lowercase English letter. The pixel at the <var>i</var>-th row from the top ...
p02800
<span class="lang-en"> <p>Score : <var>1100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have an <var>H \times W</var> grid, where each square is painted white or black in the initial state. Given are strings <var>A_1, A_2, ..., A_H</var> representing the colors of the squares in the in...
p00217
<H1>ウォーキング</H1> <p> 会津リバーサイドホスピタルでは、リハビリと健康増進のため、入院患者が一日二回のウォーキングを行っています。元気に退院するために、ウォーキングで体力を回復しようと頑張る人が日に日に増えきたことから、院長が「一日で一番長い距離を歩いた人にプレゼントをあげよう!」という企画を立ち上げました。 </p> <!-- <p> 会津リバーサイドホスピタルでは、リハビリと健康増進のため、入院患者が一日二回のウォーキングを行っています。元気に退院するために、ウォーキングで体力を回復しようと頑張る人が日に日に増えていきました。健康になるにつれ、気持ちも明るく笑顔も見られるようになったことから、院長先...
p02380
<H1>Triangle</H1><br> <p> For given two sides of a triangle <i>a</i> and <i>b</i> and the angle <i>C</i> between them, calculate the following properties: </p> <ul> <li><var>S</var>: Area of the triangle</li> <li><var>L</var>: The length of the circumference of the triangle</li> <li><var>h</var>: The height ...
p03968
<span class="lang-en"> <p>Score : <var>900</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>AtCoDeer the deer has <var>N</var> square tiles. The tiles are numbered <var>1</var> through <var>N</var>, and the number given to each tile is written on one side of the tile. Also, each corner of each...
p01955
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], skipTags: ["script","noscript","style","textarea","code"], processEscapes: true }}); </script> <script type="text/javascript" async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config...
p00647
<h1>Problem A: It's our delight!!</h1> <p> You are a student of University of Aizu. And you work part-time at a restaurant. </p> <p> Staffs of the restaurant are well trained to be delighted to provide more delicious products faster. </p> <p> The speed providing products particularly depends on skill of the staff. S...
p01406
<h2> Problem I: カスタムペイント職人 </h2> <p> slipはとあるレーシングゲームの動画が好きである。 といっても、車が走っている動画が好きであるわけではなく、このゲームに搭載されたカスタムペイントカー作成という機能によって、車体をカスタマイズする動画が好きなのである。 これは、円や多角形などといった基本的な幾何学図形を重ねあわせることで、車体にカスタムペイントができる機能である。 </p> <p> このカスタムペイントによって様々なアートを創りだす、いわゆる職人と呼ばれる人々がいる。 職人達の手にかかれば、車体にガリガリしたアイスキャンディーのキャラクターや、アイドルをプロデュースして楽しむゲ...
p03591
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Ringo is giving a present to Snuke.</p> <p>Ringo has found out that Snuke loves <em>yakiniku</em> (a Japanese term meaning grilled meat. <em>yaki</em>: grilled, <em>niku</em>: meat). He supposes that Sn...
p01056
<h1>Lights of Apartment</h1> <h2>Problem</h2> <p> エーちゃんとリカちゃんとハルトくんはマンションに遊びに来た。<br> 3人は全ての部屋の電気を管理できる部屋に忍び込みいたずらをすることにした。<br><br> このマンションは<var>n</var>個の立方体が1列に並んでいる形をしている。<br> 各立方体は西から順に1辺の長さが1ずつ増えていて(1,2,3,...,<var>n</var>)、<var>i</var>番目の立方体は<var>i</var>階あり、各階に縦<var>i</var>×横<var>i</var>個の部屋がある。<br> 2番目以降の立方体の西側...
p01543
<h1>まるかいて</h1> <p> 太郎君は小学生で、チラシの裏に落書きをしています。 ある時、太郎君は次のゲームを思いつきました。 </p> <ul> <li><var>n&times;n</var>の格子状のマス目を書いておきます。 </li><li>それぞれのマス目の初期状態は、丸印が書かれているか、書かれていないかのどちらか一方です。 </li><li>これらの丸印を消したり書いたりして最終的にどの一列を見ても必ずちょうど1つのみの丸印が、どの一行を見ても必ず1つのみの丸印が存在するようにすることが目標であり、この状態にすればゲームをクリアしたことになります。 </li></ul> <p> 太郎君はこのゲームを...
p03084
<span class="lang-en"> <p>Score : <var>1200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>In Takaha-shi, the capital of Republic of AtCoder, there are <var>N</var> roads extending east and west, and <var>M</var> roads extending north and south. There are no other roads. The <var>i</var>-th ...
p01113
<h3>Floating-Point Numbers</h3> <!-- end en only --> <!-- begin en only --> <p> In this problem, we consider floating-point number formats, data representation formats to approximate real numbers on computers. </p> <!-- end en only --> <!-- begin en only --> <p> Scientific notation is a method to express a number, ...
p00352
<H1>Handsel</H1> <!-- New Year’s gift money --> <p> Alice and Brown are brothers in a family and each receives pocket money in celebration of the coming year. They are very close and share the total amount of the money fifty-fifty. The pocket money each receives is a multiple of 1,000 yen. </p> <p> Write a progr...
p03987
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>One day, Snuke was given a permutation of length <var>N</var>, <var>a_1, a_2, ..., a_N</var>, from his friend.</p> <p>Find the following:</p> <p><img src="https://atcoder.jp/img/agc005/520049e1a049bb981...
p02695
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Given are positive integers <var>N</var>, <var>M</var>, <var>Q</var>, and <var>Q</var> quadruples of integers ( <var>a_i</var> , <var>b_i</var> , <var>c_i</var> , <var>d_i</var> ).</p> <p>Consider a seq...
p01810
<h2>監獄</h2> <p>無限人の囚人たちがいる。はじめ、囚人たちは <var>0, 1, 2,</var> ... と番号が振られている。</p> <p>次の操作を <var>N</var> 回行う。</p> <ul> <li><var>0</var> 番目の囚人を釈放し、<var>k, 2k, 3k,</var> ... 番目の囚人たちを処刑する。</li> <li>その後、残った囚人たちに番号を振り直す。このとき、元の番号が小さい囚人から順に <var>0, 1, 2, </var> ... と番号を振る。</li> </ul> <p><var>N</var> 回目の操作で釈放される囚人がはじめに振られていた番...
p00702
<h1> Kanglish : Analysis on Artificial Language </h1> <p>The late Prof. Kanazawa made an artificial language named Kanglish, which is similar to English, for studying mythology. Words and sentences of Kanglish are written with its own special characters called "Kan-characters". The size of the set of the Kan-char...
p00597
<H1><font color="#000000">Problem C:</font> Finding the Largest Carbon Compound Given Its Longest Chain</H1> <p> An bydrocarbon is an organic compound which contains only carbons and hydrogens. An isomer is a compound that has the same number of carbons but different structures. Heptane, for example, is a hydrocarbon...
p02050
<h3>Kは多角形のケイ</h3> <!-- begin ja only --> <p>「<i>1</i> 番じゃなきゃダメですか?<i>K</i> 番じゃダメなんでしょうか?」</p> <p>これがケイ氏の座右の銘である.最近ケイ氏はもっぱら多角形に興味があるようで,目の前に広がる広大な二次元平面上に置かれた <i>N</i> 個の点を見て,そこから多角形を形成する方法について思いを馳せている.ケイ氏はどうやら,この <i>N</i> 個の点のうちいくつかの点を選んで自由な順番で繋げることで,選んだ点を頂点とする多角形を構成することにしたようだ.ただし,多角形は以下の条件を満たす必要がある.</p> <ul> <li>単純多角...
p02400
<H1>Circle</H1> <p> Write a program which calculates the area and circumference of a circle for given radius <var>r</var>. </p> <H2>Input</H2> <p> A real number <var>r</var> is given. </p> <H2>Output</H2> <p> Print the area and circumference of the circle in a line. Put a single space between them. The output shou...
p01386
<div> <h1 class="title">問題 K : 巡回セールスマン問題</h1> <p>2011 年のあの頃,まだプログラミングコンテストはとても平和であり, 我々はルールを精読せずに気軽にコンテストに参加していた. しかし,そこに G○○gle の陰謀は迫っていた. ある日,G○○gle によって秘密裏に買収されていた T○pC○der のコンテストは, 人知れずうちにルールが改変されており,命がけのプログラミングコンテストとなっていた. そして僕は,そこで,何も知らず, まっ先に kita_masa のプログラムのオーバーフローを突いたのだ….</p> <dl class="docutils"> <dt>(...
p02953
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There are <var>N</var> squares arranged in a row from left to right. The height of the <var>i</var>-th square from the left is <var>H_i</var>.</p> <p>For each square, you will perform either of the foll...
p03641
<span class="lang-en"> <p>Score : <var>800</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Let <var>N</var> be a positive even number.</p> <p>We have a permutation of <var>(1, 2, ..., N)</var>, <var>p = (p_1, p_2, ..., p_N)</var>. Snuke is constructing another permutation of <var>(1, 2, ..., ...
p03211
<span class="lang-en"> <p>Score : <var>200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There is a string <var>S</var> consisting of digits <code>1</code>, <code>2</code>, <var>...</var>, <code>9</code>. Lunlun, the Dachshund, will take out three consecutive digits from <var>S</var>, treat...
p02816
<span class="lang-en"> <p>Score : <var>600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Given are two sequences <var>a=\{a_0,\ldots,a_{N-1}\}</var> and <var>b=\{b_0,\ldots,b_{N-1}\}</var> of <var>N</var> non-negative integers each.</p> <p>Snuke will choose an integer <var>k</var> such that...
p03704
<span class="lang-en"> <p>Score : <var>800</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>For a positive integer <var>n</var>, we denote the integer obtained by reversing the decimal notation of <var>n</var> (without leading zeroes) by <var>rev(n)</var>. For example, <var>rev(123) = 321</var...
p01739
<p> You are a programmer who loves pretty girl games (a sub-genre of dating simulation games). A game, which is titled "Floatable Heart" and was released last Friday, has arrived at your home just now. This game has multiple stories. When you complete all of those stories, you can get a special figure of the main heroi...
p03354
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a permutation of the integers from <var>1</var> through <var>N</var>, <var>p_1</var>, <var>p_2</var>, .., <var>p_N</var>. We also have <var>M</var> pairs of two integers between <var>1</var> and...
p01369
<!-- begin en only --> <h3><U>koukyoukoukokukikou</U></h3> <!-- end en only --> <!-- begin ja only --> <!-- end ja only --> <div> <!-- begin en only --> <p> English text is not available in this practice contest. </p> <!-- end en only --> <!-- begin ja only --> <p> ACM-ICPC を愛する誰もが手から喉が出るほど欲しがるもの, それが Accepted. 略...
p00981
<h2>Wall Painting</h2> <p> Here stands a wall made of a number of vertical panels. The panels are not painted yet. </p> <p> You have a number of robots each of which can paint panels in a single color, either red, green, or blue. Each of the robots, when activated, paints panels between a certain position and anot...
p01693
<h2>G - Derangement / 完全順列</h2> <h3>Story</h3> <p>Dのひとは順列に関する研究をしている。あるときDのひとは、&quot;完全順列 (Derangement)&quot;という順列のクラスを見つけた。「完全な順列とかなんかかっこいい!!!しかもDからはじまる!!!」と廚二病をこじらせたDのひとは、与えられた順列をすべて完全順列に書き換えてしまおうと考えた。</p> <h3>Problem</h3> <p>長さ<var>n</var>の順列<var>p</var> <var>=</var> <var>(p_1</var> <var>p_2</var> <var>...</var>...
p00128
<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>' (半角空白)、'<sp...
p02115
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h1>Problem E: Piano</h1> <h2>Problem</h2> <p> がっちょ君はピアノを弾こうとしている。ピアノは右側にある鍵盤ほど高い音が出る。がっちょ君はある楽譜を持っており、その楽譜に従って弾く。 </p> <p> 楽譜には、ある時刻にどの鍵盤を弾くべきかを示す音符が時系列順に記載されている。この楽譜には和音(複数の鍵盤...
p00578
<h1>日本沈没 (Japan Sinks)</h1> <!--  時間制限 : 2sec / メモリ制限 : 256MB--> <h2>問題文</h2> <p> 日本列島は細長い列島である.日本列島は平行な境界線により <var>N</var> 個の区画に分けられている.区画には端から順に <var>1</var> から <var>N</var> の番号が付けられている.区画 <var>i</var> (<var>1 ≦ i ≦ N</var>) の高さは <var>A_i</var> である. </p> <p> 日本列島は海に囲まれており,海面の高さは場所によらず一定である.高さが海面の高さより高い区画を<strong>陸...
p02545
<span class="lang-en"> <p>Score : <var>1800</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Given are integer sequences <var>A</var> and <var>B</var> of length <var>3N</var>. Each of these two sequences contains three copies of each of <var>1, 2, \dots, N</var>. In other words, <var>A</var> a...
p00082
<H1>メリーゴーランド</H1> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_10_1"> </center><br/> <p> 遊園地にあるメリーゴーランドはご存じでしょう。大きな円盤の上に馬や馬車などの乗り物が固定されていて、円盤が回転すると同時に乗り物が上下に揺れる、定番の遊具です。ある遊園地のメリーゴーランドは、4人乗りの馬車が2台、2人乗りの車2台、1人乗りの馬が4台、計8台の乗り物が図1のような順序で備えられています。そして、遊園地においでのお客様は、図1に示す乗り場0〜7のどこかで待つようになっています。 ...
p01040
<h1>Problem D: Friday the 13th</h1> <h2>Problem</h2> <p> 今年も「立命館大学競技プログラミング合宿」が開催されることとなった。僕は毎年開催されるこの合宿をとても楽しみにしている。しかし、欲望に耐え切れず合宿前に散財してしまい、お金に余裕が無くなってしまった。そこで僕は、立命館大学の最寄り駅である南草津まで移動するのに最も安く済む青春18きっぷを使うことにした。この切符は安く済む代わりに乗り換えが多く発生し、移動に丸1日使わなければならないのでとても疲れる。そんな移動をする日が13日の金曜日であることに気づいたのは会津若松駅を出発した後だった。僕は12時間、不安を感じながら電車...
p03587
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke prepared <var>6</var> problems for a upcoming programming contest. For each of those problems, Rng judged whether it can be used in the contest or not.</p> <p>You are given a string <var>S</var> o...
p01410
<H1>D: Dangerous Tower</H1> <p> ICPC で良い成績を収めるには修行が欠かせない.うさぎは ICPC で勝ちたいので,今日も修行をすることにした. </p> <p> 今日の修行は,積み木を丁寧に積み上げることによって,決してミスタイピングをしないほどの手先の器用さを手に入れようというものである.せっかく積み木がたくさんあるので,高い塔を作ろう. </p> <p> 積み木は <i>N</i> 個あり,<i>i</i> 番目 (1 &le; <i>i</i> &le; <i>N</i>) の積み木は 1 &times; <i>A</i><sub><i>i</i></sub> &times; <i>B...
p00651
<h1>Problem E: Legend of Storia</h1> <p> In Storia Kingdom, there is an artifact called "Perfect Sphere" made by a great meister Es. This is handed down for generations in the royal palace as a treasure. Es left a memo and filled mysterious values in it. Within achievements of researches, it has been revealed that the...
p01943
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']], skipTags: ["script","noscript","style","textarea","code"]} }); </script> <script type="text/javascript" async src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML"> </script> <h2>...
p02396
<H1>Print Test Cases</H1> <p> In the online judge system, a judge file may include multiple datasets to check whether the submitted program outputs a correct answer for each test case. This task is to practice solving a problem with multiple datasets. </p> <p> Write a program which reads an integer <var>x</var> and ...
p00201
<h1>錬金マスター</h1> <p> あなたはついに魔法の釜、錬金釜を手に入れました。錬金釜に複数のアイテムを入れると、新しいア イテムを作ることができます。新しく作ったアイテムは、他のアイテムを作るために錬金釜へ入れることもできます。アイテムを作るために必要なアイテムのリストを記したものを錬金レシピと呼ぶことにします。以下の 3 つは錬金レシピの例です。 </p> <ol> <li> 木片と糸でラケットができる。</li> <li> お米と水でおにぎりができる。</li> <li> ラケットとマイクとおにぎりでギターができる。</li> </ol> <p> アイテムはお金を使って手...
p02729
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3> <p>We have <var>N+M</var> balls, each of which has an integer written on it.<br/> It is known that: </p> <ul> <li>The numbers written on <var>N</var> of the balls are even.</li> <li>The numbers written o...