question_id
stringlengths
6
6
content
stringlengths
1
27.2k
p03108
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There are <var>N</var> islands and <var>M</var> bridges.</p> <p>The <var>i</var>-th bridge connects the <var>A_i</var>-th and <var>B_i</var>-th islands bidirectionally.</p> <p>Initially, we can travel b...
p01135
<h1><font color="#000000">Problem E:</font> Poor Mail Forwarding</h1> <p> Masa 君が住んでいる地域の郵便システムは少々変わっている。 この地域では、各々の郵便局に対して 1 から順に連続した異なる番号がつけられており、ある郵便局に届けられた郵便物は、その郵便局からいくつかの郵便局を経由して目的の郵便局に届けられる。 郵便物の「転送」は、特定の郵便局の間でしか行われない。 ただし、転送が行われる郵便局同士の間では、転送は双方向に行われる。 </p> <p> ある郵便局から宛先まで郵便物を転送するための経路が複数存...
p01420
<script src="./IMAGE/varmath.js" charset="UTF-8"></script> <H1>Marathon Match</H1> <p> <var>N</var> people run a marathon. There are <var>M</var> resting places on the way. For each resting place, the <var>i</var>-th runner takes a break with probability <var>P_i</var> percent. When the <var>i</var>-th runner takes ...
p01070
<h1>String in String</h1> <h2>Problem</h2> <p> 文字列<var>S</var>と<var>Q</var>個のクエリが与えられる。<br> <var>i</var>番目のクエリ(0 &le; <var>i</var> &le; <var>Q</var>-1)には閉区間[<var>l<sub>i</sub></var>,<var>r<sub>i</sub></var>]と文字列<var>M<sub>i</sub></var>が与えられる。 <var>S</var>の<var>l<sub>i</sub></var>文字目から<var>r<sub>i</sub></var>文字目までの部...
p00231
<H1>危ない橋</H1> <p> 会津若松市よりずっと北に位置する会津古松村では、「ヤ橋(やばし) 」と呼ばれる橋が周辺の村へ移動する唯一の手段となっています。その橋は通行人が多いにも関わらず、今にも壊れそうなほど老朽化が進んでしまっています。 </p> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_dengarousBridge"><br/> </center> <br/> <p> ヤ橋は 150 [kg] まで耐えられる強度を持っています。例えば、80 [kg] の人と 50 [kg] の人が同時に渡るこ...
p01973
<h2>G: 検閲により置換 (Censored String)</h2> <h3>Problem Statement</h3> <p>You are given the string <var>S</var>, and the set of strings <var>\mathcal P</var> whose size is <var>N</var>. Now we consider applying the following operation to <var>S</var>:</p> <ul> <li> Choose exactly one character in <var>S</var>, and replace...
p00661
<H1>Problem C: Time Manipulation</H1> <p> 彼女は見習いの魔法使いだ。 彼女はまず最初に時間を操る魔法を覚えた。 そして彼女は生計を立たせるために酒屋を開くことにした。 彼女の住んでいる国の住人達はみんなお酒が大好き、ということが関係している。 住人達は長い年数をかけて熟成させたお酒が特に好きで、熟成させた年数に応じてその価値も比例して上がる。 50年熟成させたお酒より100年熟成させたお酒のほうが価値が高いのは簡単に想像がつくはずだ。 そして手に入れるのが難しいということも。 彼女は自分の魔法を使って、長い年月熟成させたお酒を一瞬で作って、それを売って収入を得ようとしているのであった...
p01359
<H1><font color="#000">Problem A:</font> Era Name</H1> <p> As many of you know, we have two major calendar systems used in Japan today. One of them is Gregorian calendar which is widely used across the world. It is also known as “Western calendar” in Japan. </p> <p> The other calendar system is era-based calendar, or...
p03364
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke has two boards, each divided into a grid with <var>N</var> rows and <var>N</var> columns. For both of these boards, the square at the <var>i</var>-th row from the top and the <var>j</var>-th colum...
p01709
<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> <meta http-equiv="X-UA-Compatibl...
p03734
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You have <var>N</var> items and a bag of strength <var>W</var>. The <var>i</var>-th item has a weight of <var>w_i</var> and a value of <var>v_i</var>.</p> <p>You will select some of the items and put th...
p02826
<span class="lang-en"> <p>Score : <var>1200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p><var>N</var> problems have been chosen by the judges, now it's time to assign scores to them!</p> <p>Problem <var>i</var> must get an integer score <var>A_i</var> between <var>1</var> and <var>N</var>,...
p02575
<span class="lang-en"> <p>Score : <var>600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There is a grid of squares with <var>H+1</var> horizontal rows and <var>W</var> vertical columns.</p> <p>You will start at one of the squares in the top row and repeat moving one square right or down. H...
p00548
<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> <h2>オレンジの出荷(Oranges)</h2> <p> あなたはJuicy Orang...
p02125
<h1>Problem B: OOllOll</h1> <h2>Problem</h2> <p> 非負整数$x$を2進数表記したときの各桁の和を$f(x)$とする。<br> 正整数$N$が与えられるので$f(0)$,$f(1)$,...,$f(N)$の中で最大のものを出力せよ。<br> </p> <p> 関数$f(5)$の計算の例:<br> 5を2進数表記すると101で各桁の和は1+0+1=2<br> よって$f(5) = 2$となる。<br> </p> <p> Note: https://ja.wikipedia.org/wiki/二進法<br> </p> <h2>Input</h2> <p>入力は以下...
p00118
<H1>Property Distribution</H1> <p> タナカ氏が <var>HW</var> アールの果樹園を残して亡くなりました。果樹園は東西南北方向に <var>H &times; W</var> の区画に分けられ、区画ごとにリンゴ、カキ、ミカンが植えられています。タナカ氏はこんな遺言を残していました。 </p> <p> 果樹園は区画単位でできるだけ多くの血縁者に分けること。ただし、ある区画の東西南北どれかの方向にとなりあう区画に同じ種類の果物が植えられていた場合は、区画の境界が分からないのでそれらは 1 つの大きな区画として扱うこと。 </p> <p> 例えば次のような 3 &times...
p02430
<h1>Enumeration of Combinations</h1> <p> Print all combinations which can be made by $k$ different elements from $0, 1, ..., n-1$. Note that we represent $0, 1, ... n-1$ as 00...0001, 00...0010, 00...0100, ..., 10...0000 in binary respectively and the integer representation of a combination is calculated by bitwise...
p02060
<h2>A: four tea</h2> <h3>問題</h3> <p>プログラミングコンテストにはお茶が欠かせない。お茶にはコンテスタントの緊張を和らげる作用があるのだ [要出典]</p> <p>コンテストに参加する選手が <var>N</var> 人いるので、この人数分のお茶を用意したいと考えている。お茶のパッケージは <var>A</var>, <var>B</var>, <var>C</var>, <var>D</var> の 4 種類あり、どれも同じ品種であるが内容量が異なる。あるパッケージ <var>X</var> について、そのパッケージ 1 つ分の値段は <var>p_X</var> 円であり、1 つ買うと <v...
p03221
<span class="lang-en"> <p>Score: <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>In Republic of Atcoder, there are <var>N</var> prefectures, and a total of <var>M</var> cities that belong to those prefectures.</p> <p>City <var>i</var> is established in year <var>Y_i</var> and belongs...
p03671
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is buying a bicycle. The bicycle of his choice does not come with a bell, so he has to buy one separately.</p> <p>He has very high awareness of safety, and decides to buy two bells, one for each h...
p02963
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Given is an integer <var>S</var>. Find a combination of six integers <var>X_1,Y_1,X_2,Y_2,X_3,</var> and <var>Y_3</var> that satisfies all of the following conditions:</p> <ul> <li><var>0 \leq X_1,Y_1,X...
p03606
<span class="lang-en"> <p>Score : <var>200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Joisino is working as a receptionist at a theater.</p> <p>The theater has <var>100000</var> seats, numbered from <var>1</var> to <var>100000</var>.</p> <p>According to her memo, <var>N</var> groups of a...
p00929
<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 F: There is No Alternat...
p02914
<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> non-negative integers: <var>A_1, A_2, ..., A_N</var>.</p> <p>Consider painting at least one and at most <var>N-1</var> integers among them in red, and painting the rest in blue.</p>...
p03256
<span class="lang-en"> <p>Score : <var>900</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You are given an undirected graph consisting of <var>N</var> vertices and <var>M</var> edges. The vertices are numbered <var>1</var> to <var>N</var>, and the edges are numbered <var>1</var> to <var>M</v...
p01791
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type='text/javascript' src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script> </script> <h2>Problem B Card Game Strategy</...
p00883
<H1><font color="#000">Problem J:</font> Infected Land</H1> <p> The earth is under an attack of a deadly virus. Luckily, prompt actions of the Ministry of Health against this emergency successfully confined the spread of the infection within a square grid of areas. Recently, public health specialists found an interes...
p02017
<h2>C: 祈祷 (Pray)</h2> <p>とある双子は、コンテスト前に祈祷をすることで有名である。</p> <p>4 つの整数 $H, W, X, Y$ があって、$H \times W$ と $x + y$ が両方とも奇数だと縁起が悪いらしい。</p> <h3>入力</h3> <p>4 つの整数 $H, W, X, Y$ が空白区切りで与えられる。</p> <h3>出力</h3> <p>縁起が悪いなら "No"、そうでないなら "Yes" を出力しなさい。ただし、最後の改行を忘れないこと。</p> <h3>制約</h3> <ul> <li>$H, W, X, Y$ は $1$ 以上 $100$ 以下の整数<...
p02447
<h1>Sorting Pairs</h1> <p> Write a program which print coordinates $(x_i, y_i)$ of given $n$ points on the plane by the following criteria. </p> <ol> <li>first by $x$-coordinate</li> <li>in case of a tie, by $y$-coordinate</li> </ol> <h2>Input</h2> <p> The input is given in the following format. </p> <pre> $...
p00180
<H1>橋の取り壊し</H1> <p> 水の国ウォーターデブンには <var>n</var> 個の都市があります。各都市は水に囲まれており、島国のようになっています。ウォーターデブンには <var>m</var> 本の橋があり、都市間の交通はそれらの橋によって行われ、全ての都市に行き来することができます。 </p> <p> 最近、道路特定財源の見直しにより橋の維持費の削減が決定されました。全部の橋を維持することができなくなってしまい、いくつかの橋を取り壊すことになりました。そこで、ウォーターデブンはどの都市にでも行くことができるように橋を残しつつ、橋の維持費を最小化することが課題となりました。 </p> <p> 都市の数...
p00495
<H1> たのしいカードゲーム(Card Game is Fun) </H1> <p> 1 から1000 までのどれかの整数が書かれたカードがたくさんある.アンナとブルーノはそれらのカードを用いて,次のようなゲームをする. </p> <p> アンナは<i>A</i> 枚,ブルーノは<i>B</i> 枚のカードからなる山を持つ.アンナは<i>A</i> 枚のカードの中から任意の何枚か(0 枚でもよい)を捨てて新しい山を作る.ブルーノは<i>B,</i> 枚のカードからなる山の一番上から何枚か(0枚でもよい)と,一番下から何枚か(0 枚でもよい)を捨てて新しい山を作る.ただし,捨てる際に残ったカードの並び替えは行わない.こ...
p02152
<h1>Problem D: Tunnel</h1> <h2>Problem</h2> <p> 横軸$x$、縦軸$y$の$xy$平面上に$n$個の長方形がある。$i$番目の長方形は、高さ$h_i$、幅$1$であり、頂点は点$(i-1, 0)$、点$(i-1, h_i)$、点$(i, h_i)$、点$(i, 0)$である。<br> あなたは$n$個の正の整数$y_1, y_2, ... y_n$を選び、以下の$n$回の操作を行う。<br> (1) 1回目の操作では、点$(0, 1)$と点$(1, y_1)$を結ぶ線分を引く。<br> (2) $i$回目$(2 \le i \le n)$の操作では、点$(i-1...
p01284
<H1><font color="#000">Problem B:</font> Erratic Sleep Habits</H1> <p> Peter is a person with erratic sleep habits. He goes to sleep at twelve o'lock every midnight. He gets up just after one hour of sleep on some days; he may even sleep for twenty-three hours on other days. His sleeping duration changes in a cycle, ...
p03743
<span class="lang-en"> <p>Score : <var>900</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Alice lives on a line. Today, she will travel to some place in a mysterious vehicle. Initially, the distance between Alice and her destination is <var>D</var>. When she input a number <var>x</var> to th...
p02851
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Given are a sequence of <var>N</var> positive integers <var>A_1, A_2, \ldots, A_N</var>, and a positive integer <var>K</var>.</p> <p>Find the number of non-empty contiguous subsequences in <var>A</var> ...
p03313
<span class="lang-en"> <p>Score : <var>700</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There is an integer sequence of length <var>2^N</var>: <var>A_0, A_1, ..., A_{2^N-1}</var>. (Note that the sequence is <var>0</var>-indexed.)</p> <p>For every integer <var>K</var> satisfying <var>1 \leq...
p01904
<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>G: 最小包含矩形 - Minimum Enclosing Rectangle -</h2> <h3>物語</h3> <p> みんなぁ、こんにちは! 八森中ぷろこん部の藍座あいりだよぉ。 突然だけど、あいりがこの前解けなかった問題をみんなに解いて欲しいんだぁ~。 この前部活で<a h...
p03939
<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> balls and <var>N+1</var> holes in a line. Balls are numbered <var>1</var> through <var>N</var> from left to...
p00616
<H1><font color="#000000">Problem B:</font> Cubes Without Holes</H1> <p> There is a cube which consists of <i>n</i> &times; <i>n</i> &times; <i>n</i> small cubes. Small cubes have marks on their surfaces. An example where <i>n</i> = 4 is shown in the following figure. </p> <br> <center> <img src="https://judgeapi.u...
p03893
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a cord whose length is a positive integer. We will perform the following condition until the length of the cord becomes at most <var>2</var>:</p> <ul> <li>Operation: Cut the rope at two positi...
p02781
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Find the number of integers between <var>1</var> and <var>N</var> (inclusive) that contains exactly <var>K</var> non-zero digits when written in base ten.</p> </section> </div> <div class="part"> <secti...
p00246
<H1>ばらばら饅頭</H1> <p> 会津若松市にある和菓子屋・友栗堂の店長さんは、とても腕のいい職人さんなのにちょっと気分屋なのが玉にキズです。店長さんの作る饅頭はとても美味しいのですが、その時の気分によって大きさがまちまちになってしまいます。 </p> <!-- 時には普通の饅頭の何倍もの大きさで作ってしまうこともあるほどです。大きさや重さをいちいち量り、一つ一つ違う値段をつけるのはお客さんにとっても店にとっても不便なので困りものでした。 --> <p> 見かねた店長さんの奥さんは、大きさと重さがばらばらな饅頭を袋に詰めて売り出すことを思いつきました。一定の重さになるように饅頭を袋に詰めて売れば、一つ一つの大きさはばら...
p01007
<h1>Problem B: Matrix Operations</h1> <h2>Problem</h2> <p> 要素が1と0からなる<var>n</var>×<var>n</var>の行列に対して、以下の種類の操作を行うプログラムを作成せよ。 </p> <!-- <p> 祖父から1と0だけが書かれた<var>n</var>×<var>n</var>の行列と<var>m</var>個の操作が書かれている紙が送られてきた。 </p> <p> 紙の裏を見てみると、「この紙に書いてある行列に操作を加えて新しくできた行列をわしのとこに送ってくるのじゃ! ...
p03190
<span class="lang-en"> <p>Score : <var>1400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You are given strings <var>s</var> and <var>t</var>, both of length <var>N</var>. <var>s</var> and <var>t</var> consist of <code>0</code> and <code>1</code>. Additionally, in these strings, the same ch...
p01457
<script src="./IMAGE/varmath.js" charset="UTF-8"></script> <H1>Carpenters' Language</H1> <p> International Carpenters Professionals Company (ICPC) is a top construction company with a lot of expert carpenters. What makes ICPC a top company is their original language. </p> <p> The syntax of the language is simply gi...
p01142
<!-- begin en only --> <h3><U>Karakuri Doll</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> からくり人形師の JAG 氏は,長年の研究の果てに,伝統技術と最新技術を融...
p03485
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You are given two positive integers <var>a</var> and <var>b</var>. Let <var>x</var> be the average of <var>a</var> and <var>b</var>. Print <var>x</var> rounded up to the nearest integer.</p> </section> ...
p01512
<H1>Tree Allocation</H1> <p> A tree is one of the most popular data structures in computer science. Tree itself is very elegant, but it is incompatible with current computer architecture. In the current architecture, memory can be regarded as a one-dimensional array. Since a tree is not a one-dimensional structure, ...
p01841
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>C - みさわさんの根付き木</h2> <h3>Problem Statement</h3...
p00753
<h3><U>Chebyshev's Theorem</U></h3> <!-- end en only --> <div> <!-- please enclose each h3 level section with div --> <!-- begin en only --> <p> If <i>n</i> is a positive integer, there exists at least one prime number greater than <i>n</i> and less than or equal to 2<i>n</i>. This fact is known as Chebyshev's the...
p02294
<H1>Intersection</H1> <br/> <p> For given two segments <var>s1</var> and <var>s2</var>, print "1" if they are intersect, "0" otherwise. </p> <p> <var>s1</var> is formed by end points <var>p0</var> and <var>p1</var>, and <var>s2</var> is formed by end points <var>p2</var> and <var>p3</var>. </p> <H2>Input</H2> <p> ...
p00303
<h1>デッドロックを検出せよ</h1> <p> コンピュータにおける「データベース」とは、情報を管理するための入れ物で、「データベースマネジメントシステム(DBMS)」とは、その管理をする仕組みです。複数のユーザが利用するデータベースでは、DBMS は慎重に構築する必要があります。 </p> <p> 例えば、倉庫から商品を1つ取り出した人が、データベースに対して以下の処理を行うとしましょう。<br> (1) 商品の個数 <var>N</var> をデータベースから読む。<br> (2) 新たな商品の個数 <var>N</var>-1 をデータベースに書き込む。<br> </p> <p> ユーザ1が(1)を終えて(...
p02410
<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>Matrix Vector Multiplicati...
p00587
<H1>Binary Tree Intersection And Union</H1> <p> Given two binary trees, we consider the “intersection” and “union” of them. Here, we distinguish the left and right child of a node when it has only one child. The definitions of them are very simple. First of all, draw a complete binary tree (a tree whose nodes have e...
p02040
<h1>D: 場所当てゲーム</h1> <h2>問題</h2> <p>AORイカちゃん と そすうさ がグラフを使った場所当てゲームを行う.</p> <p> 最初に,AORイカちゃん が整数 $N$ を指定し,そすうさ は頂点数 $N$ の無向グラフを生成する. $N$ 個の頂点には, $1$ ~ $N$ までの番号が割り振られている.この無向グラフを使って,$K$ 回ゲームを行う. </p> <p>各ゲームのはじめに AORイカちゃん は頂点を $1$ つ選び,そすうさ がその頂点を当てる.</p> <p> そすうさ は AORイカちゃん に最大 $10$ 回まで質問することができる...
p03201
<span class="lang-en"> <p>Score : <var>600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Takahashi has <var>N</var> balls with positive integers written on them. The integer written on the <var>i</var>-th ball is <var>A_i</var>. He would like to form some number of pairs such that the sum o...
p01396
<script src="./IMAGE/varmath.js" charset="UTF-8"></script> <h1><font color="#000">問題 I </font>山</h1> <h2>問題文</h2> <p> L 氏はある都市の市長である.L 氏の市長としての手腕はすさまじく時を止め一瞬にして都市中に鉄道網を引いたり,財政の赤字を一夜にして莫大な黒字にしたり,はては巨大な怪獣をどこからともなく呼んでパフォーマンスに使うこともした. </p> <p> そんな L 氏は土地の隣り合った行または列同士を何度も入れ替えることででこぼこな土地を山形にするという遊びを最近発明した.土地は <var>H×W<...
p03651
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There is a box containing <var>N</var> balls. The <var>i</var>-th ball has the integer <var>A_i</var> written on it. Snuke can perform the following operation any number of times:</p> <ul> <li>Take out ...
p02943
<span class="lang-en"> <p>Score : <var>1300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Takahashi has a string <var>S</var> of length <var>N</var> consisting of lowercase English letters. On this string, he will perform the following operation <var>K</var> times:</p> <ul> <li>Let <var>T</...
p03344
<span class="lang-en"> <p>Score : <var>1000</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There is a simple undirected graph with <var>N</var> vertices and <var>M</var> edges. The vertices are numbered <var>1</var> through <var>N</var>, and the edges are numbered <var>1</var> through <var>M...
p01379
<div> <h1 class="title">問題 D : 停止問題</h1> <p>G○○gle Code Jam は G○○gle 社が年に 1 度開催するコンテストである. 優勝者は G○○gle への入社を許される,世界最高峰のコンテストだ. しかし勿論,それ以外の参加者は帰らぬ者となる.</p> <p>G○○gle Code Jam では自分の好きなプログラミング言語や処理系を使うことができる. 僕は Defunge という自らが開発したプログラミング言語で参加することにした. この言語を使えば,計算困難な問題はおろか,判定不能な問題ですら解決できる気がしている.</p> <div> <h1>問題</h1> <p...
p01683
<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>...
p00991
<h1>Problem B : Grid</h1> <p> <i>r</i> × <i>c</i> の2次元グリッド上の2つの座標 (<i>a<sub>1</sub></i>,<i>a<sub>2</sub></i>) と (<i>b<sub>1</sub></i>,<i>b<sub>2</sub></i>) が与えられる。 あるマス (e,f) から (e+1,f)、(e-1,f)、(e,f+1)、(e,f-1) のどれかのマスに移動するコストを1とする。 また、(e,c-1) と (e,0)、(r-1,f) と (0,f) の間もコスト1で移動することができる。 この時に1つ目の座標から2つ目の座標へ最短コストで移動できる...
p03714
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Let <var>N</var> be a positive integer.</p> <p>There is a numerical sequence of length <var>3N</var>, <var>a = (a_1, a_2, ..., a_{3N})</var>. Snuke is constructing a new sequence of length <var>2N</var>...
p01729
<p>20XX年, ICPC (Ikuta's Computer Pollutes Community) 商店街の経営者たちは大気汚染に悩まされていた。かつての活気を取り戻すためにも大気の綺麗さを一定以上にしなければならない。 </p> <p>商店街の店は一列に並んでおり、1から<var>n</var>で番号付けられている。 現在、おのおのの店のまわりの大気の綺麗さは <var>p<sub>i</sub></var> である。 あなたは2から<var>n&minus;1</var>番目の店を選んで、その周辺の大気を循環させることで, その店と周囲の店の大気の綺麗さを変更することができる。 正確にいうと, <var>i</va...
p02806
<span class="lang-en"> <p>Score : <var>200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3> <p>Niwango created a playlist of <var>N</var> songs. The title and the duration of the <var>i</var>-th song are <var>s_i</var> and <var>t_i</var> seconds, respectively. It is guaranteed that <var>s_1,\ldo...
p00568
<h1>森林伐採 (Deforestation)</h1> <h2>問題文</h2> <p> JOI 王国には広大な森林がある.森林は長方形の形をしており,南北に <var>H</var> マス,東西に <var>W</var> マスのマス目状に分けられている.北から <var>i</var> マス目,西から <var>j</var> マス目(<var>1 ≦ i ≦ H, 1 ≦ j ≦ W</var>)の領域には <var>A_{i,j}</var> 本の木が生えている.ただし,北西の端の領域には木材加工工場があり,木が生えていない.すなわち,<var>A_{1,1}=0</var> である.</p> <p> 木が生えて...
p02555
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Given is an integer <var>S</var>. Find how many sequences there are whose terms are all integers greater than or equal to <var>3</var>, and whose sum is equal to <var>S</var>. The answer can be very lar...
p00092
<H1>正方形探索</H1> <p> 縦に <var>n</var> 行、横に <var>n</var> 列並べられた、合計 <var> n &times; n</var> のマス目があります。いくつかのマス目には印がついています。各マス目の印の状態を読み込み、印のついていないマス目だけからなる最大の正方形の辺の長さを出力として表示するプログラムを作成してください。 </p> <p> たとえば各データセットで以下のようなデータが与えられます。 </p> <pre> 10 ...*....** .......... **....**.. ........*. ..*....... .......... .*...........
p00138
<H1>陸上競技大会</H1> <p> 陸上競技大会 200M の準決勝 3 組のレースが行われました。それぞれの組に 8 名(計 24 名)の選手が出場します。各組上位 2 位までの選手と、各組の 3 位以下の全選手の中から上位 2 名の計 8 名が決勝に進出します。 </p> <p> 選手番号とタイムを入力とし、決勝進出者 8 名の番号とそのタイムを出力するプログラムを作成してください。 </p> <!-- <p> 入力データの1件目から8件目までが1組目、9件目から16件目までが2組目、17件目から24件目までが3組目のデータとします。タイムは、1/100まで計測し、同タイムの選手はいないものとし、棄権は無いものと...
p02105
<h1>Problem H: Zombie Hunter</h1> <h2>Problem</h2> <p> がっちょ君は人気のゲーム、Zombie Hunterに熱中している。このゲームには、頭、胴、腕、腰、足専用の5種類の防具があり、がっちょ君が操作するプレイヤーキャラクター(PC)は、体の各部に対応する防具をそれぞれ最大1つまで装備することができる。<br> また、各防具には重さと防御力が設定されており、PCの装備している防具の重さの合計が<var>A</var>以上<var>B</var>以下であり、かつ防御力の合計も<var>A</var>以上<var>B</var>以下であるとき、そのPCはスキルを発動するこ...
p01400
<h2> Problem C: Seishun 18 Kippu </h2> <p> R大学のとある学生sirokurostoneはA津大学で行われる合宿に参加しようとしていた。 他のメンバーは新幹線を使用する予定なのだが、sirokurostoneは青春18切符を使って向かおうとしていた。 同じく青春18切符使いのとある2D好きな人物も合宿に参加しようとしていた。 </p> <p> どうせならと一緒に行こうと考えたsirokurostoneは途中の駅で2D好きな彼を拾って向かおうと考えた。 sirokurostoneはR大学を出る前に遅延状況を確認してすこしでも時間のかからないルートを通ってA津大学のある駅に着...
p01050
<h1>String Compression</h1> <h2>Problem</h2> <p> アルファベットの小文字と数字からなる文字列 <var>S</var> が与えられる。次の手順で文字列 <var>S</var> の長さを圧縮する。 </p> <ol> <li>文字列内の文字の順番を任意の順番に入れ替える。<br> 例: "0ig3he12fz99" &rarr; "efghiz012399"</li> <li>次の操作を任意の回数行う。</li> </ol> <ul style="margin: 0 0 0 2em"> <li>文字列内にある、"abcdefghijklmnopqrstuvwxyz"の連続し...
p03597
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have an <var>N \times N</var> square grid.</p> <p>We will paint each square in the grid either black or white.</p> <p>If we paint exactly <var>A</var> squares white, how many squares will be painted ...
p00211
<H1>みんなでジョギング</H1> <p> 赤ベコ小学校では、生徒全員が参加する、ちょっと変わったジョギングをします。生徒は、それぞれ独自の周回コースを、自分のペースで走ります。それぞれ自分のコースを 1 周すると小学校に戻ってきます。全員が小学校を同時にスタートしてから、全員が同時に小学校で最初に出会うのは、それぞれ何周したときでしょうか? </p> <p> 生徒の人数 <var>n</var>、各生徒のコースの 1 周の距離 <var>d</var> (km) 、各生徒の走る速さ <var>v</var> (km/時間)を入力とし、全員が小学校を同時にスタートしてから次に同時に小学校に位置するのは、各生徒がそれ...
p01953
<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...
p00641
<H1><font color="#000000">Problem E:</font> Huge Family</H1> <p> Mr. Dango's family has 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 near future. They all have warm and gracious persona...
p02386
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h1>Dice IV</h1><br> <p> Writ...
p03981
<span class="lang-en"> <p>Score : <var>200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3> <p> You are going to take the entrance examination of Kyoto University tomorrow and have decided to memorize a set of strings <var>S</var> that is expected to appear in the examinatio...
p02693
<span class="lang-en"> <p>Score: <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3> <p>Takahashi the Jumbo will practice golf.</p> <p>His objective is to get a carry distance that is a multiple of <var>K</var>, while he can only make a carry distance of between <var>A</var> and <var>B</va...
p02369
<H1>Cycle Detection for a Directed Graph</H1> <br/> <p> Find a cycle in a directed graph <var>G(V, E)</var>. </p> <H2>Input</H2> <p> A directed graph <var>G</var> is given in the following format: </p> <pre> <var>|V|</var> <var>|E|</var> <var>s<sub>0</sub></var> <var>t<sub>0</sub></var> <var>s<sub>1</sub></var> <v...
p00354
<!--<H1>X-th day of September</H1>--> <h1>Day of Week</h1> <p> The 9th day of September 2017 is Saturday. Then, what day of the week is the X-th of September 2017? </p> <p> Given a day in September 2017, write a program to report what day of the week it is. </p> <h2>Input</h2> <p> The input is given in t...
p01816
<h2>H - Bit Operation Game</h2> <p> <var>N</var> 頂点の根付き木が与えられる。 頂点には <var>0</var> から <var>N &minus; 1</var> の番号がついており、<var>0</var>番目の頂点が根を表す。 根には <code>T = 0</code> が、それ以外の頂点には </p> <ul> <li><code>T=T&X</code></li> <li><code>T=T&Y</code></li><li><code>T=T|X</code></li> <li><code>T=T|Y</code></li> <li><code>T=T^X</c...
p02739
<span class="lang-en"> <p>Score : <var>1400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Given are a positive integer <var>N</var> and a sequence of length <var>2^N</var> consisting of <var>0</var>s and <var>1</var>s: <var>A_0,A_1,\ldots,A_{2^N-1}</var>. Determine whether there exists a cl...
p00704
<h1> Enclosing Circles </h1> <p>A number of circles are given. A circle may be disjoint from other circles, overlapping with some other circles, or even totally surrounding or surrounded by another circle. </p> <table> <tbody> <tr> <td align="center"><img src="https://judgeapi.u-aizu.ac.jp/resources/images...
p03082
<span class="lang-en"> <p>Score : <var>600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3> <p>Snuke has a blackboard and a set <var>S</var> consisting of <var>N</var> integers. The <var>i</var>-th element in <var>S</var> is <var>S_i</var>.</p> <p>He wrote an integer <var>X</var> on the blackboa...
p01545
<h1>引越し</h1> <p> 太郎君は引っ越しをすることになりました。太郎君はたくさんの荷物を持っているので、荷物の運搬を引っ越し業者に頼むことにしました。荷物はいろいろな重さの物があるので、わかりやすいように軽い方から順番に並べて置いてもらうように頼みましたが、引っ越し業者の人はばらばらの順番で荷物を置いていってしまいました。そこで太郎君は荷物を並べ替えようとしましたが、荷物は重いので運ぶのには体力が必要です。それぞれの荷物は今ある場所から他の荷物の間や荷物の端など好きな場所に運ぶことができますが、ある荷物を運ぶにはその荷物の重さと同じだけ体力を使います。太郎君はあまり体力がないので、できるだけ体力を使わずに荷物を軽い方...
p03578
<span class="lang-en"> <p>Score : <var>200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Rng is preparing a problem set for a qualification round of CODEFESTIVAL.</p> <p>He has <var>N</var> candidates of problems. The difficulty of the <var>i</var>-th candidate is <var>D_i</var>.</p> <p>The...
p01115
<h3>Expression Mining</h3> <!-- end en only --> <!-- begin en only --> <p> Consider an arithmetic expression built by combining single-digit positive integers with addition symbols <tt>+</tt>, multiplication symbols <tt>*</tt>, and parentheses <tt>(</tt> <tt>)</tt>, defined by the following grammar rules with the st...
p03128
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Find the largest integer that can be formed with exactly <var>N</var> matchsticks, under the following conditions:</p> <ul> <li>Every digit in the integer must be one of the digits <var>A_1, A_2, ..., A...
p02955
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a sequence of <var>N</var> integers: <var>A_1, A_2, \cdots, A_N</var>.</p> <p>You can perform the following operation between <var>0</var> and <var>K</var> times (inclusive):</p> <ul> <li>Choose...
p00968
<h2>Digits Are Not Just Characters</h2> <p> Mr. Manuel Majorana Minore made a number of files with numbers in their names. He wants to have a list of the files, but the file listing command commonly used lists them in an order different from what he prefers, interpreting digit sequences in them as ASCII code sequenc...
p03647
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>In Takahashi Kingdom, there is an archipelago of <var>N</var> islands, called Takahashi Islands. For convenience, we will call them Island <var>1</var>, Island <var>2</var>, ..., Island <var>N</var>.</p...
p01380
<div> <h1 class="title">問題 E : ファーストアクセプタンス</h1> <p>プログラミングコンテストでは,各問題に関して, その問題を最初に正解した人の名前や正解時間が, ファーストアクセプタンス(最初の正解)として解説等でしばしば言及される.</p> <p>久しぶりにプログラミングコンテストに参加するとはいえ,予選で落ちるとは到底思えない. ならば,最初のうちは,多少高いスコアを取ることを目指すよりも, ファーストアクセプタンスを多く獲得し,存在をアピールしたほうが良いのではないか.</p> <p>自分の実力を持ってすれば,各問題を見た瞬間に, その問題を自分が何分で解くことができるかと, その...
p03217
<span class="lang-en"> <p>Score : <var>800</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3> <p>Niwango-kun, an employee of Dwango Co., Ltd., likes Niconico TV-chan, so he collected a lot of soft toys of her and spread them on the floor.</p> <p>Niwango-kun has <var>N</var> black rare soft toys of...
p04028
<span class="lang-en"> <p>Score : <var>800</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has <var>3</var> keys on it: the <code>0</code> key, the <code>1</code> key and the backspace key.</p> <p>To begin wi...
p02056
<h2>E: ジャム (Jam)</h2> <h3>問題</h3> <p>ある国には <var>N</var> 個の街があり、<var>1,\ 2,\ ...,\ N</var> の番号がつけられています。これらの街は <var>M</var> 本の道で双方向に結ばれており、<var>i</var> 番目の道を使うと街 <var>u_i</var> と <var>v_i</var> の間を時間 <var>t_i</var> で移動することができます。また、どの <var>2</var> つの街もいくつかの道を使うことで行き来することができます。</p> <p>それぞれの街では食パンが売られており、街 <var>i</var> ...
p00591
<H1>Advanced Algorithm Class</H1> <p> In the advanced algorithm class, n<sup>2</sup> students sit in n rows and n columns. One day, a professor who teaches this subject comes into the class, asks the shortest student in each row to lift up his left hand, and the tallest student in each column to lift up his right...
p02406
<H1>Structured Programming</H1> <p> In programming languages like C/C++, a goto statement provides an unconditional jump from the "goto" to a labeled statement. For example, a statement "goto CHECK_NUM;" is executed, control of the program jumps to CHECK_NUM. Using these constructs, you can implement, for example, lo...
p02113
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h1>Problem C: Palindrome</h1> <h2>Problem</h2> <p> 太郎君はそれぞれの長さが<var>L</var>の文字列を<var>N</var>個持っている。太郎君は回文が大好きなので、<var>N</var>個のうちいくつかの文字列を選んで好きな順番に並べることで、できるだけ長い回文を作りたい。 </p> <...