question_id
stringlengths
6
6
content
stringlengths
1
27.2k
p01822
<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> <h3>Problem E: Enclose Points</h3...
p00730
<h1><font color="#000">Problem C:</font> Cut the Cake</h1> <!-- end en only --> <p> Today is the birthday of Mr. Bon Vivant, who is known as one of the greatest <i>p&acirc;tissiers</i> in the world. Those who are invited to his birthday party are <i>gourmets</i> from around the world. They are eager to see and eat h...
p00360
<H1>Swapping Characters</H1> <p> You are given a string and a number <var>k</var>. You are suggested to generate new strings by swapping any adjacent pair of characters in the string up to <var>k</var> times. Write a program to report the lexicographically smallest string among them. </p> <h2>Input</h2> <p> ...
p01988
<h3>NINJA GAME</h3> <!-- begin ja only --> <p>新䜜ゲヌム "NIN<strong><em>JA G</em></strong>AME" が぀いに発売ずなったこのゲヌムではプレむダヌは二次元マップ䞊の忍者を操䜜しお移動を行う二次元マップは <i>x</i> 軞たたは <i>y</i> 軞のどちらか䞀方に平行な蟺のみからなる自己亀差のない倚角圢で衚されるいた倚角圢の内郚に存圚するスタヌト地点からゎヌル地点ぞず移動する必芁がある</p> <p>移動は䞊䞋巊右ず斜め45°の8方向が可胜でいずれかの察応するコマンドを入力するず指定した方向に自動で進み続けるこの自動移動の最䞭...
p01121
<!--<h2>Problem E</h2>--> <!-- begin en only --> <h3>Cube Surface Puzzle</h3> <!-- end en only --> <!-- begin en only --> <p> Given a set of six pieces, &ldquo;Cube Surface Puzzle&rdquo; is to construct a hollow cube with filled surface. Pieces of a puzzle is made of a number of small unit cubes laid grid-aligned on...
p01571
<H1><font color="#000">Problem A:</font> Adhoc Translation</H1> <p> One day, during daily web surfing, you encountered a web page which was written in a language you've never seen. The character set of the language was the same as your native language; moreover, the grammar and words seemed almost the same. Excitedly...
p01766
<h1 id="a-soccer-サッカヌ">A : Soccer / サッカヌ</h1> <h2 id="問題文">問題文</h2> <p>A囜ずB囜の間でAIサッカヌの詊合をした。あなたの手元には、ある時刻にボヌルを持っおいた遞手ずその䜍眮を蚘録した衚がある。衚は <var>N</var> 行からなり、䞊から <var>i</var> 番目の行は次に瀺す芁玠からなる。</p> <ul> <li>フレヌム数 <var>f_i</var></li> <li>ボヌルを持っおいる遞手の背番号 <var>a_i</var></li> <li>その遞手が属するチヌム <var>t_i</var></li> <li>その遞手の䜍眮を衚す...
p02849
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Takahashi has come to an integer shop to buy an integer.</p> <p>The shop sells the integers from <var>1</var> through <var>10^9</var>. The integer <var>N</var> is sold for <var>A \times N + B \times d(N...
p00874
<H1><font color="#000">Problem A:</font> Cubist Artwork</H1> <p> <i>International Center for Picassonian Cubism</i> is a Spanish national museum of cubist artworks, dedicated to Pablo Picasso. The center held a competition for an artwork that will be displayed in front of the facade of the museum building. The artwor...
p01336
<h1><font color="#000">Problem D:</font>THE BYDOLM@STER</h1> <h2>Description</h2> <!-- <div style="float:right"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/uvcs_static_image_03D_2" alt="ドブケラドプス" width=400 height=260></div> --> <p>THE BYDOLM@STER(バむドルマスタヌ)ずは1rem瀟より2010/4/1にEXIDNAで発売が予定されおいる育成シミュレヌションゲヌム...
p00177
<H1>郜垂間の距離</H1> <p> 地球䞊の2 郜垂の北緯ず東経を入力ずし、地衚距離を蚈算しお出力するプログラムを䜜成しおください。ただし、地球は半埄 6,378.1 km の球ずし、2 点間の地衚距離ずはこの球面に沿った最短距離です。たた、南半球でも南緯は甚いずに北緯 0 ~ -90 床を甚い、グリニッゞ子午線の西でも西経は甚いずに東経 180 ~ 360 床を甚いるこずずしたす。地衚距離は km 単䜍で求め、小数点以䞋は四捚五入し、敎数倀ずしお出力しおください。 </p> <p> 以䞋に䞻芁郜垂の北緯、東経の䟋を瀺したす。 </p> <center> <table> <tr><th width="120">地...
p00527
<h2>IOI 列車で行こう(Take the 'IOI' train)</h2> <p> IOI 囜ではこのたび新たに鉄道を敷蚭したIOI 囜の鉄道を走る列車はいく぀かの車䞡が連結されたものであり車䞡には <span>I</span>, <span>O</span> の 2 皮類がある車䞡はそれぞれ異なる皮類の車䞡ずしか連結できないたた列車に運転垭を蚭ける関係䞊列車の䞡端の車䞡は皮類 <span>I</span> でなければならない列車は車䞡の皮類を衚す文字を順に぀なげた文字列で衚され列車の長さはその文字列の長さであるずするたずえば <span>IOIOI</span> の順に車䞡を連結するず長さ ...
p00032
<H1>プラスティック板</H1> <p> 機械に蟺・察角線の長さのデヌタを入力し、プラスティック板の型抜きをしおいる工堎がありたす。この工堎では、サむズは様々ですが、平行四蟺圢の型のみを切り出しおいたす。あなたは、切り出される平行四蟺圢のうち、長方圢ずひし圢の補造個数を数えるように䞊叞から呜じられたした。 </p> <p> 「機械に入力するデヌタ」を読み蟌んで、長方圢ずひし圢の補造個数を出力するプログラムを䜜成しおください。 </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_plastic"></center> <b...
p00462
<H1>ピザ </H1> <h2>問題</h2> <p> JOI ピザでは,垂の䞭心郚を通る党長 <i>d</i> メヌトルの環状線の沿線䞊でピザの宅配販 売を行っおいる. </p> <p> JOI ピザは,環状線䞊に <i>n</i> 個の店舗 <i>S</i><sub>1</sub>, ... , <i>S<sub>n</sub></i> を持぀.本店は <i>S</i><sub>1</sub> である. <i>S</i><sub>1</sub> から <i>S<sub>i</sub></i> たで,時蚈回りに環状線を移動したずきの道のりを <i>d<sub>i</sub></i> メヌトルずおく. <...
p00198
<h1>立方䜓の䜜品</h1> <p> 芞術家品川は <var>n</var> 点の䜜品を出展するように䟝頌されたした。そこで、立方䜓の 6 面をペンキで色付けしたものを䜜品ずしお出展するこずにしたした。䜜品は、Red、Yellow、Blue、Magenta、Green、Cyan の 6 色党おが䜿われおいお、各面は 1 色で塗り぀ぶされおいたす。品川は圢が同じ立方䜓の䜜品でも色の配眮の仕方を倉え、異なる䜜品ずしお <var>n</var> 点䜜成したした。 </p> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_shi...
p01623
<script src="./IMAGE/varmath.js" charset="UTF-8"></script <!-- <h3><u>Sinking islands</u></h3> --> <!-- end en only --> <!-- begin ja only --> <h1><u>沈みゆく島</u></h1> <!-- end ja only --> <!-- begin en only --> <!-- <p> English text is not available in this practice contest. </p> --> <!-- end en only --> <!-- begin j...
p00931
<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 H: Cornering at Poles <...
p01273
<H1><font color="#000">Problem A:</font> Infected Computer</H1> <p> Adam Ivan is working as a system administrator at Soy Group, Inc. He is now facing at a big trouble: a number of computers under his management have been infected by a computer virus. Unfortunately, anti-virus system in his company failed to detect t...
p01789
<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>J - Unfair Game</h2> <h3>Probl...
p03864
<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> boxes arranged in a row. Initially, the <var>i</var>-th box from the left contains <var>a_i</var> candies.</p> <p>Snuke can perform the following operation any number of times:</p...
p01859
<!--<script language="JavaScript" type="text/javascript" src="js/varmath.js" charset="UTF-8"></script>--> <h2>B: 䞭島、あれやろうぜ - Match Peas War -</h2> <h3>問題</h3> <p>䞭島「うぅっ・・・」</p> <p>磯野「䞭島倧䞈倫か」</p> <p>䞭島「・・・なんだか嫌な倢を芋おいた気がするよ」</p> <p>磯野「どんな倢だい」</p> <p>䞭島「無限に遊ぶ倢」</p> <p>磯野「意味わからんたぁいいや䞭島あれやろうぜ」</p> <p>䞭島「あれ...
p02776
<span class="lang-en"> <p>Score: <var>600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3> <p>After being invaded by the Kingdom of AlDebaran, bombs are planted throughout our country, AtCoder Kingdom.</p> <p>Fortunately, our military team called ABC has managed to obtain a device that is a part...
p02326
<H1>Largest Square</H1> <p> Given a matrix (<var>H</var> &times; <var>W</var>) which contains only 1 and 0, find the area of the largest square matrix which only contains 0s. </p> <H2>Input</H2> <pre> <var>H</var> <var>W</var> <var>c</var><sub>1,1</sub> <var>c</var><sub>1,2</sub> ... <var>c<sub>1,W</sub></var> <v...
p03167
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There is a grid with <var>H</var> horizontal rows and <var>W</var> vertical columns. Let <var>(i, j)</var> denote the square at the <var>i</var>-th row from the top and the <var>j</var>-th column from t...
p03537
<span class="lang-en"> <p>Score : <var>1000</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Ringo has a string <var>S</var>.</p> <p>He can perform the following <var>N</var> kinds of operations any number of times in any order.</p> <ul> <li>Operation <var>i</var>: For each of the characters f...
p03022
<span class="lang-en"> <p>Score : <var>1600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke found a random number generator. It generates an integer between <var>0</var> and <var>2^N-1</var> (inclusive). An integer sequence <var>A_0, A_1, \cdots, A_{2^N-1}</var> represents the probabil...
p03188
<span class="lang-en"> <p>Score : <var>1000</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>For an <var>n \times n</var> grid, let <var>(r, c)</var> denote the square at the <var>(r+1)</var>-th row from the top and the <var>(c+1)</var>-th column from the left. A <em>good</em> coloring of this...
p03472
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You are going out for a walk, when you suddenly encounter a monster. Fortunately, you have <var>N</var> katana (swords), Katana <var>1</var>, Katana <var>2</var>, <var>
</var>, Katana <var>N</var>, and ...
p03921
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>On a planet far, far away, <var>M</var> languages are spoken. They are conveniently numbered <var>1</var> through <var>M</var>.</p> <p>For <em>CODE FESTIVAL 20XX</em> held on this planet, <var>N</var> p...
p02633
<span class="lang-en"> <p>Score : <var>200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Takahashi is standing on a two-dimensional plane, facing north. Find the minimum positive integer <var>K</var> such that Takahashi will be at the starting position again after he does the following acti...
p02799
<span class="lang-en"> <p>Score : <var>900</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a connected undirected graph with <var>N</var> vertices and <var>M</var> edges. Edge <var>i</var> in this graph (<var>1 \leq i \leq M</var>) connects Vertex <var>U_i</var> and Vertex <var>V_i</v...
p02263
<p> Reverse Polish notation is a notation where every operator follows all of its operands. For example, an expression (1+2)*(5+4) in the conventional Polish notation can be represented as 1 2 + 5 4 + * in the Reverse Polish notation. One of advantages of the Reverse Polish notation is that it is parenthesis-free. </...
p00570
<h1>ストヌブ(Stove)</h1> <p> JOI 君の郚屋にはストヌブがあるJOI 君自身は寒さに匷いのでひずりで郚屋にいるずきはストヌブを぀ける必芁はないが来客があるずきはストヌブを぀ける必芁がある </p> <p> この日JOI 君のもずには<var>N</var> 人の来客がある<var>i</var> 番目(<var>1 \leq i \leq N</var>) の来客は時刻<var>T_i</var> に到着し時刻<var>T_i + 1</var>に退出する同時に耇数人の来客があるこずはない </p> <p> JOI 君は任意の時刻にストヌブを぀けたり消したりできるただしスト...
p00120
<H1>パティシ゚</H1> <p> ケヌキ屋さんが、たちたちな倧きさのロヌルケヌキをたくさん䜜りたした。あなたは、このケヌキを箱に䞊べる仕事を任されたした。 </p> <p> ロヌルケヌキはずおもやわらかいので、他のロヌルケヌキが䞊に乗るず぀ぶれおしたいたす。ですから、図(a) のように党おのロヌルケヌキは必ず箱の底面に接しおいるように䞊べなければなりたせん。䞊べ替えるず必芁な幅も倉わりたす。 </p> <center> <table> <tr><td><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_patisserie1"></td>...
p01361
<H1><font color="#000">Problem C:</font> Dungeon Quest II</H1> <p> The cave, called "Mass of Darkness", had been a agitating point of the evil, but the devil king and all of his soldiers were destroyed by the hero and the peace is there now. </p> <p> One day, however, the hero was worrying about the rebirth of the d...
p00989
<h2>Draw in Straight Lines</h2> <P> You plan to draw a black-and-white painting on a rectangular canvas. The painting will be a grid array of pixels, either black or white. You can paint black or white lines or dots on the initially white canvas. </p> <p> You can apply a sequence of the following two operations in a...
p01731
<p>Nathan O. Davis has been running an electronic bulletin board system named JAG-channel. He is now having hard time to add a new feature there --- threaded view. </p> <p>Like many other bulletin board systems, JAG-channel is thread-based. Here a thread (also called a topic) refers to a single conversation with a co...
p00823
<H1><font color="#000">Problem E:</font> Molecular Formula</H1> <p> Your mission in this problem is to write a computer program that manipulates molecular for- mulae in <i>virtual chemistry</i>. As in real chemistry, each molecular formula represents a molecule consisting of one or more atoms. However, it may not hav...
p04026
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Given a string <var>t</var>, we will call it <em>unbalanced</em> if and only if the length of <var>t</var> is at least <var>2</var>, and more than half of the letters in <var>t</var> are the same. For e...
p01224
<h1><font color="#000">Problem B:</font> 完党数</h1> <p> ある敎数 <var>N</var> に察しその数自身を陀く玄数の和を <var>S</var> ずする <var>N</var> = <var>S</var> のずき <var>N</var> は完党数 (perfect number) <var>N</var> &gt; <var>S</var> のずき <var>N</var> は䞍足数 (deficient number) <var>N</var> &lt; <var>S</var> のずき ...
p03219
<span class="lang-en"> <p>Score: <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There is a train going from Station <var>A</var> to Station <var>B</var> that costs <var>X</var> yen (the currency of Japan).</p> <p>Also, there is a bus going from Station <var>B</var> to Station <var>C...
p01674
<h2>H - Rings</h2> <h3>Problem Statement</h3> <p> There are two circles with radius 1 in 3D space. Please check two circles are connected as chained rings. </p> <h3>Input</h3> <p> The input is formatted as follows. </p> <pre> <var>{c_x}_1</var> <var>{c_y}_1</var> <var>{c_z}_1</var> <var>{v_x}_{1,1}</var> <var>{v_...
p03649
<span class="lang-en"> <p>Score : <var>600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a sequence of length <var>N</var> consisting of non-negative integers. Consider performing the following operation on this sequence until the largest element in this sequence becomes <var>N-1</v...
p00966
<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...
p02408
<H1>Finding Missing Cards</H1> <p> Taro is going to play a card game. However, now he has only <var>n</var> cards, even though there should be 52 cards (he has no Jokers). </p> <p> The 52 cards include 13 ranks of each of the four suits: spade, heart, club and diamond. </p> <H2>Input</H2> <p> In the first line,...
p00435
<H1>シヌザヌ暗号</H1> <h2>問題</h2> <p> ガむりス・ナリりス・カ゚サルGaius Julius Caesar)英語読みでゞュリアス・シヌザヌJulius Caesarは叀代ロヌマの軍人であり政治家であるカ゚サルは秘密の手玙を曞くずきに 'A' を 'D' に 'B' を 'E' に 'C' を 'F' にずいうように3぀ずらしお衚蚘したずいう蚘録が残っおいる </p> <p> 倧文字のアルファベット26文字だけからなる文字列をカ゚サルがしたように3文字ず぀ずらす倉換を斜し埗られた文字列があるこのような文字列を元の文字列に戻すプログラムを䜜成せよ </p> <p> 各文字の倉...
p02058
<h2>G: Tree</h2> <h3>問題</h3> <p><var>N</var> 頂点からなる朚が䞎えられたす。朚の各頂点には <var>1</var> から <var>N</var> の番号が割り振られおいたす。たた、<var>N−1</var> 本の蟺のうち、 <var>i\ (= 1, 2, ..., N-1)</var> 本目の蟺は頂点 <var>u_i</var> ず頂点 <var>v_i</var> ずを結んでいたす。</p> <p>この朚の <var>K</var> 個の空でない郚分グラフの組であっお、各郚分グラフがいずれも連結で、どの二぀の盞異なる郚分グラフも頂点を共有しないものの個数を求めるプログラムを...
p00065
<H1>取匕</H1> <p> 取匕先の顧客番号ず取匕日を月ごずに蚘録したデヌタがありたす。今月のデヌタず先月のデヌタを読み蟌んで、先月からヶ月連続で取匕のある䌚瀟の顧客番号ず取匕のあった回数を出力するプログラムを䜜成しおください。ただし、月々の取匕先数は 1,000 瀟以内です。 </p> <H2>Input</H2> <p> 今月のデヌタず、先月のデヌタが行の空行で区切られお䞎えられたす。それぞれのデヌタは以䞋のような圢匏で䞎えられたす。 </p> <pre> <var>c<sub>1</sub></var>,<var>d<sub>1</sub></var> <var>c<sub>2</sub></var>,<...
p03560
<span class="lang-en"> <p>Score : <var>700</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Find the smallest possible sum of the digits in the decimal notation of a positive multiple of <var>K</var>.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var>2 \leq K...
p03130
<span class="lang-en"> <p>Score : <var>200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There are four towns, numbered <var>1,2,3</var> and <var>4</var>. Also, there are three roads. The <var>i</var>-th road connects different towns <var>a_i</var> and <var>b_i</var> bidirectionally. No two...
p03999
<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> consisting of digits between <code>1</code> and <code>9</code>, inclusive. You can insert the letter <code>+</code> into some of the positions (possibly none) between...
p02371
<H1>Diameter of a Tree</H2> <br/> <p> Given a tree <var>T</var> with non-negative weight, find the diameter of the tree. </p> <p> The diameter of a tree is the maximum distance between two nodes in a tree. </p> <H2>Input</H2> <pre> <var>n</var> <var>s<sub>1</sub></var> <var>t<sub>1</sub></var> <var>w<sub>1</sub></...
p03833
<span class="lang-en"> <p>Score : <var>1000</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There are <var>N</var> barbecue restaurants along a street. The restaurants are numbered <var>1</var> through <var>N</var> from west to east, and the distance between restaurant <var>i</var> and restau...
p02721
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Takahashi has decided to work on <var>K</var> days of his choice from the <var>N</var> days starting with tomorrow.</p> <p>You are given an integer <var>C</var> and a string <var>S</var>. Takahashi will...
p00209
<H1>写真に写っおいる景色は?</H1> <p> A 君は䌚接に芳光にやっおきたした。宿泊したホテルの窓からは䌚接盆地が䞀望できたす。景色を眺めおいるず、床に写真の切れ端が萜ちおいるのに気が぀きたした。どうやら窓から倖の景色を撮ったようです。「どの蟺りを撮ったのかな」ず、A 君は窓の倖の景色ず写真が同じ倧きさになるように写真をかざしお、写真ず窓の倖の景色が䞀臎する堎所を探し始めたした。 </p> <p> それでは、A 君がやっおいるこずをコンピュヌタでやっおみたしょう。窓の倖の景色を <var>n &times; n</var> マスの正方圢に分割したす (<var>n</var> を景色の倧きさず呌びたす)。各マス...
p02234
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Matrix-chain Multiplication...
p03976
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3> <blockquote> <p> Kyoto University Programming Contest is a programming contest voluntarily held by some Kyoto University students. This contest is abbreviated as <b>K</...
p00659
<H1>Problem A: Popularity Estimation</H1> <p> あなたはずあるアニメヌション制䜜䌚瀟の䌁画郚長である。昚今のアニメヌション制䜜䌚瀟が制䜜するものは、アニメヌションそのものにずどたらない。関連商品、䟋えば登堎キャラクタヌのフィギュアやキャラクタヌ゜ングCDなども、重芁な収益源なのである。この収益をどれだけ䌞ばせるかは、ひずえに䌁画郚長のあなたにかかっおいるのであった。 </p> <p> 圓たり前のこずだが、こういった関連商品は闇雲に発売すればいいずいうものではない。商品の開発には倚くの時間ず予算が必芁なためだ。アニメの登堎キャラクタヌのフィギュアを発売するにしおも、倚くの売䞊が芋蟌たれ...
p02664
<span class="lang-en"> <p>Score : <var>200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>For a string <var>S</var> consisting of the uppercase English letters <code>P</code> and <code>D</code>, let the <em>doctoral and postdoctoral quotient</em> of <var>S</var> be the total number of occurr...
p03425
<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. The name of the <var>i</var>-th person is <var>S_i</var>.</p> <p>We would like to choose three people so that the following conditions are met:</p> <ul> <li>The name of ev...
p01418
<script src="./IMAGE/varmath.js" charset="UTF-8"></script> <H1>Sleeping Time</H1> <p> Miki is a high school student. She has a part time job, so she cannot take enough sleep on weekdays. She wants to take good sleep on holidays, but she doesn't know the best length of sleeping time for her. She is now trying t...
p03075
<span class="lang-en"> <p>Score: <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3> <p>In AtCoder city, there are five antennas standing in a straight line. They are called Antenna <var>A, B, C, D</var> and <var>E</var> from west to east, and their coordinates are <var>a, b, c, d</var> a...
p01048
<h1>Divisor</h1> <h2>Problem</h2> <p> 12以䞋の自然数 <var>N</var> が䞎えられるので、玄数の個数がちょうど <var>N</var> 個であるような最小の自然数を求めよ。 </p> <h2>Input</h2> <p> 1぀の自然数 <var>N</var> が 1 行で䞎えられる。 </p> <h2>Constraints</h2> <ul> <li>1 &le; <var>N</var> &le; 12</li> </ul> <h2>Output</h2> <p> 玄数の個数がちょうど <var>N</var> 個であるような最小の自然数を1行に出力せよ。 </p...
p00835
<H1><font color="#000">Problem I:</font> Crossing Prisms</H1> <p> Prof. Bocchan is a mathematician and a sculptor. He likes to create sculptures with mathematics. </p> <p> His style to make sculptures is very unique. He uses two identical prisms. Crossing them at right angles, he makes a polyhedron that is their inte...
p02808
<span class="lang-en"> <p>Score : <var>800</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3> <p>There are <var>N</var> children, numbered <var>1,2,\ldots,N</var>. In the next <var>K</var> days, we will give them some cookies. In the <var>i</var>-th day, we will choose <var>a_i</var> children amon...
p01727
<p>プログラミングコンテストの合宿で出す問題のアむディアが出ずに困っおいたむクタ君は、ある日友人に盞談した。 </p> <p>むクタ君「こういうアルゎリズムを䜿わないず解けないような問題が出したいんですけど、なにかありたせんかね」 </p> <p>友人「それではこういうものを考えたらいいんじゃないですか」 </p> <p>このようにしおその友人は以䞋のような問題の原案ずなるアむデアを考えおくれた。 </p> <p>2進数<var>A,B</var>が䞎えられた時、以䞋の様なク゚リを凊理せよ。 <ul> <li> 出力ク゚リ: max{<var>x</var> を2進数で衚したずきの、1の数 | <var>A &l...
p01377
<div> <h1 class="title">問題 B : (iwi)</h1> <p>20XX 幎の今G○○gle 瀟の䞖界的な支配により人々のコミュニケヌションは限られおおり 䟋えば自由に人ず情報をやりずりするこずは基本的に蚱されおいない 特に過去にプログラミングコンテストで名を銳せた匷豪たちは危険ず刀断され お互いバラバラにされ密かに泚意深く監芖されおいるずいう</p> <p>自分もそんな䞀人であったような気がする しかし実は自分は蚘憶を倱っおしたっおいるのだ 自分が䜕ず名乗っおいたかそれすらも思い出せない 'i' ずか 'w' ずか括匧ずかを䜿っおいた気がするが それっぜいものを曞...
p00136
<H1>床数分垃</H1> <p> 健康蚺断で生埒の身長を蚈枬したした。身長のデヌタを入力ずし、床数分垃を䜜成しお出力するプログラムを䜜成しおください。床数分垃の階玚は 5 cm 刻みの 6 ぀の階玚ずし、床数は人数を *半角アスタリスクで衚瀺したす。ただし、その階玚の床数人数が 0 の堎合、階玚の芋出しのみを出力しおください。 </p> <H2>Input</H2> <p> 入力は以䞋の圢匏で䞎えられたす。 </p> <pre> <var>n</var> <var>h<sub>1</sub></var> <var>h<sub>2</sub></var> : <var>h<sub>n</sub></var> <...
p00566
<h1>幹線道路 (Trunk Road)</h1> <h2>問題文</h2> <p> JOI 垂は東西方向にたっすぐに䌞びる <var>H</var> 本の道路ず南北方向にたっすぐに䌞びる <var>W</var> 本の道路によっお碁盀の目の圢に区分けされおいる道路ず道路の間隔は <var>1</var> であるJOI 垂ではこれら <var>H+W</var> 本の道路から東西方向に <var>1</var> 本南北方向に <var>1</var> 本合蚈 <var>2</var> 本の道路を幹線道路ずしお遞ぶこずになった</p> <p> 北から <var>i</var> 本目 (<var>1≩i≩H</...
p00073
<H1>四角すいの衚面積</H1> <p> 1 蟺が <var>x</var> の正方圢を底面ずする、高さ <var>h</var> の四角すいの衚面積 <var>S</var> を出力するプログラムを䜜成しお䞋さい。ただし、頂点ず底面の䞭心を結ぶ線分は底面ず盎亀しおいるずしたす。たた、 <var>x</var>、<var>h</var> は 100 以䞋の正の敎数ずしたす。 </p> <H3 class="bar">Input</H3> <p> 耇数のデヌタセットが䞎えられたす。各デヌタセットは以䞋の圢匏で䞎えられたす。 </p> <pre> <var>x</var> <var>h</var> </pre> <p...
p00589
<!-- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>problem</title> </head> <body bgcolor="#FFFFFF"> <link rel="stylesheet" href="../problem_e.css" type="text/css" /> --> <H1>Extraordinary Girl (II)</H1> <p> She loves e-mail so much! She sends e-mails by her cellular phone t...
p00423
<H1><!-- Card Game--></H1> <p> A ず B の 2 人のプレヌダヌが 0 から 9 たでの数字が曞かれたカヌドを䜿っおゲヌムを行う最初に 2 人は䞎えられた n 枚ず぀のカヌドを裏向きにしお暪䞀列に䞊べるその埌 2 人は各自の巊から 1 枚ず぀カヌドを衚向きにしおいき曞かれた数字が倧きい方のカヌドの持ち䞻がその 2 枚のカヌドを取るこのずきその 2 枚のカヌドに曞かれた数字の合蚈がカヌドを取ったプレヌダヌの埗点ずなるものずするただし開いた 2 枚のカヌドに同じ数字が曞かれおいるずきには匕き分けずし各プレヌダヌが自分のカヌドを 1 枚ず぀取るものずする </p> ...
p00970
<h2>Emergency Evacuation</h2> <p> The Japanese government plans to increase the number of inbound tourists to forty million in the year 2020, and sixty million in 2030. Not only increasing touristic appeal but also developing tourism infrastructure further is indispensable to accomplish such numbers. </p> <p> One...
p01662
<h2>G - 自由研究</h2> <p> き぀ねの次郎は倏䌑みの自由研究で<em>最倧独立集合問題</em>のアルゎリズムを考えおいる 最倧独立集合問題では入力ずしお無向グラフ <var>G=(V,E)</var> が䞎えられる <var>G</var> の各頂点が癜たたは黒で塗られおおりどの蟺の端点も少なくずも䞀方が癜く塗られおいるずき黒い頂点集合のこずを<em>独立集合</em>ず呌ぶ 䟋えば䞋図においお図の巊郚のようなグラフが䞎えられた時図の䞭倮郚のように色を塗るず黒い頂点集合は独立集合になっおいるが䞀方で図の右郚のように色を塗った堎合は黒い頂点集合は独立集合になっおいない 問題の目的は芁玠数が...
p01398
<script src="./IMAGE/varmath.js" charset="UTF-8"></script> <h2> Problem A: スワップ暗号 </h2> <p> R倧孊のずある2D奜きな圌は、人に芋られるず赀面するような恥ずかしい文章を日頃からよく曞いおいる。 そのため、第䞉者に自分の曞いおいる文章を芋られないために、圌が独自に考え出したスワップ暗号ずいう手法により文章を暗号化しおいる。 スワップ暗号では、次のようなステップを<i>N</i>回繰り返し、暗号化を行う。 </p> <ol> <li> 文字列の<i>a<sub>i</sub></i>番目ず<i>b<sub>i</sub></i>番目を入れ...
p01232
<h1><font color="#000">Problem J:</font> いにしえの数匏</h1> <p> あなたの友人の考叀孊者が遺跡を発掘しおいた ある日圌は怪しげな蚘号の矅列が刻たれおいる石盀を倧量に発芋した 圌はこの倧発芋に倧喜びしすぐさた石盀に刻たれおいる蚘号の解読を始めた 䜕週間にもわたる圌の解読の努力の結果 どうやらこれらの石盀には倉数・挔算子・カッコの組み合わせで成り立っおいる 数匏のようなものが刻たれおいるこずがわかった 発掘した石盀ず遺跡に関わる文献を調べおいくうちに圌はさらに それぞれの石盀で挔算子の結合芏則が異な...
p04030
<span class="lang-en"> <p>Score : <var>200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has <var>3</var> keys on it: the <code>0</code> key, the <code>1</code> key and the backspace key.</p> <p>To begin wi...
p02737
<span class="lang-en"> <p>Score : <var>900</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Given are simple undirected graphs <var>X</var>, <var>Y</var>, <var>Z</var>, with <var>N</var> vertices each and <var>M_1</var>, <var>M_2</var>, <var>M_3</var> edges, respectively. The vertices in <var>...
p01818
<h2>Leapfrog</h2> <h3>Problem Statement</h3> <p><var>N</var> 個のマスが円状に䞊んでいる。マスは時蚈回りに <var>1,\ 2,\ </var> ... <var>,\ N</var> ず番号が振られおいる。各 <var>i</var> (<var>1 &le; i &le; N&minus;1</var>) に぀いお、<var>i</var> 番目のマスず <var>i+1</var> 番目のマスは隣り合う。たた、<var>N</var> 番目のマスず <var>1</var> 番目のマスは隣り合う。</p> <p>これらのうち <var>M</var> 個...
p03825
<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> zeros and <var>M</var> ones written on a blackboard. Starting from this state, we will repeat the following operation: select <var>K</var> of the rational numbers written on the ...
p02367
<H1>Bridges</H1> <p> Find bridges of an undirected graph <var>G(V, E)</var>. </p> <p> A bridge (also known as a cut-edge) is an edge whose deletion increase the number of connected components. </p> <H2>Input</H2> <pre> <var>|V|</var> <var>|E|</var> <var>s<sub>0</sub></var> <var>t<sub>0</sub></var> <var>s<sub>1</su...
p03126
<span class="lang-en"> <p>Score : <var>200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Katsusando loves omelette rice.</p> <p>Besides, he loves crÚme brûlée, tenderloin steak and so on, and believes that these foods are all loved by everyone.</p> <p>To prove that hypothesis, he conducted ...
p03576
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have <var>N</var> points in a two-dimensional plane.<br/> The coordinates of the <var>i</var>-th point <var>(1 \leq i \leq N)</var> are <var>(x_i,y_i)</var>.<br/> Let us consider a rectangle whose si...
p03599
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is making sugar water in a beaker. Initially, the beaker is empty. Snuke can perform the following four types of operations any number of times. He may choose not to perform some types of operatio...
p03063
<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> stones arranged in a row. Every stone is painted white or black. A string <var>S</var> represents the color of the stones. The <var>i</var>-th stone from the left is white if the ...
p03433
<span class="lang-en"> <p>Score: <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3> <p>E869120 has <var>A</var> <var>1</var>-yen coins and infinitely many <var>500</var>-yen coins.<br/> Determine if he can pay exactly <var>N</var> yen using only these coins.</p> </section> </div> <div cla...
p02388
<H1>X Cubic</H1> <p> Write a program which calculates the cube of a given integer <var>x</var>. </p> <H2>Input</H2> <p> An integer <var>x</var> is given in a line. </p> <H2>Output</H2> <p> Print the cube of <var>x</var> in a line. </p> <h2>Constraints</h2> <ul> <li> 1 &le; <var>x</var> &le; 100</li> </ul> <...
p02672
<span class="lang-en"> <p>Score : <var>1100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p><strong>This is an interactive task.</strong></p> <p>You have to guess a secret password <var>S</var>. A password is a nonempty string whose length is at most <var>L</var>. The characters of a passwo...
p03960
<span class="lang-en"> <p>Score : <var>800</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Mr. Takahashi has in his room an art object with <var>H</var> rows and <var>W</var> columns, made up of <var>H \times W</var> blocks. Each block has a color represented by a lowercase English letter (<c...
p02222
<span class="lang"> <span class="lang-ja"> <h1>L: 朚の圩色</h1> <div class="part"> <section> <h3>問題文</h3><p>モデュヌロさんは朚の絵を描くのがずおもうたいです。</p> <p>モデュヌロさんは長い幎月をかけお頂点が $N$ 個である朚の絵を曞きたした。 この朚の頂点には $1$ から $N$ たでの番号が぀いおおり、頂点 $a_i$ ず $b_i$ $(1 \leq i \leq N-1)$ は盎接蟺で぀ながれおいたす。 すべおの頂点には色がただ塗られおいたせん。</p> <p>モデュヌロさんが曞いたこの朚の絵はたくさんの人を感動させ...
p00531
<h2>氎道料金 (Water Rate)</h2> <h2> 問題</h2> <p> JOI 君が䜏んでいる地域には氎道䌚瀟が X 瀟ず Y 瀟の 2 ぀ある2 ぀の䌚瀟の 1 ヶ月の氎道料金は1 ヶ月の氎道の䜿甚量に応じお次のように決たる </p> <ul> <li>X 瀟 1 リットル あたり A 円かかる</li> <li>Y 瀟 基本料金は B 円である䜿甚量が C リットル以䞋ならば料金は基本料金 B 円のみがかかる䜿甚量が C リットルを超えるず基本料金 B 円に加えお远加料金がかかる远加料金は䜿甚量が C リットルを 1 リットル超えるごずに D 円である</li> </ul> <...
p00161
<H1>䜓育祭Sport Meet</H1> <p> 秋の䜓育祭が行われたす。皮目は埒競走、ボヌル運び、障害物競走、リレヌの4皮目です。参加チヌムは <var>n</var> チヌムで、この4皮目の合蚈タむムが最も小さいチヌムが「優勝」、次に小さいチヌムが「準優勝」、そしお、最䞋䜍より2番目のチヌムを「ブヌビヌ賞」ずしお衚地したいず思いたす。 </p> <p> 各チヌムの成瞟を入力ずしお、「優勝」、「準優勝」、「ブヌビヌ賞」のチヌムを出力するプログラムを䜜成しおください。 ただし、チヌムにはそれぞれ 1 から <var>n</var> のチヌム番号が割り圓おられおいたす。 </p> <H2>Input</H2> <p...
p01320
<h1><font color="#000">Problem G:</font> Magical Island 2</h1> <!-- <h3><U>魔法島物語2</U></h3> --> <p>ただ魔法があたりたえのように存圚した時代であるある魔導士の䞀族は魔力によっお䜜られた正方圢の圢の島に䜏んでいた</p> <p>ある時この島に危機が蚪れた垝囜が倧陞間匟道魔導ミサむルを開発しこの島を照準に合わせおきたのであるこの䞖界の魔法は地属性氎属性火属性颚属性などに分類でき魔導ミサむルもその四぀の属性のいずれかに属しおいた島の四隅にはそれぞれ地の氎晶氎の氎晶火の氎晶颚の氎晶が配眮されおいお氎晶に...
p00862
<H1><font color="#000">Problem I:</font> Most Distant Point from the Sea</H1> <p> The main land of Japan called Honshu is an island surrounded by the sea. In such an island, it is natural to ask a question: "Where is the most distant point from the sea?" The answer to this question for Honshu was found in 1996. The m...
p01770
<h1 id="arojams-mask-ムゞュラの仮面">E : Arojam&#39;s Mask / 仮面</h1> <h2 id="問題文">問題文</h2> <p>あなたは勇者である。勇者が旅をしおいる䞖界は <var>N</var> 個の街ず、異なる街同士を結ぶ <var>M</var> 本の道からなる。道 <var>i</var> は街 <var>a_i</var> ず街 <var>b_i</var> を結び、双方向に移動可胜である。</p> <p>街 <var>S</var> から出発し、街 <var>T</var> に移動するこずが勇者の目的である。 <var>S,T</var> は異なる街である。勇者は <...
p03258
<span class="lang-en"> <p>Score : <var>1300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There is a string <var>s</var> consisting of <code>a</code> and <code>b</code>. Snuke can perform the following two kinds of operation any number of times in any order:</p> <ul> <li>Choose an occurrenc...
p01265
<H1><font color="#000">Problem F:</font> Ninja Legend</H1> <p> Ninjas are professional spies in the Middle Age of Japan. They have been popular in movies and games as they have been described with extraordinary physical abilities and unrealistic abilities. </p> <p> You are absorbed in one of ninja games, <i>Ninja Leg...
p00927
<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 D: Space Golf </h2> <p...
p03608
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There are <var>N</var> towns in the State of Atcoder, connected by <var>M</var> bidirectional roads.</p> <p>The <var>i</var>-th road connects Town <var>A_i</var> and <var>B_i</var> and has a length of <...
p01635
<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 B: Time Complexity</h1> <p class="ndo...