question_id
stringlengths
6
6
content
stringlengths
1
27.2k
p03740
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Alice and Brown loves games. Today, they will play the following game.</p> <p>In this game, there are two piles initially consisting of <var>X</var> and <var>Y</var> stones, respectively. Alice and Bob ...
p03310
<span class="lang-en"> <p>Score : <var>600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke has an integer sequence <var>A</var> of length <var>N</var>.</p> <p>He will make three cuts in <var>A</var> and divide it into four (non-empty) contiguous subsequences <var>B, C, D</var> and <var>...
p00496
<H1>夜店(Night Market) </H1> <p> 太郎くんは,JOI 神社で開かれる夏祭りに行くことにした. </p> <p> JOI 神社に向かう道に沿って,<i>N</i> 個の夜店が開かれている.それぞれの夜店には,1 から<i>N</i> までの番号が順番についており,遊んだ時の楽しさと遊ぶのにかかる時間がそれぞれ整数で決まっている.夜店<i>i</i> で遊んだ時の楽しさは<i>A<sub>i</sub></i> で,夜店<i>i</i> で遊ぶのにかかる時間は<i>B<sub>i</sub></i> である. </p> <p> また,夏祭りのイベントとして花火大会があり,時刻<i>S</i...
p02151
<h1>Problem C: Phone Number</h1> <h2>Problem</h2> <p> 株式会社ウクニキアの電話番、デンさんは毎日とても長い電話番号を電話に入力しています。<br> ある日余りにも疲れたデンさんは、疲れからか驚くべき考えに至りました。<br> 「電話のボタンの配置を並べ替えたら少しでも楽できるのでは?!」<br> <br> 電話には$3 \times 3$で等間隔に区切られた正方形があり、9個のマスには並べ替えることのできる1から9までのボタンがそれぞれ1つずつついています。<br> 電話番号を打つ際、デンさんは片手だけを使って、次の二つの操作を行うことができます。<br> </p> <ul> ...
p00029
<H1>English Sentence</H1> <p> Your task is to write a program which reads a text and prints two words. The first one is the word which is arise most frequently in the text. The second one is the word which has the maximum number of letters. </p> <p> The text includes only alphabetical characters and spaces. A word i...
p02014
<h1>Problem K. Rough Sorting</h1> <!-- Time Limit: 2 sec Memory Limit: 512 MB --> <p> For skilled programmers, it is very easy to implement a sorting function. Moreover, they often avoid full sorting to reduce computation time if it is not necessary. Here, we consider "rough sorting" which sorts an array except for...
p00479
<H1>タイル (Tile)</H1> <h2>問題</h2> <p> JOI 高校では, 1 &times; 1 の正方形のタイルを使って N &times; N の正方形の壁画を作り,文化祭で展示することになった.タイルの色は,赤,青,黄の 3 種類である.壁画のデザインは次の通りである.まず,最も外側の周に赤のタイルを貼り,その内側の周に青のタイルを貼る.さらにその内側の周に黄色のタイルを貼る.これを N &times; N の正方形が埋め尽くされるまで繰り返す.用いるタイルの色は,一番外側の周から順番に赤,青,黄,赤,青,黄,…である. </p> <p> 文化祭が近づいてきたある日,壁画のうち K 枚のタイルがは...
p02444
<h1>Rotate</h1> <p> Write a program which reads a sequence of integers $A = \{a_0, a_1, ..., a_{n-1}\}$ and rotate specified elements by a list of the following operation: </p> <ul> <li>rotate($b, m, e$): For each integer $k$ ($0 \leq k < (e - b)$), move element $b + k$ to the place of element $b + ((k + (e - m)...
p00183
<H1>三目並べ</H1> <p> 3 &times; 3 の盤面の三目並べを考えましょう。三目並べは 2 人で行う対戦ゲームです。先攻後攻を決め、一人は黒石、一人は白石を打ちます。盤面に石を交互に一つずつ置いていき、縦横斜めのいずれかの方向に先に 3 つ自分の石を並べた人が勝ちとなります。 </p> <p> 盤面の情報を入力とし、勝敗の判定を行い、黒が勝ちの場合は「b」、白が勝ちの場合は「w」、どちらもそろっていない場合は「NA」と出力するプログラムを作成してください。 盤面の情報は、3行3列の文字列で構成されます。「b」は黒石、「w」は白石、「+」(半角プラ ス)は何も置かれていない状況を表します。ただし、同時...
p02917
<span class="lang-en"> <p>Score : <var>300</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> whose values are unknown.</p> <p>Given is an integer sequence <var>B</var> of length <var>N-1</var> which is known to satisfy the followi...
p03605
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>It is September <var>9</var> in Japan now.</p> <p>You are given a two-digit integer <var>N</var>. Answer the question: Is <var>9</var> contained in the decimal notation of <var>N</var>?</p> </section> <...
p01638
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [['\\(','\\)']] } }); </script> <script type='text/javascript' src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script> <h1 class="ndoc-heading1">Problem E: Pie Chart is as easy as pie.</h...
p03255
<span class="lang-en"> <p>Score : <var>700</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke has decided to use a robot to clean his room.</p> <p>There are <var>N</var> pieces of trash on a number line. The <var>i</var>-th piece from the left is at position <var>x_i</var>. We would like t...
p01268
<h1><font color="#000">Problem B:</font> Matsuzaki Number</h1> <p> Matsuzaki 教授は,宇宙の真理を研究している科学者である.人生,宇宙,すべての答えは 42 であると言われているが,Matsuzaki 教授はこれだけでは宇宙の真理を解明するには不十分であると考えている.Matsuzaki 教授は,宇宙の真理は 2 つのパラメータからなる関数で表されると考えており,42 はその 1 つに過ぎないというのである. </p> <p> Matsuzaki 教授の定義した関数 M(<i>N</i>, <i>P</i>) は,<i>N</i> より大きい素数を...
p00880
<H1><font color="#000">Problem G:</font> Malfatti Circles</H1> <p> The configuration of three circles packed inside a triangle such that each circle is tangent to the other two circles and to two of the edges of the triangle has been studied by many mathematicians for more than two centuries. Existence and uniqueness...
p01792
<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 C Casino</h2> <p> Tar...
p00750
<h1><font color="#000000">Problem E:</font> The Most Powerful Spell</h1> <!-- end en only --> <!-- begin en only --> <p> Long long ago, there lived a wizard who invented a lot of "magical patterns." In a room where one of his magical patterns is drawn on the floor, anyone can use magic by casting magic spells! Th...
p01842
<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> <h2>D - インビジブル</h2> <h3>Problem Statement</h3> <...
p02297
<H1>Area</H1> <br/> <p> For a given polygon <var>g</var>, computes the area of the polygon. </p> <p> <var>g</var> is represented by a sequence of points <var>p<sub>1</sub></var>, <var>p<sub>2</sub></var>,..., <var>p<sub>n</sub></var> where line segments connecting <var>p<sub>i</sub></var> and <var>p<sub>i+1</sub></v...
p00300
<h1>有益氏のオーディオルーム</h1> <p> 数学者である有益氏の趣味は音楽鑑賞で、家に念願のオーディオルームを作りました。完成したオーディオルームで、友人を招いてお披露目会を開きたいと考えています。全員にできるだけ良い音で聴いてもらいたいので、部屋の中の何か所かで音を計測し、友人たちの位置での音の質を計算するつもりです。 </p> <p> 計測点は、下の図の円弧と線分の交点である 1 番から 35 番までの点から選択します。1つの線分上にある点は、オーディオシステムからの距離が 100cmから 500cmまで 100cmずつ離れて並んでいます。1つの円弧状にある点は、もっとも右のもの(1 番から 5 番までの点)か...
p01141
<!-- begin en only --> <h3><U>Lifeguard in the Pool</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> Horton Moore はプールの監視員として働いてい...
p03486
<span class="lang-en"> <p>Score : <var>200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You are given strings <var>s</var> and <var>t</var>, consisting of lowercase English letters. You will create a string <var>s'</var> by freely rearranging the characters in <var>s</var>. You will also c...
p01511
<script src="./IMAGE/varmath.js" charset="UTF-8"></script> <H1>Three-way Branch</H1> <p> There is a grid that consists of <var>W \times H</var> cells. The upper-left-most cell is <var>(1, 1)</var>. You are standing on the cell of <var>(1,1)</var> and you are going to move to cell of <var>(W, H)</var>. You can only...
p01004
<h1>Problem F: Ballon Contest</h1> <h2>Problem</h2> <p>空の様子がいつもと違う。色とりどりの多彩な熱気球が空を覆っていた。今日は熱気球の大会だ。<!--大会の会場に行ってみると、熱気球を使ったレクリエーションが開催されていた。-->熱気球から落とされた得点付きボールを参加者全員で取り合うらしい。<!--残念ながら申し込み期限が切れてしまっていたが、-->せっかくなので優勝者を予想してみることにした。</p> <ul> <li>レクリエーションにはN人参加する。</li> <li><var> N </var>人の参加者はそれぞれ自分の位置が与えられる。複数の参加者に同じ位...
p03039
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a grid of squares with <var>N</var> rows and <var>M</var> columns. Let <var>(i, j)</var> denote the square at the <var>i</var>-th row from the top and <var>j</var>-th column from the left. We wi...
p03193
<span class="lang-en"> <p>Score : <var>200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There are <var>N</var> rectangular plate materials made of special metal called AtCoder Alloy. The dimensions of the <var>i</var>-th material are <var>A_i \times B_i</var> (<var>A_i</var> vertically and...
p01454
<H1>Problem H: ねこ鍋改造計画(仮)</H1> <p> あなたは、自宅にたくさんのねこを飼っている。そんなあなたの日課は、飼っているねこが土鍋の中 に入って昼寝している様子(通称:ねこ鍋)を撮影することだ。何匹かのねこが、鍋の中でいっしょ に丸くなって眠る姿は、実に愛くるしい。 </p> <p> それぞれのねこには、「重さ」<i>m<sub>i</sub></i> と「Cute」<i>c<sub>i</sub></i> が定義されている。Cute とは、そのねこ1 匹だけを見たときの、愛らしさ・あどけなさ・しなやかさ・やわらかさ・ういういしさ、などを総合的に評価した数値であり、大きければ大きいほどそのねこは魅...
p03469
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>On some day in January <var>2018</var>, Takaki is writing a document. The document has a column where the current date is written in <code>yyyy/mm/dd</code> format. For example, January <var>23</var>, <...
p02628
<span class="lang-en"> <p>Score : <var>200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>A shop sells <var>N</var> kinds of fruits, Fruit <var>1, \ldots, N</var>, at prices of <var>p_1, \ldots, p_N</var> yen per item, respectively. (Yen is the currency of Japan.)</p> <p>Here, we will choose...
p00615
<h1><font color="#000000">Problem A:</font> Traffic Analysis</h1> <p> There are two cameras which observe the up line and the down line respectively on the double lane (please see the following figure). These cameras are located on a line perpendicular to the lane, and we call the line 'monitoring line.' (the red lin...
p01907
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]} }); </script> <script type="text/javascript" async src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML"> </script> <h1>C: Fractal Tree</h1> <h2>問題</h2> <p> AORイカちゃんは、フラクタルな(自己相似的な...
p02782
<span class="lang-en"> <p>Score : <var>600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is standing on a two-dimensional plane. In one operation, he can move by <var>1</var> in the positive <var>x</var>-direction, or move by <var>1</var> in the positive <var>y</var>-direction.</p> <p...
p03890
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p><em>Kode Festival</em> is an anual contest where the hardest stone in the world is determined. (Kode is a Japanese word for "hardness".)</p> <p>This year, <var>2^N</var> stones participated. The hardnes...
p02278
<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> <H1>Minimum Cost Sort</H1> <p>...
p00245
<H1>タイムセール</H1> <p> より良い物を、より安く。今日もどこかのスーパーマーケットで行われるタイムセールでは、激しい闘いが繰り広げられています。ここ会津にある「LL堂」もそんなスーパーマーケットのひとつで、他のチェーン店と対抗すべく、少し変わったタイムセールを実施しています。一般的なタイムセールでは複数の商品が同じ時間に安くなるものですが、LL堂では対象となる商品によって、タイムセールを開始する時間が別々に設定されています。 </p> <p> 坂井家はLL堂をよく利用する家庭の一つです。そんな坂井家では、奥様主導のもと、次の日曜に行われるタイムセールに向けて作戦会議を開き、どのような順番で買い物をすれば値引きが...
p02556
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There are <var>N</var> points on the 2D plane, <var>i</var>-th of which is located on <var>(x_i, y_i)</var>. There can be multiple points that share the same coordinate. What is the maximum possible Man...
p00091
<H1>Blur</H1> <p> 図 1 のような 10×10 のマス目の「布」があり、(1,2)のようにX座標・Y座標の値の対でマス目を示すことにします。座標値は 0 から始まる整数とします。例えば、図 1 の◎の座標は (1, 2) です。 この「布」に染料を少しずつたらして染物を作ります。たらす染料の滴には「大」「中」「小」の 3 サイズがあり、染料の滴の落ちたマス目を中心に図 1 のように周囲も色がつきます。図 1 で☆が中心、○が色のにじむ範囲です。 </p> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_19...
p02106
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h1>Problem I: Tree-Light</h1> <h2>Problem</h2> <p>あなたはツリーライトというツリー状の照明器具を買ってきた。</p> <p>この照明器具には<var>n</var>個の接点があり、それぞれ<var>0</var>から<var>n&minus;1</var>までの番号がついている。各接点は10段階...
p03347
<span class="lang-en"> <p>Score : <var>700</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There is a sequence <var>X</var> of length <var>N</var>, where every element is initially <var>0</var>. Let <var>X_i</var> denote the <var>i</var>-th element of <var>X</var>.</p> <p>You are given a sequ...
p00992
<h1>Problem C : War</h1> <p> A国とB国という2つの国が戦争をしている。A国の軍人であるあなたは<i>n</i>人の兵士を率いて、B国の領土を占領する事になった。 </p> <p> B国の領土は2次元グリッドで表されている。あなたが最初に占領する場所は二次元グリッド上のある1マスである。 あなたが率いている兵士たちは、それぞれh_iの体力を持っている。 それぞれの兵士は体力を1を消費して移動することができる。 現在いるマスを(a,b)とすると、(a+1,b),(a-1,b),(a,b+1),(a,b-1)の4方向を移動先として選ぶことが可能である。 兵士は体力が0になったらそこから動くことができ...
p01680
<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>&...
p00838
<H1><font color="#000">Problem C:</font> Colored Cubes</H1> <p> There are several colored cubes. All of them are of the same size but they may be colored differently. Each face of these cubes has a single color. Colors of distinct faces of a cube may or may not be the same. </p> <p> Two cubes are said to be <i>identi...
p02805
<span class="lang-en"> <p>Score : <var>600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Given are <var>N</var> points <var>(x_i, y_i)</var> in a two-dimensional plane.</p> <p>Find the minimum radius of a circle such that all the points are inside or on it.</p> </section> </div> <div class=...
p03717
<span class="lang-en"> <p>Score : <var>800</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There are <var>N</var> squares arranged in a row. The squares are numbered <var>1</var>, <var>2</var>, <var>...</var>, <var>N</var>, from left to right.</p> <p>Snuke is painting each square in red, gree...
p03202
<span class="lang-en"> <p>Score : <var>700</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There are <var>N</var> strings arranged in a row. It is known that, for any two adjacent strings, the string to the left is lexicographically smaller than the string to the right. That is, <var>S_1&lt;S...
p01395
<script src="./IMAGE/varmath.js" charset="UTF-8"></script> <h1><font color="#000">問題 H </font>あばれうなぎ</h1> <h2>問題文</h2> <p>きつねのしえるはうなぎを食べるのが好きである.</p> <p><var>2T+1</var> 枚の鉄板が連続して並んでおり,順番に <var>-T, -T+1, ..., T</var> の番号が付いている.しえるはこれらの鉄板に熱を加え,生きたうなぎを焼こうとしている.うなぎを焼く手順は以下のようなものである.</p> <ul> <li>まず,時刻 <var>t=-1</...
p02940
<span class="lang-en"> <p>Score : <var>800</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have <var>3N</var> colored balls with IDs from <var>1</var> to <var>3N</var>. A string <var>S</var> of length <var>3N</var> represents the colors of the balls. The color of Ball <var>i</var> is red i...
p03652
<span class="lang-en"> <p>Score : <var>700</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Takahashi is hosting an sports meet. There are <var>N</var> people who will participate. These people are conveniently numbered <var>1</var> through <var>N</var>. Also, there are <var>M</var> options of...
p02413
<H1>Spreadsheet</H1><br> <p> Your task is to perform a simple table calculation. </p> <p> Write a program which reads the number of rows <var>r</var>, columns <var>c</var> and a table of <var>r</var> &times; <var>c</var> elements, and prints a new table, which includes the total sum for each row and column. </p...
p00584
<h1>コイン集め(Coin Collecting)</h1> <p> JOI 氏のコレクションルームには非常に大きな机があり,その上には何枚もの貴重なコインがある.机の掃除をするために,JOI 氏はコインを整理して並べることにした. </p> <p> 机は2 000 000 001 $\times$ 2 000 000 001 のマス目になっている.列には左から順に-1 000 000 000 から1 000 000 000までの番号がつけられており,行には下から順に-1 000 000 000 から1 000 000 000 までの番号がつけられている.列の番号が$x$,行の番号が$y$ であるマスを($x, y$)...
p02043
<h1>G: イルミネーション</h1> <h2>問題</h2> <p> $1 \leq x \leq h , 1 \leq y \leq w$ をみたす格子点 $(x,y)$ に電球がある. </p> <p> 電源装置は座標 $(i+0.5,j+0.5) (1 \leq i < h,1 \leq j < w, i+j$ は偶数)に設置されている(14:21修正). 座標 $(i+0.5,j+0.5)$ に設置されている電源装置をオンにすると, 座標 $(i,j),(i+1,j),(i,j+1),(i+1,j+1)$ に存在する $4$ つの電球が光る. </p> <p> $(i,j...
p03081
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3> <p>There are <var>N</var> squares numbered <var>1</var> to <var>N</var> from left to right. Each square has a character written on it, and Square <var>i</var> has a letter <var>s_i</var>. Besides, there i...
p01546
<h1>Sports Days 2.0</h1> <p> 会津大学附属小学校(会津大小)は日本有数の競技プログラマー養成校として有名である。 もちろん、運動会に参加しているときでさえアルゴリズムの修行を欠かせない。 競技プログラミング部部長のあなたはもちろんこの大会でも勝利したい。 今回はある競技に注目する。 </p> <p> ある競技とは会津大小で行われている伝統的な競技だ。 校庭にコーンが<var>V</var>個置いてある。 コーンのいくつかのペアは白線で描かれた矢印で結ばれている。 矢印の先は片側だけについており、整数が併記されている。 同じコーンのペアがの複数の矢印に結ばれている場合もある。 </p> <p> 競技者は...
p01116
<h3>For Programming Excellence</h3> <!-- end en only --> <!-- begin en only --> <p> A countless number of skills are required to be an excellent programmer. Different skills have different importance degrees, and the total programming competence is measured by the sum of products of levels and importance deg...
p02690
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Give a pair of integers <var>(A, B)</var> such that <var>A^5-B^5 = X</var>. It is guaranteed that there exists such a pair for the given integer <var>X</var>.</p> </section> </div> <div class="part"> <s...
p03982
<span class="lang-en"> <p>Score : <var>200</var> points</p> <div class="part"><section> <h3>Problem Statement</h3> <p> Kyoto University decided to build a straight wall on the west side of the university to protect against gorillas that attack the university from the west every night. Since it i...
p00357
<H1>Trampoline</H1> <p> A plurality of trampolines are arranged in a line at 10 m intervals. Each trampoline has its own maximum horizontal distance within which the jumper can jump safely. Starting from the left-most trampoline, the jumper jumps to another trampoline within the allowed jumping range. The jumper wan...
p00707
<H1>The Secret Number</H1> <P> Your job is to find out the secret number hidden in a matrix, each of whose element is a digit ('0'-'9') or a letter ('A'-'Z'). You can see an example matrix in Figure 1. </P> <CENTER> <DIV style="margin-bottom: 5mm"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_sec...
p01815
<h2>Escape</h2> <p> 頂点に正の値を持つ無向グラフが与えられる。 頂点には 1 から <var>N</var> の番号がついており、<var>i</var> 番目の頂点は <var>w_i</var> の値を持っている。 1 番目の頂点からスタートし、直前に通った辺を通ることができないという制約のもとでグラフ上を移動することができる。 各頂点では,初めて訪れた時に限りその頂点が持つ値の点数を得られる。 </p> <p> 取得できる点数の総和の最大値を求めよ。 </p> <h3>Constraints</h3> <ul> <li><var>1 &le; N &le; 100000</var></li...
p03828
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You are given an integer <var>N</var>. Find the number of the positive divisors of <var>N!</var>, modulo <var>10^9+7</var>.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <l...
p00212
<H1> 高速バス</H1> <p> A 君は高校の休みを利用して、高速バス(以下、「バス」 )で一人旅をする計画を立てています。まず、A 君は一番行ってみたい町を選んでそこを目的地にしました。次に出発地から目的地までバスを乗り継いでいくルートを決めなければなりません。乗り継ぎをするときは、バスを降りてから別のバスに乗り換えるので、それぞれのバスの乗車券が必要になります。 </p> <p> A 君は親戚のおじさんからバスの割引券を何枚かもらいました。 この券を 1 枚使うと乗車券 1 枚を半額で購入できます。例えば、図 1 の出発地5から目的地1へ行く場合には、5→4→6→2→1と5→3→1の二つの経路が考えられます...
p00642
<H1><font color="#000000">Problem F:</font> Ben Toh</H1> <p> As usual, those who called wolves get together on 8 p.m. at the supermarket. The thing they want is only one, a box lunch that is labeled half price. Scrambling for a few discounted box lunch, they fiercely fight every day. And those who are blessed by hung...
p01950
<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...
p02385
<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> <h1>Dice III</h1><br> <p> Wr...
p01403
<h2> Problem F: Farey Sequence </h2> <p> slipは数字を眺めるのが好きである。 ファイルをダウンロードしているときの、残り時間を眺めているだけで、時間を潰せるほどである。 そんなslipが友人から面白い数列を教えられた。 その数列の定義は以下のとおりである。 </p> <p> 一般項を<i>F<sub>n</sub></i>と表わす。 <i>F<sub>n</sub></i>とは、<i>n</i>以下の分母を持つ0以上1以下のすべての約分された分数(既約分数)を小さな順から並べたものである。 ただし、整数0、1はそれぞれ分数0/1、1/1として扱われる。 </p> <p> つま...
p01053
<h1>Lucky Number</h1> <h2>Problem</h2> <p> 0 から <var>N</var>-1 までの数字があります。 <var>M</var>+1日間のラッキーナンバーを以下の方法で選びたいと思います。 最初の日にラッキーナンバーをランダムに決めます。 <var>i</var>日後のラッキーナンバーを <var>A</var> 、(<var>i</var>+1)日後のラッキーナンバーを <var>B</var> とすると、 </p> <pre> <var>B</var> = ( <var>A</var> + <var>j</var> ) % <var>N</var> (ただし <var>j<...
p03594
<span class="lang-en"> <p>Score : <var>700</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a grid with <var>H</var> rows and <var>W</var> columns of squares. We will represent the square at the <var>i</var>-th row from the top and <var>j</var>-th column from the left as <var>(i,\ j)</...
p03701
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You are taking a computer-based examination. The examination consists of <var>N</var> questions, and the score allocated to the <var>i</var>-th question is <var>s_i</var>. Your answer to each question w...
p02813
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have two permutations <var>P</var> and <var>Q</var> of size <var>N</var> (that is, <var>P</var> and <var>Q</var> are both rearrangements of <var>(1,~2,~...,~N)</var>).</p> <p>There are <var>N!</var> ...
p01696
<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> <!-- begin en only --> <!--<h3...
p00984
<h2>Halting Problem</h2> <p> A unique law is enforced in the Republic of Finite Loop. Under the law, programs that never halt are regarded as viruses. Releasing such a program is a cybercrime. So, you want to make sure that your software products always halt under their normal use. </p> <p> It is widely known tha...
p03351
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Three people, A, B and C, are trying to communicate using transceivers. They are standing along a number line, and the coordinates of A, B and C are <var>a</var>, <var>b</var> and <var>c</var> (in meter...
p02110
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h1>Problem M: Settler</h1> <h2>Problem</h2> <p> 二次元平面上に<var>N</var>個の空き地がある。空き地にはそれぞれ1から<var>N</var>までの番号が割り振られている。どの空き地もとても小さいので、点とみなすことができる。<var>i</var>番目の空き地は(<var>x<sub>...
p00087
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
p02540
<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> cities on a 2D plane. The coordinate of the <var>i</var>-th city is <var>(x_i, y_i)</var>. Here <var>(x_1, x_2, \dots, x_N)</var> and <var>(y_1, y_2, \dots, y_N)</var> are both permua...
p02055
<h2>D: Two Colors Sort</h2> <h3>問題</h3> <p>umg 君は散歩中に <var> 1,2, ... ,N </var> を並び変えてできる長さ <var>N</var> の数列 <var> P_1, P_2, ..., P_N </var> を見つけました。</p> <p>umg 君は不思議な力を使うことで、同じ色に塗られた異なる数を二つ選んで場所を交換することができます。</p> <p>umg 君は、数列に含まれる数のうち <var>R</var> 個を赤に、残りの <var>N-R</var> 個を青に塗ることで数列を昇順に並び替えられるようにしたいと考えました。</p> <p>um...
p00068
<H1>輪ゴム</H1> <p> <var>n</var> 本の釘を平板上の座標 <var>P<sub>1</sub></var> (<var>x<sub>1</sub></var>, <var>y</sub>1</sub></var>), <var>P<sub>2</sub></var> (<var>x<sub>2</sub></var>, <var>y<sub>2</sub></var>), <var>P<sub>3</sub></var> (<var>x<sub>3</sub></var>, <var>y<sub>3</sub></var>),..., <var>P<sub>n</sub></var> (<var>x<...
p00592
<H1>Boring Commercial</H1> <p> Now it is spring holidays. A lazy student has finally passed all final examination, and he decided to just kick back and just watch TV all day. Oh, his only source of entertainment is watching TV. And TV commercial, as usual, are a big nuisance for him. He can watch any thing on ...
p02405
<H1>Print a Chessboard</H1> <p> Draw a chessboard which has a height of <var>H</var> cm and a width of <var>W</var> cm. For example, the following figure shows a chessboard which has a height of 6 cm and a width of 10 cm. </p> <pre> #.#.#.#.#. .#.#.#.#.# #.#.#.#.#. .#.#.#.#.# #.#.#.#.#. .#.#.#.#.# </pre> <p> Note ...
p00438
<H1>通学経路</H1> <h2>問題</h2> <p> 太郎君の住んでいるJOI市は,南北方向にまっすぐに伸びる a 本の道路と,東西方向にまっすぐに伸びる b 本の道路により,碁盤の目の形に区分けされている. </p> <p> 南北方向の a 本の道路には,西から順に 1, 2, ... , a の番号が付けられている.また,東西方向の b 本の道路には,南から順に 1, 2, ... , b の番号が付けられている.西から i 番目の南北方向の道路と,南から j 番目の東西方向の道路が交わる交差点を (i, j) で表す. </p> <p> 太郎君は,交差点 (1, 1) の近くに住んでおり,交差点 (a, b) ...
p01679
<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>Y...
p03644
<span class="lang-en"> <p>Score : <var>200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Takahashi loves numbers divisible by <var>2</var>.</p> <p>You are given a positive integer <var>N</var>. Among the integers between <var>1</var> and <var>N</var> (inclusive), find the one that can be di...
p02956
<span class="lang-en"> <p>Score : <var>600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a set <var>S</var> of <var>N</var> points in a two-dimensional plane. The coordinates of the <var>i</var>-th point are <var>(x_i, y_i)</var>. The <var>N</var> points have distinct <var>x</var>-c...
p01383
<div> <h1 class="title">問題 H : キャッシュ戦略</h1> <p>今,G○○gle Code Jam の地区大会が始まろうとしている. 斜め右前の席に座っている男の ID は lyrically と言うらしい. 東京大学時代の記憶に,似たような ID の仲間が居た覚えがあるが,僕の仲間は一人残さず美少女だったはずだ.</p> <p>僕の記憶の中の lyrically は,アルゴリズムの力や実装の力もさながら, 気合で問題に正解することにも定評があった. 例えば,計算量が多少悪いプログラムでも,上手な実装をすることで高速にし, 正解とするようなことも得意としていた.</p> <p>プログラムを高速に...
p01229
<h1><font color="#000">Problem G:</font>エナジー・トランスポーター</h1> <p> とある研究所で, エネルギー伝達用の媒体の開発をしていた. この媒体は図3に示すような特殊な物質からなる ポリマー構造をなしている. </p> <center> <table> <tr> <td> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_energy" alt="エネルギー伝達用媒体の構造."> </td> </tr> <tr> ...
p03214
<span class="lang-en"> <p>Score : <var>200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3> <p>Niwango-kun is an employee of Dwango Co., Ltd.<br/> One day, he is asked to generate a thumbnail from a video a user submitted.<br/> To generate a thumbnail, he needs to select a frame of the video acc...
p01803
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]} }); </script> <script type="text/javascript" async src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML"> </script> <!-- begin en only --> <h3><u>Airport Codes</u></h3> ...
p00711
<H1><font color="#000">Problem B:</font> Red and Black</H1> <P> There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can't move on red tiles, he can move only on black tiles...
p00341
<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> アイヅ放送協会の教育番組(AHK教育)では...
p03994
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Mr. Takahashi has a string <var>s</var> consisting of lowercase English letters. He repeats the following operation on <var>s</var> exactly <var>K</var> times.</p> <ul> <li>Choose an arbitrary letter on...
p02686
<span class="lang-en"> <p>Score : <var>600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>A <strong>bracket sequence</strong> is a string that is one of the following:</p> <ol> <li>An empty string;</li> <li>The concatenation of <code>(</code>, <var>A</var>, and <code>)</code> in this order, ...
p01100
<h3>Gift Exchange Party</h3> <p> A gift exchange party will be held at a school in TKB City. </p> <p> For every pair of students who are close friends, one gift must be given from one to the other at this party, but not the other way around. It is decided in advance the gift directions, that is, which student of ea...
p01550
<h1>問題名</h1> <p>今 <var>n</var> 枚の数字が書かれたカードがあります。これらの一部または全部を適当に並べて数字を作ることを考えます。この時作られる数字を全て足した数を求めて下さい。 </p> <p>例えば、 1 と 2 があったら、作られる数字は 1, 2, 12, 21 の 4 つなので、全て足した数は 36 になります。並べた結果同じ数字が出来ても違う並べ方だとしたら別々に足します。たとえば、 1 というカードと 11 というカードがあったら並べて 111 になる並べ方が2通りありますがそれぞれ別のものとして足し合わせます。カードの中にリーディングゼロのカードはありませんし、リーディングゼロになる...
p03097
<span class="lang-en"> <p>Score : <var>800</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You are given integers <var>N,\ A</var> and <var>B</var>. Determine if there exists a permutation <var>(P_0,\ P_1,\ ...\ P_{2^N-1})</var> of <var>(0,\ 1,\ ...\ 2^N-1)</var> that satisfies all of the fol...
p03582
<span class="lang-en"> <p>Score : <var>1600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>For a string <var>S</var>, let <var>f(S)</var> be the lexicographically smallest cyclic shift of <var>S</var>. For example, if <var>S = </var><code>babca</code>, <var>f(S) = </var><code>ababc</code> be...
p03078
<span class="lang-en"> <p>Score: <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3> <p>The Patisserie AtCoder sells cakes with number-shaped candles. There are <var>X</var>, <var>Y</var> and <var>Z</var> kinds of cakes with <var>1</var>-shaped, <var>2</var>-shaped and <var>3</var>-shaped ...
p01045
<h1>Problem I: Hopping Mind</h1> <h2>Problem</h2> <p> チエノとカカオは同じ喫茶店で働く姉妹である。2人はとても仲が良く、ある日、とあるテーブルゲームで遊ぶことになった。 </p> <p> ゲームは<var>R</var>マス&times;<var>C</var>マスの盤面と、駒としてうさぎのTPを用いる。盤面の各マスは白か黒の色が塗られている。最初にTPを盤面の右下(<var>R</var>,<var>C</var>)におき、2人で次の行動を交互に行う。TPの現在の位置を(<var>a</var>,<var>b</var>)とすると、そこからジャンプ可能な位置(<var>...
p03428
<span class="lang-en"> <p>Score : <var>600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There are <var>N</var> holes in a two-dimensional plane. The coordinates of the <var>i</var>-th hole are <var>(x_i,y_i)</var>.</p> <p>Let <var>R=10^{10^{10^{10}}}</var>. Ringo performs the following ope...
p01415
<H1>I: Starting Line</H1> <p> ICPC で良い成績を収めるには修行が欠かせない.うさぎは ICPC で勝ちたいので,今日も修行をすることにした. </p> <p> 今日の修行は,一直線上の道を走って,体力と判断力を養おうというものである.うさぎは今,スタートラインに立って長い長い道を見渡している. </p> <p> 道の途中にはいくつかニンジンが置かれており,うさぎはニンジンを食べると加速することができる.加速していないときのうさぎの走る速さは毎秒 <i>U</i> メートルであるが,ニンジンを食べることで,最後のニンジンを食べてから <i>T</i> 秒後までは速さが毎秒 <i>V</i> メー...
p02393
<H1>Sorting Three Numbers</H1> <p> Write a program which reads three integers, and prints them in ascending order. </p> <H2>Input</H2> <p> Three integers separated by a single space are given in a line. </p> <H2>Output</H2> <p> Print the given integers in ascending order in a line. Put a single space betwe...