question_id
stringlengths
6
6
content
stringlengths
1
27.2k
p00923
<H1><font color="#000">Problem J: </font><span>C(O|W|A*RD*|S)* CROSSWORD</span> Puzzle</H1> <p> The first crossword puzzle was published on December 21, 1913 by Arthur Wynne. To celebrate the centennial of his great-great-grandfather's invention, John "Coward" Wynne<sup>1</sup> was struggling to make crossword puzzl...
p00470
<H1>通勤経路 </H1> <h2>問題</h2> <p> JOIさんが住むカナダのある都市は,南北方向にまっすぐに伸びる w 本の道路と,東西方向にまっすぐに伸びる h 本の道路により,碁盤の目の形に区分けされている. </p> <p> 南北方向の w 本の道路には,西から順に 1, 2, ... , w の番号が付けられている.また,東西方向の h 本の道路には,南から順に 1, 2, ... , h の番号が付けられている.西から i 番目の南北方向の道路と,南から j 番目の東西方向の道路が交わる交差点を (i, j) で表す. </p> <p> JOIさんは,交差点 (1, 1) の近くに住んでおり,交差点 ...
p00020
<H1>Capitalize</H1> <p> Write a program which replace all the lower-case letters of a given text with the corresponding captital letters. </p> <H2>Input</H2> <p> A text including lower-case letters, periods, and space is given in a line. The number of characters in the text is less than or equal to 200. </p> <H2>...
p00535
<h2>砂の城 (Sandcastle)</h2> <h2> 問題</h2> <p> JOI 君は家族とともに海水浴に来た.さんざん泳いで泳ぎ疲れた JOI 君は,次は砂浜で砂の城を作って遊んだ.しばらくして砂遊びにも飽きると,JOI 君は城を放置してまた海に泳ぎに向かった. </p> <p> JOI 君が作った城は,砂浜のうちのある長方形の領域に含まれている.この長方形の領域は,東西南北にマス目状に区切られている.各マスは,JOI 君が作った城の一部であるマス (以下,「城マス」と呼ぶ) かそうでないマス (以下,「更地マス」と呼ぶ) のいずれかである.それぞれの城マスには「強度」と呼ばれる 1 以上 9 以下の整...
p00165
<H1>宝くじ</H1> <p> ある国の王様は素数とギャンブルが大好きです。この国の通貨の単位はプライムといいます。2007 年 11 月 1 日現在のプライムのクロス円レートは 9973 とちょうど素数になっていたので、王様は大喜びです。この国では 1/101 プライムを1サブプライムとする補助貨幣が使われています。 </p> <p> この国の政府は、国家財政の安定、国民の娯楽、王様の趣味を同時に満足させることを目的に宝くじ振興公社を設立し、宝くじ事業を始めることにしました。素数が大好きな王様は、素数が話題になればそれだけで満足して、賞金をあげたくなります。そこで振興公社は次のような宝くじを考えました。 </p> <u...
p02158
<h1>Problem J: Rings</h1> <h2>Problem</h2> <p>とある水族館に住むイルカ君は、ジャンプをして$N$個のリングをくぐり抜けるとご褒美がもらえます。</p> <ul> <li>イルカ君は座標$(0,0)$から飛び、$(T,0)$で着水する。</li> <li>ジャンプの軌道は放物線である。</li> <li>$i$番目のリングは、ジャンプの軌道が$(X_i,L_i)$と$(X_i,H_i)$を結ぶ線分と交わると、くぐり抜けたと判定される。</li> <li>$1$回のジャンプには初速と同じだけの体力が必要である。</li> </ul> <p>イルカ君は、必要であれば何度でもジャ...
p03319
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There is a sequence of length <var>N</var>: <var>A_1, A_2, ..., A_N</var>. Initially, this sequence is a permutation of <var>1, 2, ..., N</var>.</p> <p>On this sequence, Snuke can perform the following ...
p01324
<h1><font color="#000">Problem D:</font> 無矛盾な単位系</h1> <pre> 京、垓、{禾予}、穣、溝、澗、正、載、極、恒河沙、阿僧祇、那由他、不可思議、無量大数 分、厘、毛、糸、忽、微、繊、沙、塵、埃、渺、漠、模糊、逡巡、須臾、瞬息、弾指、刹那、六徳、虚空、清浄、阿頼耶、阿摩羅、涅槃寂静 </pre> <p>これらが何か分かるだろうか。これらは全て10の累乗につけられた数詞である。</p> <pre> 京 = 10<sup>16</sup>, 垓 = 10<sup>20</sup>, {禾予} = 10<sup>24</sup>, 穣 = 10<sup>28</sup>, 溝 = ...
p03749
<span class="lang-en"> <p>Score : <var>1600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Joisino has a bar of length <var>N</var>, which has <var>M</var> marks on it. The distance from the left end of the bar to the <var>i</var>-th mark is <var>X_i</var>.</p> <p>She will place several squa...
p01774
<h2>C: Digital Clock / デジタル時計</h2> <h3>物語</h3> <p>あいずにゃんは最近,風邪を引いてしまった.あまりのだるさにベットから出られない.辛そうにしている姿もまたかわいい.</p> <p>しかし暇で暇で仕方がないあいずにゃんは,枕下にあるデジタル時計で遊ぶ方法を考えついた.下の図のようなデジタル時計の光っている棒の本数を毎秒毎秒,ただひたすらに数えるのである.</p> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_HUPC2015_Digital"></img> <p>何時間かこの遊びを続けた頃...
p00866
<H1><font color="#000">Problem C:</font> Stopped Watches</H1> <p> In the middle of Tyrrhenian Sea, there is a small volcanic island called Chronus. The island is now uninhabited but it used to be a civilized island. Some historical records imply that the island was annihilated by an eruption of a volcano about 800 ye...
p03067
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There are three houses on a number line: House <var>1</var>, <var>2</var> and <var>3</var>, with coordinates <var>A</var>, <var>B</var> and <var>C</var>, respectively. Print <code>Yes</code> if we pass ...
p03437
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You are given positive integers <var>X</var> and <var>Y</var>. If there exists a positive integer not greater than <var>10^{18}</var> that is a multiple of <var>X</var> but not a multiple of <var>Y</var...
p01959
<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...
p03964
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two...
p02676
<span class="lang-en"> <p>Score: <var>200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3> <p>We have a string <var>S</var> consisting of lowercase English letters.</p> <p>If the length of <var>S</var> is at most <var>K</var>, print <var>S</var> without change.</p> <p>If the length of <var>S</va...
p02226
<h2> test </h2> UnionFind(バイナリ入力)
p03821
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There are an integer sequence <var>A_1,...,A_N</var> consisting of <var>N</var> terms, and <var>N</var> buttons. When the <var>i</var>-th <var>(1 ≦ i ≦ N)</var> button is pressed, the values of the <var...
p02733
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a chocolate bar partitioned into <var>H</var> horizontal rows and <var>W</var> vertical columns of squares.</p> <p>The square <var>(i, j)</var> at the <var>i</var>-th row from the top and the <v...
p02699
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There are <var>S</var> sheep and <var>W</var> wolves.</p> <p>If the number of wolves is greater than or equal to that of sheep, the wolves will attack the sheep.</p> <p>If the wolves will attack the she...
p02363
<script src="./IMAGE/varmath.js" charset="UTF-8"></script> <H1>All Pairs Shortest Path</H1> <br/> <H2>Input</H2> <p> An edge-weighted graph <var>G</var> (<var>V</var>, <var>E</var>). </p> <pre> |<var>V</var>| |<var>E</var>| <var>s<sub>0</sub></var> <var>t<sub>0</sub></var> <var>d<sub>0</sub></var> <var>s<sub>1</sub>...
p03122
<span class="lang-en"> <p>Score : <var>1000</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p><font color="red"><strong>Red bold fonts show the difference from C1.</strong></font></p> <p>There is an infinitely large triangular grid, as shown below. Each point with integer coordinates contains a...
p03088
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You are given an integer <var>N</var>. Find the number of strings of length <var>N</var> that satisfy the following conditions, modulo <var>10^9+7</var>:</p> <ul> <li>The string does not contain charact...
p03572
<span class="lang-en"> <p>Score : <var>1800</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Three men, A, B and C, are eating sushi together. Initially, there are <var>N</var> pieces of sushi, numbered <var>1</var> through <var>N</var>. Here, <var>N</var> is a multiple of <var>3</var>.</p> <p...
p00077
<H1>ランレングス</H1> <p> 文字列が連続した場合、ある規則で文字を置き換え文字列を短くすることができます。たとえば、AAAA という文字列の場合、@4A と表現すれば 1 文字分圧縮されます。この規則で圧縮された文字列を入力してもとの文字列に復元するプログラムを作成してください。ただし、復元した文字列に@文字は出現しないものとします。 </p> <p> また、原文の文字列は英大文字、英小文字、数字、記号であり 100 文字以内、連続する文字は 9 文字以内です。 </p> <H2>入力</H2> <p>複数の文字列が与えられます。1行に1つの文字列が与えられます。文字列の数は 50 を超えません。</p>...
p00427
<H1></H1> <p> 次のようなゲームを考える. 1 から n までの数が 1 つずつ書かれた n 枚のカードが k 組ある.これら kn 枚のカードをよくシャッフル(よく切ること)して, k 枚ずつの山を作り横一列に並べる.このようにしてできる n 個の山の左から i 番目の(k 枚のカードの)山を「山 i 」と呼ぶことにする. </p> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2006-yo-t5-fig_base"> </center> <br> <p> ゲームは山 1 から始める.山の一番上のカード 1...
p01666
<h2>K - encode/decode</h2> <p> 以下の2条件を全て満たす文字列Tの事を「良い」文字列と呼ぶことにする <ul> <li>TはABCDEFGHIの9種類の文字列からなる</li> <li>T上の連続する2文字は次のグラフ上でも隣接している </ul> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_KUPC2013_graph"> <p>「良い」文字列の例</p> <ul> <li>BEB</li> <li>ABCDCBEFGHI</li> </ul> <p>「良い」文字列ではない例</p> <ul> <li>AC(...
p00974
<h3>What Goes Up Must Come Down</h3> <p> Several cards with numbers printed on them are lined up on the table. </p> <p> We'd like to change their order so that first some are in non-decreasing order of the numbers on them, and the rest are in non-increasing order. For example, (1, 2, 3, 2, 1), (1, 1, 3, 4, 5, 9, ...
p02949
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There is a directed graph with <var>N</var> vertices numbered <var>1</var> to <var>N</var> and <var>M</var> edges. The <var>i</var>-th edge is directed from Vertex <var>A_i</var> to Vertex <var>B_i</var...
p04034
<span class="lang-en"> <div class="part"> <section> <h3>Problem Statement</h3><p>We have <var>N</var> boxes, numbered <var>1</var> through <var>N</var>. At first, box <var>1</var> contains one red ball, and each of the other boxes contains one white ball.</p> <p>Snuke will perform the following <var>M</var> operations,...
p01236
<H1><font color="#000">Problem C:</font> Median Filter</H1> <p> The median filter is a nonlinear digital filter used to reduce noise in images, sounds, and other kinds of signals. It examines each sample of the input through a <i>window</i> and then emits the <i>median</i> of the samples in the win- dow. Roughly spea...
p01723
<p>イクタ君の住む町には<var>N</var>個の塔がある。 それぞれの塔には0から<var>N&minus;1</var>までの異なる番号が与えられており、番号<var>i</var>の塔を塔<var>i</var>と呼ぶ。 好奇心旺盛なイクタ君は<var>N</var>個の塔の高さに興味を持ち、それらの大小関係を表す表<var>T</var>を作ることにした。 <var>T</var>は<var>N &times; N</var>個の要素を持ち、各要素<var>T<sub>i, j</sub> (0 &le; i, j &le; N &minus; 1)</var>は次のように定義される。 </p> <ul> <li...
p00831
<H1><font color="#000">Problem E:</font> Confusing Login Names</H1> <p> Meikyokan University is very famous for its research and education in the area of computer science. This university has a computer center that has advanced and secure computing facilities including supercomputers and many personal computers conne...
p01373
<!-- begin en only --> <!--<h3><U>Divide the Cake</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> イコとピコはACM博士によって開発された人工知...
p01689
<h2>C - Dowsing Machine / ダウジングマシーン</h2> <h3>Story</h3> <p>世間ではXだとかYだとかで騒がしいけれど、これからの時代は&quot;D&quot;である。&quot;パクリンモンスターD&quot;は、秘密結社&quot;R団&quot;によって開発された&quot;Dマシン&quot;を使って&quot;Dのひと&quot;が財宝探索を行う大人気ゲームである。</p> <p>このゲームでは、格子状マップのあるマスにいるDのひとが、隣接する上下左右のマスへの移動を繰り返し、財宝が存在するマスへの到達を目指す。 マップ上には財宝が存在するマスが1つだけある。 財宝が存在す...
p00132
<h1>ジグソーパズル</h1> <p> 子供から大人まで脳トレ系パズルゲームが流行しています。我々も遅れを取らぬよう、パズルゲームを作ってみんなで遊ぶことにしました。 </p> <p> 我々が考えたのはジグソーパズルのゲームで、未完成の部分を埋めるのに必要なピースを選ぶというものです。図 1 (a) はパズルの枠の例です。黒が埋まっている部分、白が未完成の部分です。このパズルを完成するのに使えるピースが図 1 (b) のように与えられます。この中から、枠の白い部分を埋めることができる黒いピースを 1 つ以上選択します。例えば、図 2 の選択例 1 のような組み合わせなら正解となります。一方、選択例 2 のような組み合わ...
p00562
<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>Soccer</h1> <p> You are a manager of a pr...
p00098
<H1>Maximum Sum Sequence II</H1> <p> 与えられた整数の行列 </p> <pre> <var>a<sub>1,1</sub></var> <var>a<sub>1,2</sub></var> ... <var>a<sub>1,n</sub></var> <var>a<sub>2,1</sub></var> <var>a<sub>2,2</sub></var> ... <var>a<sub>2,n</sub></var> : <var>a<sub>n,1</sub></var> <var>a<sub>n,2</sub></var> ... <var>a<sub>n, n</sub></var...
p02230
UF with binary input (K = 100)
p02660
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3> <p>Given is a positive integer <var>N</var>. Consider repeatedly applying the operation below on <var>N</var>:</p> <ul> <li>First, choose a positive integer <var>z</var> satisfying all of the conditions b...
p03972
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>On an <var>xy</var> plane, in an area satisfying <var>0 ≤ x ≤ W, 0 ≤ y ≤ H</var>, there is one house at each and every point where both <var>x</var> and <var>y</var> are integers.</p> <p>There are unpav...
p03421
<span class="lang-en"> <p>Score : <var>700</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Determine if there exists a sequence obtained by permuting <var>1,2,...,N</var> that satisfies the following conditions:</p> <ul> <li>The length of its longest increasing subsequence is <var>A</var>.</l...
p03071
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There are two buttons, one of size <var>A</var> and one of size <var>B</var>.</p> <p>When you press a button of size <var>X</var>, you get <var>X</var> coins and the size of that button decreases by <va...
p03564
<span class="lang-en"> <p>Score : <var>200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Square1001 has seen an electric bulletin board displaying the integer <var>1</var>. He can perform the following operations A and B to change this value:</p> <ul> <li>Operation A: The displayed value is...
p01559
<h1>MinimumCostPath</h1> <p>NxNの方眼がある。 </p> <p><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE_mcp_grid" height="140px"><br> (N=3の場合の図) </p> <p>隣接するマス目に移動するにはコストが1かかる。ただし、斜めに移動することは出来ない。 また障害物があるマス目がM個あり、そのマスに入ることは許されない。 マス(1, 1)からマス(N, N)に最小のコストで移動する方法は何通りあるか。 答えは大きくなることがありうるので、1000000009(=10<sup>9</s...
p03134
<span class="lang-en"> <p>Score : <var>900</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There are <var>N</var> Snukes lining up in a row. You are given a string <var>S</var> of length <var>N</var>. The <var>i</var>-th Snuke from the front has two red balls if the <var>i</var>-th character ...
p01109
<h3>Income Inequality</h3> <!-- end en only --> <!-- begin en only --> <p> We often compute the average as the first step in processing statistical data. Yes, the average is a good tendency measure of data, but it is not always the best. In some cases, the average may hinder the understanding of the data. </p> <p> ...
p00348
<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> 高校入学後、プログラミング部に入部したタケ子さんは...
p02375
<H1>Range Query on a Tree II</H1> <p> Write a program which manipulates a weighted rooted tree $T$ with the following operations: </p> <ul> <li>$add(v,w)$: add $w$ to all edges from the root to node $u$<br> <li>$getSum(u)$: report the sum of weights of all edges from the root to node $u$<br> </ul> <p> The give...
p00718
<h1><font color="#000">Problem C:</font> Numeral System</h1> <p> Prof. Hachioji has devised a new numeral system of integral numbers with four lowercase letters "m", "c", "x", "i" and with eight digits "2", "3", "4", "5", "6", "7", "8", "9". He doesn't use digit "0" nor digit "1" in this system. </p> <p> The let...
p02725
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There is a circular pond with a perimeter of <var>K</var> meters, and <var>N</var> houses around them.</p> <p>The <var>i</var>-th house is built at a distance of <var>A_i</var> meters from the northmost...
p03837
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You are given an undirected connected weighted graph with <var>N</var> vertices and <var>M</var> edges that contains neither self-loops nor double edges.<br/> The <var>i</var>-th <var>(1≤i≤M)</var> edge...
p01220
<H1><font color="#000">Problem E:</font> Triangles</H1> <p> There is a group that paints an emblem on the ground to invite aliens every year. You are a member of this group and you have to paint the emblem this year. </p> <p> The shape of the emblem is described as follows. It is made of <i>n</i> regular triangles wh...
p04022
<span class="lang-en"> <p>Score : <var>1100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke got positive integers <var>s_1,...,s_N</var> from his mother, as a birthday present. There may be duplicate elements.</p> <p>He will circle some of these <var>N</var> integers. Since he dislikes ...
p00962
<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...
p01670
<h2>D - Medical Inspection</h2> <h3>Problem Statement</h3> <p> The government has declared a state of emergency due to the MOFU syndrome epidemic in your country. Persons in the country suffer from MOFU syndrome and cannot get out of bed in the morning. You are a programmer working for the Department of Health. You...
p00431
<H1></H1> <p> 両端にリングのついた紐を考える.リングは正整数が付いていて,紐を区別する.紐の両端のリングには異なる数 <i>a</i>, <i>b</i> が付けられる.これを,[<i>a</i>, <i>b</i>] と記述する.複数の紐があり,一方の紐と他方の紐のリングに付いている数が同じ場合,そのリングのところで,これらの紐をつなげることができて,つなげてできたものを鎖と呼ぶことにする.例えば,[1, 3] と [3, 4] という紐からは [1, 3, 4] という鎖ができる.紐と鎖や鎖同志も同じ整数が付いているリングのところでつなげることができるものとする. </p> <p> 例えば,鎖 [1, 3...
p00061
<H1>Rank Checker</H1> <!-- <p> 時は2020 年。パソコン甲子園 2020 の予選結果を保存したデータがあります。このデータには、各チームに振られる整理番号と正解数が保存されています。参加者チーム数は不明ですが、かなり多い模様です(主催者のささやかな要望でもあります)。正解数の多いほうから順に 1 位、2 位 ... と順位をつけていくこととします。 </p> --> <p> 時は2020 年。パソコン甲子園 2020 の予選結果を保存したデータがあります。このデータには、各チームに振られる整理番号と正解数が保存されています。ここでは、正解数で順位を決定するものとし、正解数の多いほうから順に ...
p02549
<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> cells arranged in a row, numbered <var>1, 2, \ldots, N</var> from left to right.</p> <p>Tak lives in these cells and is currently on Cell <var>1</var>. He is trying to reach Cell ...
p00574
<h1>毒蛇の脱走(Snake Escaping)</h1> <p> JOI 研究所では<var>2^L</var> 匹の毒蛇を飼っており,それぞれ<var>0, 1, ..., 2^L - 1</var> の番号が付けられている.すべての毒蛇は頭から順に<var>L</var> 個の部分に分かれており,それぞれの部分は青または赤である.毒蛇<var>i</var> に対し,<var>i</var> を2進表記して<var>i =</var> $\sum_{k=1}^{L}$<var> c_k2^{L-k} (0 \leq c_k \leq 1)</var> とおいたとき, </p> <ul> <li> <var>c_k = ...
p02119
<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 I: Making Pairs</...
p00124
<h1>リーグ戦のスコアシート</h1> <p> スポーツの大会にはリーグ戦とトーナメント戦があります。サッカーのリーグ戦では勝・負・引分にそれぞれ点数を付け、その勝ち点で順位を競います。勝ち点はそれぞれ勝(3点)、負(0点)、引分(1点)です。 </p> <p> チーム数とリーグ戦の成績を入力とし、成績の良い順(勝ち点の多い順)に並べ替え、チーム名と勝ち点を出力するプログラムを作成してください。勝ち点が同点の場合は入力順に出力してください。 </p> <H2>Input</H2> <p> 複数のデータセットが与えられます。各データセットは以下の形式で与えられます。 </p> <pre> <var>n</var...
p01365
<H1><font color="#000">Problem G:</font> Camera Control</H1> <p> "ACM48" is one of the most popular dance vocal units in Japan. In this winter, ACM48 is planning a world concert tour. You joined the tour as a camera engineer. </p> <p> Your role is to develop software which controls the camera on a stage. For simplic...
p03358
<span class="lang-en"> <p>Score : <var>800</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There is a tree with <var>N</var> vertices numbered <var>1</var> through <var>N</var>. The <var>i</var>-th edge connects Vertex <var>x_i</var> and <var>y_i</var>. Each vertex is painted white or black. ...
p00827
<H1><font color="#000">Problem A:</font> The Balance</H1> <p> Ms. Iyo Kiffa-Australis has a balance and only two kinds of weights to measure a dose of medicine. </p> <p> For example, to measure 200mg of aspirin using 300mg weights and 700mg weights, she can put one 700mg weight on the side of the medicine and three 3...
p01735
<p> Fox Ciel is developing an artificial intelligence (AI) for a game. This game is described as a game tree T with n vertices. Each node in the game has an evaluation value which shows how good a situation is. This value is the same as maximum value of child nodes’ values multiplied by -1. Values on leaf nodes are ev...
p03708
<span class="lang-en"> <p>Score : <var>900</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Nukes has an integer that can be represented as the bitwise OR of one or more integers between <var>A</var> and <var>B</var> (inclusive). How many possible candidates of the value of Nukes's integer the...
p03026
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You are given a tree with <var>N</var> vertices <var>1,2,\ldots,N</var>, and positive integers <var>c_1,c_2,\ldots,c_N</var>. The <var>i</var>-th edge in the tree <var>(1 \leq i \leq N-1)</var> connects...
p03476
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We say that a odd number <var>N</var> is <em>similar to 2017</em> when both <var>N</var> and <var>(N+1)/2</var> are prime.</p> <p>You are given <var>Q</var> queries.</p> <p>In the <var>i</var>-th query,...
p02637
<span class="lang-en"> <p>Score : <var>1500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Given are an integer <var>K</var> and integers <var>a_1,\dots, a_K</var>. Determine whether a sequence <var>P</var> satisfying below exists. If it exists, find the lexicographically smallest such seque...
p03925
<span class="lang-en"> <p>Score : <var>1300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a graph with <var>N</var> vertices, numbered <var>0</var> through <var>N-1</var>. Edges are yet to be added.</p> <p>We will process <var>Q</var> queries to add edges. In the <var>i</var>-th <va...
p01918
<link rel="stylesheet" href="css/description.css" type="text/css" /> <script language="JavaScript" type="text/javascript" src="js/varmath2017.js" charset="UTF-8"></script> <h2>C: 今川焼きマン - Imagawayaki Man -</h2> <h3>物語</h3> <p>今川焼きマンは、正義のヒーローである。顔は直径 <var>1</var> メートルの今川焼き(主に小麦粉でできた生地の中にたっぷりと餡を詰めて焼いた食べ物であり、見た目は円形で...
p02267
<H1>Search I</H1> <p> You are given a sequence of <i>n</i> integers S and a sequence of different <i>q</i> integers T. Write a program which outputs C, the number of integers in T which are also in the set S. </p> <H2>Input</H2> <p> In the first line <i>n</i> is given. In the second line, <i>n</i> integers are give...
p02288
<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>Maximum Heap</h1> <p> A ...
p02772
<span class="lang-en"> <p>Score: <var>200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3> <p>You are an immigration officer in the Kingdom of AtCoder. The document carried by an immigrant has some number of integers written on it, and you need to check whether they meet certain criteria.</p> <p...
p03860
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is going to open a contest named "AtCoder <var>s</var> Contest". Here, <var>s</var> is a string of length <var>1</var> or greater, where the first character is an uppercase English letter, and the...
p02322
<h1>Knapsack Problem with Limitations II</h1> <p>You have $N$ items that you want to put them into a knapsack. Item $i$ has value $v_i$, weight $w_i$ and limitation $m_i$.</p> <p>You want to find a subset of items to put such that:</p> <ul> <li>The total value of the items is as large as possible.</li> <li>The it...
p03499
<span class="lang-en"> <p>Score : <var>1000</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke has a rooted tree with <var>N+1</var> vertices. The vertices are numbered <var>0</var> through <var>N</var>, and Vertex <var>0</var> is the root of the tree. The parent of Vertex <var>i</var> <va...
p03163
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There are <var>N</var> items, numbered <var>1, 2, \ldots, N</var>. For each <var>i</var> (<var>1 \leq i \leq N</var>), Item <var>i</var> has a weight of <var>w_i</var> and a value of <var>v_i</var>.</p>...
p03533
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You are given a string <var>S</var>.</p> <p>Takahashi can insert the character <code>A</code> at any position in this string any number of times.</p> <p>Can he change <var>S</var> into <code>AKIHABARA</...
p00036
<H1>平面上の図形</H1> <p> 縦 8、横 8 のマスからなる図 1 のような平面があります。 <br> <center> <table cellspacing=0 cellpadding=0> <tr><td>□</td><td>□</td><td>□</td><td>□</td><td>□</td><td>□</td><td>□</td><td>□</td></tr> <tr><td>□</td><td>□</td><td>□</td><td>□</td><td>□</td><td>□</td><td>□</td><td>□</td></tr> <tr><td>□</td><td>□</td><td>□</td>...
p00466
<H1>レシート </H1> <h2>問題</h2> <p> 太郎君は10冊の本を購入した. 後日, レシートをもとに価格を調べようとしたが, レシートには汚れがあり, ある本の価格が読み取れなかった. その本の価格を, 10冊の総額と他の9冊の価格から計算することにした. </p> <p> 価格が読み取れなかった本の価格を出力するプログラムを書け. なお,本の価格はすべて正の整数である. また,消費税を考慮する必要はない. </p> <h2> 入力</h2> <p> 入力は複数のデータセットからなる.各データセットは以下の形式で与えられる. </p> <p> 各データセットは10行からなり,1行に1つずつ正の整数...
p02908
<span class="lang-en"> <p>Score : <var>1600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke has permutations <var>(P_0,P_1,\cdots,P_{N-1})</var> and <var>(Q_0,Q_1,\cdots,Q_{N-1})</var> of <var>(0,1,\cdots,N-1)</var>.</p> <p>Now, he will make new permutations <var>A</var> and <var>B</var...
p00935
<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 A Decimal Sequences</h...
p01627
<h1>Problem A: 青春18きっぷ 2013</h1> <h2>Problem Statement</h2> <p> 会津合宿に参加予定の高槻さんは、家が貧乏であまりお金を持っていない。そのため、青春18きっぷを使用して、お金を節約しようとしている。18きっぷは、これ1枚だけで、鈍行列車ならば1日中乗り放題、改札の出入りも自由という優れものである(詳しい利用ルールについては省略)。 </p> <p> 18きっぷの魅力は、乗り換えを行う駅で、空いている時間を使って、ご当地のお土産等を見てまわれる点である。彼女は、せっかくの機会なので、旅の途中でいろいろな駅を見て回りたいと考えている。ただし、次の電車に乗り遅れては困る...
p01277
<H1><font color="#000">Problem E:</font> Symmetry</H1> <p> Open Binary and Object Group organizes a programming contest every year. Mr. Hex belongs to this group and joins the judge team of the contest. This year, he created a geometric problem with its solution for the contest. The problem required a set of points f...
p00870
<H1><font color="#000">Problem G:</font> Search of Concatenated Strings</H1> <p> The amount of information on the World Wide Web is growing quite rapidly. In this information explosion age, we must survive by accessing only the Web pages containing information relevant to our own needs. One of the key technologies fo...
p01762
<h1>C : Pruning / 枝刈り</h1> <h1>Problem</h1> <p>とにかくあつい。あづい君の住んでいる地域は今年猛暑であった。 さらに、家の庭には 1 本の木が生えており、毎日やかましく鳴く蝉が暑さを増幅させているような気がする。</p> <p>庭の木は、まさにグラフ理論でいうところの木のような形をしており、この木にはたくさんの蝉が止まっている。 蝉は、必ず枝の先端(葉)または枝の分かれ目(頂点)に止まる習性がある。 ただし、木の根には 1 匹も止まることはない。 この木のある枝(辺)を切ると、それより空側(根と反対側)にいる蝉を全て駆除することができる。 ただし、枝を切るためには、その枝に応じた...
p01298
<H1><font color="#000">Problem F:</font> Water Tank</H1> <p> You built an apartment. The apartment has a water tank with a capacity of <i>L</i> in order to store water for the residents. The tank works as a buffer between the water company and the residents. </p> <p> It is required to keep the tank "not empty" at le...
p01332
<h1><font color="#000">Problem L:</font> Problem L: 3つのシルエット</h1> <p>JAVA(Japan Aerospace Voyage Agency: 日本宇宙飛行研究機構)は、宇宙開発事業の一環として2003年に探査機を打ち上げた。 この探査機打ち上げの目的の一つに、小惑星イシカワに接近し、その表面物質のサンプルを採集することがある。 様々なアクシデントに見舞われながらも、探査機はイシカワに到達し、そしてついに2010年、地球へ帰還し、イシカワのサンプル試料の入ったカプセルを回収することに成功した。</p> <p>東京大学を卒業し、JAVAに就職したきたまさ君は、こ...
p00173
<H1>お化け屋敷</H1> <p> 会津学園高等学校では、毎年学園祭をおこなっています。その中でも一番人気はお化け屋敷です。一番人気の理由は、お化け屋敷をおこなうクラスが 1クラスや 2クラスではなく、9クラスがお化け屋敷をおこなうことです。それぞれが工夫することより、それぞれが個性的なお化け屋敷になっています。そのため、最近では近隣から多くの来場者が訪れます。 </p> <p> そこで、学園祭実行委員会では、お化け屋敷の入場料金を下表のように校内で統一し、これにもとづき各クラスごとに入場者総数と収入の集計をおこなうことにしました。 </p> <p> 入場料金表(入場者 1人あたりの入場料) </p> <pre> ...
p00489
<H1>サッカー (Soccer) </H1> <h2> 問題</h2> <p> JOI 国ではサッカーが人気であり,JOI リーグというリーグ戦が毎週行われている. </p> <p> JOI リーグには N 個のチームが所属していて,1 から N までの番号がつけられている.すべての組み合わせの試合がちょうど一度ずつ行われる.つまり, <nobr>N × (N - 1) / 2</nobr> 試合が行われる.各試合の勝敗はそれぞれのチームの得点で決まる.勝ったチームの勝ち点は 3 点であり,負けたチームの勝ち点は 0 点である.引き分けの場合,両チームの勝ち点は 1 点である.順位は各チームの獲得した勝ち...
p00523
<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> バームクーヘン(Baumkuchen) </H1...
p00734
<h1><font color="#000000">Problem A:</font> Equal Total Scores</h1> <!-- <img src="https://judgeapi.u-aizu.ac.jp/resources/images/A-1" width=300 align=left> --> <!-- begin en only --> <p> Taro and Hanako have numbers of cards in their hands. Each of the cards has a score on it. Taro and Hanako wish to make the tot...
p02709
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There are <var>N</var> children standing in a line from left to right. The activeness of the <var>i</var>-th child from the left is <var>A_i</var>.</p> <p>You can rearrange these children just one time ...
p01826
<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: Live Programming </...
p00364
<H1>Bange Hills Tower</H1> <p> A project is underway to build a new viewing tower in Bange town called “Bange Hills Tower” whose selling point will be the gorgeous view of the entire main keep of Wakamatsu Castle from top to bottom. Therefore, the view line from the top of the tower must reach the bottom of the keep w...
p02359
<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 Maximum Number of Customers</H1> <p> ...
p03118
<span class="lang-en"> <p>Score : <var>2718</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There is a very long bench. The bench is divided into <var>M</var> sections, where <var>M</var> is a very large integer.</p> <p>Initially, the bench is vacant. Then, <var>M</var> people come to the ben...
p01125
<h1>Mysterious Gems</h1> <p> 宇宙暦 1603〜1867 年,人々はその時代のことを EDO 時代と呼ぶ.EDO とは当時最先端の宇宙航行技術,Enhanced Driving Operation のことであり、1603 年に Dr.Izy によって開発された. </p> <p> あなたは宇宙冒険家であり,宇宙を飛び回って様々な惑星を冒険していた.その冒険の途中で,あなたはとても不思議な惑星を発見した.その惑星には,至るところに七色に輝く不思議な宝石が落ちていた.あなたはその惑星への降下を試みようと考えたが,重大な問題のためにそれは不可能であることがわかった.その惑星の空気には,人間が触れただけで...