question_id
stringlengths
6
6
content
stringlengths
1
27.2k
p00714
<h1> <font color="#000">Problem E:</font> Water Tank </h1> <p> Mr. Denjiro is a science teacher. Today he has just received a specially ordered water tank that will certainly be useful for his innovative experiments on water flow. </p> <CENTER> <TABLE> <TR> <TD ALIGN="center"><img src="https://judgeapi.u-aizu....
p01806
<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> <!-- begin en only --> <h3><u>Dice Stamp</u></h3> <!-- ...
p02683
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem</h3><p>Takahashi, who is a novice in competitive programming, wants to learn <var>M</var> algorithms. Initially, his <em>understanding level</em> of each of the <var>M</var> algorithms is <var>0</var>.</p> <p>Takahashi ...
p03991
<span class="lang-en"> <p>Score : <var>1900</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><style> #nck { width: 30px; height: auto; } </style> <p>One day, Takahashi was given the following problem from Aoki:</p> <ul> <li>You are given a tree with <var>N</var> vertices and an ...
p02379
<H1>Distance</H1><br> <p> Write a program which calculates the distance between two points P1(x1, y1) and P2(x2, y2). </p> <H2>Input</H2> <p> Four real numbers x1, y1, x2 and y2 are given in a line. </p> <H2>Output</H2> <p> Print the distance in real number. The output should not contain an absolute error...
p00344
<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> ユキさんは、子供会の催しでみんなで遊べるよう...
p01105
<h3><u>Boolean Expression Compressor</u></h3> <p> You are asked to build a compressor for Boolean expressions that transforms expressions to the shortest form keeping their meaning. </p> <p> The grammar of the Boolean expressions has terminals <tt>0</tt>&nbsp;<tt>1</tt>&nbsp;<tt>a</tt>&nbsp;<tt>b</tt>&nbsp;<tt>c<...
p03138
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You are given <var>N</var> non-negative integers <var>A_1, A_2, ..., A_N</var> and another non-negative integer <var>K</var>.</p> <p>For a integer <var>X</var> between <var>0</var> and <var>K</var> (inc...
p03092
<span class="lang-en"> <p>Score : <var>1000</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You are given a permutation <var>p = (p_1, \ldots, p_N)</var> of <var>\{ 1, \ldots, N \}</var>. You can perform the following two kinds of operations repeatedly in any order:</p> <ul> <li>Pay a cost <v...
p01555
<h1>FizzBuzz</h1> <p>FizzBuzzとは、1以上の整数を順に、以下のルールに従って発言していくゲームである。 </p><ul><li><p> 3で割り切れる時には「Fizz」 </p></li><li><p> 5で割り切れる時には「Buzz」 </p></li><li><p> 3と5の両方で割り切れる時には「FizzBuzz」 </p></li><li><p> それ以外の時はその数字 </p></li></ul> <p>ゲームの進行状況の例を以下に示す。 </p> <p>1, 2, Fizz, 4, Buzz, Fizz, 7, 8, Fizz, Buzz, 11, Fizz, 13, 14, FizzB...
p03568
<span class="lang-en"> <p>Score : <var>200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We will say that two integer sequences of length <var>N</var>, <var>x_1, x_2, ..., x_N</var> and <var>y_1, y_2, ..., y_N</var>, are <em>similar</em> when <var>|x_i - y_i| \leq 1</var> holds for all <var...
p03246
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>A sequence <var>a_1,a_2,... ,a_n</var> is said to be /\/\/\/ when the following conditions are satisfied:</p> <ul> <li>For each <var>i = 1,2,..., n-2</var>, <var>a_i = a_{i+2}</var>.</li> <li>Exactly tw...
p00893
<H1><font color="#000">Problem J:</font> Matrix Calculator</H1> <p> Dr. Jimbo, an applied mathematician, needs to calculate matrices all day for solving his own problems. In his laboratory, he uses an excellent application program for manipulating matrix expressions, however, he cannot use it outside his laboratory b...
p01781
<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>B - Cube Coloring</h2> <h3>Pro...
p00939
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type='text/javascript' src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script> </script> <h2>Problem E Bringing Order to Di...
p02904
<span class="lang-en"> <p>Score : <var>700</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke has a permutation <var>(P_0,P_1,\cdots,P_{N-1})</var> of <var>(0,1,\cdots,N-1)</var>.</p> <p>Now, he will perform the following operation <strong>exactly once</strong>:</p> <ul> <li>Choose <var>K<...
p03616
<span class="lang-en"> <p>Score : <var>700</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a sandglass consisting of two bulbs, bulb A and bulb B. These bulbs contain some amount of sand. When we put the sandglass, either bulb <var>A</var> or <var>B</var> lies on top of the other and ...
p02457
<h1>Set: Range Search</h1> <p> For a set $S$ of integers, perform a sequence of the following operations. Note that <u>each value in $S$ must be unique</u>. </p> <ul> <li>insert($x$): Insert $x$ to $S$ and report the number of elements in $S$ after the operation.</li> <li>find($x$): Report the number of $x$ in ...
p00190
<H1>11 パズル</H1> <p> 太郎君は 8 パズルが大得意で休み時間などにいつも友達に並び替えてもらって遊んでいます。そんなとき、友達から「もっと複雑なパズルは解ける?」と聞かれたのですが、他のパズルはやったことはありません。どうやらその友達は自作で 11 パズルを作っていたみたいです。そのパズルは以下のような形をしています。 </p> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_elevenPuzzle"> </center> <br/> <p> 11 パズルは 11 枚の正方形のカードと、図 1 のような形...
p02007
<h1>Problem D. Prefix Suffix Search</h1> <!-- Time Limit: 3 sec Memory Limit: 512 MB --> <p> As an English learner, sometimes you cannot remember the entire spelling of English words perfectly, but you can only remember their prefixes and suffixes. For example, you may want to use a word which begins with '<span>ap...
p00485
<H1> JOI 国の買い物事情(Shopping in JOI Kingdom) </H1> <p> JOI 国には<i>N</i> 個の町があり,それらの間は<i>M</i> 本の双方向に通行可能な道路で結ばれている.<i>K</i> 個の町にはショッピングモールがあり,国民は道路を通ってそれらの町のいずれかに行き買い物をする. </p> <p> 家の場所によっては,買い物に行くために長い距離を移動する必要があり,それは非常に不便である.国王はこの実情を把握するため,ショッピングモールのある町までの最短距離が家の場所によってどれだけ長くなりうるのかを調べることにした.家は道路の途中に建てられることもあるので(入力例...
p02142
<h1>Problem F: Timing</h1> <h2>Problem</h2> <p>$N$頂点$M$辺の無向グラフが与えられる。各頂点には相異なる$1$から$N$までの番号が定められている。あなたは時刻$0$に頂点$S$を出発し、頂点$G$まで移動したい。各辺にはパラメータ$a, b$が設定されていて、時刻$t$にその辺の片側の頂点から出発した場合、もう片側の頂点には時刻$t+ceil\left(\cfrac{b}{t+a}\right)$に到達することがわかっている。ここで、$ceil(x)$は$x$以上の最小の整数を表す。また、各頂点では任意の非負整数時間を余分に消費することができる。つまり、時刻$t$にある頂点にいる...
p03303
<span class="lang-en"> <p>Score : <var>200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You are given a string <var>S</var> consisting of lowercase English letters. We will write down this string, starting a new line after every <var>w</var> letters. Print the string obtained by concatenat...
p01294
<H1><font color="#000">Problem B:</font> For the Peace</H1> <p> This is a story of a world somewhere far from the earth. In this world, the land is parted into a number of countries ruled by empires. This world is not very peaceful: they have been involved in army race. </p> <p> They are competing in production of m...
p02841
<span class="lang-en"> <p>Score: <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3> <p>In this problem, a date is written as Y-M-D. For example, <var>2019</var>-<var>11</var>-<var>30</var> means November <var>30</var>, <var>2019</var>.</p> <p>Integers <var>M_1, D_1, M_2</var>, and <var>D_...
p03753
<span class="lang-en lang-child hidden-lang"> <div id="task-statement"> Max Score: <var>500</var> Points <br/> <section> <h3>Problem Statement</h3> We have a grid with <var>n</var> rows and <var>7</var> columns. We call it a calendar. The cell at <var>i</var>-th row and <var>j</var>-th column is denoted <var>(...
p02791
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3> <p>Given is a permutation <var>P_1, \ldots, P_N</var> of <var>1, \ldots, N</var>. Find the number of integers <var>i</var> <var>(1 \leq i \leq N)</var> that satisfy the following condition: </p> <ul> <li...
p03883
<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>Snuke received <var>N</var> intervals as a birthday present. The <var>i</var>-th interval was <var>[-L_i, R_i]</var>. It is guaran...
p00256
<H1>マヤの大予言</H1> <p> 真也君はテレビで「マヤの大予言!2012年で世界が終る?」という番組を見ました。結局、世界が終るかどうかはよくわかりませんでしたが、番組で紹介されていたマヤの「長期暦」という暦に興味を持ちました。その番組では以下のような説明をしていました。 </p> <table cellpadding="18" cellspacing="18"> <tr> <td> <p> マヤ長期暦は、右の表のような単位からなる、全部で13バクトゥン(187万2000日)で構成される非常に長い暦である。ある計算法では、この暦は紀元前3114年8月11日に始まり2012年12月21日に終わると考えられていて、この...
p00606
<H1><font color="#000000">Problem B:</font> Cleaning Robot</H1> <p> Dr. Asimov, a robotics researcher, loves to research, but hates houseworks and his house were really dirty. So, he has developed a cleaning robot. </p> <p> As shown in the following figure, his house has 9 rooms, where each room is identified by an ...
p01914
<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>J: エナジードリンク</h1> <h2>問題</h2> <p> ixmel、Pulmn 兄弟は $N$ 種類のエナジー...
p03929
<span class="lang-en lang-child hidden-lang"> <div class="part"> Max Score: $250$ Points <br/> <section> <h3>Problem Statement</h3> Snuke has a very long calendar. It has a grid with $n$ rows and $7$ columns. One day, he noticed that calendar has a following regularity. <br/> <ul> <li>The cell at the $i$-th ro...
p03180
<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> rabbits, numbered <var>1, 2, \ldots, N</var>.</p> <p>For each <var>i, j</var> (<var>1 \leq i, j \leq N</var>), the compatibility of Rabbit <var>i</var> and <var>j</var> is describ...
p01447
<H1>Problem A: 雅先生の地球侵略日誌</H1> <p> クァークゴ帝国遠征軍は、地球侵略をもくろむ悪の組織である。彼らは侵略者の伝統にのっとり、日 本の東京周辺をターゲットに、毎週1体のペースで怪人を送りこみ続けていた。しかし、そのたびに 人類戦隊アースファイブと名乗る5人の戦士があらわれ、街で暴れまわっていた怪人はあっさりと倒 されてしまうのであった。 </p> <p> ワルザード・スルー(地球名:源雅)は、そんな現状を本気で憂いている、クァークゴ帝国遠征軍の 女幹部である。彼女は、毎週の敗北から何も学ぼうとしない司令官や、どこかズレた発明を繰り返す 天才科学者らの下で、頭の痛い日々を過ごしていた。 </p...
p01017
<h1>Problem B: Yu-kun Likes Rectangles</h1> <h2>Background</h2> <p> 会津大学付属幼稚園はプログラミングが大好きな子供が集まる幼稚園である。園児の一人であるゆう君は、プログラミングと同じくらい長方形が大好きだ。そんなゆう君は3つの長方形を使って得点を得る新たな遊びを考え、得られる最大の得点を計算するためのプログラムを書くことにした。 </p> <h2>Problem</h2> <p> <var>H</var> <var>×</var> <var>W</var> マスの長方形 A , B と<var>h</var> <var>×</var> <var>w</var...
p01502
<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: Sightseeing Tour </h...
p01152
<H1><font color="#000">Problem E:</font> Reading a Chord</H1> <p> In this problem, you are required to write a program that enumerates all chord names for given tones. </p> <p> We suppose an ordinary scale that consists of the following 12 tones: </p> <p> C, C<sup><i>#</i></sup> , D, D<sup><i>#</i></sup> , E, F, F<s...
p03495
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Takahashi has <var>N</var> balls. Initially, an integer <var>A_i</var> is written on the <var>i</var>-th ball.</p> <p>He would like to rewrite the integer on some balls so that there are at most <var>K<...
p00313
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML"> </script> <H1>極秘調査</H1> <p> 秘密の組織アイヅアナリティクス(AiZu Analyt...
p00743
<h1><font color="#000000">Problem D:</font> Discrete Speed</h1> <p> Consider car trips in a country where there is no friction. Cars in this country do not have engines. Once a car started to move at a speed, it keeps moving at the same speed. There are acceleration devices on some points on the road, where a car ca...
p01851
<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>先日,あなたの競技プログラミング仲間であるOさんは野球観戦に出かけ...
p02284
<H1>Binary Search Tree II</H1> <p> Write a program which performs the following operations to a binary search tree $T$ by adding the find operation to A: Binary Search Tree I. </p> <ul> <li><span>insert </span> $k$: Insert a node containing $k$ as key into $T$.</li> <li><span>find </span>$k$: Report whether $T$ h...
p02093
<h2>F: Invariant Tree</h2> <h3>Problem Statement</h3> <p>You have a permutation <var>p_1, p_2, ... , p_N</var> of integers from <var>1</var> to <var>N</var>. You also have vertices numbered <var>1</var> through <var>N</var>. Find the number of trees while satisfying the following condition. Here, two trees <var>T</va...
p00554
<h1>ポイントカード (Point Card)</h1> <h2>問題</h2> <p> JOI 商店街ではポイントカードのサービスを行っている.各ポイントカードには 2N 個のマスがある.商品を購入すると,くじを引くことができ,結果によって「当たり」か「はずれ」の印がマスに押される.同じマスに印が 2 回押されることはない.2N 個のマスのうち N 個以上のマスに当たりの印が書かれたポイントカードは,景品と交換することができる. また,ポイントカードの印は,1 マスにつき 1 円で書き換えてもらうことができる. </p> <p> JOI 君は 2N 個のマスが全て埋まっているポイントカードを M 枚持っている.ポイ...
p02569
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You are given a binary array <var>A=(A_1,A_2,\cdots,A_N)</var> of length <var>N</var>. </p> <p>Process <var>Q</var> queries of the following types. The <var>i</var>-th query is represented by three inte...
p00104
<H1>Magic Tile</H1> <p> There is a magic room in a homestead. The room is paved with H &times W tiles. There are five different tiles: </p> <ul> <li>Tile with a east-pointing arrow</li> <li>Tile with a west-pointing arrow</li> <li>Tile with a south-pointing arrow</li> <li>Tile with a north-pointing arrow</li> <li>T...
p02139
<h1>Problem C: Round And Round</h1> <h2>Problem</h2> <p> 長さ$N$の数列$A=${$a_{1},a_{2},a_{3},...,a_{n}$}が与えられる。<br> $a_{i}$ ($i=1,2,3,...,n$)は、$i$で初期化されているものとする。<br><br> 以下の二種類のクエリを合計$Q$回処理せよ。<br> <ul> <li>数列$A$の先頭から$k$番目の要素の値を出力する。</li> <li>数列$A$の先頭から$k$と$k+1$番目を境界に二つの数列をスワップする。</li> </ul> <br>詳しくはサン...
p02990
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There are <var>K</var> blue balls and <var>N-K</var> red balls. The balls of the same color cannot be distinguished. Snuke and Takahashi are playing with these balls.</p> <p>First, Snuke will arrange th...
p03682
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There are <var>N</var> towns on a plane. The <var>i</var>-th town is located at the coordinates <var>(x_i,y_i)</var>. There may be more than one town at the same coordinates.</p> <p>You can build a road...
p03378
<span class="lang-en"> <p>Score : <var>200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There are <var>N + 1</var> squares arranged in a row, numbered <var>0, 1, ..., N</var> from left to right.</p> <p>Initially, you are in Square <var>X</var>. You can freely travel between adjacent square...
p01345
<H1><font color="#000">Problem G: </font> DON'T PANIC!</H1> <p> Arthur is an innocent man who used to live on the Earth. He had lived a really commonplace life, until the day when the Earth was destroyed by aliens, who were not evil invaders but just contractors ordered to build a hyperspace bypass. In the moment whe...
p00807
<H1><font color="#000">Problem E:</font> Beehives</H1> <p> Taro and Hanako, students majoring in biology, have been engaged long in observations of beehives. Their interest is in finding any egg patterns laid by queen bees of a specific wild species. A queen bee is said to lay a batch ofeggs in a short time. Taro and...
p03728
<span class="lang-en"> <p>Score : <var>2400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Takahashi loves sorting.</p> <p>He has a permutation <var>(p_1,p_2,...,p_N)</var> of the integers from <var>1</var> through <var>N</var>. Now, he will repeat the following operation until the permutati...
p01715
<h1>問題 D : TiMe Table </h1> <h2>問題文</h2> <p> ある学生は朝にいつも乗る通学バスで,あることに気がついた. そのバスの利用者がいつも同じなのだ. 気になってバスに乗っている利用者たちに聞いてみると,毎日決まった時刻にバス停に来ているようである. それなら,乗客にとってもっとよいバスの時間割があるのではないかとその学生は考えた. </p> <p> 学生の乗る通学路には,バスの営業所から終点までに<var>s</var>個のバス停が一直線に並んでいる.(営業所はバス停には含まれないが,終点はバス停に含まれる.) 各バス停には,営業所から近い方から順に<var>1</var> から <var...
p01200
<H1><font color="#000"></font>Resource</H1> <!-- Problem G --> <p> Dr. Keith Miller is a researcher who studies the history of Island of Constitutional People’s Country (ICPC). Many studies by him and his colleagues have revealed various facts about ICPC. Although it is a single large island today, it was divided in s...
p04002
<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. At first, all cells were painted white.</p> <p>Snuke painted <var>N</var> of these cells. The <var>i</var>-th ( <var>1 \leq i \leq N</var>...
p00942
<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 Rotating Cutter Bits...
p01650
<h2>Problem Statement</h2> <p> There is a maze which can be described as a <var>W \times H</var> grid. The upper-left cell is denoted as (1, 1), and the lower-right cell is <var>(W, H)</var>. You are now at the cell (1, 1) and have to go to the cell <var>(W, H)</var>. However, you can only move to the right adjace...
p03397
<span class="lang-en"> <p>Score : <var>1600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Taichi thinks a binary string <var>X</var> of odd length <var>N</var> is <strong>beautiful</strong> if it is possible to apply the following operation <var>\frac{N-1}{2}</var> times so that the only ch...
p00411
<h1>目盛りのないストップウォッチ</h1>   <p> 図のようなストップウォッチがあります。このストップウォッチには0を示す目印が一つあるだけで、目盛りがありません。起動した瞬間、針は目印を指し、そこから針は軸を中心に一定の割合で時計回りに回転します。目盛りがないので、起動からの経過時間を直接読み取ることはできません。その代わり、針が目印から時計回りに$a$度回ったときの経過時間が$t$秒であることがわかっています。ただし、$a$は360度未満とします。 </p> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/PCK2019_stop_wat...
p00041
<H1>式</H1> <p> 与えられた 4 つの 1 から 9 の整数を使って、答えが 10 になる式をつくります。 4 つの整数 <var>a, b, c, d</var> を入力したとき、下記の条件に従い、答えが 10 になる式を出力するプログラムを作成してください。また、答えが複数ある時は、最初に見つかった答えだけを出力するものとします。答えがない時は、0 と出力してください。 </p> <ul> <li>演算子として、加算 (+)、減算 (-)、乗算 (*) だけを使います。除算 (/) は使いません。使用できる演算子は3個です。</li> <li>数を4つとも使わなければいけません。</li...
p02586
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There are <var>K</var> items placed on a grid of squares with <var>R</var> rows and <var>C</var> columns. Let <var>(i, j)</var> denote the square at the <var>i</var>-th row (<var>1 \leq i \leq R</var>) ...
p01579
<H1><font color="#000">Problem J:</font> Substring Expression</H1> <p> Trees are sometimes represented in the form of strings. Here is one of the most popular ways to represent unlabeled trees: </p> <ul> <li> Leaves are represented by "<span>()</span>".</li> <li> Other nodes (i.e. internal nodes) are represented by ...
p03544
<span class="lang-en"> <p>Score : <var>200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>It is November <var>18</var> now in Japan. By the way, <var>11</var> and <var>18</var> are adjacent Lucas numbers.</p> <p>You are given an integer <var>N</var>. Find the <var>N</var>-th Lucas number.</p...
p01083
<h1>Problem L: RedBlue</h1> <h2>Story</h2> <p> 天空都市AIZUのUZIA高校では、競技プログラミングの部活動がとても盛んである。 この部活には、<var>n</var>人のRed Coderと<var>n</var>人のBlue Coderが所属している。 </p> <p> ある日の部活の時間に、Red CoderとBlue Coderでペアを組み、この部活から<var>n</var>組、KCPというコンテストに参加することとなった。この高校では、ペアを組む学生同士は握手するという習わしがあるので、部員たちは今すぐ自分のパートナーを見つけることにした。 </p> <p> 部員...
p01129
<h1>Data Center on Fire</h1> <p> 今から少し未来の話である.高密度記憶および長期保存可能である記録デバイスが開発されてきたが,コンテンツが生み出される速度が異常なほどに速かったため,データセンターを設立した.データセンターを設立した当初は小さな建物だったが,増え続けるデータにあわせて何度も拡張工事をしたため,性能の異なるエレベータを何基も持つこととなった. </p> <p> ところが,データセンターで火災が発生した.火は一定時間だけ経過すると上の階ないし下の階に燃え広がる.また,火がついてから一定時間だけ経過するとその階は焼失してしまう.そこでエレベータを使ってデバイスを運び出すこととした....
p03114
<span class="lang-en"> <p>Score : <var>1400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Count the number of strings <var>S</var> that satisfy the following constraints, modulo <var>10^9 + 7</var>.</p> <ul> <li>The length of <var>S</var> is exactly <var>N</var>.</li> <li><var>S</var> consi...
p02355
<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 Smallest Window II</H1> <p> For a gi...
p00368
<H1>Checkered Pattern</H1> <p> You have a cross-section paper with W x H squares, and each of them is painted either in white or black. You want to re-arrange the squares into a neat checkered pattern, in which black and white squares are arranged alternately both in horizontal and vertical directions (the figure show...
p00692
<H1> Patience </H1> <p> As the proverb says, </p> <BLOCKQUOTE> <I>"Patience is bitter, but its fruit is sweet."</I> </BLOCKQUOTE> <p> Writing programs within the limited time may impose some patience on you, but you enjoy it and win the contest, we hope. </P> <p> The word "patience" has the meaning of perseverance,...
p01980
<h1>G: エレベータ</h1> <h2>問題</h2> <p> 株式会社AORは $N$ 階建てのビルである。地下階は存在しない。<br> AORイカちゃんはイカであるため、階段を下りることは可能だが、上ることは不可能である。 </p> <p> 上の階に登れないと不便なため、$M$ 個のエレベータをビルに設置することにした。<br> エレベータを設置するには時間がかかり、$i$ 番目のエレベータは $D_i$ 日後の夜に設置が完了し、 $A_i$ 階以上 $B_i$ 階以下の全ての階を移動可能にする。 </p> <p> あなたはAORイカちゃんに $Q$ 個の質問をされた。$i$ 番目の質問は「 $E_i$ 日後の昼に、$S_...
p02705
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Print the circumference of a circle of radius <var>R</var>.</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var>1 \leq R \leq 100</var></li> <li>All values in input are ...
p00738
<h1><font color="#000000">Problem E:</font> Roll-A-Big-Ball</h1> <!-- end en only --> <!-- <img src="https://judgeapi.u-aizu.ac.jp/resources/images/A-1" width=300 align=left> --> <!-- begin en only --> <p> ACM University holds its sports day in every July. The "Roll-A-Big-Ball" is the highlight of the day. In the...
p03817
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke has decided to play with a six-sided die. Each of its six sides shows an integer <var>1</var> through <var>6</var>, and two numbers on opposite sides always add up to <var>7</var>.</p> <p>Snuke wi...
p02210
<h2>五等分のケーキ (Divide Cake into Five)</h2> <p> Segtree 君は五つ子の家庭教師をしています。今日はクリスマスイブなので、五つ子のために円形のケーキを五等分しようとしています。</p> <p>ケーキは中心から扇形状に $N$ 個のピースに分けられており、 $i$ 番目と $i + 1$ 番目($1 \leq i \leq N - 1$) 、 $N$ 番目と $1$ 番目のピースは隣り合っています。</p> <p>$i$ 番目のピースの大きさは $A_i$ です。全てのピースの大きさの和を $S$ とすると、全ての入力について $S$ が $5$ の倍数であることが保証されます。</p> ...
p00387
<h1>Party Dress</h1> <p> Yae joins a journey plan, in which parties will be held several times during the itinerary. She wants to participate in all of them and will carry several dresses with her. But the number of dresses she can carry with her may be smaller than that of the party opportunities. In that case, she ha...
p02640
<span class="lang-en"> <p>Score : <var>200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There are some animals in a garden. Each of them is a crane with two legs or a turtle with four legs.</p> <p>Takahashi says: "there are <var>X</var> animals in total in the garden, and they have <var>Y<...
p03952
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a pyramid with <var>N</var> steps, built with blocks. The steps are numbered <var>1</var> through <var>N</var> from top to bottom. For each <var>1≤i≤N</var>, step <var>i</var> consists of <var>2...
p03401
<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> sightseeing spots on the <var>x</var>-axis, numbered <var>1, 2, ..., N</var>. Spot <var>i</var> is at the point with coordinate <var>A_i</var>. It costs <var>|a - b|</var> yen (th...
p01596
<h2>Problem F: Magnum Tornado</h2> <p>We have a toy that consists of a small racing circuit and a tiny car. For simplicity you can regard the circuit as a 2-dimensional closed loop, made of line segments and circular arcs. The circuit has no branchings. All segments and arcs are connected smoothly, i.e. there are no ...
p03051
<span class="lang-en"> <p>Score : <var>800</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>The <em>beauty</em> of a sequence <var>a</var> of length <var>n</var> is defined as <var>a_1 \oplus \cdots \oplus a_n</var>, where <var>\oplus</var> denotes the bitwise exclusive or (XOR).</p> <p>You ar...
p00850
<H1><font color="#000">Problem F:</font> Power Calculus</H1> <p> Starting with <i>x</i> and repeatedly multiplying by <i>x</i>, we can compute <i>x</i><sup>31</sup> with thirty multiplications: </p> <center> <p> <i>x</i><sup>2</sup> = <i>x</i> &times; <i>x</i>, <i>x</i><sup>3</sup> = <i>x</i><sup>2</sup> &time...
p01742
<p> すぬけ君の辞書には,<var>n</var> 個の英小文字からなる単語 <var>s<sub>1</sub>, . . ., s<sub>n</sub></var> がのっている.これは辞書順で比較したとき <var>s<sub>1</sub> &lt; . . . &lt; s<sub>n</sub></var> をみたす.残念ながらいくつかの文字はかすれて読めなくなってしまっている.読めなくなった文字は <span>?</span> で表される.<span>?</span> を英小文字で置き換えて辞書を復元する方法は何通りあるか,mod 1,000,000,007 でもとめよ. </p> <h2>Constra...
p03285
<span class="lang-en"> <p>Score : <var>200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p><em>La Confiserie d'ABC</em> sells cakes at <var>4</var> dollars each and doughnuts at <var>7</var> dollars each. Determine if there is a way to buy some of them for exactly <var>N</var> dollars. You ca...
p01312
<h1><font color="#000">Problem J:</font> ねこ泥棒と金曜日のお屋敷</h1> <p> なつめは大のねこ好きである。なつめの通学路には通称ねこ屋敷と呼ばれている家がある。その家はたくさんのねこを飼っていることで有名で、なつめは通学途中によくこの家の前で飼いねこに遭遇し、一緒に遊んでいた。そんなある日、なつめは衝撃的な事実を知ってしまった。それは、実はねこ屋敷の主人は、機嫌が悪くなるとよく飼いねこたちを虐待している、ということだった。ねこ屋敷の主人を許せなくなったなつめは、ねこたちを救うため、主人の居ない間にねこたちを盗みだすことにした。 </p> <p> なつめはねこ屋敷の主人の行動パ...
p00153
<H1>三角形と円</H1> <p> 平面上にある三角形と円の位置関係を判定するプログラムを作成してください。対象となる図形はいずれも境界を含むものとします。 三角形は 3 頂点の位置が与えられ、円は中心の位置と半径が与えられます。位置は直交座標系による2つの整数の組によって与えられます。半径も整数で与えられます。 </p> <H2>Input</H2> <p> 複数のデータセットの並びが入力として与えられます。入力の終わりはゼロふたつの行で示されます。 各データセットは以下の形式で与えられます。 </p> <pre> <var>x<sub>1</sub></var> <var>y<sub>1</sub></var>...
p00503
<H1>魚の生息範囲 (Fish) </H1> <br/> <h2> 問題</h2> <p> オーストラリア大陸の西には,広いインド洋が広がっている.海洋研究者である JOI 氏は,インド洋に生息しているある N 種類の魚の性質について研究している. </p> <p> それぞれの魚の種類に対して,海の中に直方体状の生息範囲が定まっている.魚は境界も含めて生息範囲の中のどの場所にも移動できるが,生息範囲の外に出ることは決してない.海の中の点は,3 つの実数 (x, y, d) によって表される: (x, y, d) は,上空から見たときにある地点を基準にして東に x,北に y 進んだ位置であり,海面からの深さが d の点を...
p00016
<H1>Treasure Hunt</H1> <p> When a boy was cleaning up after his grand father passing, he found an old paper: </p> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_treasure_en"><br> </center> <br/> <!-- <center> <table> <tr> <td align="top"> <img src="https://judgeapi.u-aizu.ac.jp/resources/im...
p02181
<h1>G: AOR-String</h1> <h2>問題</h2> <p> $N$ 個の文字列 $S_i$ が与えられる. </p> <p> $S_i$ を任意の順に繋げて得られる文字列に含まれる "AOR" の数の最大値を求めよ. </p> <h2>制約</h2> <ul> <li>$1 \leq N \leq 10^5$</li> <li>$1 \leq |S_i| \leq 20$</li> <li>$S_i$ は大文字アルファベットのみからなる</li> </ul> <h2>入力形式</h2> <p> 入力は以下の形式で与えられる. </p...
p00446
<H1> カードゲーム </H1> <h2>問題</h2> <p> 次のような2人で行うカードゲームがある. </p> <ul> <li> このゲームでは, 1から2nまでの各整数が書かれた全部で2n枚のカードを使用する. ここで,nは1以上100以下の整数である.</li> <li> このカードを2人にn枚ずつ配る.</li> <li> 次のルールに従って交互にカードを1枚ずつ場に出す.</li> <ul> <li> 場にカードが出ていないならば, 好きなカードを出すことができる.</li> <li> 場にカードが出ているならば, 最後に場に出たカード...
p00915
<H1><font color="#000">Problem B: </font>The Last Ant</H1> <p> A straight tunnel without branches is crowded with busy ants coming and going. Some ants walk left to right and others right to left. All ants walk at a constant speed of 1 cm/s. When two ants meet, they try to pass each other. However, some sections of t...
p02928
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a sequence of <var>N</var> integers <var>A~=~A_0,~A_1,~...,~A_{N - 1}</var>.</p> <p>Let <var>B</var> be a sequence of <var>K \times N</var> integers obtained by concatenating <var>K</var> copies...
p01607
<h2>魔法陣</h2> <h2>Problem Statement</h2> <p>〜魔法陣の描き方〜</p> <ol class="list1" style="padding-left:16px;margin-left:16px"><li>十分広くて真っ白な床を用意します.</li> <li>床の座標 <var>(0,0)</var> の点を中心にして,半径 <var>1, 2, ..., R</var> の円を描きます.</li> <li>半径 <var>1</var> の円と半径 <var>2</var> の円の間,半径 <var>3</var> の円と半径 <var>4</var> の円の間,<var>...<...
p02882
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Takahashi has a water bottle with the shape of a rectangular prism whose base is a square of side <var>a~\mathrm{cm}</var> and whose height is <var>b~\mathrm{cm}</var>. (The thickness of the bottle can ...
p03790
<span class="lang-en"> <p>Score : <var>1700</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There is a railroad in Takahashi Kingdom. The railroad consists of <var>N</var> sections, numbered <var>1</var>, <var>2</var>, ..., <var>N</var>, and <var>N+1</var> stations, numbered <var>0</var>, <va...
p01257
<H1><font color="#000">Problem H:</font> Vending Machine</H1> <p> There has been marketing warfare among beverage vendors, and they have been working hard for in- crease of their sales. The Kola-Coqua Company is one of the most successful vendors among those: their impressive advertisements toward the world has broug...
p00295
<h1>フロッピーキューブ</h1> <p> フロッピーキューブをプログラミングで解いてみましょう。フロッピーキューブは図のように表面に色のついた9個の立方体から構成されている立体パズルで、キューブの列を回転させることによって、6つの各面の色をそろえます。 </p> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_PCK2014_floppyCube1" width="300"> </center> <br> <p> フロッピーキューブに対しては下図のような4種類の操作を行うことができ、一回の操作で、端にある3つの隣接したキ...
p02752
<span class="lang-en"> <p>Score : <var>1100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3> <p>We have a tree <var>G</var> with <var>N</var> vertices numbered <var>1</var> to <var>N</var>. The <var>i</var>-th edge of <var>G</var> connects Vertex <var>a_i</var> and Vertex <var>b_i</var>.</p> <p>...
p03840
<span class="lang-en"> <p>Score : <var>600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>A <em>tetromino</em> is a figure formed by joining four squares edge to edge. We will refer to the following seven kinds of tetromino as I-, O-, T-, J-, L-, S- and Z-tetrominos, respectively:</p> <div s...
p02302
<H1>Convex Cut</H1> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_CGL_CGL_4_C"> </center> <br> <p> As shown in the figure above, cut a convex polygon <var>g</var> by a line <var>p1p2</var> and print the area of the cut polygon which is on the left-hand side of the line. </p> <p> <var>g<...