question_id
stringlengths
6
6
content
stringlengths
1
27.2k
p01848
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h3>夏合宿の朝は早い</h3> <p>JAG夏合宿の朝は早い. 正確にはそこまで早くないが,早...
p03875
<span class="lang-en"> <p>Score : <var>1500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><style> #nck { width: 30px; height: auto; } </style> <p>Snuke received two matrices <var>A</var> and <var>B</var> as birthday presents. Each of the matrices is an <var>N</var> by <var>N<...
p03526
<span class="lang-en"> <p>Score : <var>700</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>In the final of CODE FESTIVAL in some year, there are <var>N</var> participants. The <em>height</em> and <em>power</em> of Participant <var>i</var> is <var>H_i</var> and <var>P_i</var>, respectively.</p...
p03176
<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> flowers arranged in a row. For each <var>i</var> (<var>1 \leq i \leq N</var>), the height and the beauty of the <var>i</var>-th flower from the left is <var>h_i</var> and <var>a_i...
p03199
<span class="lang-en"> <p>Score : <var>900</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Takahashi has an <var>N \times N</var> grid. The square at the <var>i</var>-th row and the <var>j</var>-th column of the grid is denoted by <var>(i,j)</var>. Particularly, the top-left square of the gri...
p03463
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>A game is played on a strip consisting of <var>N</var> cells consecutively numbered from 1 to <var>N</var>. </p> <p>Alice has her token on cell <var>A</var>. Borys has his token on a different cell <var...
p03033
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There is an infinitely long street that runs west to east, which we consider as a number line.</p> <p>There are <var>N</var> roadworks scheduled on this street. The <var>i</var>-th roadwork blocks the p...
p02788
<span class="lang-en"> <p>Score : <var>600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Silver Fox is fighting with <var>N</var> monsters.</p> <p>The monsters are standing in a row, and we can assume them to be standing on a number line. The <var>i</var>-th monster, standing at the coordin...
p02272
<H1>Merge Sort</H1> <p> Write a program of a Merge Sort algorithm implemented by the following pseudocode. You should also report the number of comparisons in the Merge function. </p> <pre> Merge(A, left, mid, right) n1 = mid - left; n2 = right - mid; create array L[0...n1], R[0...n2] for i = 0 to n1-1 ...
p02622
<span class="lang-en"> <p>Score : <var>200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Given are strings <var>S</var> and <var>T</var>. Consider changing <var>S</var> to <var>T</var> by repeating the operation below. Find the minimum number of operations required to do so.</p> <p>Operatio...
p03930
<span class="lang-en lang-child hidden-lang"> <div id="task-statement"> <div class="part"> Max Score: $300$ Points <br/> <section> <h3>Problem Statement</h3> We are playing a puzzle. An upright board with $H$ rows by $W$ columns of cells, is used in this puzzle. <br/> A stone in $i$-th row and $j$-th c...
p01327
<h1><font color="#000">Problem G:</font> 天体観測</h1> <p> 2012年のある日のこと。 北の田舎町に住むあなたは、愛娘を連れて展望台で星見をすることにした。 この町は都会と違って街明かりが少なく、空気も澄んでいるので、晴れた日は満天の星空が広がっている。 天文にそこそこ詳しいあなたは季節ごとの有名な星や星座、それにまつわる神話ぐらいは知っているのだが、 なにせここは星降る町、名前のわからない星座もたくさん見えている。 この前の星見のときにそういった星々に関する娘の質問に答えられなかったあなたは、 星見の時刻にいったいどの星座が見えるのかを調べたいと思った。 </p> <p>...
p00865
<H1><font color="#000">Problem B:</font> Expected Allowance</H1> <p> Hideyuki is allowed by his father Ujisato some 1000 yen bills every month for his pocket money. In the first day of every month, the number of bills is decided as follows. Ujisato prepares <i>n</i> pieces of <i>m</i>-sided dice and declares the cutb...
p02858
<span class="lang-en"> <p>Score: <var>900</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3> <p>In <var>2937</var>, DISCO creates a new universe called DISCOSMOS to celebrate its <var>1000</var>-th anniversary.</p> <p>DISCOSMOS can be described as an <var>H \times W</var> grid. Let <var>(i, j)</va...
p01777
<h2>F: Disordered Data Detection / 異常検知</h2> <h3>物語</h3> <p>宮守あかねは武蔵野ソフトウェアに務めるエンジニアである.今日は顧客から受けた不具合報告に頭を悩ませている.「変な話,この前作ってもらったソフトの挙動がぷるんぷるんしてるんでぇ,そちらでチェックしてもらえますか?保守するのもおたくらの仕事でしょ?」いつも無理難題ばかり押し付けてくるこの顧客だが,今回ばかりはこちらに非がある.なぜなら,いつも適当な仕事ばかりのジローがテストに通っていないコードをそのまま放置して製品に組み込んだことを告白したからである.普通の人間ならジローに殴りかかりそうなものだが,もはやいつ...
p00536
<h2>財宝 (Treasures)</h2> <h2>問題</h2> <p> 盗賊の Anna と Bruno は大富豪の邸宅に忍び込み,財宝 1 から財宝 N までの N 個の財宝を見つけた.これらの財宝を Anna と Bruno で分配することになった.財宝のうちのいくつかを Anna が取り,残りの財宝のうちのいくつかを Bruno が取る.同じ財宝を 2 人が取ることはできない.Anna や Bruno は財宝を 1 個も取らなくてもよい.また,残った財宝は邸宅に残しておくので,2 人とも取らない財宝があってもよい. </p> <p> それぞれの財宝には「市場価値」と「貴重度」という 2 つの値が定まって...
p00166
<H1>多角形の面積</H1> <p> 1つの円に内接する2つの多角形の頂点情報を入力とし、それらの面積の大小関係を出力するプログラムを作成してください。 </p> <p> <var>X</var> 角形の各頂点には反時計回りに 1 から <var>X</var> まで番号が振ってあるものとします(図は、<var>X</var> = 4 の場合の例を示しています)。ただし、与えられる多角形は円の中心を内部に含むものとし、頂点 <var>i</var> の位置に関するデータは、頂点 <var>i</var> から頂点 <var>i+1</var> まで反時計回りに計った中心角の角度 <var>v</var> (1 &le; ...
p00473
<H1>お菓子の分割  </H1> <h2> 問題</h2> <p> 長さ N ミリメートルの棒状のお菓子が 1 本ある(ここで N は偶数). 2 人の JOI 関係者が,このお菓子を複数本に切断して,合計 N/2 ミリメートルずつに分けること にした. </p> <p> 理由は不明であるが,このお菓子は場所によって切断のしやすさが異なっている. 2 人は,お菓子を左から 1 ミリメートルごとに調べ,各場所で切断に何秒かかるか を割り出した.2 人がお菓子を分けるための切断にかかる秒数の最小値を求めるプ ログラムを作成せよ. </p> <h2>入力</h2> <!-- <p> 入力ファイルのファイル名は inpu...
p00189
<H1>便利な町</H1> <p> 来春卒業するAさんは、就職を機に引越しをすることにしました。就職する会社は、オフィスがいくつかの町にあって、日によって出勤するオフィスが違います。そこでAさんは,どこのオフィスに 行くにも時間の短い町に住もうと考えました。 </p> <p> そこであなたは、Aさんを助けるため、住むのに一番便利な町を探すことになりました。 </p> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_location"> </center> <br/> <p> 町には 0 から始まる番号が振られており、町...
p00023
<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>Circles Intersection</H1> <p> You are given...
p01262
<H1><font color="#000">Problem C:</font> Adaptive Time Slicing Quantization</H1> <p> Nathan O. Davis is a student at the department of integrated systems. Today he learned digital quanti- zation in a class. It is a process that approximates analog data (e.g. electrical pressure) by a finite set of discrete values or ...
p01798
<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 Midpoint</h2> <p> ...
p00920
<H1><font color="#000">Problem G: </font>Longest Chain</H1> <p> Let us compare two triples <var>a = (x<sub>a</sub>, y<sub>a</sub>, z<sub>a</sub>)</var> and <var>b = (x<sub>b</sub>, y<sub>b</sub>, z<sub>b</sub>)</var> by a partial order &ang; defined as follows. <br/> <center> <var>a</var> &ang; <var>b</var> &hArr; <v...
p01632
<h1>Problem F: 自転車</h1> <h2>Problem Statement</h2> <p> 菊地君は、大の自転車好きである。今日も彼は、お気に入りの自転車に乗ってサイクリングロードへと走り出そうとしている。 </p> <p> 彼が住む地域には、N個の町が存在する。各町を町1、町2...、町Nと呼ぶこととする。彼が住む町は、町1である。この地域には、サイクリングを趣味としている人が多く、最近では頻繁に町と町を結ぶサイクリングロードが作られている。サイクリングロードを使うと、2つの町を双方向に移動できる。入力では、どの町とどの町が新しくサイクリングロードで繋がれたかが時系列順に入力される。 </p> <p...
p03121
<span class="lang-en"> <p>Score : <var>1000</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There is an infinitely large triangular grid, as shown below. Each point with integer coordinates contains a lamp.</p> <p><img alt="" src="https://img.atcoder.jp/wtf19/f617c94527a62ed72fe7db12b6d1f6b0....
p03571
<span class="lang-en"> <p>Score : <var>1600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We constructed a rectangular parallelepiped of dimensions <var>A \times B \times C</var> built of <var>ABC</var> cubic blocks of side <var>1</var>. Then, we placed the parallelepiped in <var>xyz</var>-...
p02730
<span class="lang-en"> <p>Score : <var>200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>A string <var>S</var> of an odd length is said to be a <em>strong palindrome</em> if and only if all of the following conditions are satisfied:</p> <ul> <li><var>S</var> is a palindrome.</li> <li>Let <v...
p03822
<span class="lang-en"> <p>Score : <var>800</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p><var>N</var> contestants participated in a competition. The total of <var>N-1</var> matches were played in a knockout tournament. For some reasons, the tournament may not be "fair" for all the contestan...
p03988
<span class="lang-en"> <p>Score : <var>700</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Aoki loves numerical sequences and trees.</p> <p>One day, Takahashi gave him an integer sequence of length <var>N</var>, <var>a_1, a_2, ..., a_N</var>, which made him want to construct a tree.</p> <p>Ao...
p02360
<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 Overlaps</H1> <p> G...
p02675
<span class="lang-en"> <p>Score: <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3> <p>The cat Snuke wants to play a popular Japanese game called ÅtCoder, so Iroha has decided to teach him Japanese.</p> <p>When counting pencils in Japanese, the counter word "本" follows the number. The pro...
p00648
<h1>Problem B: Watchin' TVA</h1> <p> Animation is one of methods for making movies and in Japan, it is popular to broadcast as a television program or perform as a movie. Many people, especially the young, love one. And here is an anime lover called Jack. We say he is an mysterious guy with uncertain age. He likes ani...
p03967
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>AtCoDeer the deer and his friend TopCoDeer is playing a game. The game consists of <var>N</var> turns. In each turn, each player plays one of the two <em>gestures</em>, <em>Rock</em> and <em>Paper</em>,...
p02225
<a href="https://onlinejudge.u-aizu.ac.jp/resources/icpcooc2019practice/A.pdf" target='_blank'>Problem description is available from here.</a>
p00218
<H1>クラス分け</H1> <p> 会津進学塾では、生徒が塾に入る際に実力テストを行ってクラス分けをします。テストは数学、英語、国語の 3 科目行い、生徒を A,B,C クラスにクラス分けします。A クラスのレベルが一番高く、順に低くなっていきます。 </p> <p> クラス分けの判断は以下の表に基づきます。 </p> <center> <table border=1> <tr> <th width="460"> 条件 </th><th width="80"> クラス</th> </tr> <tr> <td>100 点の科目がある </td><td> ...
p01059
<h1>Gossip</h1> <!-- <p> 12プロこと会津プロダクションは有名芸能プロダクションである。12プロには多くのアイドルが在籍している。 </p> --> <h2>Problem</h2> <p> 1から<var>n</var>までの番号が順番に割り当てられている<var>n</var>人のアイドルが横一列に並んでいる。<br> アイドル<var>i</var>は単位時間でアイドル<var>i</var>-1とアイドル<var>i</var>+1に情報を伝達することができる。ただし、アイドル1はアイドル2にしか情報を伝達できず、アイドル<var>n</var>はアイドル<var>n</var>-1に...
p03064
<span class="lang-en"> <p>Score : <var>600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You are given <var>N</var> integers. The <var>i</var>-th integer is <var>a_i</var>. Find the number, modulo <var>998244353</var>, of ways to paint each of the integers red, green or blue so that the fol...
p01409
<H1>C: Common Palindromes</H1> <p> ICPC で良い成績を収めるには修行が欠かせない.うさぎは ICPC で勝ちたいので,今日も修行をすることにした. </p> <p> 今日の修行は,文字列中にある回文を探すことによって,文章から隠れたメッセージを読解する能力を高めようというものである.回文はたくさんあるかもしれないので,探すついでに個数も数えてしまいたい. </p> <p> 2 つの文字列 <i>S</i>, <i>T</i> が与えられるので,以下を満たす整数の組 (<i>i</i>, <i>j</i>, <i>k</i>, <i>l</i>) の個数を求めたい. </p> <ul> <l...
p03434
<span class="lang-en"> <p>Score: <var>200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3> <p>We have <var>N</var> cards. A number <var>a_i</var> is written on the <var>i</var>-th card.<br/> Alice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. ...
p00131
<h1>博士の光電管</h1> <p> 博士 : ピーター君。やったよ。 </p> <p> ピーター : またですか。今度はどんなくだらない発明ですか。 </p> <p> 博士 : あの幻の素粒子アキシオンの検出器を発明したんじゃ。 </p> <p> ピーター : アキシオンといえば、欧州合同原子核研究機構 (CERN) をはじめとする研究者たちが血眼で追っかけているという、あれですよね。本当ですかぁ? </p> <p> 博士 : 本当だってばよ。細かい説明は省くが、非常に強力な磁場を内蔵する特殊な光電管が光ることによって、通過するアキシオンを検出する。 </p> <p> ピーター : 他 に先んじて検出すれば、...
p00561
<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>Kingdom of JOIOI</h1> <p> The Kingdom of ...
p00832
<H1><font color="#000">Problem F:</font> Dice Puzzle</H1> <p> Let’s try a dice puzzle. The rules of this puzzle are as follows. </p> <ol> <li> Dice with six faces as shown in Figure 1 are used in the puzzle. <br><br> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/dicePuzzle1"> <p>Figure 1: Faces ...
p01720
<p>イクタ君は、無向グラフについて異常なほどの思い入れを持っている。イクタ君は、無向グラフ <var>G</var> とその 2 点 <var>s,t</var>の組<var>(G,s,t)</var>のうち、その「うつくしさ」が大きいものが好きである。 組<var>(G,s,t)</var>の「うつくしさ」とは、辺 <var>e = \{u, v\}</var> (<var>u</var> と <var>v</var> は <var>G</var> の異なる 2 点) で、<var>G</var>における<var>s</var>から<var>t</var>への最短路の長さが、<var>G</var>に<var>e</var...
p01370
<!-- begin en only --> <!--<h3><U>Brave Force Story</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><i> 「最果ての地,ナイン...
p00998
<h1>Problem I : RMQ</h1> <p> <i>n</i> 個の数字<i>a<sub>0</sub></i> ,<i>a<sub>1</sub></i> , ... ,<i>a<sub>n-1</sub></i> と<i>q</i> が与えられる。<br> <i>q</i> 個のクエリーに対して適切な処理を行なって欲しい。<br> クエリーは以下の3種類の操作が存在する。<br> </p> <ul> <li>値のシフトを行う</li> <i>l</i> と<i>r</i> のペアが与えられる。(<i>l</i> &lt; <i>r</i> ) <i>a<sub>l</sub></i> から <i>a<su...
p00977
<h2>Colorful Tree</h2> <p> A tree structure with some colors associated with its vertices and a sequence of commands on it are given. A command is either an update operation or a query on the tree. Each of the update operations changes the color of a specified vertex, without changing the tree structure. Each of the...
p03658
<span class="lang-en"> <p>Score : <var>200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke has <var>N</var> sticks. The length of the <var>i</var>-th stick is <var>l_i</var>.</p> <p>Snuke is making a snake toy by joining <var>K</var> of the sticks together.</p> <p>The length of the toy ...
p01665
<h2>J - タイル置き</h2> <p> サイズ<var>H</var>×<var>W</var>の盤面にサイズ1×2のタイルをマス目にそって<var>N</var>個配置する方法が何通りあるか求めたい.</p> <p>タイルは重なってはいけない. また縦横どちらの向きに置いても構わない.</p> <p>タイルは全て同じ見た目であり互いに区別しないものとする.</p> <p>タイルは180度回転しても同じ見た目であり、区別しないものとする.</p> <p>答えは大きくなる可能性があるので1,000,000,007で割った余りを答えよ</p> <h2>入力形式</h2> <p> 入力は以下の形式で与えられる. <pre...
p04037
<span class="lang-en"> <div class="part"> <section> <h3>Problem Statement</h3><p>There are <var>N</var> piles of candies on the table. The piles are numbered <var>1</var> through <var>N</var>. At first, pile <var>i</var> contains <var>a_i</var> candies.</p> <p>Snuke and Ciel are playing a game. They take alternating tu...
p03208
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>In some other world, today is Christmas Eve.</p> <p>There are <var>N</var> trees planted in Mr. Takaha's garden. The height of the <var>i</var>-th tree <var>(1 \leq i \leq N)</var> is <var>h_i</var> met...
p01235
<H1><font color="#000">Problem B:</font> Electrophoretic</H1> <p> Scientist Frank, majoring in electrochemistry, has developed line-shaped strange electrodes called <i>F-electrodes</i>. During being activated, each F-electrode causes a special potential on and between the two lines touching the F-electrode’s endpoint...
p00074
<H1>ビデオテープ</H1> <p> 標準録画で 120 分のビデオテープがあります。テープを完全に巻き戻した状態でビデオデッキのカウンタを 00:00:00 にし、標準録画モードで録画したところ、あるカウンタ値になりました。このカウンタ値(時、分、秒)を入力し、残りのテープの長さ(録画可能時間)を求め、時:分:秒の形式で出力するプログラムを作成して下さい。 </p> <p> ただし、2 時間(120分)以内の入力とします。なお、テープ残量は標準録画モードと 3 倍録画モードの場合の2通りを計算し、出力例のように時、分、秒とも 2 桁ずつ出力します。また "05" のように 10 の位が 0 の場合は、"0" をつけて...
p02049
<h3>全宇宙生命ゲノムデータベース リターンズ</h3> <!-- begin ja only --> <p>西暦2301年,宇宙連邦共和国の生命科学局では,宇宙生物のゲノム配列の研究を行っていた.近年の研究の結果,ゲノム配列に特定のパターンが何回現れるかが生物の性質に大きく影響することが分かってきた.</p> <p>宇宙生物のゲノム配列は英大文字からなる文字列で表される.研究員たちはゲノム配列の中に,ある特定のパターンが何回現れるかを数え上げることにした.しかしながら,宇宙生物のゲノム配列は非常に長いため,後述する方法で繰り返しがある部分文字列を圧縮してデータベースに保存している.</p> <p>あなたの仕事は圧縮されたゲノ...
p00424
<H1></H1> <p> 与えられた変換表にもとづき,データを変換するプログラムを作成しなさい. </p> <p> データに使われている文字は英字か数字で,英字は大文字と小文字を区別する.変換表に現れる文字の順序に規則性はない. </p> <p> 変換表は空白をはさんで前と後ろの 2 つの文字がある(文字列ではない).変換方法は,変換表のある行の前の文字がデータに現れたら,そのたびにその文字を後ろの文字に変換し出力する.変換は 1 度だけで,変換した文字がまた変換対象の文字になっても変換しない.変換表に現れない文字は変換せず,そのまま出力する. </p> <p> 入力ファイルには,変換表(最初の n + 1 行)に続き変...
p02419
<H1>Finding a Word</H1><br> <p> Write a program which reads a word <var>W</var> and a text <var>T</var>, and prints the number of word <var>W</var> which appears in text <var>T</var> </p> <p> <var>T</var> consists of string <var>T<sub>i</sub></var> separated by space characters and newlines. Count the number of <va...
p02376
<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 Flow</H1> <p> A fl...
p03834
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>As a New Year's gift, Dolphin received a string <var>s</var> of length <var>19</var>.<br/> The string <var>s</var> has the following format: <code>[five lowercase English letters],[seven lowercase Engli...
p01809
<h2>幾何問題を解こう</h2> <p> A君は今日も幾何の問題を解いている。 幾何の問題を解く時は浮動小数点誤差に気をつけることが大事である。 </p> <p> 浮動小数点誤差とは、2進法の有限小数で数を表す際におこる丸めによって起きる誤差である。 例えば、10進法での <var>0.1</var> は2進法では <var>0.00011001100110011</var> ... という無限小数になるが、 これを有限の桁で丸める際に誤差が発生してしまう。 </p> <p> 正の整数 <var>p</var>, <var>q</var> が10進法で与えられる。 有理数 <var>p</var> / <var>q<...
p02726
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3> <p>We have an undirected graph <var>G</var> with <var>N</var> vertices numbered <var>1</var> to <var>N</var> and <var>N</var> edges as follows:</p> <ul> <li>For each <var>i=1,2,...,N-1</var>, there is an ...
p03567
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke built an online judge to hold a programming contest.</p> <p>When a program is submitted to the judge, the judge returns a verdict, which is a two-character string that appears in the string <var>S...
p03137
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We will play a one-player game using a number line and <var>N</var> pieces.</p> <p>First, we place each of these pieces at some integer coordinate.</p> <p>Here, multiple pieces can be placed at the same...
p03422
<span class="lang-en"> <p>Score : <var>900</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Takahashi and Aoki are playing a stone-taking game. Initially, there are <var>N</var> piles of stones, and the <var>i</var>-th pile contains <var>A_i</var> stones and has an associated integer <var>K_i<...
p03588
<span class="lang-en"> <p>Score : <var>200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>A group of people played a game. All players had distinct scores, which are positive integers.</p> <p>Takahashi knows <var>N</var> facts on the players' scores. The <var>i</var>-th fact is as follows: t...
p03072
<span class="lang-en"> <p>Score : <var>200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There are <var>N</var> mountains ranging from east to west, and an ocean to the west.</p> <p>At the top of each mountain, there is an inn. You have decided to choose where to stay from these inns.</p> <...
p02233
<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>Fibonacci Number</H1> <p> ...
p02399
<H1>A/B Problem</H1> <p> Write a program which reads two integers <var>a</var> and <var>b</var>, and calculates the following values: </p> <ul> <li><var>a</var> &divide; <var>b</var>: <var>d</var> (in integer)</li> <li>remainder of <var>a</var> &divide; <var>b</var>: <var>r</var> (in integer)</li> <li><var>a...
p03971
<span class="lang-en"> <p>Score : <var>200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There are <var>N</var> participants in the CODE FESTIVAL 2016 Qualification contests. The participants are either students in Japan, students from overseas, or neither of these.</p> <p>Only Japanese stu...
p02663
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>In this problem, we use the <var>24</var>-hour clock.</p> <p>Takahashi gets up exactly at the time <var>H_1</var> : <var>M_1</var> and goes to bed exactly at the time <var>H_2</var> : <var>M_2</var>. (S...
p01366
<H1><font color="#000">Problem H:</font> Road Construction</H1> <p> King Mercer is the king of ACM kingdom. There are one capital and some cities in his kingdom. Amazingly, there are no roads in the kingdom now. Recently, he planned to construct roads between the capital and the cities, but it turned out that the con...
p01736
<p> You and your grandma are playing with graph automata, which is generalization of cell automata. </p> <p> A graph automaton is expressed by a graph. The vertices of the graph have a time-dependent value, which can be either 0 or 1. There is no more than one edge between any of two vertices, but self-loops might ex...
p02819
<span class="lang-en"> <p>Score: <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3> <p>Find the minimum prime number greater than or equal to <var>X</var>.</p> </section> </div> <div class="part"> <section> <h3>Notes</h3> <p>A prime number is an integer greater than <var>1</var> that cann...
p00824
<H1><font color="#000">Problem F:</font> Gap</H1> <p> Let’s play a card game called Gap. </p> <p> You have 28 cards labeled with two-digit numbers. The first digit (from 1 to 4) represents the suit of the card, and the second digit (from 1 to 7) represents the value of the card. </p> <p> First, you shuffle the cards ...
p00577
<h1>マルバツスタンプ (Circle Cross Stamps)</h1> <!--  時間制限 : 2sec / メモリ制限 : 256MB--> <h2>問題文</h2> <p> JOI 君はマルスタンプ,バツスタンプ,マルバツスタンプの3種類のスタンプをそれぞれ <var>0</var> 個以上持っている.これらはマルやバツのマークを紙に印字することができるスタンプである. </p> <p> マルスタンプを使うとマルが <var>1</var> つ印字され,バツスタンプを使うとバツが <var>1</var> つ印字される.マルバツスタンプを使うとマルとバツが横一列に <var>1</var> つずつ印字され,スタン...
p00127
<h1>ポケベル打ち</h1> <p> ある日、たろう君は、本文に「519345213244」という数字だけが書いてあるおかしなメールを受け取り ました。そのメールは、10 歳年上の従姉からだったので電話して聞いてみると、「あ、急いでたから ポケベル打ちで送っちゃった。便利よね。よろしくねっ!」といって切られてしまいました。いつも せわしなく、少し強引なところのあるこの従姉をよく知るたろう君は、仕方なく自分で「ポケベル打 ち」について調べてみると、10 年ぐらい前に一世を風靡したかな入力の方法だということが分かりまし た。 </p> <p> 「ポケベル打ち」では、図 1 のような変換表に従い‘あ’は 11、‘お’は 15 と...
p00432
<H1></H1> <p> 平面に長方形のシートが何枚か置かれている. これらのシートで覆われている部分の面積や周長を求めるプログラムを作成せよ. </p> <p> ただし, 平面を座標平面とみなしたとき, シートの配置は次の条件 (1), (2) を満たすものとする. </p> <p> (1) 各シートの長方形の 4 頂点の <i>x</i>, <i>y</i> 座標は全て 0 以上 10000 以下の整数であり, 長方形の各辺は <i>x</i> 軸, または <i>y</i> 軸に平行である. </p> <p> (2) シートの枚数は高々 10000 枚以下である. </p> <!-- <p> 入力ファイルのファイル...
p00062
<H1>一番下の行の数字は?</H1> <p> 次のような数字のパターンを作ることを考えます。 </p> <pre> 4 8 2 3 1 0 8 3 7 6 2 0 5 4 1 8 1 0 3 2 5 9 5 9 9 1 3 7 4 4 4 8 0 4 1 8 8 2 8 4 9 6 0 0 2 5 6 0 2 1 6 2 7 8 5 </pre> <p> このパターンは以下の規則に従っています。 </p> <pre> A B C </pre> <p> という数字の並びにおいて、C は A + B の 1 の位の数字である。たとえ...
p00598
<H1><font color="#000000">Problem D:</font> Operations with Finite Sets</H1> <p> Let <i>A, B, C, D, E</i> be sets of integers and let <i>U</i> is a universal set that includes all sets under consideration. All elements in any set are different (no repetitions). </p> <p> u - <b>union</b> of two sets, <i>AuB</i> = {<i...
p01223
<h1><font color="#000">Problem A:</font>サイゾウ</h1> <p> ある国で「サイゾウ」というテレビ番組が流行している. この番組は参加者がフィールドアスレチックに挑戦し, 見事攻略すれば賞金をもらえるというものである. </p> <p> フィールドアスレチックは高さが異なるブロックを一列に並べて作られていて, 攻略のためにはいかにして段差を登り降りするかが重要になる (図1). この番組に参加することになったあなたの友人は, フィールドアスレチックの構造が与えられたときに, 登らなければならない最大...
p04021
<span class="lang-en"> <p>Score : <var>600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke got an integer sequence of length <var>N</var> from his mother, as a birthday present. The <var>i</var>-th <var>(1 ≦ i ≦ N)</var> element of the sequence is <var>a_i</var>. The elements are pairwi...
p01673
<h2>G - Revenge of Minimum Cost Flow</h2> <h3>Problem Statement</h3> <p> Flora is a freelance carrier pigeon. Since she is an excellent pigeon, there are too much task requests to her. It is impossible to do all tasks, so she decided to outsource some tasks to Industrial Carrier Pigeon Company. </p> <p> There are <...
p00961
<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...
p01389
<script src="./IMAGE/varmath.js" charset="UTF-8"></script> <h1><font color="#000">問題 B </font> 蝉</h1> <h2>問題文</h2> <p> N 君は毎日学校に通っているが,その道のりはとても長い.さらに今は暑い夏である.道中,蝉が五月蝿い.出来れば避けたいものである.ところで情報化が発達した現代社会においては,家に居ながらにしてどこに何匹の蝉がいるか調べることが出来る.その情報を使い,途中で出会う蝉の数が最も少ない道で学校に行くことに決めた. </p> <p> 家と学校が描かれた地図は長方形状になっており,<var>H ...
p03160
<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> stones, numbered <var>1, 2, \ldots, N</var>. For each <var>i</var> (<var>1 \leq i \leq N</var>), the height of Stone <var>i</var> is <var>h_i</var>.</p> <p>There is a frog who is ...
p03530
<span class="lang-en"> <p>Score : <var>1600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>In some place in the Arctic Ocean, there are <var>H</var> rows and <var>W</var> columns of ice pieces floating on the sea. We regard this area as a grid, and denote the square at the <var>i</var>-th ro...
p03863
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There is a string <var>s</var> of length <var>3</var> or greater. No two neighboring characters in <var>s</var> are equal.</p> <p>Takahashi and Aoki will play a game against each other. The two players ...
p02771
<span class="lang-en"> <p>Score: <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3> <p>A triple of numbers is said to be <em>poor</em> when two of those numbers are equal but the other number is different from those two numbers.</p> <p>You will be given three integers <var>A</var>, <var>B...
p02321
<H1>Huge Knapsack Problem</H1> <br/> <p> You have <var>N</var> items that you want to put them into a knapsack. Item <var>i</var> has value <var>v<sub>i</sub></var> and weight <var>w<sub>i</sub></var>. </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...
p03926
<span class="lang-en"> <p>Score : <var>1600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There are <var>N</var> squares in a row, numbered <var>1</var> through <var>N</var> from left to right. Snuke and Rng are playing a board game using these squares, described below:</p> <ol> <li>First, ...
p00609
<H1><font color="#000000">Problem E:</font> Amazing Graze</H1> <p> In 2215 A.D., a war between two planets, ACM and ICPC, is being more and more intense. </p> <p> ACM introduced new combat planes. These planes have a special system that is called Graze, and fighting power of a plane increases when it is close to ene...
p02634
<span class="lang-en"> <p>Score : <var>600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a grid with <var>A</var> horizontal rows and <var>B</var> vertical columns, with the squares painted white. On this grid, we will repeatedly apply the following operation:</p> <ul> <li>Assume th...
p00259
<H1>有限体電卓</H1> <p> 0以外のすべての実数の逆数は実数になりますが、整数の逆数が整数になるとは限りません。C言語などで 3.0/2.0*2.0 = 3.0 なのに 3/2*2 = 2 になってしまうのはこのためです。ですが、素数で割った余りが等しい整数を同じものとみなすと、0以外のすべての整数が逆数をもつようにできます。 </p> <p> 整数 x と y を p で割った余りが等しいとき、x &equiv; y (mod p) と書きます。p が素数のとき、このような x と y を同じものとみなすなら、すべての整数 n は0から p&minus;1 までのどれかの整数 x に対して x &equiv; ...
p02264
<p> There are <i>n</i> processes in a queue. Each process has name<sub><i>i</i></sub> and time<sub><i>i</i></sub>. The round-robin scheduling handles the processes in order. A round-robin scheduler gives each process a <i>quantum</i> (a time slot) and interrupts the process if it is not completed by then. The proce...
p03025
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Takahashi and Aoki will play a game. They will repeatedly play it until one of them have <var>N</var> wins in total.</p> <p>When they play the game once, Takahashi wins with probability <var>A</var> %, ...
p01018
<h1>Problem C: Warping Girl</h1> <h2>Problem</h2> <p> 会津魔法学校は, 魔法を使える者が集まる学校である. その学校の生徒の一人であるハルカは, 魔法陣の上でワープの魔法を使う事ができる. </p> <p> 彼女の家から学校には, 長さ <var>L</var> の一直線状の道がある. また, この道には所々魔法陣が描かれている.<br> 彼女は毎日この道を使って学校に通っているため, できるだけ短い時間で学校に辿り着きたいと思っている. </p> <p> そこでプログラマーであるあなたは, 彼女に学校まで行くときにかかる最小の時間を教えてあげることにした. </p> <...
p03475
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>A railroad running from west to east in Atcoder Kingdom is now complete.</p> <p>There are <var>N</var> stations on the railroad, numbered <var>1</var> through <var>N</var> from west to east.</p> <p>Tomo...
p01448
<H1>Problem B: 友だちの誘い方</H1> <p> 明日から、待ちに待った夏休みが始まります。なのでわたしは、友だちを誘って、海に遊びに行くこ とに決めました。 </p> <p> けれども、わたしの友だちには、恥ずかしがりやさんが多いです。その人たちは、あまり多くの人が いっしょに来ると知ったら、きっと嫌がるでしょう。 </p> <p> ほかにも、わたしの友だちには、目立ちたがりやさんも多いです。その人たちは、いっしょに来る人 があまり多くないと知れば、きっと嫌がるでしょう。 </p> <p> それと、わたしの友だちには、いつもは目立ちたがりやなのに実は恥ずかしがりやさんな人もいま す。その人たちは、いっし...
p00170
<H1>ランチ</H1> <p> お昼に食べるお弁当を作るために、お店で食べ物を買いました。お店では、食べ物を入れるのに細長い袋しかもらえなかったので、すべての食べ物を縦に積んで袋に入れる必要があります。袋が倒れにくいように、できるだけ重い物を下にして詰めたいのですが、食べ物の中にはやわらかい物もあって、上に重い物を乗せるとつぶれてしまいます。 </p> <!-- そこで、それぞれの食べ物がつぶれないように、かつ出来るだけ重い物が下になるように食べ物を積みたいと思います。 --> <p> そこで、食べ物の情報を入力とし、全ての食べ物がつぶれず、かつ全体の重心が最も低くなるような積み方を出力するプログラムを作成してくださ...
p00520
<H1>問題 6: 小籠包 (Xiao Long Bao) </H1> <br/> <h2>問題</h2> <p> JOI 君はお昼ごはんに,中華料理屋で小籠包を食べることにした. 小籠包とは,具と熱いスープを小麦粉の皮で包んだ料理であり,食べるときにスープが周囲に飛び散ることで知られている. </p> <p> JOI 君が注文した小籠包のセットは,具やスープの異なる N 個の小籠包からなる. N 個の小籠包は等間隔に一列に並んでおり,順番に 1 から N の番号がつけられている. i 番目の小籠包と j 番目の小籠包の間の距離は絶対値 |i - j| である. </p> <p> JOI 君は小籠包をある順番で食...
p01761
<h1>B : Books / 本</h1> <h1>Problem</h1> <p>大学生のいづあ君はかなりの読書家である。面白そうだと思った本は迷わず買うため、蔵書が増えすぎて管理できなくなっているのが悩みである。そこでいづあ君は、持っている本の中から目的の本を検索するシステムを作ることにした。</p> <p>全ての本は次の 3 つの属性を持つ。</p> <ul> <li><em>title</em> : 本のタイトルを表す文字列である。</li> <li><em>author</em> : 本の著者を表す文字列である。</li> <li><em>date</em> : 本の出版日を表す <code>2014/07/07...
p00873
<H1><font color="#000">Problem J:</font> Zigzag</H1> <p> Given several points on a plane, let’s try to solve a puzzle connecting them with a zigzag line. The puzzle is to find the zigzag line that passes through all the given points with the minimum number of turns. Moreover, when there are several zigzag lines with ...