question_id
stringlengths
6
6
content
stringlengths
1
27.2k
p00524
<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> フクロモモンガ(Sugar Glider) </...
p00877
<H1><font color="#000">Problem D:</font> Separate Points</H1> <p> Numbers of black and white points are placed on a plane. Let's imagine that a straight line of infinite length is drawn on the plane. When the line does not meet any of the points, the line divides these points into two groups. If the division by such ...
p01765
<h1>F : Todaiji / 東大寺</h1> <h1>Problem</h1> <p>づいあ君は旅行が大好きである。奈良旅行に訪れたづいあ君は、<a href="http://www.nkdaibutsu.com/nara/daibutsuden.html">東大寺にある柱の穴</a>をくぐることにした。しかし、づいあ君は最近太りだしたため、穴に引っかかってしまうかもしれない。そこでづいあ君は、どこまで太っても大丈夫かを調べるプログラムを書くことにした。</p> <p>簡単のため問題は平面上で考える。穴は2本の折れ線で、づいあ君は円で表すこととする。折れ線 1 は点 (0,0) が始点、点 (1000,0) が終点...
p03758
<span class="lang-en lang-child hidden-lang"> <div class="part"> Max Score: $1500$ Points <br/> <section> <h3>Problem Statement</h3> Huge kingdom: $Atcoder$ contains $N$ towns and $N-1$ roads. This kingdom is connected.<br/> <br/> You have to detect the kingdom's road.<br/> In order to detect, You ca...
p01335
<h1><font color="#000">Problem C:</font> K Poker</h1> <h2>Description</h2> <p>時は200X年、K大学で活動する謎のサークルKはその大学の文化祭の最中にK東4Fで彼らが作成した新たなゲーム、Kポーカーを発表した。<br> このゲームは一見すると普通のポーカーであるが、カードに基本点という要素をつけてポーカーをより奥の深いゲームにしたものである。<br> カードの基本点はそれぞれのカードに書かれている絵柄によって決まり、手札の点数は手札にある5枚の基本点の合計に手札の役の倍率を掛けたものになる。<br> この基本点を導入した事により、例えばフルハウスなど...
p03308
<span class="lang-en"> <p>Score : <var>200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You are given an integer sequence <var>A</var> of length <var>N</var>. Find the maximum absolute difference of two elements (with different indices) in <var>A</var>.</p> </section> </div> <div class="pa...
p02630
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You have a sequence <var>A</var> composed of <var>N</var> positive integers: <var>A_{1}, A_{2}, \cdots, A_{N}</var>.</p> <p>You will now successively do the following <var>Q</var> operations:</p> <ul> <...
p03922
<span class="lang-en"> <p>Score : <var>700</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Takahashi is playing with <var>N</var> cards.</p> <p>The <var>i</var>-th card has an integer <var>X_i</var> on it.</p> <p>Takahashi is trying to create as many pairs of cards as possible satisfying one ...
p03888
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>In an electric circuit, when two resistors <var>R_1</var> and <var>R_2</var> are connected in parallel, the equivalent resistance <var>R_3</var> can be derived from the following formula:</p> <ul> <li><...
p02260
<H1>Selection Sort</H1> <p> Write a program of the Selection Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> SelectionSort(A) 1 for i = 0 to A.length-1 2 mini = i 3 for j = i to A.length-1 4 if A[j] < A[mini] 5 ...
p03021
<span class="lang-en"> <p>Score : <var>1500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You are given a tree with <var>N</var> vertices numbered <var>1, 2, ..., N</var>. The <var>i</var>-th edge connects Vertex <var>a_i</var> and Vertex <var>b_i</var>. You are also given a string <var>S</...
p03471
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>The commonly used bills in Japan are <var>10000</var>-yen, <var>5000</var>-yen and <var>1000</var>-yen bills. Below, the word "bill" refers to only these.</p> <p>According to Aohashi, he received an oto...
p03164
<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>...
p01159
<H1><font color="#000">Problem E:</font> Autocorrelation Function</H1> <p> Nathan O. Davis is taking a class of signal processing as a student in engineering. Today’s topic of the class was autocorrelation. It is a mathematical tool for analysis of signals represented by functions or series of values. Autocorrelation...
p03534
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke has a string <var>S</var> consisting of three kinds of letters: <code>a</code>, <code>b</code> and <code>c</code>.</p> <p>He has a phobia for palindromes, and wants to permute the characters in <v...
p01509
<H1>PLAY in BASIC</H1> <p> One sunny day, Dick T. Mustang found an ancient personal computer in the closet. He brought it back to his room and turned it on with a sense of nostalgia, seeing a message coming on the screen: </p> <pre> READY? </pre> <p> Yes. BASIC. </p> <p> BASIC is a programming language designed fo...
p00748
<h1><font color="#000000">Problem C:</font> Pollock's conjecture</h1> <!-- begin en only --> <p> The <I>n</I>th triangular number is defined as the sum of the first <I>n</I> positive integers. The <I>n</I>th tetrahedral number is defined as the sum of the first <I>n</I> triangular numbers. It is easy to show that ...
p02775
<span class="lang-en"> <p>Score: <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3> <p>In the Kingdom of AtCoder, only banknotes are used as currency. There are <var>10^{100}+1</var> kinds of banknotes, with the values of <var>1, 10, 10^2, 10^3, \dots, 10^{(10^{100})}</var>. You have come...
p03867
<span class="lang-en"> <p>Score : <var>1000</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Takahashi and Aoki are going to together construct a sequence of integers.</p> <p>First, Takahashi will provide a sequence of integers <var>a</var>, satisfying all of the following conditions:</p> <ul>...
p00318
<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> アイヅ考古学会は、ヒバラ海に沈む古代国家イ...
p02325
<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>Bitonic Traveling Salesman Problem (Bitonic...
p00436
<H1>カードの並び替え</H1> <h2>問題</h2> <p> 1 から 2n の数が書かれた 2n 枚のカードがあり,上から 1, 2, 3, ... , 2n の順に積み重なっている. </p> <p> このカードを,次の方法を何回か用いて並べ替える. </p> <p> <b>整数 k でカット</b><br> 上から k 枚のカードの山 A と 残りのカードの山 B に分けた後, 山 A の上に山 B をのせる. </p> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_card01"> </center> <b...
p00066
<H1>三目並べ</H1> <p> 三目並べは,3 &times; 3のマス目の中に交互に ○ と × を入れていき、縦・横・斜めの何れかに一列 ○ か × が並んだときに、勝ちとなるゲームです(図1〜図3 を参照) </p> <center> <table> <tr> <td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic1"></td> <td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic2"><...
p04025
<span class="lang-en"> <p>Score : <var>200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Evi has <var>N</var> integers <var>a_1,a_2,..,a_N</var>. His objective is to have <var>N</var> equal <strong>integers</strong> by transforming some of them.</p> <p>He may transform each integer at most ...
p01227
<h1><font color="#000">Problem E:</font> カントリーロード</h1> <p> ある過疎地域での話である. この地域ではカントリーロードと呼ばれるまっすぐな道に沿って, 家がまばらに建っている. 今までこの地域には電気が通っていなかったのだが, 今回政府からいくつかの発電機が与えられることになった. 発電機は好きなところに設置できるが, 家に電気が供給されるにはどれかの発電機に電線を介してつながっていなければならず, 電線には長さに比例するコストが発生する. 地域で唯一の技術系公務員であるあなたの仕事は, ...
p02958
<span class="lang-en"> <p>Score : <var>200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a sequence <var>p</var> = {<var>p_1,\ p_2,\ ...,\ p_N</var>} which is a permutation of {<var>1,\ 2,\ ...,\ N</var>}.</p> <p>You can perform the following operation at most once: choose integers ...
p00965
<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...
p01677
<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>N...
p01362
<H1><font color="#000">Problem D:</font> Dice Room</H1> <p> You are playing a popular video game which is famous for its depthful story and interesting puzzles. In the game you were locked in a mysterious house alone and there is no way to call for help, so you have to escape on yours own. However, almost every room ...
p01698
<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> <!-- begin en only --> <!--<h...
p00820
<H1><font color="#000">Problem B:</font> Lagrange's Four-Square Theorem</H1> <p> The fact that any positive integer has a representation as the sum of at most four positive squares (i.e. squares of positive integers) is known as Lagrange’s Four-Square Theorem. The first published proof of the theorem was given by Jos...
p01732
<p> Nathan O. Davis is running a company. His company owns a web service which has a lot of users. So his office is full of servers, routers and messy LAN cables. </p> <p>He is now very puzzling over the messy cables, because they are causing many kinds of problems. For example, staff working at the company often tri...
p00573
<h1>定期券(Commuter Pass)</h1> <p> JOI 君が住む都市には<var>N</var> 個の駅があり,それぞれ<var>1, 2, ..., N</var> の番号が付けられている.また,<var>M</var> 本の鉄道路線があり,それぞれ<var>1, 2, ..., M</var> の番号が付けられている.鉄道路線<var>i</var> (<var>1 \leq i \leq M</var>) は駅<var>A_i</var> と駅<var>B_i</var> を双方向に結んでおり,乗車運賃は<var>C_i</var> 円である. </p> <p> JOI 君は駅S の近くに住んでおり,...
p00089
<H1>最短経路</H1> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_17_1"> </center> <br/> <p> 図1に例示するように整数(0 以上 99 以下)をひしがたに並べます。このような、ひしがたを表すデータを読み込んで、一番上からスタートして一番下まで次のルールに従って進むとき、通過する整数の和の最大値を出力するプログラムを作成してください。 </p> <ul> <li>各ステップで、対角線上の左下か対角線上の右下に進むことができます。</li> </ul> <p> 例えば図1の例では、図2に示す...
p00123
<h1>スピードスケートバッジテスト</h1> <p> スピードスケートバッジテストでは、2 種類の距離で規定されたタイムを上回った場合に級が認定されます。例えば A 級になるには 500 M で 40.0 秒未満、かつ 1000 M で 1 分 23 秒未満であることが求められます。 </p> <p> スピードスケート大会 (500 M と 1000 M) で記録したタイムを入力とし、スピードスケートバッジテストで何級に相当するかを出力するプログラムを作成して下さい。500 M と1000 M のバッジテスト規定タイムは下表のとおりです。 E 級に満たなかった場合には、NA と出力してください。 </p> <center...
p03426
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a grid with <var>H</var> rows and <var>W</var> columns. The square at the <var>i</var>-th row and the <var>j</var>-th column will be called Square <var>(i,j)</var>.</p> <p>The integers from <var...
p03076
<span class="lang-en"> <p>Score: <var>200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3> <p>The restaurant AtCoder serves the following five dishes:</p> <ul> <li>ABC Don (rice bowl): takes <var>A</var> minutes to serve.</li> <li>ARC Curry: takes <var>B</var> minutes to serve.</li> <li>AGC Past...
p02237
<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>Graph</H1> <p> There are t...
p02667
<span class="lang-en"> <p>Score : <var>900</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Takahashi has an empty string <var>S</var> and a variable <var>x</var> whose initial value is <var>0</var>.</p> <p>Also, we have a string <var>T</var> consisting of <code>0</code> and <code>1</code>.</p...
p03975
<span class="lang-en"> <p>Score : <var>66</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3> <p> Summer vacation ended at last and the second semester has begun. You, a Kyoto University student, came to university and heard a rumor that somebody will barricade the entrance of your classroom. ...
p01948
<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...
p02688
<span class="lang-en"> <p>Score : <var>200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p><var>N</var> <em>Snukes</em> called Snuke <var>1</var>, Snuke <var>2</var>, ..., Snuke <var>N</var> live in a town.</p> <p>There are <var>K</var> kinds of snacks sold in this town, called Snack <var>1</...
p02372
<H1>Height of a Tree</H1> <br/> <p> Given a tree <var>T</var> with non-negative weight, find the height of each node of the tree. For each node, the height is the distance to the most distant leaf from the node. </p> <H2>Input</H2> <pre> <var>n</var> <var>s<sub>1</sub></var> <var>t<sub>1</sub></var> <var>w<sub>1...
p02722
<span class="lang-en"> <p>Score : <var>600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Given is a positive integer <var>N</var>.</p> <p>We will choose an integer <var>K</var> between <var>2</var> and <var>N</var> (inclusive), then we will repeat the operation below until <var>N</var> beco...
p03830
<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>. Find the number of the positive divisors of <var>N!</var>, modulo <var>10^9+7</var>.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <l...
p03099
<span class="lang-en"> <p>Score : <var>1300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>A museum exhibits <var>N</var> jewels, Jewel <var>1, 2, ..., N</var>. The coordinates of Jewel <var>i</var> are <var>(x_i, y_i)</var> (the museum can be regarded as a two-dimensional plane), and the va...
p03563
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Takahashi is a user of a site that hosts programming contests.<br/> When a user competes in a contest, the <em>rating</em> of the user (not necessarily an integer) changes according to the <em>performan...
p03133
<span class="lang-en"> <p>Score : <var>800</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There is a square grid with <var>N</var> rows and <var>M</var> columns. Each square contains an integer: <var>0</var> or <var>1</var>. The square at the <var>i</var>-th row from the top and the <var>j</...
p01661
<h2>F - 7歳教</h2> <p>7歳の誕生日に"彼"は父から告げられた.</p> <p>「お前が7歳になったということは,私はもう引退だ.今日からお前が7歳教の長だ.<br> 7歳教の戒律により,7歳教の長が7歳の間だけ布教活動を行うことが認められている.<br> この宇宙船を使って,よりたくさんの人々に7歳教の素晴らしさを広めてきなさい.」 </p> <p> 7歳教をよりたくさんの人に広めるために"彼"は,自分の周りの星についての情報を集めた.<br> "彼"の星の周りには,<var>n</var> 個の惑星があり,惑星は <var> 1, ... , n</var> で番号付けされていることがわかっ...
p00973
<h2>Fair Chocolate-Cutting</h2> <p> You are given a flat piece of chocolate of convex polygon shape. You are to cut it into two pieces of precisely the same amount with a straight knife. </p> <p> Write a program that computes, for a given convex polygon, the maximum and minimum lengths of the line segments that d...
p01231
<h1><font color="#000">Problem I:</font> Aaron と Bruce</h1> <p> Aaron は凶悪な犯罪者である. 彼は幾度も犯罪を繰り返しながら (万引き2回,のぞき16回,下着泥棒256回,食い逃げ65,536回) も,その人並み外れた身体能力を用いて 警察の手から逃れ続けてきた. Bruce は警察官である. 彼は突出した運動能力は持っていないが, 写真撮影が趣味であり, 彼の撮った写真が雑誌に載るほどの腕前を持っている. </p> <p> ある日,Bruce は山奥に写真撮影を...
p04033
<span class="lang-en"> <div class="part"> <section> <h3>Problem Statement</h3><p>You are given two integers <var>a</var> and <var>b</var> (<var>a≤b</var>). Determine if the product of the integers <var>a</var>, <var>a+1</var>, <var>…</var>, <var>b</var> is positive, negative or zero.</p> </section> </div> <div class="p...
p00070
<H1>Combination of Number Sequences</H1> <p> 0 から 9 までの整数を使った <var>n</var> 個の数の並び <var>k<sub>1</sub></var>, <var>k<sub>2</sub></var>, ..., <var>k<sub>n</sub></var> を考えます。正の整数 <var>n</var> と <var>s</var> を読み込んで、<br/> <br/> <var>k<sub>1</sub> + 2 &times; k<sub>2</sub> + 3 &times; k<sub>3</sub> +</var> ... <var>+ n &...
p00420
<h1>化学物質アルファ</h1>  <p> アイヅ製薬では日々化学物質の研究がなされています。いま研究をしているのは、$1$番から$N$番の分子が左端から右端へ直線状にならんだ構造をしている化学物質、コードネーム「アルファ」です。 </p> <p> アイヅ製薬の開発した技術を使えば、アルファを構成する分子の位置を入れ替えることができます。入れ替えは決まった手順でしか行うことができませんが、その手順の途中から始めて途中で終わることもできます。左端から$a$番目と$b$番目の分子を入れ替える操作を$(a,b)$と書くとします。たとえば、$N=5$で決まった手順が$(1,3),(2,5),(4,3),(1,5)$のとき、$1$番目の操...
p00135
<H1>時計の短い針と長い針</H1> <p> 原始スローライフ主義組織「アカルイダ」から、いたずらの予告状が届きました。アカルイダといえば、要人の顔面にパイを投げつけたりするいたずらで有名ですが、最近では火薬を用いてレセプション会場にネズミ花火をまき散らすなど、より過激化してきました。予告状は次の文面です。 </p> <pre> ---パソコン ヒトの時間を奪う。良くない。 時計の短い針と長い針 出会うころ、アカルイダ 正義行う。 スローライフ 偉大なり。 </pre> <p> たどたどしくてよく解らないのですが、時計の短針と長針とが重なったころにいたずらを決行するという意味のようです。 </p> <p> このいた...
p02108
<h1>Problem K: Donuts Purchase</h1> <h2>Problem</h2> <p> ラフイは休暇の間することがなく暇で、なんとなくドーナツが食べたくなったので、店を巡りドーナツを購入していくことにした。<br> 各街には1軒のドーナツ店があり、すべてのドーナツ店は奇数日が定休日となっている。<br> ラフイにはドーナツの好みがあるので、店によって得られる満足度が違う。<br> そこでラフイは最適に行動することで、できるだけ多くの満足度を得ることにした。<br> </p> <p> ラフイが住んでいる世界には、それぞれ0から<var>n</var>-1の番号が割り当てられた<var>n</var>個...
p00565
<h1>双六 (Sugoroku)</h1> <h2> 問題文</h2> <p> JOI 君はおじさんの家で双六を見つけた.双六は直線状に並んだ <var>N+2</var> 個のマスからなり,<var>1</var> 番目のマスはスタート,<var>N+2</var> 番目のマスはゴールである.その他の各マスには <var>0</var> または <var>1</var> が書かれていて,各 <var>i</var> (<var>1≦i≦N</var>) について,<var>i+1</var> 番目のマスに書かれた数字は <var>A_i</var> である. </p> <p> 双六では,最初にスタートのマスにコマを置き,サイ...
p02558
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You are given an undirected graph with <var>N</var> vertices and <var>0</var> edges. Process <var>Q</var> queries of the following types.</p> <ul> <li><code>0 u v</code>: Add an edge <var>(u, v)</var>.<...
p03719
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You are given three integers <var>A</var>, <var>B</var> and <var>C</var>. Determine whether <var>C</var> is not less than <var>A</var> and not greater than <var>B</var>.</p> </section> </div> <div class...
p01724
<p>負けず嫌いのイクタ君は、最近囲碁盤を使って遊ぶゲームに熱中している。 しかし、囲碁も五目並べも友人に全く勝てないので、あまり有名でない Phutball というゲームの特訓をすることにした。 </p> <p>このゲームは難しいゲームなので、手始めに自分のターンに勝って終局できるかを判定できるように特訓することにした。 </p> <p>ゲームの勝利条件は以下のようなものである。 </p> <ul> <li> 白石は黒石の置かれている場所にジャンプすることは出来ない。 </li> <li> 碁盤の中央の<var> 19 &times; 15 </var>の部分を用いる。 </li> <li> 勝利条件を判定したい碁盤は...
p00836
<H1><font color="#000">Problem A:</font> Sum of Consecutive Prime Numbers</H1> <p> Some positive integers can be represented by a sum of one or more consecutive prime numbers. How many such representations does a given positive integer have? For example, the integer 53 has two representations 5 + 7 + 11 + 13 + 17 and...
p03349
<span class="lang-en"> <p>Score : <var>1200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Find the number of the possible tuples of sequences <var>(A_0,A_1,...,A_N)</var> that satisfy all of the following conditions, modulo <var>M</var>:</p> <ul> <li>For every <var>i</var> <var>(0\leq i\leq...
p01374
<!-- begin en only --> <!--<h3><U>Sakura Poetry</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> Nathan O. Davi...
p03963
<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> balls placed in a row. AtCoDeer the deer is painting each of these in one of the <var>K</var> colors of his paint cans. For aesthetic reasons, any two adjacent balls must be paint...
p02671
<span class="lang-en"> <p>Score : <var>1000</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There are <var>3^N</var> people dancing in circle. We denote with <var>0,1,\dots, 3^{N}-1</var> the positions in the circle, starting from an arbitrary position and going around clockwise. Initially ea...
p02221
<span class="lang"> <span class="lang-ja"> <h1>K: トーナメント</h1> <div class="part"> <section> <h3>問題文</h3><p>京都大学クスノキ前にて、$2$ 人用対戦ゲームのトーナメントが行われようとしています。</p> <p>このトーナメントの参加者は $2^N$ 人いて、 $1$ から $2^N$ までの番号がついています。</p> <p>参加者のうちの $2$ 人が戦った時の勝敗は、$0$ と $1$ からなる長さ $2^N-1$ の文字列 $S$ によって表されます。</p> <p>人 $x$ と人 $y$ $(1 \le x &lt; ...
p03060
<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> gems. The value of the <var>i</var>-th gem is <var>V_i</var>.</p> <p>You will choose some of these gems, possibly all or none, and get them.</p> <p>However, you need to pay a cost...
p03430
<span class="lang-en"> <p>Score : <var>900</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Takahashi has decided to give a string to his mother.</p> <p>The <em>value</em> of a string <var>T</var> is the length of the longest common subsequence of <var>T</var> and <var>T'</var>, where <var>T'<...
p01118
<!--<h2>Problem B</h2>--> <!-- begin en only --> <h3>On-Screen Keyboard</h3> <!-- end en only --> <!-- begin en only --> <p> You are to input a string with an OSK (on-screen keyboard). A remote control with five buttons, four arrows and an OK (Fig. B-1), is used for the OSK. Find the minimum number o...
p03125
<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>A</var> and <var>B</var>.</p> <p>If <var>A</var> is a divisor of <var>B</var>, print <var>A + B</var>; otherwise, print <var>B - A</var>.</p> </section> </div> <div ...
p01548
<h1>問題名 Audition</h1> <p>アイドル---それは女の子達の永遠の憧れ。しかし、頂点に立てるのはほんの一握り。そんなサバイバルな世界に、あなたはアイドルプロデューサーとして足を踏み入れることになりました。そして、今日はあなたの担当アイドルを連れて大事なオーディションに挑むことになりました。 </p> <p>オーディションの決め手になるのはビジュアル、ダンス、ボーカルの 3 要素です。オーディション中には <var>m</var> 回のアピールタイムがあり、 1 回のアピールタイムごとに各アイドルはビジュアルアピール、ダンスアピール、ボーカルアピールのいずれかを行うことが出来ます。ビジュアルアピールを行うとその...
p03575
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You are given an undirected connected graph with <var>N</var> vertices and <var>M</var> edges that does not contain self-loops and double edges.<br/> The <var>i</var>-th edge <var>(1 \leq i \leq M)</var...
p03826
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There are two rectangles. The lengths of the vertical sides of the first rectangle are <var>A</var>, and the lengths of the horizontal sides of the first rectangle are <var>B</var>. The lengths of the v...
p02734
<span class="lang-en"> <p>Score : <var>600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Given are a sequence of <var>N</var> integers <var>A_1</var>, <var>A_2</var>, <var>\ldots</var>, <var>A_N</var> and a positive integer <var>S</var>.<br/> For a pair of integers <var>(L, R)</var> such th...
p00709
<H1>Square Carpets</H1> <P> Mr. Frugal bought a new house. He feels deeply in love with his new house because it has a comfortable living room in which he can put himself completely at ease. He thinks his new house is a really good buy. </P> <P> But, to his disappointment, the floor of its living room has some sc...
p02364
<H1>Minimum Spanning Tree</H1> <br/> <p> Find the sum of weights of edges of the Minimum Spanning Tree for a given weighted undirected graph <var>G</var> = (<var>V</var>, <var>E</var>). </p> <H2>Input</H2> <pre> <var>|V|</var> <var>|E|</var> <var>s<sub>0</sub></var> <var>t<sub>0</sub></var> <var>w<sub>0</sub></var>...
p00359
<H1>Dungeon</H1> <p> Bob is playing a popular game called "Dungeon". The game is played on a rectangular board consisting of <var>W &times; H</var> squares. Each square is identified with its column and row number, thus the square located in the <var>x</var>-th column and the <var>y</var>-th row is represented as (<v...
p00477
<H1>合計時間 (Total Time)</H1> <h2>問題</h2> <p> 太郎君は 3 カ所の店を訪ねることを日課にしている.家を出発し,決まった順番で 3 カ所の店を回った後,家に帰る.ときどき,ストップウォッチを使って,各区間を移動するのに何秒かかったかを計り,その秒数を記録する. </p> <p> ある日の計測結果が与えられたとき,この日の移動時間の合計が何分何秒かを求めるプログラムを作成せよ. </p> <h2>入力</h2> <p> 入力は 4 行からなり, 1 行に 1 つずつ正の整数が書かれている.<br> 1 行目の整数は家から 1 つ目の店までの移動時間を表す秒数である.<br> 2 行目...
p00027
<H1>What day is today?</H1> <p> Your task is to write a program which reads a date (from 2004/1/1 to 2004/12/31) and prints the day of the date. Jan. 1, 2004, is Thursday. Note that 2004 is a leap year and we have Feb. 29. </p> <H2>Input</H2> <p> The input is a sequence of datasets. The end of the input is indicat...
p01266
<H1><font color="#000">Problem H:</font> Robot Communication</H1> <p> In the year 21xx, human beings are proliferating across the galaxy. Since the end of the last century, thousands of pioneer spaceships have been launched in order to discover new habitation planets. </p> <p> The Presitener is one of those spaceship...
p01636
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [['\\(','\\)']] } }); </script> <script type='text/javascript' src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script> <h1 class="ndoc-heading1">Problem C: Mysterious Operator</h1> <p clas...
p00924
<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: Bit String Reorderi...
p02919
<span class="lang-en"> <p>Score: <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3> <p>Given is a permutation <var>P</var> of <var>\{1, 2, \ldots, N\}</var>.</p> <p>For a pair <var>(L, R) (1 \le L \lt R \le N)</var>, let <var>X_{L, R}</var> be the second largest value among <var>P_L, P_{L...
p01323
<h1><font color="#000">Problem C:</font> コンパイル</h1> <p>東京大学に入学したきたまさ君はTSG(東大スーパーゲーマーズ)というサークルに入った。</p> <p>このサークルは毎年、駒場祭でゲームを展示しており、きたまさ君もゲームを作成して展示することにした。</p> <p>きたまさ君の作成するゲームは次のような、よくある落ち物パズルゲームである。</p> <p> <ul> <li>横6マス×縦12マスの格子状のフィールドがあり、各マスにつき1個のブロックを置くことができる。</li> <li>上からブロックが2つ1組で落下してくる。ブロックには赤・緑・青・黄・紫の5色の基本ブ...
p01773
<h2>B: Cram School Schedule / 塾の時間割</h2> <h3>物語</h3> <p>あなたは塾の経営者である.あなたの塾は個人授業制で1人の生徒と1人の先生で授業を行う.この塾の先生は非常に優秀で科目にかかわらずすべての授業を行うことができる.また,先生と生徒は非常にタフなので,出席できる授業には他の授業の出席状況にかかわらず,すべて出席することが可能である.例えば,同じ時間帯の授業に出席できる2人の生徒と4人の先生がいる場合は,その時間帯に2つの授業を行える.</p> <p>あなたは来月の授業予定を立てなくてはいけないが,先生と生徒の人数が多いため予定を立てるのが非常に大変である.また,あなた...
p00861
<H1><font color="#000">Problem H:</font> Bug Hunt</H1> <p> In this problem, we consider a simple programming language that has only declarations of one- dimensional integer arrays and assignment statements. The problem is to find a bug in the given program. </p> <p> The syntax of this language is given in BNF as foll...
p01289
<H1><font color="#000">Problem G:</font> Strange Couple</H1> <p> Alice and Bob are going to drive from their home to a theater for a date. They are very challenging - they have no maps with them even though they don’t know the route at all (since they have just moved to their new home). Yes, they will be going just b...
p00532
<h2>クリスマスパーティー (Christmas Party)</h2> <h2> 問題</h2> <p> JOI 君は友達 1 から友達 N までの N 人の友達を招いてクリスマスパーティーを行った.クリスマスパーティーも盛り上がってきたところで,友達と一緒に次のようなゲームを行うことになった. </p> <ol> <li> 最初に JOI 君は N 人の友達の中から 1 人を選ぶ.以降はその友達をターゲットと呼ぶことにする. </li> <li> JOI 君は,ターゲットとして選んだ友達に,その人がターゲットであることをこっそり伝える.ターゲット以外の友達は,誰がターゲットかを知ることはできない. </li>...
p00162
<H1>ハミング数</H1> <p> 1 に 2, 3, 5 を何回か (0 回以上) かけ算して得られる数をハミング数 (Hamming numbers) と呼びます。例えば、 </p> <ul> <li>1</li> <li>1 × 2 × 2 = 4</li> <li>1 × 2 × 2 × 3 × 5 × 5 = 300</li> </ul> <p> などはハミング数ですが、11, 13, 14 などはハミング数ではありません。 </p> <p> ハミング数はどれも 60 のべき乗を割り切る(例えば、54 は 60<sup>3</sup> = 21600 を割り切る) ので、時刻など 60 進法の計算には都合の...
p00498
<H1> JOI 国のお祭り事情(Festivals in JOI Kingdom) </H1> <p> JOI 国にはN 個の街があり,それらの間は<i>M</i> 本の双方向に通行可能な道路で結ばれている.国民は道路を通ってそれらの街を移動する. </p> <p> JOI 国の国民には,お祭りが好きな人が多く,現在,<i>K</i> 個の街でお祭りが開催されており,非常に賑わっている.一方で,一部の国民はお祭りを騒がしいとして嫌い,お祭りにできるだけ近づきたくないと思っている. </p> <p> そこで国王は,優秀なプログラマーであるあなたに,そのようなお祭りを嫌う国民のため,ある街からある街に移動するために,お祭...
p03467
<span class="lang-en"> <p>Score : <var>1400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Consider the following set of rules for encoding strings consisting of <code>0</code> and <code>1</code>:</p> <ul> <li>Strings <code>0</code> and <code>1</code> can be encoded as <code>0</code> and <co...
p03037
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have <var>N</var> ID cards, and there are <var>M</var> gates.</p> <p>We can pass the <var>i</var>-th gate if we have one of the following ID cards: the <var>L_i</var>-th, <var>(L_i+1)</var>-th, ..., ...
p02276
<H1>Partition</H1> <!-- <p style="color:#f00"> Please note that problem description and judge data for this problem are still under construction. They may revised and your submissions can be rejudged. </p> --> <p> Quick sort is based on the Divide-and-conquer approach. In QuickSort(A, p, r), first, a procedure Partiti...
p01909
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]} }); </script> <script type="text/javascript" async src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML"> </script> <h1>E: 卒業式</h1> <h2>背景</h2> <p> ある日 Y さんはプログラミングコンテストに参加するため,会場が...
p03934
<span class="lang-en lang-child hidden-lang"> <div id="task-statement"> <div class="part"> Max Score: $1200$ Points <br/> <section> <h3>Problem statement</h3> There are $N$ customers in a restaurant. Each customer is numbered $1$ through $N$. <br/> A sushi chef carried out $Q$ operations for customers....
p02626
<span class="lang-en"> <p>Score : <var>600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There are <var>N</var> piles of stones. The <var>i</var>-th pile has <var>A_i</var> stones.</p> <p>Aoki and Takahashi are about to use them to play the following game:</p> <ul> <li>Starting with Aoki, t...
p02333
<!--<h1>写像12相 その3:ボールに区別あり・箱に区別あり・箱の中身は1つ以上</h1>--> <h1>Balls and Boxes 3</h1> <table border=""> <tr><th>Balls</th><th>Boxes</th><th>Any way</th><th>At most one ball</th><th>At least one ball</th></tr> <tr><th>Distinguishable</th><th>Distinguishable</th><td>1</td><td>2</td><td style="background-color:#aff">3</td><...
p02299
<H1>Polygon-Point-Containment</H1> <br/> <p> For a given polygon <var>g</var> and target points <var>t</var>, print "2" if <var>g</var> contains <var>t</var>, "1" if <var>t</var> is on a segment of <var>g</var>, "0" otherwise. </p> <p> <var>g</var> is represented by a sequence of points <var>p<sub>1</sub></var>, <va...
p03871
<span class="lang-en"> <p>Score : <var>1000</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><style> #nck { width: 30px; height: auto; } </style> <p>There are two (6-sided) dice: a red die and a blue die. When a red die is rolled, it shows <var>i</var> with probability <var>p_i<...
p02763
<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> of length <var>N</var> consisting of lowercase English letters.</p> <p>Process <var>Q</var> queries of the following two types:</p> <ul> <li>Type <var>1</var>: change...