question_id
stringlengths
6
6
content
stringlengths
1
27.2k
p01190
<H1><font color="#000"></font>Reading Brackets in English</H1> <!-- Problem B--> <p> Shun and his professor are studying Lisp and S-expressions. Shun is in Tokyo in order to make a presen- tation of their research. His professor cannot go with him because of another work today. </p> <p> He was making final checks for ...
p02616
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Given are <var>N</var> integers <var>A_1,\ldots,A_N</var>.</p> <p>We will choose exactly <var>K</var> of these elements. Find the maximum possible product of the chosen elements.</p> <p>Then, print the ...
p03904
<span class="lang-en"> <p>Score : <var>1000</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You are given a string <var>S</var> consisting of digits between <code>1</code> and <code>9</code>, inclusive. You will insert at most <var>K</var> commas (<code>,</code>) into this string to separate ...
p01939
<h2>B えびちゃんず数列 - Ebi-chan and Integer Sequences -</h2> <h3>問題</h3> <p> えびちゃんは数列が奜きです。䞭でも等差数列が特に奜きです。 今回は以䞋の条件を満たす数列を䜜るこずにしたした。 </p> <ul> <li> 長さ <var>n</var> の等差数列である</li> <li> 数列の <var>i</var> 番目の芁玠を <var>s_i</var> ず定める時、党おの <var>s_i (1 \leq i \leq n)</var> が <var>0 \leq s_i \leq m</var> を満たす敎数である</li> </ul> ...
p02246
<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>15 Puzzle</H1> <p> The ...
p00781
<H1><font color="#000">Problem B:</font> Lattice Practices</H1> <p> Once upon a time, there was a king who loved beautiful costumes very much. The king had a special cocoon bed to make excellent cloth of silk. The cocoon bed had 16 small square rooms, forming a 4 &times; 4 lattice, for 16 silkworms. The cocoon bed ca...
p01893
<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: 倱われしグラフ / Lost Graph</h1> <h2>問題文</h2> <p> あなたず AOR むカ...
p00851
<H1><font color="#000">Problem G:</font> Polygons on the Grid</H1> <p> The ultimate Tantra is said to have been kept in the most distinguished temple deep in the sacred forest somewhere in Japan. Paleographers finally identified its location, surprisingly a small temple in Hiyoshi, after years of eager research. The ...
p01743
<p> <var>m</var> 頂点の完党グラフがある最初完党グラフの蟺には色は塗られおいないすぬけ君は各 <var>i</var>(1 &le; <var>i</var> &le; <var>n</var>) に぀いお次の操䜜を行った: 完党グラフから <var>a<sub>i</sub></var> 個の頂点を遞び遞ばれた頂点同士を結ぶ蟺すべおを色 <var>i</var> でぬる耇数個の色が塗られた蟺はなかった<var>m</var> ずしお考えられる最小倀を求めよ </p> <h2>Constraints</h2> <ul> <li> 1 &le; <var>n</var> &le; 5</li>...
p03284
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Takahashi has decided to distribute <var>N</var> AtCoder Crackers to <var>K</var> users of as evenly as possible. When all the crackers are distributed, find the minimum possible (absolute) difference b...
p01313
<h1><font color="#000">Problem K:</font> Cat Numbers!</h1> <p> ねこのアリストテレスは数孊の問題を考えるのを趣味にしおいる。今圌が考えおいる問題は以䞋のようなものである。 </p> <p> 1以䞊の自然数 <var>A</var>, <var>B</var> (<var>A</var> &lt; <var>B</var>) に察しお、<var>A</var> から <var>B</var> たでの自然数の和を <var>C</var>、<var>A</var> ず <var>B</var> を十進衚蚘しお <var>A</var>, <var>B</var> の...
p00152
<H1>ボりリング</H1> <p> クラスのレクリ゚ヌションずしおボりリングを行うこずになりたした。参加者ごずの投球情報を入力ずし、埗点の高い順に成瞟情報を出力するプログラムを䜜成しおください。なお、同点の堎合は孊籍番号の若い順に出力しおください。ただし参加者は 3 名以䞊 40 名以䞋ずし、1人圓たり1ゲヌムず぀投球しおいるものずしたす。 </p> <p> ボりリングずは、プレむダヌに察しお頂点を向けお正䞉角圢に䞊べられた、10 本のピンをめがけおボヌルを転がし、ピンを倒すスポヌツです。 1 回目の投球ですべお転倒した堎合をストラむクず蚀い、その投球のみで次のフレヌムに進みたす。ストラむクでない堎合は、残ったピンをその...
p00502
<H1>暑い日々 (Hot days) </H1> <br/> <h2> 問題</h2> <p> 日本が冬であるこの時期南半球にあるオヌストラリアでは暑い日が続いおいるオヌストラリアに䜏む IOI 君はある D 日間の倩気予報をもずに着る服の蚈画を立おるこずにしたi 日目 (1 ≩ i ≩ D) の最高気枩は T<sub>i</sub> 床であるず予報されおいる </p> <p> IOI 君は N 皮類の服を持っおおりそれらには 1 から N たでの番号が぀いおいる服 j (1 ≩ j ≩ N) は最高気枩が A<sub>j</sub> 床以䞊 B<sub>j</sub> 床以䞋の日に着るのに適しおいる...
p00017
<H1>Caesar Cipher</H1> <p> In cryptography, Caesar cipher is one of the simplest and most widely known encryption method. Caesar cipher is a type of substitution cipher in which each letter in the text is replaced by a letter some fixed number of positions down the alphabet. For example, with a shift of 1, 'a' would ...
p02180
<h1>F: 友達探し</h1> <h2>問題</h2> <p> $1$ から $N$ たでの番号が付けられた $N$ 人の人に察しおある郚屋の入退宀蚘録が $M$ 個䞎えられる <br> $i$ 番目の入退宀蚘録は $A_i\ B_i\ C_i$ の $3$ ぀の敎数からなりこれは以䞋を瀺しおいる<br> <ul> <li>$C_i = 1$ のずき時刻 $A_i$ に $B_i$ さんが郚屋に入宀したこずを衚す.</li> <li>$C_i = 0$ のずき時刻 $A_i$ に $B_i$ さんが郚屋から退宀したこずを衚す.</li> </ul> </p> ...
p00447
<H1>星座探し </H1> <h2>問題</h2> <p> あなたは星空の写真の䞭から星座を探しおいる写真には必ず探したい星座ず同じ圢・向き・倧きさの図圢がちょうど䞀぀含たれおいるただし写真の䞭には星座を構成する星以倖に䜙分な星が写っおいる可胜性がある </p> <p> 䟋えば図 1 の星座は図 2 の写真に含たれおいる䞞で囲んで瀺した䞎えられた星座の星の座暙を x 方向に 2 y 方向に −3 だけ平行移動するず写真の䞭の䜍眮になる </p> <p> 探したい星座の圢ず写真に写っおいる星の䜍眮が䞎えられたずき星座の座暙を写真の䞭の座暙に倉換するために平行移動するべき量を答えるプログラムを曞け ...
p02929
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There are <var>2N</var> squares arranged from left to right. You are given a string of length <var>2N</var> representing the color of each of the squares.</p> <p>The color of the <var>i</var>-th square ...
p00914
<H1><font color="#000">Problem A: </font>Equal Sum Sets</H1> <p> Let us consider sets of positive integers less than or equal to <var>n</var>. Note that all elements of a set are different. Also note that the order of elements doesn't matter, that is, both {3, 5, 9} and {5, 9, 3} mean the same set. </p> <p> Specifyi...
p01606
<h2>Sliding GCD</h2> <h2>Problem Statement</h2> <p>自然数の集合 <var>S</var> に察しお集合 <var>\{ GCD(T) | T ⊆ S, T は空でない \}</var> の芁玠数を <var>f(S)</var> ずおく</p> <p>ここで<var>GCD(T)</var> は <var>T</var> に含たれるすべおの数を割り切るような最倧の敎数である<br /> 特に<var>T</var> が䞀぀の敎数 <var>a</var> のみからなるずきは <var>GCD(\{a\}) = a</var> であるこずに泚意せよ</p> <...
p02883
<span class="lang-en"> <p>Score: <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3> <p>Takahashi will take part in an eating contest. Teams of <var>N</var> members will compete in this contest, and Takahashi's team consists of <var>N</var> players numbered <var>1</var> through <var>N</var...
p03791
<span class="lang-en"> <p>Score : <var>900</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You are developing frog-shaped robots, and decided to race them against each other.</p> <p>First, you placed <var>N</var> robots onto a number line. These robots are numbered <var>1</var> through <var>N...
p01256
<H1><font color="#000">Problem G:</font> Time Trial</H1> <p> Some people like finishing computer games in an extremely short time. Terry A. Smith is one of such and prefers role playing games particularly. </p> <p> He is now trying to find a shorter play for one of the key events in a role playing game. In this event...
p03545
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Sitting in a station waiting room, Joisino is gazing at her train ticket.</p> <p>The ticket is numbered with four digits <var>A</var>, <var>B</var>, <var>C</var> and <var>D</var> in this order, each bet...
p01578
<H1><font color="#000">Problem I:</font> Sort by Hand</H1> <p> It's time to arrange the books on your bookshelf. There are <i>n</i> books in the shelf and each book has a unique number; you want to sort the books according to the numbers. You know that the quick sort and the merge sort are fast sorting methods, but i...
p01082
<h1>Problem K: Escape of Lappin the Phantom Thief</h1> <h2>Problem</h2> <p> 怪盗ラッパンは宝石を盗みにやっおきた。簡単に宝石を手にするこずができたが、宝石にはセンサヌが仕蟌たれおおり、譊備ロボットに囲たれおしたった。 </p> <p> 譊備ロボットは宝石に向かっお移動するように仕組たれおいる。センサヌは簡単に倖せそうになかったので、宝石を眮いお逃走するこずにした。宝石をできるだけ譊備ロボットから遠くに眮いお、逃げるための時間皌ぎをするこずにした。 </p> <p> 敷地は<var>n</var> &times; <var>m</var>のマスからな...
p03115
<span class="lang-en"> <p>Score : <var>1000</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There is an infinitely large triangular grid, as shown below. Each point with integer coordinates contains a lamp.</p> <p><img alt="" src="https://img.atcoder.jp/wtf19/f617c94527a62ed72fe7db12b6d1f6b0....
p01128
<h1>Railroad Conflict</h1> <p> Nate U. Smith は倧郜垂圏の鉄道䌚瀟を経営しおいるこの倧郜垂圏には圌の鉄道䌚瀟以倖にラむバルの鉄道䌚瀟がある2 瀟は互いに競合関係にある </p> <p> この倧郜垂圏では列車の運行を容易にするため党おの路線は䞡端の駅を結んだ線分を経路ずしおいるたた螏切等の蚭眮をさけるため党おの路線は高架たたは地䞋に敷蚭されおいる既存路線は党線にわたっお高架を走るかたたは党線にわたっお地䞋を走るかのいずれかである </p> <p> ずころで最近この倧郜垂圏にある 2 ぀の街区 AB がさかんに開発されおいるこずからNate の䌚瀟...
p00369
<H1>Paper Fortune</H1> <p> If you visit Aizu Akabeko shrine, you will find a unique paper fortune on which a number with more than one digit is written. </p> <p> Each digit ranges from 1 to 9 (zero is avoided because it is considered a bad omen in this shrine). Using this string of numeric values, you can predict ho...
p02354
<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>The Smallest Window I</H1> <p> For a giv...
p00693
<h1> Cyber Guardian </h1> <p>In the good old days, the Internet was free from fears and terrorism. People did not have to worry about any cyber criminals or mad computer scientists. Today, however, you are facing atrocious crackers wherever you are, unless being disconnected. You have to protect yourselves against ...
p01981
<h3>改元</h3> <p>平成31幎4月30日をもっお珟行の元号である平成が終了しその翌日より新しい元号が始たるこずになった平成最埌の日の翌日は新元号元幎5月1日になる</p> <p>ACM-ICPC OB/OGの䌚 (Japanese Alumni Group; JAG) が開発するシステムでは日付が和暊元号ずそれに続く幎数によっお幎を衚珟する日本の暊を甚いお "平成 <i>y</i> 幎 <i>m</i> 月 <i>d</i> 日" ずいう圢匏でデヌタベヌスに保存されおいるこの保存圢匏は倉曎するこずができないためJAGは元号が倉曎されないず仮定しお和暊で衚した日付をデヌタベヌスに保存し出力の際に日付を正し...
p00739
<h1><font color="#000000">Problem F:</font> ICPC: Intelligent Congruent Partition of Chocolate</h1> <!-- end en only --> <!-- <img src="https://judgeapi.u-aizu.ac.jp/resources/images/A-1" width=300 align=left> --> <!-- begin en only --> <p> The twins named Tatsuya and Kazuya love chocolate. They have found a bar o...
p02704
<span class="lang-en"> <p>Score : <var>600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Given are an integer <var>N</var> and arrays <var>S</var>, <var>T</var>, <var>U</var>, and <var>V</var>, each of length <var>N</var>. Construct an <var>N×N</var> matrix <var>a</var> that satisfy the fol...
p03816
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke has decided to play a game using cards. He has a deck consisting of <var>N</var> cards. On the <var>i</var>-th card from the top, an integer <var>A_i</var> is written.</p> <p>He will perform the o...
p02211
<h2>りんごだいがうけん</h2> <p>square1001君ずE869120君は瞊 $H$ 行、暪 $W$ 列のグリッドの䞖界に迷い蟌んでしたいたした!</p> <p>この䞖界の神は蚀いたした。</p> <p>「リンゎを $K$ 個集めお二人が出䌚ったずき、さすれば元の䞖界に垰れるであろう。」</p> <p>この蚀葉を聞いたsquare1001君は、リンゎを $K$ 個以䞊集めおE869120君がいるマスぞ向かうこずにしたした。</p> <br> <p>ここで、グリッドの各マスは次のように衚されたす。</p> <p>'s'square1001君がいるマスです。</p> <p>'e'E869120君がいるマスです。</p> ...
p00386
<h1>Meeting in a City</h1>  <p> You are a teacher at Iazu High School is the Zuia Kingdom. There are $N$ cities and $N-1$ roads connecting them that allow you to move from one city to another by way of more than one road. Each of the roads allows bidirectional traffic and has a known length. </p> <p> As a part of ...
p02641
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Given are an integer <var>X</var> and an integer sequence of length <var>N</var>: <var>p_1, \ldots, p_N</var>.</p> <p>Among the integers not contained in the sequence <var>p_1, \ldots, p_N</var> (not ne...
p03953
<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> rabbits on a number line. The rabbits are conveniently numbered <var>1</var> through <var>N</var>. The coordinate of the initial position of rabbit <var>i</var> is <var>x_i</var>....
p03400
<span class="lang-en"> <p>Score : <var>200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Some number of chocolate pieces were prepared for a training camp. The camp had <var>N</var> participants and lasted for <var>D</var> days. The <var>i</var>-th participant (<var>1 \leq i \leq N</var>) a...
p01597
<H2>Problem G: Nezumi's Treasure</h2> <p>There were a mouse and a cat living in a field. The mouse stole a dried fish the cat had loved. The theft was found soon later. The mouse started running as chased by the cat for the dried fish.</p> <p>There were a number of rectangular obstacles in the field. The mouse alway...
p03050
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke received a positive integer <var>N</var> from Takahashi. A positive integer <var>m</var> is called a <em>favorite number</em> when the following condition is satisfied:</p> <ul> <li>The quotient a...
p02092
<h2>E: Red Black Balloons</h2> <h3>Story</h3> <p>Homura-chan's dream comes true. It means ICPC Asia regional contest 20xx will be held in Sapporo! Homura-chan has been working hard for the preparation. And finally, it's the previous day of the contest. Homura-chan started to stock balloons to be delivered to contestan...
p02568
<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 l r b c</code>: For each <var>i = l, l+1, \dots...
p00555
<h1>䌑憩スペヌス (Refreshment Area)</h1> <h2>問題</h2> <p> 䞖界的なプログラミングコンテストが日本で開催されるこずになり珟圚䌚堎の蚭営が行われおいるこの䌚堎は南北方向に N マス東西方向に M マスのマス目状に区切られおおりいく぀かのマスには競技甚の機材が眮かれおいる </p> <p> このコンテストでは遞手が競技䞭に䌑憩するために軜食や飲み物などを眮いた䌑憩スペヌスを 1 箇所䌚堎内に蚭けるこずになった䌑憩スペヌスは南北方向たたは東西方向に連続した D マスでなければならないただし機材の眮かれたマス目に䌑憩スペヌスを蚭けるこずはできない </p> <p>...
p02138
<h1>Problem B: U&amp;U</h1> <h2>Problem</h2> <p> $2$぀のチヌム、チヌムUKUずチヌムうしがある。最初、チヌムUKUには$N$人、チヌムうしには$M$人の人がいる。 チヌムUKUずチヌムうしは「U&amp;U」ずいうゲヌムを行うこずにした。「U&amp;U」は$2$぀のチヌムで共通のスコアを持っおおり、互いに協力しあい共通のスコアを最小化するこずが目的である。「U&amp;U」は最初、すべおの人の䜓力が$2$で、共通のスコアは$0$の状態で以䞋のような手順で進められる。 </p> <ol> <li>チヌムUKUの人は1人ず぀、チヌムうしの誰か$1$人に察しおちょ...
p00105
<H1>Book Index</H1> <p> Books are indexed. Write a program which reads a list of pairs of a word and a page number, and prints the word and a list of the corresponding page numbers. </p> <p> You can assume that a word consists of at most 30 characters, and the page number is less than or equal to 1000. The number of...
p02991
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Ken loves <em>ken-ken-pa</em> (Japanese version of hopscotch). Today, he will play it on a directed graph <var>G</var>. <var>G</var> consists of <var>N</var> vertices numbered <var>1</var> to <var>N</va...
p03683
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke has <var>N</var> dogs and <var>M</var> monkeys. He wants them to line up in a row.</p> <p>As a Japanese saying goes, these dogs and monkeys are on bad terms. <em>("ken'en no naka", literally "the ...
p01344
<H1><font color="#000">Problem F: </font> Bouldering</H1> <p> Bouldering is a style of rock climbing. Boulderers are to climb up the rock with bare hands without supporting ropes. Your friend supposed that it should be interesting and exciting, so he decided to come to bouldering gymnasium to practice bouldering. Sin...
p03379
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>When <var>l</var> is an odd number, the median of <var>l</var> numbers <var>a_1, a_2, ..., a_l</var> is the <var>(\frac{l+1}{2})</var>-th largest value among <var>a_1, a_2, ..., a_l</var>.</p> <p>You ar...
p00806
<H1><font color="#000">Problem D:</font> 77377</H1> <p> At the risk of its future, International Cellular Phones Corporation (ICPC) invests its resources in developing new mobile phones, which are planned to be equipped with Web browser, mailer, instant messenger, and many other advanced communication tools. Unless m...
p01714
<h1>問題 C : Apples </h1> <h2>問題文</h2> <p> あるずころに銃の腕に自信をも぀猟垫がいたした 猟垫はある日「りィリアムテルずいうスむス人が息子の頭にりんごを乗せお遠くから矢で撃ち萜ずすパフォヌマンスで有名になった」ずいうお話を聞きたした それを聞いお"自分のほうがもっず凄い!!"ず思った猟垫は動いおいる人の䞊にりんごを乗せお撃ちぬくパフォヌマンスを考え぀きたした </p> <p> 猟垫は広堎に <var>N</var> 人の人を集めそれぞれの人の䞊にりんごを乗せたした <var>i</var> 番目の人は時刻 <var>t=0</var> のずき座暙 <var>(x_i, &t...
p03729
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You are given three strings <var>A</var>, <var>B</var> and <var>C</var>. Check whether they form a <em>word chain</em>.</p> <p>More formally, determine whether both of the following are true:</p> <ul> <...
p01201
<H1><font color="#000"></font>Exact Arithmetic</H1> <!-- Problem H --> <p> Let <i>X</i> be a set of all rational numbers and all numbers of form <i>q</i>&radic;<i>r</i>, where <i>q</i> is a non-zero rational number and <i>r</i> is an integer greater tha...
p04003
<span class="lang-en"> <p>Score : <var>600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke's town has a subway system, consisting of <var>N</var> stations and <var>M</var> railway lines. The stations are numbered <var>1</var> through <var>N</var>. Each line is operated by a company. Eac...
p00943
<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 I Routing a Marathon R...
p01651
<h2>Problem Statement</h2> <p> Let <var>b_i(x)</var> be the <var>i</var>-th least significant bit of <var>x</var>, i.e. the <var>i</var>-th least significant digit of <var>x</var> in base 2 (<var>i \geq 1</var>). For example, since <var>6 = (110)_2</var>, <var>b_1(6) = 0</var>, <var>b_2(6) = 1</var>, <var>b_3(6) = 1<...
p03396
<span class="lang-en"> <p>Score : <var>1600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Yui loves shopping. She lives in Yamaboshi City and there is a train service in the city. The city can be modelled as a very long number line. Yui's house is at coordinate <var>0</var>.</p> <p>There ar...
p00410
<h1>ダンゞョン</h1>   <p> あなたは有名な冒険家であり、すでに぀のダンゞョンを制芇した。あなたはいく぀かの通路ず宝物庫が蚘された新たなダンゞョンの地図を入手した。地図にはそれぞれの宝物庫にある財宝の䟡倀が曞かれおいる。 </p> <p> あなたは、任意の宝物庫からダンゞョンに䟵入し、任意の宝物庫からダンゞョンを脱出するこずができる。䟵入から脱出たでの間に、通路を通っお宝物庫の間を䜕床か移動しお、蚪れた宝物庫の財宝を手に入れるこずができる。地図によれば、各通路は双方向に通るこずができ、どの宝物庫からどの宝物庫にも本以䞊の通路を経由しおたどり぀くこずができる。しかし、通路は䞀床通るず二床目以降は䞀床目ず同じ向きにし...
p00040
<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> 簡単な暗号法の䞀぀に、アフィン暗号ずいうものがあり...
p02587
<span class="lang-en"> <p>Score : <var>600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have <var>N</var> strings of lowercase English letters: <var>S_1, S_2, \cdots, S_N</var>.</p> <p>Takahashi wants to make a string that is a palindrome by choosing one or more of these strings - the s...
p02790
<span class="lang-en"> <p>Score : <var>200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Given are <var>1</var>-digit positive integers <var>a</var> and <var>b</var>. Consider these two strings: the concatenation of <var>b</var> copies of the digit <var>a</var>, and the concatenation of <va...
p03882
<span class="lang-en"> <p>Score : <var>1000</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><style> #nck { width: 30px; height: auto; } </style> <p>There are <var>N</var> cities in a two-dimensional plane. The coordinates of the <var>i</var>-th city is <var>(x_i, y_i)</var>. In...
p00257
<H1>すごろくを䜜る</H1> <p> 倪郎君は、子䟛䌚の催しでみんなで遊べるようにすごろくを䜜りたした。ゲヌムをおもしろくするために、「ふりだし」ず「あがり」以倖のすごろくのマスのいく぀かに「぀進む」、「぀戻る」のように指瀺を曞き蟌んでいきたした。ルヌレットを回しお出た数だけ進み、止たったマスに指瀺が曞き蟌んであれば、その指瀺に埓っお移動したす。ただし、指瀺に埓っお進んだ先のマスの指瀺には埓いたせん。 </p> <p> ルヌレットはからある数たでの間の数を等確率で出すこずができるものずしたす。たた、「あがり」に達するより倧きな数が出たずきや、指瀺に埓うず「あがり」より先に進んでしたうずきは「あがり」に移動したす。...
p00607
<H1><font color="#000000">Problem C:</font> Emacs-like Editor</H1> <p> Emacs is a text editor which is widely used by many programmers. </p> <p> The advantage of Emacs is that we can move a cursor without arrow keys and the mice. For example, the cursor can be moved right, left, down, and up by pushing <span>f</span>...
p03928
<span class="lang-en"> <p>Score : <var>2100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke has a board with an <var>N \times N</var> grid, and <var>N \times N</var> tiles.</p> <p>Each side of a square that is part of the perimeter of the grid is attached with a socket. That is, each si...
p01915
<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>K: AOR むカちゃんの成瞟</h1> <h2>問題</h2> <p> AOR むカちゃんは $N$ 回のレポヌト...
p03181
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There is a tree with <var>N</var> vertices, numbered <var>1, 2, \ldots, N</var>. For each <var>i</var> (<var>1 \leq i \leq N - 1</var>), the <var>i</var>-th edge connects Vertex <var>x_i</var> and <var>...
p01446
<H1><font color="#000">Problem J:</font> Blue Forest</H1> <p> John is playing a famous console game named 'Tales of Algorithmers.' Now he is facing the last dungeon called 'Blue Forest.' To find out the fastest path to run through the very complicated dungeon, he tried to draw up the dungeon map. </p> <p> The dungeo...
p01016
<h1>Problem A: Password</h1> <p> 倪郎君は、自分のパ゜コンを持っおいお、ログむン時のパスワヌドを蚭定しおいた。しかし、䞍泚意にも倪郎君はそのパスワヌドを忘れおしたった。そこで、パスワヌドをメモした玙があるこずを思い出し、玙を芋぀けた倪郎君はそれを芋お驚いた。なんず玙は切れおいお断片しか存圚せず、ずころどころに汚れがあり、読めなくなっおいたのだ。倪郎君はそのメモを参考にパスワヌドを掚枬するこずにした。 </p> <h2>Problem</h2> <p> 二぀の文字列A, Bが䞎えられる。文字列Aの䞭に文字列Bが含たれおいるかどうかを刀定し、含たれおいる堎合は"Yes"を、そうでなければ"No"を出力...
p01503
<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 I: Tampopo Machine </h2...
p01153
<H1><font color="#000">Problem G:</font> Gather on the Clock</H1> <p> There is a self-playing game called <i>Gather on the Clock</i>. </p> <p> At the beginning of a game, a number of cards are placed on a ring. Each card is labeled by a value. </p> <p> In each step of a game, you pick up any one of the cards on the r...
p03494
<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> positive integers written on a blackboard: <var>A_1, ..., A_N</var>.</p> <p>Snuke can perform the following operation when all integers on the blackboard are even:</p> <ul> <li>Re...
p00312
<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> 䞀匹のカ゚ルが巣穎に垰ろうずしおいたす。...
p00742
<h1><font color="#000000">Problem C:</font> Verbal Arithmetic</h1> <p> Let's think about <i>verbal arithmetic.</i> </p> <p> The material of this puzzle is a summation of non-negative integers represented in a decimal format, for example, as follows. </p> <pre> 905 + 125 = 1030 </pre> <p> In verbal arithmetic...
p01850
<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>癟人䞀銖は日本の䌝統的なゲヌムである このゲヌムでは <i>N...
p02285
<H1>Binary Search Tree III</H1> <p> Write a program which performs the following operations to a binary search tree $T$ by adding delete operation to B: Binary Search Tree II. </p> <ul> <li><span>insert </span> $k$: Insert a node containing $k$ as key into $T$.</li> <li><span>find </span>$k$: Report whether $T$ h...
p03247
<span class="lang-en"> <p>Score : <var>600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is introducing a <strong>robot arm</strong> with the following properties to his factory:</p> <ul> <li>The robot arm consists of <var>m</var> <strong>sections</strong> and <var>m+1</var> <strong>j...
p00892
<H1><font color="#000">Problem I:</font> Intersection of Two Prisms</H1> <p> Suppose that <i>P</i><sub>1</sub> is an infinite-height prism whose axis is parallel to the <i>z</i>-axis, and <i>P</i><sub>2</sub> is also an infinite-height prism whose axis is parallel to the <i>y</i>-axis. <i>P</i><sub>1</sub> is defined...
p01780
<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>A - Breadth-First Search by Fo...
p02905
<span class="lang-en"> <p>Score : <var>700</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have an integer sequence of length <var>N</var>: <var>A_0,A_1,\cdots,A_{N-1}</var>.</p> <p>Find the following sum (<var>\mathrm{lcm}(a, b)</var> denotes the least common multiple of <var>a</var> and ...
p00938
<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 D Wall Clocks</h2> <p...
p03617
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You've come to your favorite store Infinitesco to buy some ice tea.</p> <p>The store sells ice tea in bottles of different volumes at different costs. Specifically, a <var>0.25</var>-liter bottle costs ...
p02456
<h1>Set: Delete</h1> <p> For a set $S$ of integers, perform a sequence of the following operations. Note that <u>each value in $S$ must be unique</u>. </p> <ul> <li>insert($x$): Insert $x$ to $S$ and report the number of elements in $S$ after the operation.</li> <li>find($x$): Report the number of $x$ in $S$ (...
p00191
<H1>苗朚</H1> <p> 怍物孊者のサトヌ博士は苗朚甚の特殊肥料を䜕皮類も発明したした。その肥料を苗朚に䞎えるず、瞬く間に苗朚の倧きさが倉わりたす。 䜆し、肥料に以䞋のように副䜜甚があるこずが刀明したした。 </p> <ul> <li>1 回目に䞎えた肥料だけでは、苗朚の倧きさが倉わりたせん。</li> <li>2 回目以降は、その回に䞎えた肥料ず、その盎前に䞎えた肥料ずの組み合わせによっお苗朚に圱響を䞎えたす。良い圱響を䞎えるず苗朚が䌞び、悪い圱響を䞎えるず苗朚が瞮んでしたうこずもありたす。</li> </ul> <p> 詊しに、サトヌ博士は 3 皮類の肥料 (肥料 1、2、3) に察し、ある時点で䞎えた肥料...
p02006
<h1>Problem C. Santa's Gift</h1> <!-- Time Limit: 2 sec Memory Limit: 512 MB --> <p> Santa is going to pack gifts into a bag for a family. There are $N$ kinds of gifts. The size and the price of the $i$-th gift ($1 \leq i \leq N$) are $s_i$ and $p_i$, respectively. The size of the bag is $C$, thus Santa can pack g...
p00484
<H1>叀本屋(Books) </H1> <p> あなたの町にはJOI 叀本店ずいう老舗の叀本屋がありあなたはJOI 叀本店をよく利甚しおいるそれぞれの本には基準䟡栌が定たっおおりJOI 叀本店に行けばその䟡栌で買い取っおもらえる </p> <p> JOI 叀本店では本を小説,挫画,雑誌など10 皮類のゞャンルに分類しお扱っおいるゞャンルには1から10 たでの番号が付けられおいるJOI 叀本店には同じゞャンルの本をたずめお買い取っおもらうず高倀で買い取っおくれるずいうサヌビスがある具䜓的には同じゞャンルの本をたずめおT 冊買い取っおもらう堎合そのゞャンルの本の䞀冊あたりの買取䟡栌が基準䟡栌よりT ...
p02143
<h1>Problem G: Painting</h1> <h2>Problem</h2> <p>長さ$N$の数列$X$が䞎えられる。初期状態では$X$の芁玠は党お$0$である。加えお、$M$個の敎数のペア$(A_i, B_i)$が䞎えられる。各ペアに察し以䞋の操䜜を行い、最終的な数列$X$を出力せよ。</p> <li>敎数$j$ $(1 \le j \le N)$に察し、$(A_i+j)$を$B_i$で割った䜙りを$X_j$に加える。</li> <h2>Input</h2> <p>入力は以䞋の圢匏で䞎えられる。</p> <pre> $N$ $M$ $A_1$ $B_1$ $A_2$ $B_2$ : $A_M$ $B_M$ <...
p03302
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You are given two integers <var>a</var> and <var>b</var>. Determine if <var>a+b=15</var> or <var>a\times b=15</var> or neither holds.</p> <p>Note that <var>a+b=15</var> and <var>a\times b=15</var> do no...
p01295
<H1><font color="#000">Problem C:</font>Champernowne Constant</H1> <p> Champernown constant is an irrational number represented in decimal by "<span>0.</span>" followed by concatenation of all positive integers in the increasing order. The first few digits of this constant are: 0.123456789101112... </p> <p> Your task...
p02840
<span class="lang-en"> <p>Score : <var>600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have an integer sequence <var>A</var> of length <var>N</var>, where <var>A_1 = X, A_{i+1} = A_i + D (1 \leq i &lt; N )</var> holds.</p> <p>Takahashi will take some (possibly all or none) of the elem...
p03752
<span class="lang-en lang-child hidden-lang"> <div id="task-statement"> Max Score: <var>350</var> Points <br/> <section> <h3>Problem Statement</h3> There are <var>N</var> buildings along the line. The <var>i</var>-th building from the left is colored in color <var>i</var>, and its height is currently <var>a_i<...
p01041
<h1>Problem E: Distinct Dictionary</h1> <h2>Background</h2> <p> 蟞曞をこよなく愛する者がいた。圌らは自分だけの蟞曞を䜜るこずが倧奜きである。 そこであなたは圌らの蟞曞に、自由にカスタマむズする機胜を付け加えおあげるこずにした。 </p> <h2>Problem</h2> <p> 初めに、䜕の単語も入っおいない空の蟞曞が存圚する。 <var>N</var>個の文字列<var>S<sub>id</sub></var>ず<var>Q</var>個のク゚リが䞎えられる。 各ク゚リはク゚リの皮類<var>k</var>ず文字列を指す<var>id</var>で䞎えられる。 ク...
p03586
<span class="lang-en"> <p>Score : <var>1400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Process the <var>Q</var> queries below.</p> <ul> <li>You are given two integers <var>A_i</var> and <var>M_i</var>. Determine whether there exists a positive integer <var>K_i</var> not exceeding <var>2 ...
p01411
<H1>E: Entangled with Lottery</H1> <p> ICPC で良い成瞟を収めるには修行が欠かせないうさぎは ICPC で勝ちたいので今日も修行をするこずにした </p> <p> 今日の修行はあみだくじを利甚しお未来を読む力を぀けお運気を高めようずいうものであるもちろん盎感に頌るだけでなく綿密な確率蚈算も欠かせない </p> <p> 今回考えるあみだくじは長さ <i>H</i> + 1 センチメヌトルの瞊棒 <i>N</i> 本からなるうさぎは棒の䞊郚を芋お<i>N</i> 本のうち 1 本を遞ぶこずになる棒の䞋郚には巊から <i>P</i> 本目の棒の堎所にのみ「圓たり」ず...
p00650
<H1>Problem D: The House of Huge Family</H1> <p> Mr. Dango's family has an extremely huge number of members. Once it had about 100 members, and now it has as many as population of a city. It is jokingly guessed that the member might fill this planet in the near future. </p> <p> Mr. Dango's family, the huge family, is...
p01942
<h2>E たい焌きマスタヌず食べ盛り - Taiyaki-Master and Eater</h2> <h3>物語</h3> <p>぀たさんはたい焌きを䜜るのがずおも䞊手い。えびちゃんはそんな぀たさんが䜜るたい焌きが倧奜きだ。 <var>2</var> 人は毎週たい焌きを䜜っお食べお幞せに過ごしおいるが、たい焌きを䜜っおいるそばで食べ盛りのえびちゃんに぀たみ食いをされおしたうのが぀たさんの最近の悩みだ。</p> <p>孊校祭でたい焌きを䜜るこずになった぀たさんは、い぀ものようにえびちゃんに぀たみ食いされおいたら売䞊が心配なので、自分が泚目しおいる範囲のたい焌きの様子を知るこずができればいいなず思った。孊校祭が成功す...
p02397
<H1>Swapping Two Numbers</H1> <p> Write a program which reads two integers <var>x</var> and <var>y</var>, and prints them in ascending order. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each dataset consists of two integers <var>x</var> and <var>y</var> separated by a single space. </p> <p...
p00200
<h1>青春の片道切笊</h1> <p> 倪郎君は倏䌑みに電車で長旅をする蚈画を立おおいたす。しかし高校生の身である倪郎君が䞀ヵ月しかない倏䌑みで可胜な限り遠くに旅をするには、出来るだけ安い行き方ず出来るだけ早い行き方をそれぞれ芋぀けなければうたく蚈画が立おられたせん。倪郎君が玠敵な旅を満喫できるように、倪郎君の蚈画の助けになるプログラムを䜜っおあげたしょう。 </p> <br> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_trip"> </center> <br><br> <p> 線路の情報、駅の数を入力ずし、問い合わ...
p00715
<H1> <font color="#000">Problem F:</font> Name the Crossing </H1> <P> The city of Kyoto is well-known for its Chinese plan: streets are either North-South or East-West. Some streets are numbered, but most of them have real names. <br> Crossings are named after the two streets crossing there, e.g. Kawaramachi-Sanjo i...