question_id
stringlengths
6
6
content
stringlengths
1
27.2k
p01833
<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>Modern Announce Network</h2> ...
p01560
<h1>Enumeration</h1> <p>n個の整数a<sub>1</sub>, a<sub>2</sub>, …, a<sub>n</sub>とn個の整数p<Sub>1</sub>, p<sub>2</sub>, …, p<sub>n</sub>、整数mが与えられる。k番目の整数a<sub>k</sub>をp<sub>k</sub>[%]の確率で選ぶ、という操作を各k(1 &le; k &le; n)について行い、0個以上n個以下の整数を選び出す。1以上m以下の整数の中で、選ばれた整数の少なくとも1つで割り切れるものの個数の期待値を求めよ。 </p> <h2>Input</h2> <p>入力は以下の形式で与えられる。 ...
p01130
<h1>Water Pipe Construction</h1> <p> 21XX 年,ついに人類は火星への移住計画を開始させた.火星への移住第一陣に選抜されたあなたは,火星行政中央局(the Administrative Center of Mars)に配属され,火星で起こる様々な問題に対処している.行政中央局の目下の最大の問題は自立した需要供給サイクルの確保である.月からの援助物資が届くまでには数ヶ月単位の時間がかかるため,基本的には火星内の需要は火星内で解決する必要がある.それに加えて,循環システムを確立するまでは資源を極力節約することが求められる. </p> <p> 行政中央局は極地にある氷の採掘を開始した.太陽光...
p00408
<h1>トーナメントの記録</h1>  <p. $N$人が参加するトーナメントを行いました。トーナメントでは一対一で対戦を行い、勝ち負けを決定します。勝った方が次の試合に進んでゆき、最終的に残った一人が優勝します。トーナメントが行われる会場はひとつしかないので、同時に行えるのは1試合のみです。 </p> <p> トーナメントが終わって優勝者が決まるまで、記録係のあなたは対戦の勝者と敗者を記録しました。あなたは対戦ごとに1枚の紙を使って正しく記録しましたが、記録した紙の順序がいくつか入れ替わった可能性があります。 </p> <p> 順序が入れ替わった可能性のある対戦の記録から、あり得る対戦の順番が何通りあるかを求めるプ...
p02435
<h1>Stack</h1> <p> Stack is a container of elements that are inserted and deleted according to LIFO (Last In First Out). </p> <p> For $n$ stack $S_i$ ($i = 0, 1, ..., n-1$), perform a sequence of the following operations. </p> <ul> <li>push($t$, $x$): Insert an integer $x$ to $S_t$.</li> <li>top($t$): Report...
p00058
<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> 平面上の異なる 4 点、$A (x_A, y_A)$,...
p02065
<h2>F: グリッドの番号</h2> <h3>問題</h3> <p>えびちゃんは、横 <var>n</var> 列、縦 <var>2</var> 行のグリッドに <var>1</var> から <var>2 \times n</var> までの整数をちょうど <var>1</var> つずつ書き込もうとしています。</p> <p>グリッドの各マスにはちょうど <var>1</var> つの整数しか書き込めません。</p> <p>普通に書き込むだけでは面白くないので、以下のようなルールを定めました。</p> <ul> <li>隣り合う <var>2</var> つのマスに書き込まれた整数の、差の絶対値は <var>k</...
p03224
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You are given an integer <var>N</var>. Determine if there exists a tuple of subsets of <var>\{1,2,...N\}</var>, <var>(S_1,S_2,...,S_k)</var>, that satisfies the following conditions:</p> <ul> <li>Each o...
p01219
<H1><font color="#000">Problem D:</font> Private Teacher</H1> <p> You are working as a private teacher. Since you are giving lessons to many pupils, you are very busy, especially during examination seasons. This season is no exception in that regard. </p> <p> You know days of the week convenient for each pupil, and a...
p02966
<span class="lang-en"> <p>Score : <var>1200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a weighted directed graph with <var>N</var> vertices numbered <var>0</var> to <var>N-1</var>.</p> <p>The graph initially has <var>N-1</var> edges. The <var>i</var>-th edge (<var>0 \leq i \leq N...
p03674
<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 of length <var>n+1</var>, <var>a_1,a_2,...,a_{n+1}</var>, which consists of the <var>n</var> integers <var>1,...,n</var>. It is known that each of the <var>n</var> inte...
p01649
<h2>Problem Statement</h2> <p> You have a billiard table. The playing area of the table is rectangular. This billiard table is special as it has no pockets, and the playing area is completely surrounded with a cushion. </p> <p> You succeeded in producing a ultra-precision billiards playing robot. When you put some b...
p02989
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Takahashi made <var>N</var> problems for competitive programming. The problems are numbered <var>1</var> to <var>N</var>, and the difficulty of Problem <var>i</var> is represented as an integer <var>d_i...
p03361
<span class="lang-en"> <p>Score: <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3> <p>We have a canvas divided into a grid with <var>H</var> rows and <var>W</var> columns. The square at the <var>i</var>-th row from the top and the <var>j</var>-th column from the left is represented as <v...
p02823
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p><var>2N</var> players are running a competitive table tennis training on <var>N</var> tables numbered from <var>1</var> to <var>N</var>.</p> <p>The training consists of <i>rounds</i>. In each round, the...
p03731
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>In a public bath, there is a shower which emits water for <var>T</var> seconds when the switch is pushed.</p> <p>If the switch is pushed when the shower is already emitting water, from that moment it wi...
p02570
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Takahashi is meeting up with Aoki.</p> <p>They have planned to meet at a place that is <var>D</var> meters away from Takahashi's house in <var>T</var> minutes from now.</p> <p>Takahashi will leave his h...
p02120
<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 J: Cluster Networ...
p02157
<h1>Problem I: Shuffle 2</h1> <h2>Problem</h2> <p> $n$枚のカードからなる束があり、下から$i$番目のカードには$i$が書かれている。この束に対して、以下のように定義されるシャッフルを$q$回行う。<br> </p> <ul> <li>束を下から見たとき、奇数番目のカードを上に重ねていって作られる束$x$、偶数番目のカードを上に重ねていって作られる束$y$を考える。その後以下の$2$つのうち、好きな操作を行う。</li> <li>操作 $0$: 束$x$の上に束$y$をのせて$1$つの束にする。</li> <li>操作 $1$: 束$y$の上に束$x$をのせて$1...
p00490
<H1> 最高のピザ (Best Pizza) </H1> <h2> 問題</h2> <p> K 理事長は,JOI 市の中心部にある JOI ピザ店の常連客である.彼はある事情により,今月から節約生活を始めることにした.そこで彼は,JOI ピザ店で注文できるピザのうち,1 ドルあたりのカロリーが最大となるようなピザを注文したいと思った.このようなピザを「最高のピザ」と呼ぶことにしよう.「最高のピザ」は 1 種類とは限らない. </p> <p> JOI ピザでは N 種類のトッピングから何種類かを自由に選び,基本の生地の上に載せたものを注文することができる.同種のトッピングを 2 つ以上載せることはできない.生地...
p02854
<span class="lang-en"> <p>Score: <var>200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3> <p>Takahashi, who works at DISCO, is standing before an iron bar. The bar has <var>N-1</var> notches, which divide the bar into <var>N</var> sections. The <var>i</var>-th section from the left has a length...
p00869
<H1><font color="#000">Problem F:</font> Traveling Cube</H1> <p> On a small planet named Bandai, a landing party of the starship Tadamigawa discovered colorful cubes traveling on flat areas of the planet surface, which the landing party named beds. A cube appears at a certain position on a bed, travels on the bed for...
p03746
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You are given a connected undirected simple graph, which has <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<...
p01281
<H1><font color="#000">Problem I:</font> Tatami</H1> <p> A tatami mat, a Japanese traditional floor cover, has a rectangular form with aspect ratio 1:2. When spreading tatami mats on a floor, it is prohibited to make a cross with the border of the tatami mats, because it is believed to bring bad luck. </p> <p> Your t...
p03316
<span class="lang-en"> <p>Score : <var>200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Let <var>S(n)</var> denote the sum of the digits in the decimal notation of <var>n</var>. For example, <var>S(101) = 1 + 0 + 1 = 2</var>.</p> <p>Given an integer <var>N</var>, determine if <var>S(N)</va...
p02911
<span class="lang-en"> <p>Score: <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3> <p>Takahashi has decided to hold fastest-finger-fast quiz games. Kizahashi, who is in charge of making the scoreboard, is struggling to write the program that manages the players' scores in a game, which p...
p03603
<span class="lang-en"> <p>Score : <var>700</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a tree with <var>N</var> vertices. Vertex <var>1</var> is the root of the tree, and the parent of Vertex <var>i</var> (<var>2 \leq i \leq N</var>) is Vertex <var>P_i</var>.</p> <p>To each vertex...
p00886
<H1><font color="#000">Problem C:</font> Towns along a Highway</H1> <p> There are several towns on a highway. The highway has no forks. Given the distances between the neighboring towns, we can calculate all distances from any town to others. For example, given five towns (A, B, C, D and E) and the distances between ...
p01794
<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 E Cost Performance Flow...
p03253
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You are given positive integers <var>N</var> and <var>M</var>.</p> <p>How many sequences <var>a</var> of length <var>N</var> consisting of positive integers satisfy <var>a_1 \times a_2 \times ... \times...
p02012
<h1>Problem I. Sum of QQ</h1> <!-- Time Limit: 2 sec Memory Limit: 512 MB --> <p> You received a card with an integer $S$ and a <i>multiplication table</i> of infinite size. All the elements in the table are integers, and an integer at the $i$-th row from the top and the $j$-th column from the left is $A_{i,j} = i ...
p00185
<H1> ゴールドバッハ予想</H1> <p> ゴールドバッハ予想とは「6 以上のどんな偶数も、2 つの素数 (*1) の和として表わすことができる」というものです。 </p> <p> たとえば、偶数の 12 は <var>12 = 5 + 7</var> 、18 は <var>18 = 5 + 13 = 7 + 11</var> などと表すことができます。 </p> <p> 和が 134 となる 2 つの素数の組み合せをすべて書き出すと、以下の通りとなります。<br/> <br/> <var>134 = 3+131 = 7+127 = 31+103 = 37+97 = 61+73 = 67+67 </var><...
p02442
<h1>Lexicographical Comparison</h1> <p> Compare given two sequence $A = \{a_0, a_1, ..., a_{n-1}\}$ and $B = \{b_0, b_1, ..., b_{m-1}$ lexicographically. </p> <h2>Input</h2> <p> The input is given in the following format. </p> <pre> $n$ $a_0 \; a_1, ..., \; a_{n-1}$ $m$ $b_0 \; b_1, ..., \; b_{m-1}$ </pre> <p...
p03480
<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...
p01147
<!-- begin en only --> <h3><U> Princess, a Cryptanalyst </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> ある貧乏な国のおてんばで勇敢なお姫様は,お...
p01517
<!-- begin en only --> <h3><u>The Enemy of My Enemy is My Friend </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> 時は XXXX 年。戦乱...
p02291
<H1>Reflection</H1> <br/> <p> For given three points <var>p1, p2, p</var>, find the reflection point <var>x</var> of <var>p</var> onto <var>p1p2</var>. </p> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_CGL_CGL_1_B"> </center> <H2>Input</H2> <pre> <var>x<sub>p1</sub></var> <var>y<sub>p1...
p00756
<h3><U>And Then, How Many Are There?</U></h3> <!-- end en only --> <div> <!-- please enclose each h3 level section with div --> <!-- begin en only --> <p> To Mr. Solitarius, who is a famous solo play game creator, a new idea occurs like every day. His new game requires discs of various colors and sizes. </p> <!-- ...
p03879
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><style> #nck { width: 30px; height: auto; } </style> <p>Snuke received a triangle as a birthday present. The coordinates of the three vertices were <var>(x_1, y_1)</var>, <var>(x_2, y_2)<...
p01844
<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>F - 土地相続</h2> <h3>Problem Statement</h3> <p>...
p00306
<h1>かぐや</h1> <p> いよいよ今月末に「はやぶさ2」が打ち上げられます。4年前に「はやぶさ」が帰ってきたときは、日本中が盛り上がったのを覚えている人も多いと思います。7年前には、「かぐや」が打ち上げられ、月の周りを回りながらたくさんの鮮明な画像を地球に送ってくれました。 </p> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_PCK2014_kaguya"> </center> <br> <p> 上の図は、地球を原点とした空間座標(z軸は紙面から垂直に下から上に向いているものとします)に、月の軌道といくつかの月の...
p00613
<H1><font color="#000000">Problem I:</font> A Piece of Cake</H1> <p> In the city, there are two pastry shops. One shop was very popular because its cakes are pretty tasty. However, there was a man who is displeased at the shop. He was an owner of another shop. Although cause of his shop's unpopularity is incredi...
p01901
<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>D: 日焼け - Suntan -</h2> <h3>物語</h3> <p> あいずにゃんは若ヶ松高校のプログラミングコンテスト部、通称ぷろこん部に所属する2年生である。天使のようにかわいい。 あいずにゃんは今年の夏フェスに参加する予定なので、聴きに行くバンドのスケジュールを立てた。...
p00243
<H1>塗りつぶしゲーム</H1> <p> 指で画面にタッチして操作することのできるタブレットインターフェースの技術は、ゲームの分野でも応用され、新しい操作感を持つ様々な種類のゲームが作られています。現在、AZ社が開発しているゲームもその一つです。 </p> <p> このソフトウェア(ゲーム)の要件は以下の通りです。 </p> <ul> <li> 画面には <var>X</var> 列&times; <var>Y</var>行の2次元グリッドがあります。</li> <li> グリッドのセルは赤(R)、緑(G)、茶(B)の3色のいずれかで塗られています。</li> <li> セルの色を変更するボタンR、G、Bがあり、このボタ...
p02784
<span class="lang-en"> <p>Score : <var>200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Raccoon is fighting with a monster.</p> <p>The <em>health</em> of the monster is <var>H</var>.</p> <p>Raccoon can use <var>N</var> kinds of special moves. Using the <var>i</var>-th move decreases the mo...
p03896
<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> persons, conveniently numbered <var>1</var> through <var>N</var>. They will take <em>3y3s Challenge</em> for <var>N-1</var> seconds.</p> <p>During the challenge, each person must ...
p01002
<h1>Problem D: Smartphone Game</h1> <h2>Problem</h2> <p> 人気のスマフォゲームの一機能を実装してみよう。ゲームは以下の仕様に基づく。 </p> <ul> <li>5*5のマスに、5種類のブロックが設置されている。</li> <li>それぞれの種類のブロックには得点が設定されている。</li> <li>得点には、ブロックの得点の他に、ボーナス得点が設定されている。最初のボーナス得点は1である。</li> <li>ブロックを任意に1つだけ決めて、最大で<var> n </var>回まで上下左右に移動できる。移動先のブロックは移動元のブロックのあった場所に移動する。つまり、...
p01452
<H1>Problem F: 10歳の動的計画</H1> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_10_dp"> </center> <p> ある日の夕方。いつものようにあなたが居間でテレビを見ていると、小学5年生の妹から相談を持ち かけられた。話を聞いてみると、今日学校で出された算数の問題が難しくて理解できなかったので、 あなたに解き方を教えてほしいのだという。 </p> <p> 妹を悩ませている問題は、「道が碁盤目状に通っている街において、家(0, 0) から学校(<i>N</i>, <i>M</i>) まで最短...
p03195
<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...
p00994
<h1>Problem E : Connect</h1> <p> <i>r</i> × <i>c</i> のグリッドが与えられる。<br> グリッドのいくつかのマスには1から8までの数字が書かれている。<br> </p> <p> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_ACPC2012Day2_img_puzzle_05" height="150" witdh="150"> </p> <p> 数字が書かれているマスと他の数字が書かれているマスを線で結ぶ必要がある。<br> 数字が書かれているマスについて、そのマスに書かれている本数だけ、他...
p01686
<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>...
p03341
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There are <var>N</var> people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string <var>S</var> of length <var>N</var>. The <var>i</...
p02803
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Takahashi has a maze, which is a grid of <var>H \times W</var> squares with <var>H</var> horizontal rows and <var>W</var> vertical columns.</p> <p>The square at the <var>i</var>-th row from the top and ...
p03711
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Based on some criterion, Snuke divided the integers from <var>1</var> through <var>12</var> into three groups as shown in the figure below. Given two integers <var>x</var> and <var>y</var> (<var>1 ≤ x &...
p00097
<H1>整数の和 II</H1> <p> 0 から 100 の数字から異なる <var>n</var> 個の数を取り出して合計が <var>s</var> となる組み合わせの数を出力するプログラムを作成してください。<var>n</var> 個の数はおのおの 0 から 100 までとし、1つの組み合わせに同じ数字は使えません。たとえば、<var>n</var> が 3 で <var>s</var> が6 のとき、3 個の数字の合計が 6 になる組み合わせは、 </p> <pre> 1 + 2 + 3 = 6 0 + 1 + 5 = 6 0 + 2 + 4 = 6 </pre> <p> の 3 通りとなります。 </p> <...
p02550
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Let us denote by <var>f(x, m)</var> the remainder of the Euclidean division of <var>x</var> by <var>m</var>.</p> <p>Let <var>A</var> be the sequence that is defined by the initial value <var>A_1=X</var>...
p02100
<h1>Problem C: Factorization</h1> <h2>Problem</h2> <p> ukuku1333さんはおっちょこちょいなので、 <var>x</var> の一次式の積を展開したら、元の一次式がわからなくなってしまった。<br> <var>x</var> の <var>n</var> 次多項式が与えられるので、因数分解して元のxの一次式の積の形にせよ。 </p> <p> <var>x</var> の <var>n</var> 次多項式は以下のBNFによって与えられる。 </p> <pre> &lt;多項式&gt; &#058;&#061; &lt;項&gt; &#124; &lt;多項式&gt...
p02415
<H1>Toggling Cases</H1><br> <p> Write a program which converts uppercase/lowercase letters to lowercase/uppercase for a given string. </p> <H2>Input</H2> <p> A string is given in a line. </p> <H2>Output</H2> <p> Print the converted string in a line. Note that you do not need to convert any characters othe...
p00428
<H1></H1> <p> ある学校で修学旅行へ行く計画がある.そのためにアンケート調査を行った. 生徒は 1 から <i>n</i> までの生徒番号を持ち,旅行候補の場所を 1 から <i>m</i> までの番号で表し,行きたい場所に ○,行きたくない場所に×の印をつけて提出している. </p> <p> このとき, 行きたい場所の人数が多い順に,場所の番号を出力するプログラムを作成せよ.人数が同じときは,場所の番号順とする. </p> <!-- <p> 入力ファイルのファイル名は “input.txt” である. “input.txt” の 1 行目は生徒の人数 <i>n</i> と旅行候補の場所の数 <i...
p02045
<h3>毒の沼地</h3> <!-- begin ja only --> <p>あなたはレトロなロールプレイングゲームで遊んでいる.このゲームのフィールドは縦 100 マス,横 100 マスのマス目状である.このフィールドの左から <i>x</i> 列目,上から <i>y</i> 行目のマスは <i>(x, y)</i> と表される.あなたが操作するキャラクターはフィールド内のいずれかのマスの上におり,フィールド内を上下左右に 1 マスずつ移動することができる.</p> <p>あなたが操作するキャラクターはいま <i>(X<sub>0</sub>, Y<sub>0</sub>)</i> にいて,これから <i>N</i> 箇所の...
p00078
<H1>魔方陣</H1> <p> <var>n</var> × <var>n</var> の正方形のマス目の中に数字の1から <var>n</var> × <var>n</var> が一つずつ入っていて、縦のどの列のマス目の和も、横のどの列のマス目の和も対角線のマス目の和も等しいものを魔方陣といいます。 </p> <p> 一辺のマスの個数が奇数の魔方陣の作り方には以下の方法があります。 </p> <ol> <li>中央のマス目のちょうど一つ下のマス目に1を入れる。</li> <li>次の数字を右斜め下のマス目に入れる。<br>ただし、数字を入れようとしたマス目が正方形からはみ出している場合、すでに数字が埋まっている場...
p00582
<h1>展覧会(Exhibition)</h1> <p> あなたは,絵の展覧会を開催しようとしている.展覧会では,いくつかの絵を額縁に入れ,左から右に一列に並べて展示する. </p> <p> 展覧会で展示する候補となる絵が$N$ 枚あり,1 から$N$ までの番号が付けられている.絵$i$ ($1 \leq i \leq N$) の大きさは$S_i$,価値は$V_i$ である. </p> <p> また,これらの絵を入れるための額縁が$M$ 枚あり,1 から$M$ までの番号が付けられている.額縁$j$ ($1 \leq j \leq M$) の大きさは$C_j$ である.額縁$j$ には,大きさが$C_j$ 以下の...
p01239
<H1><font color="#000">Problem F:</font> Connect Line Segments</H1> <p> Your dear son Arnie is addicted to a puzzle named <i>Connect Line Segments</i>. </p> <p> In this puzzle, you are given several line segments placed on a two-dimensional area. You are allowed to add some new line segments each connecting the end p...
p03204
<span class="lang-en"> <p>Score : <var>1200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Takahashi's office has <var>N</var> rooms. Each room has an ID from <var>1</var> to <var>N</var>. There are also <var>N-1</var> corridors, and the <var>i</var>-th corridor connects Room <var>a_i</var> ...
p02946
<span class="lang-en"> <p>Score : <var>200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There are <var>2000001</var> stones placed on a number line. The coordinates of these stones are <var>-1000000, -999999, -999998, \ldots, 999999, 1000000</var>.</p> <p>Among them, some <var>K</var> cons...
p01669
<h2>C - Iyasugigappa</h2> <h3>Problem Statement</h3> <p> Three animals Frog, Kappa (Water Imp) and Weasel are playing a card game. </p> <p> In this game, players make use of three kinds of items: a guillotine, twelve noble cards and six action cards. Some integer value is written on the face of each noble card and ...
p03654
<span class="lang-en"> <p>Score : <var>1100</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 in this tree connects Vertices <var>A_i</var> and <var>B_i</var> and has a length of <va...
p01393
<script src="./IMAGE/varmath.js" charset="UTF-8"></script> <h1><font color="#000">問題 F</font> ボ〜ル</h1> <h2>問題文</h2> <p>2 次元平面上の原点にボールがあり,<var>x</var> 軸の正方向との角度が反時計回りに見て <var>0</var> 度 <var>180</var> 度までの間の方向に一様な確率で発射されようとしている (発射される方向は整数角であるとは限らない).ボールの大きさは十分小さく,平面上では点であると見なすことにする.この問題における目的は,このボールをできるだけ高い確率で捕獲...
p00351
<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> AIZU 国の夕暮れ時は、スマートフォンを西の空へ...
p02696
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Given are integers <var>A</var>, <var>B</var>, and <var>N</var>.</p> <p>Find the maximum possible value of <var>floor(Ax/B) - A × floor(x/B)</var> for a non-negative integer <var>x</var> not greater tha...
p03984
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3> <p> Mikan's birthday is coming soon. Since Mikan likes graphs very much, Aroma decided to give her a undirected graph this year too. </p> <p> Aroma bought a connected undirected graph, which consists of ...
p00701
<h1> Pile Up! </h1> <p>There are cubes of the same size and a simple robot named Masato. Initially, all cubes are on the floor. Masato can be instructed to pick up a cube and put it on another cube, to make piles of cubes. Each instruction is of the form `pick up cube <i>A</i> and put it on cube <i>B</i> (or on th...
p01813
<h2>坑道数式</h2> <p> ある日廃坑を探検していたあなたは、坑道に長い数式 <var>S</var> が書かれているのを発見した。大きな数が好きなあなたは、チョークを取り出し、数式を計算した結果ができるだけ大きくなるように<code>(</code>または<code>)</code>を書き加えることにした。書き加えた後も数式になっていなければならないとすると、最大でいくつにできるか。 </p> <p> 文字と文字の間は十分広く空いていて、<code>(</code>または<code>)</code>であればいくつでも書き加えることができる。最終的に数式になっていれば、最初のかっこの対応が崩れるように<code>(<...
p01540
<h1>宝探し</h1> <p> 太郎君はある広場にお宝を探しにやってきました。この広場にはたくさんのお宝が埋められていますが、太郎君は最新の機械を持っているので、どこにお宝が埋まっているかをすべて知っています。広場はとても広いので太郎君は領域を決めてお宝を探すことにしましたが、お宝はたくさんあるためどのお宝がその領域の中にあるかすぐにわかりません。そこで太郎君はその領域の中にあるお宝の数を数えることにしました。 </p> <h2>Input</h2> <blockquote> <var>n</var> <var>m</var><br><var>x<sub>1</sub></var> <var>y<sub>1</sub></...
p03087
<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> of length <var>N</var> consisting of <code>A</code>, <code>C</code>, <code>G</code> and <code>T</code>. Answer the following <var>Q</var> queries:</p> <ul> <li>Query ...
p01110
<h3>Origami, or the art of folding paper</h3> <!-- end en only --> <!-- begin en only --> <p> Master Grus is a famous <i>origami</i> (paper folding) artist, who is enthusiastic about exploring the possibility of origami art. For future creation, he is now planning fundamental experiments to establish the general the...
p03438
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You are given two integer sequences of length <var>N</var>: <var>a_1,a_2,..,a_N</var> and <var>b_1,b_2,..,b_N</var>. Determine if we can repeat the following operation zero or more times so that the seq...
p01405
<h2> Problem H: Oh, My Goat! </h2> <p> 太郎君は、次郎君に古文のノートを借りた。 明日の古文の宿題を写させてもらうためだ。 太郎君は、用心深い性格をしているため、万が一のことを考えて、近所のコンビニで次郎君のノートのコピーを取って自宅へ帰った。 </p> <p> 太郎君は、自宅で宿題を始めようとしたときに、慌てた。 次郎君から借りたノートが鞄に入っていなかったからだ。 どうやら、コンビニに忘れてきてしまったようだ。 </p> <p> 太郎君は、急いでコンビニに引き返した。 コピー機とその周辺を懸命に捜索したが、ノートを見つけることはできなかった。 </p> <p> 困り果てた太郎...
p03592
<span class="lang-en"> <p>Score : <var>200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a grid with <var>N</var> rows and <var>M</var> columns of squares. Initially, all the squares are white.</p> <p>There is a button attached to each row and each column. When a button attached to ...
p03068
<span class="lang-en"> <p>Score : <var>200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You are given a string <var>S</var> of length <var>N</var> consisting of lowercase English letters, and an integer <var>K</var>. Print the string obtained by replacing every character in <var>S</var> th...
p01055
<h1>Bomb Removal</h1> <h2>Problem</h2> <p> 縦<var>H</var>&times;横<var>W</var>のグリッド上に<var>N</var>個の点火された導火線とそれぞれに対する1つの爆弾が配置されている。それぞれの導火線と爆弾は、<var>L<sub>i</sub></var>個のマスからなる<var>path<sub>i</sub></var>上に配置され、<var>path<sub>i</sub></var>の<var>j</var>番目のマスを(<var>px<sub>ij</sub></var>, <var>py<sub>ij</sub></var>)とする。各爆弾...
p00214
<H1>秋のイルミネーション</H1> <p> 四角形が大好きな人が多く住む四角町では、四角形の電光板を組み合わせたイルミネーションで町中を彩るお祭りが開催されます。<!--このイルミネーションには四角大学で開発された特殊な電光板を使います。-->この電光板は電気を流すと発光し、発光している板に接している板も発光します。したがって、電光板を何枚使っても、すべてがひとかたまりに接していれば電源がひとつで済むという優れものです。 </p> <p> お祭り実行委員会では、四角形を組み合わせたデザインを町民から募集し多数のイルミネーションを作成します。各イルミネーションは、デザインを構成する四角形の配置によって必要となる電源の...
p02229
b
p02383
<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 I</h1><br> <p> Wri...
p00644
<H1><font color="#000000">Problem H:</font> Winter Bells</H1> <p> The best night ever in the world has come! It's 8 p.m. of December 24th, yes, the night of Cristmas Eve. Santa Clause comes to a silent city with ringing bells. Overtaking north wind, from a sleigh a reindeer pulls she shoot presents to soxes hanged ne...
p02679
<span class="lang-en"> <p>Score: <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3> <p>We have caught <var>N</var> sardines. The <em>deliciousness</em> and <em>fragrantness</em> of the <var>i</var>-th sardine is <var>A_i</var> and <var>B_i</var>, respectively.</p> <p>We will choose one or...
p01956
<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...
p02116
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h1>Problem F: nCm</h1> <h2>Problem</h2> <p> 整数<var>n</var>が与えられた時、<var>nCm</var>(異なる<var>n</var>個のものから<var>m</var>個を選ぶ組み合わせの数)が偶数となるような最小の<var>m</var>を出力せよ。 </p> <h2>Input...
p02546
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>In the Kingdom of AtCoder, people use a language called Taknese, which uses lowercase English letters.</p> <p>In Taknese, the plural form of a noun is spelled based on the following rules:</p> <ul> <li>...
p00081
<H1>線対称</H1> <p> 平面上の異なる 3 点 <var>P1(x1,y1)</var>, <var>P2(x2,y2)</var>, <var>Q(xq,yq)</var> の座標の組を読み込んで、点 <var>P1</var> 点<var>P2</var> を通る直線を対称軸として点 <var>Q</var> と線対称の位置にある点 <var>R(x,y)</var> を出力するプログラムを作成してください。なお、点 <var>Q</var> は、その対称軸上にないものとします。 </p> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/i...
p03707
<span class="lang-en"> <p>Score : <var>700</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Nuske has a grid with <var>N</var> rows and <var>M</var> columns of squares. The rows are numbered <var>1</var> through <var>N</var> from top to bottom, and the columns are numbered <var>1</var> through...
p00828
<H1><font color="#000">Problem B:</font> Make a Sequence</H1> <p> Your company’s next product will be a new game, which is a three-dimensional variant of the classic game “Tic-Tac-Toe”. Two players place balls in a three-dimensional space (board), and try to make a sequence of a certain length. </p> <p> People believ...
p02815
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>For two sequences <var>S</var> and <var>T</var> of length <var>N</var> consisting of <var>0</var> and <var>1</var>, let us define <var>f(S, T)</var> as follows:</p> <ul> <li> <p>Consider repeating the f...
p03357
<span class="lang-en"> <p>Score : <var>600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There are <var>2N</var> balls, <var>N</var> white and <var>N</var> black, arranged in a row. The integers from <var>1</var> through <var>N</var> are written on the white balls, one on each ball, and the...
p01690
<h2>D - Disciple Life is Hard / 弟子はつらいよ</h2> <h3>Story</h3> <p>Dのひとはドーナツを愛してやまない。常にドーナツを欲している。しかし、師匠であるぶなしめじたんに体を鍛えることを命じられたDのひとは、摂取カロリーを制限しなければならない。そこでDのひとは基礎代謝も考慮し、その日トレーニングによって消費したカロリーの分までドーナツを食べてもよいことにした。Dのひとはドーナツを愛してやまないとはいえ、好みはあるので、食べるドーナツによって得られる幸福感は変わる。また、その日の体力によって行えるトレーニングも変わってくるため、トレーニングの種類、ドーナツの種類、体力を考慮...
p00982
<h2>Twin Trees Bros.</h2> <p> To meet the demand of ICPC (International Cacao Plantation Consortium), you have to check whether two given <i>trees</i> are <i>twins</i> or not. </p> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/ICPCAsia2019_twin_trees_bros_1" width="400"/><br> Example of two tr...
p01385
<div> <h1 class="title">問題 J : 乱択平衡分二分探索木</h1> <p>ところで,G○○gle Code Jam の地区大会で右の席に座っていた男の ID は rng_58 と言うらしい. 東京大学時代の記憶に,似たような ID の仲間が居た覚えがあるが,僕の仲間は一人残さず美少女だったはずだ. 彼女はいわゆる無表情不思議系キャラだったような気がする.</p> <p>ということは,彼は知らない男だ.rng とは何の略だろう. おそらく Random Number Generator に違いない. 乱択アルゴリズムを得意とするのだろう.</p> <p>ところで,乱数を用いた平衡二分探索木である Tr...
p03642
<span class="lang-en"> <p>Score : <var>1200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There are infinitely many cards, numbered <var>1</var>, <var>2</var>, <var>3</var>, <var>...</var> Initially, Cards <var>x_1</var>, <var>x_2</var>, <var>...</var>, <var>x_N</var> are face up, and the o...
p02950
<span class="lang-en"> <p>Score : <var>600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Given are a prime number <var>p</var> and a sequence of <var>p</var> integers <var>a_0, \ldots, a_{p-1}</var> consisting of zeros and ones.</p> <p>Find a polynomial of degree at most <var>p-1</var>, <va...
p03212
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You are given an integer <var>N</var>. Among the integers between <var>1</var> and <var>N</var> (inclusive), how many <em>Shichi-Go-San numbers</em> (literally "Seven-Five-Three numbers") are there?</p>...