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>ダンジョン3</h1>   <p> あなたは有名な冒険家であり、すでに2つのダンジョンを制覇した。あなたはいくつかの通路と宝物庫が記された新たなダンジョンの地図を入手した。地図にはそれぞれの宝物庫にある財宝の価値が書かれている。 </p> <p> あなたは、任意の宝物庫からダンジョンに侵入し、任意の宝物庫からダンジョンを脱出することができる。侵入から脱出までの間に、通路を通って宝物庫の間を何度か移動して、訪れた宝物庫の財宝を手に入れることができる。地図によれば、各通路は双方向に通ることができ、どの宝物庫からどの宝物庫にも1本以上の通路を経由してたどりつくことができる。しかし、通路は一度通ると二度目以降は一度目と同じ向きにし...
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> 太郎君は、子供会の催しでみんなで遊べるようにすごろくを作りました。ゲームをおもしろくするために、「ふりだし」と「あがり」以外のすごろくのマスのいくつかに「6つ進む」、「5つ戻る」のように指示を書き込んでいきました。ルーレットを回して出た数だけ進み、止まったマスに指示が書き込んであれば、その指示に従って移動します。ただし、指示に従って進んだ先のマスの指示には従いません。 </p> <p> ルーレットは1からある数までの間の数を等確率で出すことができるものとします。また、「あがり」に達するより大きな数が出たときや、指示に従うと「あがり」より先に進んでしまうときは「あがり」に移動します。...
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...