question_id
stringlengths
6
6
content
stringlengths
1
27.2k
p03466
<span class="lang-en"> <p>Score : <var>1100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Let <var>f(A, B)</var>, where <var>A</var> and <var>B</var> are positive integers, be the string satisfying the following conditions:</p> <ul> <li><var>f(A, B)</var> has length <var>A + B</var>;</li> <...
p03036
<span class="lang-en"> <p>Score : <var>200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>The development of algae in a pond is as follows.</p> <p>Let the total weight of the algae at the beginning of the year <var>i</var> be <var>x_i</var> gram. For <var>i≥2000</var>, the following formula ...
p02277
<H1>Quick Sort</H1> <!-- <p style="color:#f00"> Please note that problem description and judge data for this problem are still under construction. They may revised and your submissions can be rejudged. </p> --> <p> Let's arrange a deck of cards. Your task is to sort totally n cards. A card consists of a part of a sui...
p03935
<span class="lang-en lang-child hidden-lang"> <div class="part"> Max Score: $1400$ Points <br/> <section> <h3>Problem Statement</h3> E869120 defined a sequence $a$ like this: <br/> <ul> <li>$a_1=a_2=1$, $a_{k+2}=a_{k+1}+a_k \ (k \ge 1)$</li> </ul> <br/> He also defined sequences $d_1, d_2, d_3, \dots , d_...
p01908
<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>D: パスワード</h1> <h2>問題</h2> <p> AOR イカちゃんは英小文字のみからなる強力なパスワードを作...
p02627
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>An uppercase or lowercase English letter <var>\alpha</var> will be given as input. If <var>\alpha</var> is uppercase, print <code>A</code>; if it is lowercase, print <code>a</code>.</p> </section> </div...
p02332
<!--<h1>写像12相 その2:ボールに区別あり・箱に区別あり・箱の中身は1つ以下</h1>--> <h1>Balls and Boxes 2</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 style="background-color:#aff">2</td><td>3</td><...
p02298
<H1>Is-Convex</H1> <br/> <p> For a given polygon <var>g</var>, print "1" if <var>g</var> is a convex polygon, "0" otherwise. Here, in a convex polygon, all interior angles are less than or equal to 180 degrees. </p> <p> <var>g</var> is represented by a sequence of points <var>p<sub>1</sub></var>, <var>p<sub>2</sub><...
p03870
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><style> #nck { width: 30px; height: auto; } </style> <p>A cheetah and a cheater are going to play the game of Nim. In this game they use <var>N</var> piles of stones. Initially the <var>i...
p02762
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>An SNS has <var>N</var> users - User <var>1</var>, User <var>2</var>, <var>\cdots</var>, User <var>N</var>.</p> <p>Between these <var>N</var> users, there are some relationships - <var>M</var> <em>frien...
p03523
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You are given a string <var>S</var>.</p> <p>Takahashi can insert the character <code>A</code> at any position in this string any number of times.</p> <p>Can he change <var>S</var> into <code>AKIHABARA</...
p03489
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You are given a sequence of positive integers of length <var>N</var>, <var>a = (a_1, a_2, ..., a_N)</var>. Your objective is to remove some of the elements in <var>a</var> so that <var>a</var> will be a...
p03173
<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> slimes lining up in a row. Initially, the <var>i</var>-th slime from the left has a size of <var>a_i</var>.</p> <p>Taro is trying to combine all the slimes into a larger slime. He...
p00476
<H1>ダンジョン</H1> <h2>問題</h2> <p> あなたはあるダンジョンの地下 N 階にある財宝を手に入れたいと思っている.最初,あなたは地下 1 階におり,あなたの体力は H(H は正整数) である.下の階に降りるときに,体力が消費される.あらかじめ各階における下の階に降りるときに消費される体力が分かっている.一方,各階には 1 つの回復の泉があり,泉を 1 回使うごとに回復できる体力がそれぞれ定まっている.体力が 0 以下になるとあなたは死んでしまう.また,体力が H よりも高くなることはない.回復の泉は何回でも使うことができるが,回復には時間がかかるので,あなたは泉の使用回数をできるだけ少なくしたいと考えて...
p00026
<H1>Dropping Ink</H1> <p> As shown in the following figure, there is a paper consisting of a grid structure where each cell is indicated by (<var>x</var>, <var>y</var>) coordinate system. </p> <p> We are going to put drops of ink on the paper. A drop comes in three different sizes: Large, Medium, and Small. From th...
p01267
<h1><font color="#000">Problem A:</font> Luck Manipulator</h1> <p> Nathan O. Davis くんは,あるゲームを攻略中であり,非常にレアなアイテムを手に入れようと四苦八苦していた.このレアなアイテムは,カジノのスロットマシーンで特殊な絵柄を一列に揃えたときに手に入れることができる.スロットマシーンには <i>N</i> 個のリールがあり,ボタンを一回押すと現在回転している最も左側のリールが停止する.そのため,このレアアイテムを手に入れるためには <i>N</i> 回ボタンを押す必要がある.また,特殊な絵柄で停止させるためにはあるタイミングでボタンを押す必...
p01637
<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 D: Change</h1> <p class="ndoc-top">...
p02918
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There are <var>N</var> people standing in a queue from west to east.</p> <p>Given is a string <var>S</var> of length <var>N</var> representing the directions of the people. The <var>i</var>-th person fr...
p00925
<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 B: Miscalculation </h2...
p01322
<h1><font color="#000">Problem B:</font> 宝くじチェッカー</h1> <p>あなたは無事進学振り分けを終え、駒場近辺から本郷近辺へ引っ越す準備の最中であった。 家の中を整理していたところ去年購入した宝くじが大量に見つかった。 交換期限を確認したところ明日までに換金しなければならないのだが、引っ越しの準備がまだ全く終わっていないため少額の当選金のために宝くじ売り場まで行くのは面倒である。 そこであなたはいくら当選金が得られるかを調べることにした。</p> <p>宝くじは8桁の数字からなる。当選番号は同じく8桁で数字と'*'から構成され、持っている宝くじと数字部分が一致した場合、当選番号に...
p01772
<h2>A: A-Z Cat / A-Z キャット</h2> <h3>物語</h3> <p>あいずにゃんは若ヶ松高校のプログラミングコンテスト部,通称ぷろこん部に所属する2年生である.とてつもなくかわいい.あいずにゃんは友達のジョイに頼まれて猫を預かることになった.A-Z キャットと呼ばれる珍種の猫である.あいずにゃんは預かった A-Z キャットを「あいずにゃん 2 号」と (勝手に) 名付け,大層可愛がった.</p> <p>A-Z キャットは特定の条件を満たす文字列を好むとされる.そこであいずにゃんが試しに文字列を与えてみると,あいずにゃん 2 号は文字列の一部を爪で切り取った後,満足げな表情を浮かべた.どうやら,好みの...
p00860
<H1><font color="#000">Problem G:</font> The Morning after Halloween</H1> <p> You are working for an amusement park as an operator of an <i>obakeyashiki</i>, or a haunted house, in which guests walk through narrow and dark corridors. The house is proud of their lively ghosts, which are actually robots remotely contro...
p01288
<H1><font color="#000">Problem F:</font> Marked Ancestor</H1> <p> You are given a tree <i>T</i> that consists of <i>N</i> nodes. Each node is numbered from 1 to <i>N</i>, and node 1 is always the root node of <i>T</i>. Consider the following two operations on <i>T</i>: </p> <ul> <li><span>M v</span>: (Mark) Mark n...
p00533
<h2>気象予報士 (Weather Forecaster)</h2> <h2>問題</h2> <p> JOI 市は南北方向に H キロメートル,東西方向に W キロメートルの長方形の形をしており,H &times; W 個の 1 キロメートル四方の小区画に区切られている.北から i 番目,西から j 番目の小区画を (i, j) と表す. </p> <p> 各小区画は上空に雲があるか雲がないかのどちらかである.すべての雲は,1 分経つごとに 1 キロメートル東に移動する.今日は実に天気が良いため,JOI 市の外から JOI 市内に雲が移動してくることはない. </p> <p> 今,各小区画の上空に雲があるかないか...
p00163
<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 s...
p00499
<H1>宿題 (Homework) </H1> <br/> <h2>問題</h2> <p> 冬休みの宿題に毎回苦しめられてきた JOI 君が,今回は宿題を計画的に実行することにした.宿題は国語と算数のドリルであり,国語のドリルは A ページ,算数のドリルは B ページある. </p> <p> JOI 君は,1 日に国語のドリルを最大 C ページと,算数のドリルを最大 D ページ進めることができるが,宿題をするとその日は遊ぶことができない. </p> <p> 冬休みは L 日あり,JOI 君は冬休み中に宿題を終わらせなければならない.JOI 君が冬休み中に最大で何日遊べるかを求めるプログラムを作成せよ. </p> <...
p03962
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>AtCoDeer the deer recently bought three paint cans. The color of the one he bought two days ago is <var>a</var>, the color of the one he bought yesterday is <var>b</var>, and the color of the one he bou...
p02670
<span class="lang-en"> <p>Score : <var>700</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Tonight, in your favourite cinema they are giving the movie Joker and all seats are occupied. In the cinema there are <var>N</var> rows with <var>N</var> seats each, forming an <var>N\times N</var> squa...
p02220
<span class="lang"> <span class="lang-ja"> <h1>I: 偶奇ソート</h1> <div class="part"> <section> <h3>問題文</h3><p>$0$ から $N-1$ までの整数を並び替えた長さ $N$ の順列 $P$ が与えられます。</p> <p>以下の操作を最大 $30$ 回まで行って、 $P$ を昇順に並べ替えてください。</p> </section> </div> <div class="part"> <section> <h3>操作</h3><p>$1$ 回の操作では、次の 1 から 4 を順に行う。</p> <ol> <li><code>0</co...
p03061
<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>, written on the blackboard.</p> <p>You will choose one of them and replace it with an integer of your choice between <var>1</var> and <var>...
p03431
<span class="lang-en"> <p>Score : <var>1200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>In Republic of AtCoder, Snuke Chameleons (Family: Chamaeleonidae, Genus: Bartaberia) are very popular pets. Ringo keeps <var>N</var> Snuke Chameleons in a cage.</p> <p>A Snuke Chameleon that has not ea...
p03124
<span class="lang-en"> <p>Score : <var>2718</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There is a very long bench. The bench is divided into <var>M</var> sections, where <var>M</var> is a very large integer.</p> <p>Initially, the bench is vacant. Then, <var>M</var> people come to the ben...
p01119
<!--<h2>Problem C</h2>--> <!-- begin en only --> <h3>Balance Scale</h3> <!-- end en only --> <!-- begin en only --> <p> You, an experimental chemist, have a balance scale and a kit of weights for measuring weights of powder chemicals. </p> <!-- end en only --> <!-- begin en only --> <p> For wo...
p03574
<span class="lang-en"> <p>Score : <var>200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You are given an <var>H × W</var> grid.<br/> The squares in the grid are described by <var>H</var> strings, <var>S_1,...,S_H</var>.<br/> The <var>j</var>-th character in the string <var>S_i</var> corres...
p01549
<h1>問題名 Zero division checker</h1> <p>森下さんは困っていました... 姉原さんにプログラムを書いてもらったのですが、そのプログラムがクラッシュするのです。 </p> <p>姉原さんに書いてもらったのは、逆ポーランド記法の式を読んで、その計算結果を出力するプログラムで、クラッシュログによると、 0 で割り算をしてしまったのが原因のようです。これは、森下さんが間違った式を入力してしまったからかもしれませんし、もしかしたら、もしかしたら、姉原さんの書いたプログラムにバグがあるのかもしれません。 </p> <p>姉原さんの書いたプログラムを読んでみようと思いましたが、姉原さんのプログラムはアセンブリ...
p03827
<span class="lang-en"> <p>Score : <var>200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You have an integer variable <var>x</var>. Initially, <var>x=0</var>.</p> <p>Some person gave you a string <var>S</var> of length <var>N</var>, and using the string you performed the following operation...
p00708
<H1>Building a Space Station</H1> <P> You are a member of the space station engineering team, and are assigned a task in the construction process of the station. You are expected to write a computer program to complete the task. </P> <P> The space station is made up with a number of units, called <I>cells.</I> All...
p02735
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Consider a grid with <var>H</var> rows and <var>W</var> columns of squares. Let <var>(r, c)</var> denote the square at the <var>r</var>-th row from the top and the <var>c</var>-th column from the left. ...
p00358
<!--<H1>Cargo Layout</H1>--> <H1>Loading</H1> <p> Aizu Ocean Transport Company (AOTC) accepted a new shipping order. The pieces of the cargo included in this order all have the same square footprint (2m x 2m). The cargo room has a rectangular storage space of 4m width with various longitudinal extents. Each pieces of ...
p02365
<H1>Minimum-Cost Arborescence</H1> <br/> <p> Find the sum of the weights of edges of the Minimum-Cost Arborescence with the root <var>r</var> for a given weighted directed graph <var>G</var> = (<var>V</var>, <var>E</var>). </p> <H2>Input</H2> <pre> <var>|V|</var> <var>|E|</var> <var>r</var> <var>s<sub>0</sub></var>...
p01660
<h2>E - すごろく</h2> <p> 友達のいないきつねのボブは,今日は一人ですごろく遊びをして過ごすことにした. 各面に整数<var>a_1,a_2,a_3,a_4,a_5,a_6</var>が書かれた6面ダイスと,駒と,直線上にM個のマスがあり 左から順に<var>1</var>から<var>M</var>までの番号が割り当てられたすごろく盤を用いることにした. すごろく盤の各マスには指示が数字で書かれており,<var>i</var>番目のマスには数字<var>N_i</var>が書かれている. これは,その値が正なら右,負なら左に,その絶対値だけ駒を移動せよという意味である. すなわち,<var>i+N_i</v...
p00972
<h2>Eulerian Flight Tour</h2> <p> You have an airline route map of a certain region. All the airports in the region and all the <i>non-stop routes</i> between them are on the map. Here, a non-stop route is a flight route that provides non-stop flights in both ways. </p> <p> Named after the great mathematician Leo...
p01230
<h1><font color="#000">Problem H:</font> いけるかな?</h1> <p> あるところに,日本各地をまわりながら商売をする社長がいた. 彼はある日,不思議な切符を手に入れた. その切符を使うと,なんと目的地までの距離によらず電車の運賃が無料になるという. ただし, 現在の駅から隣接する駅へ移動するのを1ステップと数えたときに, 移動するステップ数がちょうど切符に書かれた数と等しくならないと 追加料金を取られてしまう. ある区間をただちに折り返すような移動は禁止されているが, 既に訪れた駅や区間を複数回通ること自体...
p04032
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Given a string <var>t</var>, we will call it <em>unbalanced</em> if and only if the length of <var>t</var> is at least <var>2</var>, and more than half of the letters in <var>t</var> are the same. For e...
p00071
<H1>爆弾の連鎖</H1> <p> 縦 8、横 8 のマスからなる図1 のような平面があります。その平面上に、いくつかの爆弾が置かれています。図2 にその例を示します(● = 爆弾)。 </p> <center> <table> <tr> <td> <table cellpadding=0 cellspacing=0> <tr><td>□</td><td>□</td><td>□</td><td>□</td><td>□</td><td>□</td><td>□</td><td>□</td></tr> <tr><td>□</td><td>□</td><td>□</td><td>□...
p00421
<h1>三角形の個数の和</h1>   <p> 座標平面上の原点$O$を左下、座標$(W,H)$にある点を右上とする長方形の領域が与えられています。この領域に含まれる、$x$座標と$y$座標がともに整数である点を3個以上含む点の集まりを考えます。このような点の集まりのすべての組み合わせの個数を$N$とし、点の集まりのそれぞれを$D_1, D_2, ..., D_N$で表したとき、$D_1, D_2, ..., D_N$のそれぞれに含まれる点を頂点とする三角形を考えます。 </p> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/PCK2019_t...
p02109
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h1>Problem L: Select Sets</h1> <h2>Problem</h2> <p> 整数の集合が<var>N</var>個ある。 これらの集合にはそれぞれ1から<var>N</var>までの番号が割り振られている。<var>i</var>番目の集合の要素数は<var>K<sub>i</sub></var>であり、その集合の要...
p00134
<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...
p02559
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You are given an array <var>a_0, a_1, ..., a_{N-1}</var> of length <var>N</var>. Process <var>Q</var> queries of the following types.</p> <ul> <li><code>0 p x</code>: <var>a_p \gets a_p + x</var></li> <...
p00564
<h1>鉛筆 (Pencils)</h1> <h2>問題文</h2> <p> JOI 君は鉛筆を <var>N</var> 本買うために近くの文房具店に行くことにした. </p> <p> 文房具店では鉛筆が一定の本数ずつのセットで売られている.セット <var>X</var> は <var>A</var> 本で <var>B</var> 円,セット <var>Y</var> は <var>C</var> 本で <var>D</var> 円である. </p> <p> JOI 君はセット <var>X</var> かセット <var>Y</var> の一方を選び,選んだセットをいくつか購入する.両方のセットを購入することはできな...
p01725
<p>小学生のイクタ君は、ある日おじいさんから数式が書かれた紙をもらった。 どうやらおじいさんは数式の答えの金額だけお小遣いをくれるらしい。 イクタ君はまだ足し算、引き算、掛け算しか習ってなかったので、数式にも足し算と引き算と掛け算しか使われていない。 通常の計算では足し算と引き算より掛け算を先に計算しなければならないのだが、イクタ君は演算子の優先順位についての理解があやふやだったので、とりあえず数式の計算結果が最大になるような都合の良い優先順位を考えることにした。 </p> <p><var>+&minus;&times;</var>の3つの二項演算子と括弧を含む数式が与えられる。 3つの演算子の優先順位を任意に変更して、数...
p03718
<span class="lang-en"> <p>Score : <var>800</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There is a pond with a rectangular shape. The pond is divided into a grid with <var>H</var> rows and <var>W</var> columns of squares. We will denote the square at the <var>i</var>-th row from the top an...
p00837
<H1><font color="#000">Problem B:</font> Book Replacement</H1> <p> The deadline of Prof. Hachioji’s assignment is tomorrow. To complete the task, students have to copy pages of many reference books in the library. </p> <p> All the reference books are in a storeroom and only the librarian is allowed to enter it. To ob...
p01375
<!-- begin en only --> <!--<h3><U>Intelligent Circular Perfect Cleaner</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> A...
p03348
<span class="lang-en"> <p>Score : <var>1100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Coloring of the vertices of a tree <var>G</var> is called a <em>good coloring</em> when, for every pair of two vertices <var>u</var> and <var>v</var> painted in the same color, picking <var>u</var> as ...
p03427
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Find the maximum possible sum of the digits (in base <var>10</var>) of a positive integer not greater than <var>N</var>.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><...
p03077
<span class="lang-en"> <p>Score: <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3> <p>In 2028 and after a continuous growth, AtCoder Inc. finally built an empire with six cities (City <var>1, 2, 3, 4, 5, 6</var>)!</p> <p>There are five means of transport in this empire:</p> <ul> <li>Trai...
p02236
<h1>Optimal Binary Search Tree</h1> <p> Optimal Binary Search Tree is a binary search tree constructed from $n$ keys and $n+1$ dummy keys so as to minimize the expected value of cost for a search operation. </p> <p> We are given a sequence $K = {k_1, k_2, ..., k_n}$ of $n$ distinct keys in sorted order $(k_1 < k_2 ...
p02666
<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> towns numbered <var>1, 2, \cdots, N</var>.</p> <p>Some roads are planned to be built so that each of them connects two distinct towns bidirectionally. Currently, there are no road...
p01949
<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...
p03974
<span class="lang-en"> <p>Score : <var>1100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There are <var>N</var> strings of lowercase alphabet only. The <var>i</var>-th string is <var>S_i</var>. Every string is unique.</p> <p>Provide answers for the <var>Q</var> queries below. The <var>i</v...
p02689
<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> observatories in AtCoder Hill, called Obs. <var>1</var>, Obs. <var>2</var>, <var>...</var>, Obs. <var>N</var>. The elevation of Obs. <var>i</var> is <var>H_i</var>. There are also...
p02373
<H1>LCA: Lowest Common Ancestor</H1> <p> For a rooted tree, find the lowest common ancestor of two nodes <var>u</var> and <var>v</var>. </p> <p> The given tree consists of <var>n</var> nodes and every node has a unique ID from 0 to <var>n</var>-1 where 0 is the root. </p> <H2>Input</H2> <pre> <var>n</var> <var...
p02723
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>A string of length <var>6</var> consisting of lowercase English letters is said to be coffee-like if and only if its <var>3</var>-rd and <var>4</var>-th characters are equal and its <var>5</var>-th and ...
p03831
<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> towns on a line running east-west. The towns are numbered <var>1</var> through <var>N</var>, in order from west to east. Each point on the line has a one-dimensional coordinate, a...
p03098
<span class="lang-en"> <p>Score : <var>1000</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>For two permutations <var>p</var> and <var>q</var> of the integers from <var>1</var> through <var>N</var>, let <var>f(p,q)</var> be the permutation that satisfies the following:</p> <ul> <li>The <var>p...
p03562
<span class="lang-en"> <p>Score : <var>1000</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There are <var>N</var> non-negative integers written on a blackboard. The <var>i</var>-th integer is <var>A_i</var>.</p> <p>Takahashi can perform the following two kinds of operations any number of tim...
p03132
<span class="lang-en"> <p>Score : <var>600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke stands on a number line. He has <var>L</var> ears, and he will walk along the line continuously under the following conditions:</p> <ul> <li>He never visits a point with coordinate less than <var>...
p00437
<H1>品質検査</H1> <h2>問題</h2> <p> あなたはある機械の製造工場で品質管理の責任者をしている. この機械には, 部品として電源とモーターとケーブルが必要である. 製造工場には電源が a 個, モーターが b 個, ケーブルが c 個あり, それぞれ 1 から a まで, a+1 から a+b まで, a+b+1 から a+b+c までの番号が付いている. 困ったことに, 部品の中に故障しているものがあるかもしれない. 工場ではどの部品が故障していてどの部品が正常であるかを知りたい. </p> <p> そこで, 工場では次の方法で部品を検査した. 電源とモーターとケーブルを1つずつ持ってきてつなぎ, ...
p00067
<H1>島の数</H1> <p> 地勢を示す縦 12, 横 12 のマスからなる平面図があります。おのおののマスは白か黒に塗られています。白は海を、黒は陸地を表します。二つの黒いマスが上下、あるいは左右に接しているとき、これらは地続きであるといいます。この平面図では、黒いマス一つのみ、あるいは地続きの黒いマスが作る領域を「島」といいます。例えば下図には、5 つの島があります。 </p> <pre> ■■■■□□□□■■■■ ■■■□□□□□■■■■ ■■□□□□□□■■■■ ■□□□□□□□■■■■ □□□■□□□■□□□□ □□□□□□■■■□□□ □□□□□■■■■■□□ ■□□□■■■■■■■□ ■■□□□■■■■■...
p04024
<span class="lang-en"> <p>Score : <var>1700</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke got a grid from his mother, as a birthday present. The grid has <var>H</var> rows and <var>W</var> columns. Each cell is painted black or white. All black cells are <em>4-connected</em>, that is,...
p01226
<h1><font color="#000">Problem D:</font>バトルタウン</h1> <p> あなたは友人たちとゲームを開発することにした. ゲームのタイトルは「バトルタウン」. 戦車による市街戦をテーマにしたゲームだ. ゲーム開発の第一歩として,次のようなプロトタイプを開発することにした. </p> <p> このプロトタイプでは,登場する戦車はプレイヤーの戦車のみであり, 敵の戦車は登場しない. プレイヤーの戦車はプレイヤーの入力に従ってマップ上で様々な動作をする. 以下に,戦車の動作に関する仕様を述べる. </p> <...
p00964
<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...
p02959
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There are <var>N+1</var> towns. The <var>i</var>-th town is being attacked by <var>A_i</var> monsters.</p> <p>We have <var>N</var> heroes. The <var>i</var>-th hero can defeat monsters attacking the <var...
p01676
<h2>J - Tree Reconstruction</h2> <h3>Problem Statement</h3> <p> You have a directed graph. Some non-negative value is assigned on each edge of the graph. You know that the value of the graph satisfies the <em>flow conservation law</em> That is, for every node <var>v</var>, the sum of values on edges incoming to <var...
p01363
<H1><font color="#000">Problem E:</font> Alice and Bomb</H1> <p> Alice and Bob were in love with each other, but they hate each other now. </p> <p> One day, Alice found a bag. It looks like a bag that Bob had used when they go on a date. Suddenly Alice heard tick-tack sound. Alice intuitively thought that Bob is to ...
p01699
<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...
p00821
<H1><font color="#000">Problem C:</font> Area of Polygons</H1> <p> Yoko’s math homework today was to calculate areas of polygons in the <i>xy</i>-plane. Vertices are all aligned to grid points (i.e. they have integer coordinates). </p> <p> Your job is to help Yoko, not good either at math or at computer programming, ...
p01733
<p> Ievan Ritola is a researcher of behavioral ecology. Her group visited a forest to analyze an ecological system of some kinds of foxes. </p> <p> The forest can be expressed as a two-dimensional plane. With her previous research, foxes in the forest are known to live at lattice points. Here, lattice points are the ...
p00572
<h1>団子職人(Dango Maker)</h1> <p> あなたは団子を作る職人である.今,あなたは団子に串を刺そうとしているところである. </p> <p> 団子は,縦<var>N</var> 行,横<var>M</var> 列に仕切られたマスの中に配置されている.各マスには団子が1 個ずつ入っている.それぞれの団子には,赤(R),緑(G), 白(W) のいずれかの色が付いている.あなたは,左から右の方向,または,上から下の方向に連続する3 マスから団子を取り出し,この順に1 本の串にちょうど3個刺すことができる. </p> <p> 今あなたは,赤,緑,白の団子が1 個ずつこの順に刺さった串を可能な限り多く作...
p00088
<H1>博士が愛した符号</H1> <p> 博士 : ピーター君、ついにやったよ。<br/> ピーター : どうしました、デビッド博士?またくだらない発明ですか?<br/> 博士 : この表だよ、この表。<br/> </p> <center> <table width="700"><tr> <td width="140"> <table style="border: 1px #aaa solid; padding:4px"> <tr><td width="60">文字</td><td>符号</td></tr> <tr><td >(空白)</td><td>101</td></tr> <tr><td >'</td><td>0...
p00122
<H1>ぴょん吉の夏</H1> <p> 会津大学には一面芝生で覆われた公園があり、日差しを遮る木や建物がありません。日差しの強い夏の日には、公園内に設置されたスプリンクラーが作動して芝生に散水しています。この公園にはカエルのぴょん吉が住み着いています。ぴょん吉は暑いのが苦手で、日差しが強い夏の日には常にスプリンクラーの水に当たっていないと干からびて死んでしまいます。公園に設置されたスプリンクラーは、節水のため一度に一つだけ散水することになっているので、ぴょん吉はスプリンクラーの作動に合わせて移動しなくてはなりません。 </p> <center> <table> <tr><td> <img src="https://jud...
p02631
<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> Snuke Cats numbered <var>1, 2, \ldots, N</var>, where <var>N</var> is <strong>even</strong>.</p> <p>Each Snuke Cat wears a red scarf, on which his favorite non-negative integer is...
p03923
<span class="lang-en"> <p>Score : <var>1000</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Rng is baking cookies.</p> <p>Initially, he can bake one cookie per second.</p> <p>He can also eat the cookies baked by himself. When there are <var>x</var> cookies not yet eaten, he can choose to eat ...
p03889
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You are given a string <var>S</var> consisting of letters <code>b</code>, <code>d</code>, <code>p</code> and <code>q</code>. Determine whether <var>S</var> is a <em>mirror string</em>.</p> <p>Here, a mi...
p02261
<H1>Stable Sort</H1> <p> Let's arrange a deck of cards. There are totally 36 cards of 4 suits(S, H, C, D) and 9 values (1, 2, ... 9). For example, 'eight of heart' is represented by <span>H8</span> and 'one of diamonds' is represented by <span>D1</span>. </p> <p> Your task is to write a program which sorts a given s...
p03020
<span class="lang-en"> <p>Score : <var>1200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is playing with red and blue balls, placing them on a two-dimensional plane.</p> <p>First, he performed <var>N</var> operations to place red balls. In the <var>i</var>-th of these operations, he ...
p03470
<span class="lang-en"> <p>Score : <var>200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>An <em><var>X</var>-layered kagami mochi</em> <var>(X ≥ 1)</var> is a pile of <var>X</var> round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than...
p01158
<H1><font color="#000">Problem D:</font> Rock Man</H1> <p> You were the master craftsman in the stone age, and you devoted your life to carving many varieties of tools out of natural stones. Your works have ever been displayed respectfully in many museums, even in 2006 A.D. However, most people visiting the museums d...
p03165
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You are given strings <var>s</var> and <var>t</var>. Find one longest string that is a subsequence of both <var>s</var> and <var>t</var>.</p> </section> </div> <div class="part"> <section> <h3>Notes</h3...
p01508
<script src="./IMAGE/varmath.js" charset="UTF-8"></script> <H1>Longest Lane</H1> <p> Mr. KM, the mayor of KM city, decided to build a new elementary school. The site for the school has an awkward polygonal shape, which caused several problems. The most serious problem was that there was not enough space for a short ...
p03535
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>In CODE FESTIVAL XXXX, there are <var>N+1</var> participants from all over the world, including Takahashi.</p> <p>Takahashi checked and found that the <em>time gap</em> (defined below) between the local...
p02774
<span class="lang-en"> <p>Score: <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3> <p>We have <var>N</var> integers <var>A_1, A_2, ..., A_N</var>.</p> <p>There are <var>\frac{N(N-1)}{2}</var> ways to choose two of them and form a pair. If we compute the product of each of those pairs and...
p00749
<h1><font color="#000000">Problem D:</font> Off Balance</h1> <!-- end en only --> <!-- begin en only --> <p> You are working for an administration office of the International Center for Picassonian Cubism (ICPC), which plans to build a new art gallery for young artists. The center is organizing an architectural de...
p03866
<span class="lang-en"> <p>Score : <var>600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>On the <var>x</var><var>y</var>-plane, Snuke is going to travel from the point <var>(x_s, y_s)</var> to the point <var>(x_t, y_t)</var>. He can move in arbitrary directions with speed <var>1</var>. Here...
p02324
<H1>Chinese Postman Problem</H1> <p> For a given weighted undirected graph <var>G(V, E)</var>, find the distance of the shortest route that meets the following criteria: </p> <ul> <li>It is a closed cycle where it ends at the same point it starts.</li> <li>The route must go through every edge at least once.</li> </u...
p00319
<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> あなたは磐梯山で開催されるスキー競技に参加します。こ...
p00933
<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 J: Exhibition </h2> <p...
p01621
<!-- <h3><u>Sim Forest 2013</u></h3> --> <!-- end en only --> <!-- begin ja only --> <h1><u>どうぶつの盛り2013</u></h1> <!-- end ja only --> <!-- begin en only --> <!-- <p> English text is not available in this practice contest. </p> --> <!-- end en only --> <!-- begin ja only --> <p> Sim Forest 2013というゲームがある。このゲームでは、プレイヤ...
p01271
<h1><font color="#000">Problem E:</font> Mirror Cave</h1> <p> 双子の冒険者 Rin と Len は鏡の洞窟でお宝を探している.この洞窟には鏡の間という対になった 2 つの部屋があり,その部屋の扉の向こうには高価な宝が眠っているという. </p> <p> 便宜上,2 つの部屋はそれぞれ <i>W</i> &times; <i>H</i> のセルが格子状に並んだものとみなす.部屋の外側は壁で囲まれている.また,部屋の内側にもところどころ壁が設置されており,壁の配置されているセルには進入することができない.宝の部屋への扉を開くためには,2 人が左右対称の動きをして,同...