question_id
stringlengths
6
6
content
stringlengths
1
27.2k
p02728
<span class="lang-en"> <p>Score : <var>600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3> <p>We have a tree with <var>N</var> vertices numbered <var>1</var> to <var>N</var>. The <var>i</var>-th edge in this tree connects Vertex <var>a_i</var> and <var>b_i</var>. For each <var>k=1, ..., N</var>...
p01807
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]} }); </script> <script type="text/javascript" async src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML"> </script> <!-- begin en only --> <h3><u>Stamp Rally</u></h3> <!...
p02682
<span class="lang-en"> <p>Score : <var>200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have <var>A</var> cards, each of which has an integer <var>1</var> written on it. Similarly, we also have <var>B</var> cards with <var>0</var>s and <var>C</var> cards with <var>-1</var>s.</p> <p>We w...
p03990
<span class="lang-en"> <p>Score : <var>1400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Sigma and Sugim are playing a game.</p> <p>The game is played on a graph with <var>N</var> vertices numbered <var>1</var> through <var>N</var>. The graph has <var>N-1</var> red edges and <var>N-1</var>...
p00345
<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> 実数のうち、小数部が循環するものと有限桁の...
p02378
<H1>Bipartite Matching</H1> <p> A bipartite graph <var>G = (V, E)</var> is a graph in which the vertex set <var>V</var> can be divided into two disjoint subsets <var>X</var> and <var>Y</var> such that every edge <var>e &isin; E</var> has one end point in <var>X</var> and the other end point in <var>Y</var>. </p> <p>...
p03139
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We conducted a survey on newspaper subscriptions. More specifically, we asked each of the <var>N</var> respondents the following two questions:</p> <ul> <li>Question <var>1</var>: Are you subscribing to...
p01104
<h3><u>Making Lunch Boxes</u></h3> <p> Taro has been hooked on making lunch boxes recently. Taro has obtained a new lunch box recipe book today, and wants to try as many of the recipes listed in the book as possible. </p> <p> Enough of the ingredients for all the recipes are at hand, but they all are in vacuum packs...
p03093
<span class="lang-en"> <p>Score : <var>1200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Let <var>M</var> be a positive integer.</p> <p>You are given <var>2 N</var> integers <var>a_1, a_2, \ldots, a_{2 N}</var>, where <var>0 \leq a_i &lt; M</var> for each <var>i</var>.</p> <p>Consider divi...
p03569
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a string <var>s</var> consisting of lowercase English letters. Snuke can perform the following operation repeatedly:</p> <ul> <li>Insert a letter <code>x</code> to any position in <var>s</var> o...
p01554
<h1>Kagisys</h1> <p>ある部屋ではICカードを用いて鍵を開け閉めする電子錠システムを用いている。 このシステムは以下のように動作する。 </p> <p>各ユーザーが持つICカードを扉にかざすと、そのICカードのIDがシステムに渡される。 システムはIDが登録されている時、施錠されているなら開錠し、そうでないのなら施錠し、それぞれメッセージが出力される。 IDが登録されていない場合は、登録されていないというメッセージを出力し、開錠及び施錠はおこなわれない。 </p> <p>さて、現在システムにはN個のID(U<sub>1</sub>, U<sub>2</sub>, ……, U<sub>N</sub>)が登録されてお...
p00596
<H1><font color="#000000">Problem B:</font> Dominoes Arrangement</H1> <pre> [0, 0] [0, 1] [1, 1] [0, 2] [1, 2] [2, 2] [0, 3] [1, 3] [2, 3] [3, 3] [0, 4] [1, 4] [2, 4] [3, 4] [4, 4] [0, 5] [1, 5] [2, 5] [3, 5] [4, 5] [5, 5] [0, 6] [1, 6] [2, 6] [3, 6] [4, 6] [5, 6] [6, 6] </pre> <p> Consider the ...
p02051
<h3>不思議なボタン</h3> <!-- begin ja only --> <p>あなたは,町外れにあるダンジョンでコインを稼ぐことにした.このダンジョンには <i>N</i> 個の部屋が存在し,<i>1</i> から <i>N</i> までの番号がつけられている.また,ダンジョン内には「コインボタン」「脱出ボタン」「ワープボタン」と呼ばれる不思議なボタンが存在する.それぞれのボタンの詳細は次の通りである.</p> <ul> <li>コインボタンは各部屋にちょうど <i>1</i> 個存在する.コインボタンは何回でも押すことができ,そのたびにコインが <i>1</i> 枚手に入る.</li> <li>脱出ボタンは各部屋にちょ...
p02401
<H1>Simple Calculator</H1> <p> Write a program which reads two integers <var>a</var>, <var>b</var> and an operator <var>op</var>, and then prints the value of <var>a</var> <var>op</var> <var>b</var>. </p> <p> The operator <var>op</var> is '+', '-', '*' or '/' (sum, difference, product or quotient). The division shoul...
p01387
<div> <h1 class="title">問題 L : <span style="font-size:110%;font-family:times new roman;"><i>L</i></span> 番目の数字</h1> <p>反乱を嗅ぎつけた多くの G○○gle のコーダーが我々を取り押さえにやってきた. かなりの数だ. その中には,東京大学時代に僕らを優しく指導してくれた先輩たちも多く見受けられる. 残念ながら,今では敵同士だ.</p> <dl class="docutils"> <dt>wata</dt> <dd>「予想以上の数だ…」</dd> <dt>(iwi)</dt> <dd>「ああ,我々が超高速指数時...
p02952
<span class="lang-en"> <p>Score : <var>200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Given is an integer <var>N</var>. Find the number of positive integers less than or equal to <var>N</var> that have an odd number of digits (in base ten without leading zeros).</p> </section> </div> <di...
p03640
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a grid with <var>H</var> rows and <var>W</var> columns of squares. Snuke is painting these squares in colors <var>1</var>, <var>2</var>, <var>...</var>, <var>N</var>. Here, the following conditi...
p03210
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p><em>Shichi-Go-San</em> (literally "Seven-Five-Three") is a traditional event in a certain country to celebrate the growth of seven-, five- and three-year-old children.</p> <p>Takahashi is now <var>X</va...
p02817
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Given are two strings <var>S</var> and <var>T</var> consisting of lowercase English letters. Concatenate <var>T</var> and <var>S</var> in this order, without space in between, and print the resulting st...
p01738
<p> You are practicing a juggle that involves in a number of square tiles. They all look the same in their size, but actually there are three different kinds of the tiles, A, B and X. The kind of a tile can be distinguishable by its mass. All the tiles of the same kind have exactly the same mass. The mass of type A t...
p03705
<span class="lang-en"> <p>Score : <var>200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke has <var>N</var> integers. Among them, the smallest is <var>A</var>, and the largest is <var>B</var>. We are interested in the sum of those <var>N</var> integers. How many different possible sums ...
p01368
<H1><font color="#000">Problem J:</font> Merry Christmas</H1> <p> International Christmas Present Company (ICPC) is a company to employ Santa and deliver presents on Christmas. Many parents request ICPC to deliver presents to their children at specified time of December 24. Although same Santa can deliver two or more...
p03355
<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>. Among the <strong>different</strong> substrings of <var>s</var>, print the <var>K</var>-th lexicographically smallest one.</p> <p>A substring of <var>s</var> is a st...
p00980
<h2>Estimating the Flood Risk</h2> <p> Mr. Boat is the owner of a vast extent of land. As many typhoons have struck Japan this year, he became concerned of flood risk of his estate and he wants to know the average altitude of his land. The land is too vast to measure the altitude at many spots. As no steep slopes ar...
p01692
<h2>F - Dangerous Delivery / 危険な輸送</h2> <h3>Story</h3> <p>Dのひとは重大な使命を背負っていた。それはDAtaCoDer社長のDhokudai氏へ、次のDAtaCoDer Regular Contest(DARC)のD問題を届けることだ。Dのひとのアジトがある都市<var>1</var>からDAtaCoDer本社がある都市<var>N</var>までは<var>N</var>個の都市が一直線に並んでいる。この移動の間、不正を企む緑の三角形の集団がD問題を狙っており、その魔の手からD問題を守らねばならない。</p> <p>幸い、Dのひとは次元(ディメンジョン)の壁を超えて移...
p02114
<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>Problem D: Fissure Puzzle...
p00129
<h1>かくれんぼう</H1> <p> たろう君はかくれんぼうが苦手です。隠れるとすぐ見つかっちゃうし、隠れている子をなかなか見つけることができません。見かねたお父さんは、超高性能位置探索システムを作ってくれました。これを使うと自分の位置を含めて、友達の位置を正確に知ることができます。鬼になったら、隠れている子を探すことが簡単にできるようになりました。 </p> <!-- 見つけたい子の位置に行けば、それで OK のはずです。これを使っていることがばれると遊んでもらえなくなるので内緒で使います。 --> <p> たろう君はさらにこのシステムを進化させ、鬼から自分が見えるか否かを判定する機能を付加することを思いつきました。...
p02544
<span class="lang-en"> <p>Score : <var>900</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Given are a permutation <var>p_1, p_2, \dots, p_N</var> of <var>(1, 2, ..., N)</var> and an integer <var>K</var>. Maroon performs the following operation for <var>i = 1, 2, \dots, N - K + 1</var> in thi...
p00579
<h1>イルミネーション (Illumination)</h1> <!--  時間制限 : 2sec / メモリ制限 : 256MB--> <h2>問題文</h2> <p> JOI 氏は,自宅の敷地に <var>N</var> 本の木を所有している.これらの木は一列に並んでおり,順に <var>1</var> から <var>N</var> までの整数で番号が付けられている. </p> <p> この冬,JOI 氏はいくつかの木を選んで,イルミネーションを飾り付けることにした.イルミネーションには<strong>美しさ</strong>と呼ばれる値が定まっている.木 <var>i</var> にイルミネーションを飾り付ける場合...
p00083
<H1>西暦和暦変換</H1> <p> 西暦で表された年月日を、元号を用いた和暦に変換し、その年月日を出力するプログラムを作成してください。入力は例に示すように 3 つの整数であり、順に西暦年、月、日です。これを、出力例に示すように変換してください。なお、明治以前の年月日が入力された場合は「pre-meiji」と表示してください。 </p> <p> 各年号の最初の年は「元年」ではなく「1年」と出力することとします。 </p> <center> <table border=1> <tr><td align=center width=100>元号</td><td align=center width=240>期間</td><...
p00216
<H1>水道料金</H1> <p> <!--あいづ学園都市に住んでいる-->松平さんは、普段からエコに気を付けて生活をしています。先月の水道料金が 4280 円となり、いつも目標としている 4000 円を超えてしまったので、今月は節水に努めてきました。先月と比べて水道料金はどのくらい節約できたのでしょうか。 </p> <p> 今月の使用水量 <var>w</var> [m<sup>3</sup>] を入力とし、先月の水道料金である 4280 円と比較して、どのくらい水道料金を節約できたかを出力するプログラムを作成してください。 </p> <p> なお、水道料金は次のように計算されます。 </p> <p> (水道...
p02381
<H1>Standard Deviation</H1><br> <p> You have final scores of an examination for <var>n</var> students. Calculate standard deviation of the scores <var>s<sub>1</sub></var>, <var>s<sub>2</sub></var> ... <var>s<sub>n</sub></var>. </p> <p> The variance &alpha;<sup>2</sup> is defined by </p> <p> &alpha;<sup>2</sup> ...
p01954
<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...
p03969
<span class="lang-en"> <p>Score : <var>1300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>One day, AtCoDeer the deer found a simple graph (that is, a graph without self-loops and multiple edges) with <var>N</var> vertices and <var>M</var> edges, and brought it home. The vertices are numbere...
p00646
<H1><font color="#000000">Problem J:</font> No Story</H1> <p> Since I got tired to write long problem statements, I decided to make this problem statement short. For given positive integer <i>L</i>, how many pairs of positive integers <i>a</i>, <i>b</i> (<i>a</i> &le; <i>b</i>) such that LCM(<i>a</i>, <i>b</i>) = <i>...
p01407
<H1>A: Attack the Moles</H1> <p> ICPC で良い成績を収めるには修行が欠かせない.うさぎは ICPC で勝ちたいので,今日も修行をすることにした. </p> <p> 今日の修行は,もぐらたたきを何回も行って,反射神経と記憶力を高めようというものである.出てくるもぐらを次々に叩き,出来るだけ多くのポイントを獲得したい. </p> <p> もぐらが出てくる可能性のある場所は直線状に並んでいて,基準点からの距離によって座標が定まっている.うさぎはしばらく修行を続けるうちに,もぐらの出現する場所と時間が常に一緒であることに気が付いた.うさぎは,その情報をすべて記録し,コンピュータで解析を行うことにした...
p03590
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p><em>Seisu-ya</em>, a store specializing in non-negative integers, sells <var>N</var> non-negative integers. The <var>i</var>-th integer is <var>A_i</var> and has a <em>utility</em> of <var>B_i</var>. Th...
p01057
<h1>String Crossing</h1> <h2>Problem</h2> <p> <var>N</var>個の文字列{ <var>S<sub>1</sub></var>, <var>S<sub>2</sub></var>, ..., <var>S<sub>N</sub></var> } が与えられる。 続いて<var>Q</var>個のクエリが与えられる。 クエリの種類は以下の2つである。 </p> <ol> <li> <var>a</var>,<var>b</var>,<var>c</var>,<var>d</var>が入力され<var>S<sub>a</sub></var> の <var>b</var>文字目か...
p01542
<h1>失われし数</h1> <p> 時は3xxx年、高度に発達した文明は停滞期を迎えていた。歴史家たちはこの状況を打開しようと過去の叡智を学ぶことにした。注目したのはコンピュータ創世期の天才が残した資料である。この資料には計算式が書かれておりその計算結果が知りたいのだが、残念ながらその一部の文字が薄れて読めなくなっている。仕方がないので計算結果としてありえる最も大きい数を求めることにした。 計算式は2進数で書かれており、演算は足し算・引き算・掛け算の3種類である。括弧も用いられているが括弧内が数字のみであることはない。正確には以下のBNFで定義された文法を満たしている必要がある。 </p> <pre>&lt;expres...
p03085
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>On the Planet AtCoder, there are four types of bases: <code>A</code>, <code>C</code>, <code>G</code> and <code>T</code>. <code>A</code> bonds with <code>T</code>, and <code>C</code> bonds with <code>G</...
p01112
<h3>Playoff by all the teams</h3> <!-- end en only --> <!-- begin en only --> <p> The Minato Mirai Football Association hosts its annual championship as a single round-robin tournament, in which each team plays a single match against all the others. Unlike many other round-robin tournaments of football, matches ne...
p00353
<H1>Shopping</H1> <p> You are now in a bookshop with your friend Alice to buy a book, "The Winning Strategy for the Programming Koshien Contest,” just released today. As you definitely want to buy it, you are planning to borrow some money from Alice in case the amount you have falls short of the price. If the amount y...
p03986
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a string <var>X</var>, which has an even number of characters. Half the characters are <code>S</code>, and the other half are <code>T</code>.</p> <p>Takahashi, who hates the string <code>ST</cod...
p02694
<span class="lang-en"> <p>Score : <var>200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3> <p>Takahashi has a deposit of <var>100</var> yen (the currency of Japan) in AtCoder Bank.</p> <p>The bank pays an annual interest rate of <var>1</var> % compounded annually. (A fraction of less than one y...
p01811
<h2>ABC Gene</h2> <p>文字列 <code>ABC</code> で表される遺伝子配列がある。あなたは次の操作を何回か行い、この遺伝子配列を書き換えていくことができる。</p> <ul> <li>文字 <code>A</code>,<code>B</code>,<code>C</code> のうち <var>1</var> つを選ぶ。これを <var>x</var> とおく。遺伝子配列に含まれるすべての <var>x</var> をそれぞれ <code>ABC</code> へ同時に置き換える。</li> </ul> <p><code>A</code>,<code>B</code>,<code>C</co...
p00703
<h1> What is the Number in my Mind ? </h1> <p>Let us enjoy a number guess game. </p> <p>A number containing L digits is in my mind (where 4 &lt;= L &lt;= 10). You should guess what number it is. It is composed of any of the following ten digits:<br></p><pre> "0","1","2","3","4","5","6","7","8", and "9". </pre> <p...
p03206
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>In some other world, today is December <var>D</var>-th.</p> <p>Write a program that prints <code>Christmas</code> if <var>D = 25</var>, <code>Christmas Eve</code> if <var>D = 24</var>, <code>Christmas E...
p04039
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> y...
p03656
<span class="lang-en"> <p>Score : <var>1700</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There are two rooted trees, each with <var>N</var> vertices. The vertices of each tree are numbered <var>1</var> through <var>N</var>. In the first tree, the parent of Vertex <var>i</var> is Vertex <va...
p00979
<h2>Fast Forwarding</h2> <p> Mr. Anderson frequently rents video tapes of his favorite classic films. Watching the films so many times, he has learned the precise start times of his favorite scenes in all such films. He now wants to find how to wind the tape to watch his favorite scene as quickly as possible on his ...
p02944
<span class="lang-en"> <p>Score : <var>1800</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>For a sequence <var>S</var> of positive integers and positive integers <var>k</var> and <var>l</var>, <var>S</var> is said to belong to <em>level</em> <var>(k,l)</var> when one of the following conditi...
p01391
<script src="./IMAGE/varmath.js" charset="UTF-8"></script> <h1><font color="#000">問題 D </font> 列の構成</h1> <h2>問題文</h2> <p><var>1</var> から <var>N</var> までの相異なる整数が <var>N / 2</var> 個書かれたカードがいくつか与えられるので,次の条件を満たすような長さ <var>N</var> の数列 <var>seq</var> を <var>1</var> つ作って出力して欲しい.</p> <ul> <li><var>seq</var> の各要素は <var>...
p02417
<H1>Counting Characters</H1><br> <p> Write a program which counts and reports the number of each alphabetical letter. Ignore the case of characters. </p> <H2>Input</H2> <p> A sentence in English is given in several lines. </p> <H2>Output</H2> <p> Prints the number of alphabetical letters in the following f...
p02047
<h3>文字列の魔法</h3> <!-- begin ja only --> <p>魔法使いであるあなたは,今日も魔法の修行に励んでいる.あなたは今,手元に英小文字からなる文字列 <i>X</i> を持っている.あなたの今日の修行の課題は,この文字列を,別の文字列 <i>Y</i> に変化させることである.</p> <p>あなたは,文字列を変化させる魔法を 4 種類習得していて,それらを好きな順序で何回でも唱えることができる.ただし,魔法を唱えるたびに,魔法石と呼ばれる特別な石を消費する.あなたが習得している魔法は次の通りである.</p> <ul> <li>魔法石を <i>A</i> 個消費する.手元の文字列の好きな位置に,好き...
p00580
<h1>座席 (Seats) </h1> <!--  時間制限 : 5sec / メモリ制限 : 256MB --> <h2> 問題文</h2> <p> 2XXX 年,世界の国は直線状に並んでいた.<var>N</var> 個の国があり,<var>1, 2, ..., N</var> の番号が付けられている.<var>i = 1, 2, ..., N - 1</var> に対し,国 <var>i</var> と国 <var>i + 1</var> が互いに隣国である. </p> <p> この年の国際情報オリンピックでは,国 <var>i</var> からは <var>A_i</var> 人の選手が参加する.国際情報オリンピック...
p00095
<H1>ワカサギ釣り大会</H1> <p> 桧原湖でワカサギ釣り大会が行われました。一番多くのワカサギを獲得した人が優勝者です。 </p> <p> 参加者番号と釣った匹数のリストを読み込み、優勝者の番号と釣った匹数を出力するプログラムを作成してください。優勝者が複数いる場合は、<!--最初の-->その中で参加者番号が最も小さい一人を出力してください。 </p> <H2>入力</H2> <p> 入力は以下の形式で与えられる。 </p> <pre> <var>n</var> <var>a<sub>1</sub></var> <var>v<sub>1</sub></var> <var>a<sub>2</sub></var...
p02552
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Given is an integer <var>x</var> that is greater than or equal to <var>0</var>, and less than or equal to <var>1</var>. Output <var>1</var> if <var>x</var> is equal to <var>0</var>, or <var>0</var> if <...
p02102
<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>Problem E: Tangled Cables<...
p01684
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script> <h3>Problem Statement</h3> <p>...
p00996
<h1>Problem G: Dice</h1> <p> サイコロ3兄弟は三つ子であり一心同体、3つでひとつとも言ってもよい。三つ子であるため見分けがつかないほど似ている。そんなサイコロ3兄弟はA君のお気に入りのおもちゃだ。A君はいつも3つ1セットでサイコロを転がして遊んでいる。このようにA君が楽しく遊ぶおもちゃだが、実は大きな秘密があった。彼らは実は生きていて、話したり自由に動いたりできるのだ。子ども部屋は <i>r</i > × <i> c </i> の大きさのグリッドで表すことができ、とても大きいものが散乱している。 </p> <p> サイコロ3兄弟は室内を東西南北の4方向へ進行方向に向かって転がりながら移動する。そ...
p03343
<span class="lang-en"> <p>Score : <var>600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You are given an integer sequence <var>A</var> of length <var>N</var> and an integer <var>K</var>. You will perform the following operation on this sequence <var>Q</var> times:</p> <ul> <li>Choose a con...
p03713
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There is a bar of chocolate with a height of <var>H</var> blocks and a width of <var>W</var> blocks. Snuke is dividing this bar into exactly three pieces. He can only cut the bar along borders of blocks...
p02801
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Given is a lowercase English letter <var>C</var> that is not <code>z</code>. Print the letter that follows <var>C</var> in alphabetical order.</p> </section> </div> <div class="part"> <section> <h3>Cons...
p01000
<h1>Problem B: Independent Research</h1> <h2>Problem</h2> <!-- <p> 長期休暇の課題とは、長期休暇を使ってこれまでの勉強の復習をさせる<del>ことを建て前に、計画倒れがいかにして発生するかを生徒に体験させる</del>ため、長期休暇に課される試練のことである。 その中でも、自由研究とは、長期休暇の課題の中でも最も過酷な課題である。 「自由研究」と言う名に反して強制である場合が多く、研究しないという選択肢は存在しない。 絵、工作、生き物観察など、様々な分野の課題があり、とりあえず僕は、生き物観察を自由研究のテーマとした。 </p> --> <p> 僕は夏休みの...
p01450
<H1>Problem D: 僕の友達は小さい</H1> <p> 僕には、たくさんの友達がいる。どの友達も、とても小さい。<br> 僕は、よく友達と一緒に出かける。何人かの友達をリュックに入れて、一緒に出かける。<br> 僕は毎朝、その日一緒に出かける友達を決める。空のリュックに、1人ずつ友達を入れていく。<br> 僕は、あまり力が強くない。だから、同時に運べる友達の重さには限界がある。<br> 僕は、重さの限界を超えないように友達を入れていく。どの順番で入れていくかは気分次第。<br> 僕は、入れられる友達がまだ残っている限り、入れるのを止めない。決して止めない。<br> </p> <p> ……ところで、リュックに入った...
p03197
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There is an apple tree that bears apples of <var>N</var> colors. The <var>N</var> colors of these apples are numbered <var>1</var> to <var>N</var>, and there are <var>a_i</var> apples of Color <var>i</v...
p01903
<link rel="stylesheet" href="css/description.css" type="text/css" /> <script language="JavaScript" type="text/javascript" src="js/varmath.js" charset="UTF-8"></script> <h2>F: 風呂がオーバーフロー - Overflow of Furo -</h2> <h3>物語</h3> <p> 温泉宿・パロは自慢の温泉に全ての情熱を注いでおり、風呂のプロフェッショナルを集めている。 風呂のプロたちは主に温泉の配管を管理しており、複数の源泉から1つの大浴場へと繋がる...
p00611
<H1><font color="#000000">Problem G:</font> Building Water Ways</H1> <p> In ancient times, Romans constructed numerous water ways to supply water to cities and industrial sites. These water ways were amongst the greatest engineering feats of the ancient world. </p> <p> These water ways contributed to social infrastru...
p00241
<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>四元数のかけ算</H1> <p> 複素数を拡張したものに四元数と呼ばれるものがあります。物体の回転などを表現するのに便...
p03894
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You have <var>N</var> cups and <var>1</var> ball.</p> <p>The cups are arranged in a row, from left to right.</p> <p>You turned down all the cups, then inserted the ball into the leftmost cup.</p> <p>The...
p02786
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Caracal is fighting with a monster.</p> <p>The <em>health</em> of the monster is <var>H</var>.</p> <p>Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's ...
p02293
<H1>Parallel/Orthogonal</H1> <br/> <p> For given two lines <var>s1</var> and <var>s2</var>, print "2" if they are parallel, "1" if they are orthogonal, or "0" otherwise. </p> <p> <var>s1</var> crosses points <var>p0</var> and <var>p1</var>, and <var>s2</var> crosses points <var>p2</var> and <var>p3</var>. </p> <H2>...
p01846
<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>jfen</h3> <p><i>H &times; W</i> の盤面で遊ぶ一人用ゲームが...
p02769
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There is a building with <var>n</var> rooms, numbered <var>1</var> to <var>n</var>.</p> <p>We can move from any room to any other room in the building.</p> <p>Let us call the following event a <strong>m...
p00754
<h3><U>The Balance of the World</U></h3> <!-- end en only --> <div> <!-- please enclose each h3 level section with div --> <!-- begin en only --> <p> The world should be finely balanced. Positive vs. negative, light vs. shadow, and left vs. right brackets. Your mission is to write a program that judges whether a ...
p02339
<!--<h1>写像12相 その9:ボールに区別あり・箱に区別なし・箱の中身は1つ以上</h1>--> <h1>Balls and Boxes 9</h1> <table border=""> <tr><th>Balls</th><th>Boxes</th><th>Any way</th><th>At most one ball</th><th>At least one ball</th></tr> <tr><th>Distinguishable</th><th>Distinguishable</th><td>1</td><td>2</td><td>3</td></tr> <tr><th>Indistinguishab...
p00304
<h1>新薬開発</h1> <p> 英世博士は日々研究を行い、新しい薬を開発しようとしています。新薬を開発するためには、色々な物質を組み合わせて薬を作り試験を行い、良い薬を見つけなければなりません。様々な組み合わせを試していくうちに、英世博士は物質の組み合わせが樹形図で表せることを突き止めました。 </p> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_PCK2014_drugDevelopment"> </center> <br> <p> 右の図は、薬の調合を表す樹形図の例です。図の中で丸く囲まれたものを物質ノード、三...
p03482
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You are given a string <var>S</var> consisting of <code>0</code> and <code>1</code>. Find the maximum integer <var>K</var> not greater than <var>|S|</var> such that we can turn all the characters of <va...
p01145
<!-- begin en only --> <h3><U> Princess' Japanese </U></h3> <!-- end en only --> <!-- begin ja only --> <h3><U> お姫様の日本語 </U></h3> <!-- end ja only --> <!-- begin en only --> <p> English text is not available in this practice contest. </p> <!-- end en only --> <!-- begin ja only --> <p> ある貧乏な国のおてんばで勇敢なお姫様は,日本語の勉強を...
p03178
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Find the number of integers between <var>1</var> and <var>K</var> (inclusive) satisfying the following condition, modulo <var>10^9 + 7</var>:</p> <ul> <li>The sum of the digits in base ten is a multiple...
p01515
<!-- begin en only --> <h3><u>Equation </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> 論理演算では,値は T と F の2種類だけを扱う. </p> <p> &quo...
p03528
<span class="lang-en"> <p>Score : <var>1000</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Select any integer <var>N</var> between <var>1000</var> and <var>2000</var> (inclusive), and any integer <var>K</var> not less than <var>1</var>, then solve the problem below.</p> <h4>Problem</h4> <p>W...
p02010
<h1>Problem G. Additions</h1> <!-- Time Limit: 2 sec Memory Limit: 512 MB --> <p> You are given an integer $N$ and a string consisting of '<span>+</span>' and digits. You are asked to transform the string into a valid formula whose calculation result is smaller than or equal to $N$ by modifying some characters. Her...
p00187
<H1>投石おみくじ</H1> <p> 「自分の道は自分で切り開く」をモットーに、ある神社が自分自身の手で運勢を決めるおみくじを作りました。そのおみくじを引く人にはまず6つの石を投げてもらい、その投げた石の一つ目と二つ目を結ぶ 線分、三つ目と四つ目を結ぶ 線分、五つ目と六つ目を結ぶ 線分の3本の線分の交点を頂点とする 三角形の面積から運勢を決めるというものです。各運勢と三角形の面積との関係は以下のとおりです。 </p> <center> <table> <tr><th width="300">線分の交点を頂点とする三角形の面積</th><th> 運勢</th></tr> <tr><td> ...
p02440
<h1>Min-Max Element</h1> <p> Write a program which manipulates a sequence $A = \{a_0, a_1, ..., a_{n-1}\}$ by the following operations: </p> <ul> <li>min($b, e$): report the minimum element in $a_b, a_{b+1}, ..., a_{e-1}$</li> <li>max($b, e$): report the maximum element in $a_b, a_{b+1}, ..., a_{e-1}$</li> </u...
p03601
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is making sugar water in a beaker. Initially, the beaker is empty. Snuke can perform the following four types of operations any number of times. He may choose not to perform some types of operatio...
p02913
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Given is a string <var>S</var> of length <var>N</var>.</p> <p>Find the maximum length of a non-empty string that occurs twice or more in <var>S</var> as contiguous substrings without overlapping.</p> <p...
p01796
<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 G JAG-channel II</h2> ...
p00884
<H1><font color="#000">Problem A:</font> Membership Management</H1> <p> Peter is a senior manager of Agile Change Management (ACM) Inc., where each employee is a member of one or more task groups. Since ACM is agile, task groups are often reorganized and their members frequently change, so membership management is hi...
p03251
<span class="lang-en"> <p>Score : <var>200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Our world is one-dimensional, and ruled by two empires called Empire A and Empire B.</p> <p>The capital of Empire A is located at coordinate <var>X</var>, and that of Empire B is located at coordinate <...
p03744
<span class="lang-en"> <p>Score : <var>900</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You are in charge of controlling a dam. The dam can store at most <var>L</var> liters of water. Initially, the dam is empty. Some amount of water flows into the dam every morning, and any amount of wate...
p01779
<h2>H : Typing Game / タイピングゲーム</h2> <h3>物語</h3> <p> ここからは,タイピング力を鍛える時間です.皆さんは早く正確なタイピングをすることができますか? Let’s enjoy Typing Game! </p> <h3>問題</h3> <p>タイピングゲームのゲームシステムとして,ジャッジ側が用意したAIの出力に対して対話的に動作するプログラムを作成せよ.</p> <p>AIは <var>N</var> 個の文字列をタイプするゲームをプレイする.AIは体力を持っており,その初期値は <var>H</var> である.AIは体力がある限り文字のタイプを行う.システムはAIがタ...
p02856
<span class="lang-en"> <p>Score: <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3> <p><var>N</var> programmers are going to participate in the preliminary stage of DDCC 20XX. Due to the size of the venue, however, at most <var>9</var> contestants can participate in the finals.</p> <p>The...
p01283
<H1><font color="#000">Problem A:</font> Strange String Manipulation</H1> <p> A linear congruential generator produces a series R(&sdot;) of pseudo-random numbers by the following for- mulas: </p> <!-- <p> R(0) = S , R(i) = (A · R(i − 1) + C) mod M (for i = 1, 2, . . .), </p> --> <center> ...
p03314
<span class="lang-en"> <p>Score : <var>1100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You are given integers <var>N, K</var>, and an integer sequence <var>A</var> of length <var>M</var>.</p> <p>An integer sequence where each element is between <var>1</var> and <var>K</var> (inclusive) i...
p01329
<h1><font color="#000">Problem I:</font> 盗まれた宝石</h1> <p>パル王国の国宝である宝石が盗賊たちに盗まれた。 冒険者のあなたはその噂を聞きつけて盗賊のアジトに向かい、なんとか宝石を取り戻すことが出来た。</p> <p>ところが、宝石をパル王国の城へ返しに出向いたところ、城の守衛兵から、 「我が王はまだあなたを完全に信用していない。その宝石が本物かどうか怪しいし、そもそも宝石を取り戻したというのがウソで、王の命を狙う盗賊の仲間なのではないか?と疑っておられる。」 といわれた。</p> <p>あなたは、守衛兵から本当に信頼できる人物かどうか試すための試練を与えられた。試練の内容は、...
p00168
<H1>観音堂</H1> <p> 一郎君の家の裏山には観音堂があります。この観音堂まではふもとから 30 段の階段があり、一郎君は、毎日のように観音堂まで遊びに行きます。一郎君は階段を1足で3段まで上がることができます。遊んでいるうちに階段の上り方の種類(段の飛ばし方の個数)が非常にたくさんあることに気がつきました。 </p> <p> そこで、一日に 10 種類の上り方をし、すべての上り方を試そうと考えました。しかし数学を熟知しているあなたはそんなことでは一郎君の寿命が尽きてしまうことを知っているはずです。 </p> <p> 一郎君の計画が実現不可能であることを一郎君に納得させるために、階段の段数 <var>n</va...
p02155
<h1>Problem G: First Kiss</h1> <h2>Problem</h2> <p> ビット君の通う男子校では昼休みにキッポーゲームが行われている。<br> この学校のキッポーゲームは少し変わっていることで有名だ。<br> まず、$N$本のキッポーを用意する。$i$本目のキッポーの長さは$a_i$である。<br> 先手と後手が交互にキッポーを食べる。<br> すごい長さのキッポーを一気に食べると喉に刺さってしまうので、$1$以上$D$以下の好きな長さだけ食べる。<br> 彼らは不器用なので、整数長でのみキッポーを食べることができる。<br> 最初にいずれかのキッポーが食べつ...
p00492
<H1>イルミネーション (Illumination) </H1> <h2> 問題</h2> <p> JOI 社の建物は図のような 1 辺 1 メートルの正六角形をつなぎ合わせた形である.クリスマスが近づいているので,JOI 社では建物の壁面をイルミネーションで飾り付けることにした.ただし,外から見えない部分にイルミネーションを施すのは無駄なので,イルミネーションは外から建物の中を通らずに行くことのできる壁面にのみ飾り付けることにした. </p> <center> <p><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_2012-yo-...
p00538
<h2>ケーキの切り分け2 (Cake 2)</h2> <p> JOI くんと IOI ちゃんは双子の兄妹である.JOI くんは最近お菓子作りに凝っていて,今日も JOI くんはケーキを焼いて食べようとしたのだが,焼きあがったところで匂いをかぎつけた IOI ちゃんが来たので 2人でケーキを分けることになった. </p> <p> ケーキは円形である.ある点から放射状に切り目を入れ,ケーキを <var>N</var> 個のピースに切り分け,ピースに 1 から <var>N</var> まで反時計回りに番号をつけた.つまり,1 &le; <var>i</var> &le; <var>N</var> に対し,<var>i</var...