task
stringlengths
0
154k
__index_level_0__
int64
0
39.2k
Problem F: Old Memories In 4272 A.D., Master of Programming Literature, Dr. Isaac Cornell Panther-Carol, who has miraculously survived through the three World Computer Virus Wars and reached 90 years old this year, won a Nobel Prize for Literature. Media reported every detail of his life. However, there was one thing t...
38,709
E - 遞挙掻動 Problem Statement あなたは次回の遞挙の候補者であるX氏の支揎者である X氏は駅前での街頭挔説を予定しおおりできるだけ倚くの有暩者に芋おもらえる堎所で挔説しようず考えおいる 駅前は $N$ 個の障害物ず $M$ 人の有暩者が存圚しおいる二次元平面ずしお䞎えられる 各障害物は倚角圢であらわされその倚角圢の内偎の領域が障害物ずなる倚角圢の蟺䞊は障害物に含たれない たた有暩者は平面䞊の点ずしおあらわされる ある有暩者の䜍眮ずX氏の䜍眮を結ぶ線分䞊に障害物が存圚しないずきその有暩者はX氏を芋るこずができる あなたの仕事は駅前の障害物ず有暩者の情報をもずにもっずも倚くの有暩者に芋おも...
38,710
Distance For given two segments s1 and s2 , print the distance between them. s1 is formed by end points p0 and p1 , and s2 is formed by end points p2 and p3 . Input The entire input looks like: q (the number of queries) 1st query 2nd query ... q th query Each query consists of integer coordinates of end points of s1 an...
38,711
察称進数 1 グラム、3 グラム、9 グラム、27 グラムのおもりが぀ず぀あれば、倩びんを䜿っお 1 グラムから 40グラムたで 1 グラム刻みで量れるこずが知られおいたす。たずえば、倩びんの䞀方の皿に重さを量りたいものず 3 グラムのおもりを茉せ、もう䞀方の皿に 27 グラムず 1 グラムのおもりを茉せお釣り合えば、量りたいものの重さは 27-3+1=25 グラムだずわかりたす。 さらに、1(=3 0 )グラム、3 1 グラム、... 、3 n-1 グラム、3 n グラムたでのおもりが぀ず぀あれば、倩びんを䜿っお(3 n+1 -1)/2グラムたで量れるこずが知られおいたす。たた、倩びんが釣り合うようなおもりの眮き方は䞀通りし...
38,712
Square Route スクりェア・ルヌト English text is not available in this practice contest. このたび新しい豪邞を建おるこずを決めた倧富豪の品田氏はどの街に新邞を建おようかず悩んでいる実は品田氏は正方圢がずおも奜きずいう倉わった人物でありそのため少しでも正方圢の倚い街に䜏みたいず思っおいる 品田氏は碁盀目状に道路の敎備された街の䞀芧を手に入れおそれぞれの街に぀いお道路により圢䜜られる正方圢の個数を数えるこずにしたずころが道ず道の間隔は䞀定ずは限らないため手䜜業で正方圢を数えるのは倧倉であるそこであなたには碁盀目状の道路の情報が䞎えられたずきに...
38,713
Skyland Somewhere in the sky, KM kingdom built n floating islands by their highly developed technology. The islands are numbered from 1 to n . The king of the country, Kita_masa, can choose any non-negative real number as the altitude for each island, as long as the sum of the altitudes is greater than or equals to H ....
38,715
Score : 400 points Problem Statement You have N cards. On the i -th card, an integer A_i is written. For each j = 1, 2, ..., M in this order, you will perform the following operation once: Operation: Choose at most B_j cards (possibly zero). Replace the integer written on each chosen card with C_j . Find the maximum po...
38,716
Problem G: The Humans Braving the Invaders Problem 珟圚、地球は宇宙からの䟵略者であるむンベヌダヌの攻撃を受け、人類で生き残った者は基地にいる我々だけずなった。 奎らに察抗できる戊力もほずんど残されおいない。 だが、ここで我々は諊めるずいうこずはしない。 むンベヌダを党滅させるこずが、我々人類が生き残る最埌の手段である。 今から最埌になるであろう䜜戊の内容を説明する。 たず、むンベヌダヌの戊力に比べ我々の戊力はあたりにも少ないので、この基地に立おこもり、籠城戊を行う。 この基地は高い山に囲たれおいお、むンベヌダヌが䟵攻するには基地正面にある真っ盎ぐな道を通る他無い。 この道をフィヌル...
38,717
Score : 100 points Problem Statement You are given an integer N that has exactly four digits in base ten. How many times does 2 occur in the base-ten representation of N ? Constraints 1000 \leq N \leq 9999 Input Input is given from Standard Input in the following format: N Output Print the answer. Sample Input 1 1222 S...
38,718
Score : 2100 points Problem Statement You have a circle of length C , and you are placing N arcs on it. Arc i has length L_i . Every arc i is placed on the circle uniformly at random: a random real point on the circle is chosen, then an arc of length L_i centered at this point appears. Note that the arcs are placed ind...
38,719
Problem I: よくわかる二重魔法 玀慧暊2119 幎15 の月。宮廷魔術士Sengemon Lugene の手によっお、䞀冊の魔術曞が曞き蚘された。この魔術曞「In Magiray」は、この䞖界の魔術法則の根幹に深く関わる「二重魔法」を、誰にでも習埗可胜な技術ずしお䜓系化した、ずいう点で革新的な曞物であった。たずは、この曞物の内容を芁玄したものを芋おいこう。 【゚レメント】 䞖界䞭のあらゆる物䜓は、「泉」「颚」「矜」「花」「砂」「灯」  ずいった、極小芁玠「゚レメント」から構成されおいる。゚レメントには倚くの皮類があり、人間ぱレメントず契玄を亀わすこずで、契玄を亀わした皮類の゚レメントを甚いた二重魔法を発動させるこずができ...
38,720
Problem J: ICPC: Ideal Coin Payment and Change Taro, a boy who hates any inefficiencies, pays coins so that the number of coins to be returned as change is minimized in order to do smoothly when he buys something. One day, however, he doubt if this way is really efficient. When he pays more number of coins, a clerk con...
38,721
Score : 300 points Problem Statement 1000000000000001 dogs suddenly appeared under the roof of Roger's house, all of which he decided to keep. The dogs had been numbered 1 through 1000000000000001 , but he gave them new names, as follows: the dogs numbered 1,2,\cdots,26 were respectively given the names a , b , ..., z ...
38,722
B: 重さの範囲 問題 重さの異なる $N$ 色のボヌルがキュヌにたくさん入っおいたす。キュヌには、先頭から $1,2,3, \dots ,N-1,N,1,2,3, \dots ,N-1,N,1,2,3, \dots$ ずいうふうに昇順にボヌルが䞊んでいお、 色 $N$ のボヌルの埌ろにはたた色 $1$ のボヌルから順に入っおいたす。 同じ色のボヌルはそれぞれ同じ重さであり、色 $i$ のボヌルの重さは $A_i$ です。 この状態から、キュヌの先頭からボヌルを $M$ 個取り出し、これを 1 ぀のグルヌプずする䜜業を繰り返したす。 そしお、キュヌから取り出した各色のボヌルの総数がすべお等しくなったずきにグルヌプを䜜る䜜業をやめたす...
38,723
Score : 100 points Problem Statement Serval is fighting with a monster. The health of the monster is H . In one attack, Serval can decrease the monster's health by A . There is no other way to decrease the monster's health. Serval wins when the monster's health becomes 0 or below. Find the number of attacks Serval need...
38,724
Score : 100 points Problem Statement A 3×3 grid with a integer written in each square, is called a magic square if and only if the integers in each row, the integers in each column, and the integers in each diagonal (from the top left corner to the bottom right corner, and from the top right corner to the bottom left c...
38,725
枩泉旅行 枩泉奜きのたけしさんは、次の長期䌑暇を利甚しおずある枩泉地ぞの旅行を蚈画しおいたす。移動は長距離バスを乗り継ぎ、なるべくお金をかけずに目的地ぞたどり着きたいず思っおいたす。貯金があるずはいえ、資金に心蚱ないたけしさんは、おじいさんに盞談するこずにしたした。蚈画を聞いお感心したおじいさんは、たけしさんに特別な切笊を枡したした。 その切笊は、長距離バスの連続した2区間を1回だけ無料で乗れるずいうものでした。䜿いようによっおはかなりの移動費削枛が芋蟌めたすが、より倧きな効果を発揮させるためにはしっかりした蚈画を緎る必芁がありたす。 出発地ず目的地、及び䞭継地点が合わせお n 個、2぀の地点を結ぶ路線が m 個䞎えられたす。各地点...
38,726
Rooted Trees A graph G = ( V , E ) is a data structure where V is a finite set of vertices and E is a binary relation on V represented by a set of edges. Fig. 1 illustrates an example of a graph (or graphs). Fig. 1 A free tree is a connnected, acyclic, undirected graph. A rooted tree is a free tree in which one of the ...
38,727
Problem D: Luigi's Tavern Luigi's Tavern is a thriving tavern in the Kingdom of Nahaila. The owner of the tavern Luigi supports to organize a party, because the main customers of the tavern are adventurers. Each adventurer has a job: hero, warrior, cleric or mage. Any party should meet the following conditions: A party...
38,728
Score: 100 points Problem Statement We held two competitions: Coding Contest and Robot Maneuver. In each competition, the contestants taking the 3 -rd, 2 -nd, and 1 -st places receive 100000 , 200000 , and 300000 yen (the currency of Japan), respectively. Furthermore, a contestant taking the first place in both competi...
38,729
釘(Nails) JOI くんは板に釘を刺しお遊んでいる䞋図のようにJOI くんは䞀蟺 N 本の正䞉角圢の圢に釘を䞊べお刺した䞊から a 行目(1 ≀ a ≀ N ) には a 本の釘が䞊んでいるそのうち巊から b 本目(1 ≀ b ≀ a ) の釘を( a , b ) で衚す 図1: 釘の䞊び方 N = 5 の堎合 釘を頂点ずする正䞉角圢が「各蟺が党䜓の正䞉角圢の蟺のいずれかず平行で党䜓の正䞉角圢ず同じ向き」であるずきこの正䞉角圢を「 よい正䞉角圢 」ず呌ぶすなわち「よい正䞉角圢」ずは3 本の釘( a , b ), ( a + x , b ), ( a + x , b + x ) を頂点ずする正䞉角圢のこ...
38,732
Problem B: Milk Problem ちょうど$a$本の牛乳の空き瓶を持っおいくず新たに$b$本の牛乳の入った瓶ず亀換できる。 最初に$x$本の牛乳の入った瓶を持っおいる川林さんは、最倧䜕本分の牛乳を飲めるだろうか。$1000000007$で割った䜙りを出力せよ。 Input 入力は以䞋の圢匏で䞎えられる。 $a$ $b$ $x$ 3぀の敎数$a$, $b$, $x$が空癜区切りで䞎えられる。 Constraints 入力は以䞋の条件を満たす。 $1 \leq a \leq 10^{15} $ $0 \leq b \lt a $ $0 \leq x \leq 10^{15} $ Output 答えを1行に出力せよ。 Sam...
38,733
A: パ研 (Paken) あなたはパ研郚員であるから、"Paken" ず出力しなさい。 入力 この問題には入力は䞎えられない。 出力 "Paken" ず 1 行に出力しおください。 最埌の改行を忘れないようにしたしょう。 必芁な空癜や改行がなかったり、䜙蚈な空癜や改行を出力するず'Presentation Error'ずなり䞍正解になっおしたいたすので、泚意しおください。 入力䟋 (No input) 出力䟋 Paken 泚意 Pは倧文字、そのあずは小文字であるこずに泚意しおください。
38,734
Mode Value Your task is to write a program which reads a sequence of integers and prints mode values of the sequence. The mode value is the element which occurs most frequently. Input A sequence of integers a i (1 ≀ a i ≀ 100). The number of integers is less than or equals to 100. Output Print the mode values. If there...
38,735
Swap Write a program which reads a sequence of integers $A = \{a_0, a_1, ..., a_{n-1}\}$ and swap specified elements by a list of the following operation: swapRange($b, e, t$): For each integer $k$ ($0 \leq k < (e - b)$, swap element $(b + k)$ and element $(t + k)$. Input The input is given in the following format. $n$...
38,736
指茪 (Ring) 問題 あなたは N 個の指茪を持っおいるどの指茪にもアルファベットの倧文字 10 文字からなる文字列が刻印されおいる指茪には文字列の最初ず最埌が぀ながった圢で文字が刻印されおいる指茪に刻印された文字列を逆順に読む心配はない 探したい文字列が䞎えられたずきその文字列を含む指茪が䜕個あるかを求めるプログラムを䜜成せよ 入力 入力は 2+N 行からなる 1 行目には1 文字以䞊 10 文字以䞋のアルファベットの倧文字からなる探したい文字列が曞かれおいる 2 行目には指茪の個数 N ( 1 ≩ N ≩ 100 )が曞かれおいる 2+i 行目(1 ≀ i ≀ N )には i 個目の指茪に刻印されお...
38,737
ビヌカヌ いろいろな容量のビヌカヌが䞎えられおいたす。はじめに、その䞭の䞀番容量の倧きなビヌカヌを䞀個遞び、蛇口から氎をいっぱいになるたで泚ぎたす。぀ぎに、次のルヌルにしたがいながら、ビヌカヌの氎を他のビヌカヌに移し替えおいきたす。 ビヌカヌに入っおいる氎は,残さずにすべお他のビヌカヌに移さなければならない。ただし、䞀個のビヌカヌに氎を党郚移せないずきは、耇数のビヌカヌに分けお移しおもよい。 ビヌカヌに氎を入れるずき、いっぱいになるたで氎を泚がなければならない。たた、氎をこがしおはならない。 耇数のビヌカヌから同じビヌカヌに䞀床に氎を泚いではならない。 同じビヌカヌには䞀床しか氎を泚いではならない。 このルヌルにしたがったずき、ビヌ...
38,738
Score : 200 points Problem Statement Takahashi went to an all-you-can-eat buffet with N kinds of dishes and ate all of them (Dish 1 , Dish 2 , \ldots , Dish N ) once. The i -th dish (1 \leq i \leq N) he ate was Dish A_i . When he eats Dish i (1 \leq i \leq N) , he gains B_i satisfaction points. Additionally, when he ea...
38,739
Problem F: MLE ICPC World Finals 4日目 暗い嵐の倜だった。 倢の䞭でティヌ氏はタむムスリップしおいた。 ICPCの䌚堎のようだが䜕かおかしい 。 もしや これは、N幎前Nは自然数のICPCなのか ? 混乱の内に競技は開始しおしたった。 だが慌おる必芁はない。 きっず問題も簡単に違いない。 䟋えばこれなどは゜ヌトするだけで解けおしたうはずではないか。 冷静にコヌドを曞き䞊げ、速やかにSubmit。 しかしその結果は Memory Limit Exceeded
?! 問題 C++蚀語に぀いおは以䞋のコヌド long long int a[n]; unsigned long long int x = ...
38,740
Score : 1200 points Problem Statement There are 2N balls in the xy -plane. The coordinates of the i -th of them is (x_i, y_i) . Here, x_i and y_i are integers between 1 and N (inclusive) for all i , and no two balls occupy the same coordinates. In order to collect these balls, Snuke prepared 2N robots, N of type A and ...
38,741
Problem C: Brave Princess Revisited ある貧乏な囜のおおんばで勇敢なお姫様が政略結婚のため別の囜に嫁ぐこずになったずころがお姫様を亡き者ずしようずしおいる悪挢が嫁ぎ先ぞの道の途䞭で刺客を攟っおいる お姫様を無事に盞手囜に送り届けるためあなたは安党な経路を既に決定しおいたのだがお姫様の今たでに通ったこずのない道を通っおみたいずいう わがたたな たっおの願いで別の道を通るこずずなったそこであなたは地図を芋ながらお姫様が通る道を決めなおすこずにした 党おの道は宿堎同士を぀なぐ街道である䟿宜䞊出発地点及び目的地点も宿堎ずするずころが新しい道は治安の問題を抱えおいた盗賊やお姫様を亡き...
38,742
Score : 200 points Problem Statement There are N children, numbered 1, 2, ..., N . Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets. For each i ( 1 \leq i \leq N ), Child i will be happy if he/she gets exactly a_i sweets. Snuke is t...
38,743
Problem H: Twenty Questions Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fi...
38,744
Problem D Content Delivery You are given a computer network with n nodes. This network forms an undirected tree graph. The $i$-th edge connects the $a_i$-th node with the $b_i$-th node and its distance is $c_i$. Every node has different data and the size of the data on the $i$-th node is $s_i$. The network users can de...
38,745
Problem E: Colored Octahedra A young boy John is playing with eight triangular panels. These panels are all regular triangles of the same size, each painted in a single color; John is forming various octahedra with them. While he enjoys his playing, his father is wondering how many octahedra can be made of these panels...
38,746
Score : 600 points Problem Statement Takahashi is playing a board game called Sugoroku. On the board, there are N + 1 squares numbered 0 to N . Takahashi starts at Square 0 , and he has to stop exactly at Square N to win the game. The game uses a roulette with the M numbers from 1 to M . In each turn, Takahashi spins t...
38,747
倜店(Night Market) 倪郎くんはJOI 神瀟で開かれる倏祭りに行くこずにした JOI 神瀟に向かう道に沿っお N 個の倜店が開かれおいるそれぞれの倜店には1 から N たでの番号が順番に぀いおおり遊んだ時の楜しさず遊ぶのにかかる時間がそれぞれ敎数で決たっおいる倜店 i で遊んだ時の楜しさは A i で倜店 i で遊ぶのにかかる時間は B i である たた倏祭りのむベントずしお花火倧䌚があり時刻 S に最も倧きな花火が打ち䞊げられる倪郎くんはこの最も倧きな花火を芋たいず思っおいる 倪郎くんは倜店ず花火の䞡方を楜しむために倏祭りに到着する時刻0 から倏祭りが終わる時刻 T たでの予定を立おるこずに...
38,750
Problem C: Phone Number Problem 株匏䌚瀟りクニキアの電話番、デンさんは毎日ずおも長い電話番号を電話に入力しおいたす。 ある日䜙りにも疲れたデンさんは、疲れからか驚くべき考えに至りたした。 「電話のボタンの配眮を䞊べ替えたら少しでも楜できるのでは」 電話には$3 \times 3$で等間隔に区切られた正方圢があり、9個のマスには䞊べ替えるこずのできる1から9たでのボタンがそれぞれ1぀ず぀぀いおいたす。 電話番号を打぀際、デンさんは片手だけを䜿っお、次の二぀の操䜜を行うこずができたす。 人差し指を今觊れおいるボタンに蟺で隣接するいずれかのボタンに觊れるように移動させる。 人差し指が觊れおいるボタンを抌...
38,751
English Sentence Your task is to write a program which reads a text and prints two words. The first one is the word which is arise most frequently in the text. The second one is the word which has the maximum number of letters. The text includes only alphabetical characters and spaces. A word is a sequence of letters w...
38,752
Problem K. Rough Sorting For skilled programmers, it is very easy to implement a sorting function. Moreover, they often avoid full sorting to reduce computation time if it is not necessary. Here, we consider "rough sorting" which sorts an array except for some pairs of elements. More formally, we define an array is "$K...
38,753
タむル (Tile) 問題 JOI 高校では 1 × 1 の正方圢のタむルを䜿っお N × N の正方圢の壁画を䜜り文化祭で展瀺するこずになったタむルの色は赀青黄の 3 皮類である壁画のデザむンは次の通りであるたず最も倖偎の呚に赀のタむルを貌りその内偎の呚に青のタむルを貌るさらにその内偎の呚に黄色のタむルを貌るこれを N × N の正方圢が埋め尜くされるたで繰り返す甚いるタむルの色は䞀番倖偎の呚から順番に赀青黄赀青黄 である 文化祭が近づいおきたある日壁画のうち K 枚のタむルがはがれおいるこずが刀明したそこで新しいタむルを賌入しおはがれた箇所に新しいタむルを貌るこずにした 入力ず...
38,754
Rotate Write a program which reads a sequence of integers $A = \{a_0, a_1, ..., a_{n-1}\}$ and rotate specified elements by a list of the following operation: rotate($b, m, e$): For each integer $k$ ($0 \leq k < (e - b)$), move element $b + k$ to the place of element $b + ((k + (e - m)) \mod (e - b))$. Input The input ...
38,755
䞉目䞊べ 3 × 3 の盀面の䞉目䞊べを考えたしょう。䞉目䞊べは 2 人で行う察戊ゲヌムです。先攻埌攻を決め、䞀人は黒石、䞀人は癜石を打ちたす。盀面に石を亀互に䞀぀ず぀眮いおいき、瞊暪斜めのいずれかの方向に先に 3 ぀自分の石を䞊べた人が勝ちずなりたす。 盀面の情報を入力ずし、勝敗の刀定を行い、黒が勝ちの堎合は「b」、癜が勝ちの堎合は「w」、どちらもそろっおいない堎合は「NA」ず出力するプログラムを䜜成しおください。 盀面の情報は、3行3列の文字列で構成されたす。「b」は黒石、「w」は癜石、「+」(半角プラ ス)は䜕も眮かれおいない状況を衚したす。ただし、同時に黒が3぀、癜が3぀䞊ぶこずはありたせ ん。 Input 耇数のデヌタセッ...
38,756
Score : 300 points Problem Statement There is an integer sequence A of length N whose values are unknown. Given is an integer sequence B of length N-1 which is known to satisfy the following: B_i \geq \max(A_i, A_{i+1}) Find the maximum possible sum of the elements of A . Constraints All values in input are integers. 2...
38,757
Score : 100 points Problem Statement It is September 9 in Japan now. You are given a two-digit integer N . Answer the question: Is 9 contained in the decimal notation of N ? Constraints 10≀N≀99 Input Input is given from Standard Input in the following format: N Output If 9 is contained in the decimal notation of N , pr...
38,758
Problem E: Pie Chart is as easy as pie. ICPC World Finals 3日目 この日、ティヌ氏はチヌム内の蚀語䜿甚割合を調べおいた。 珍しいこずに、我々のチヌムは䜿甚蚀語を統䞀しおいない。 調査の結果、2人がC++、1人がJavaを䜿っおいるこずが分かった。 さお、これをパむチャヌト円グラフにしおみよう。 おや、Javaの䜿甚割合が少ないように芋えるな。 どう考えおもこんなはずはないので少々手を加えよう。 これは最近流行りのテクニックであり、 「パむチャヌトの䞭心座暙をずらす」ずいうものだ。 皆さんはマネしおはいけたせん。 うむ、これでバランスがずれた。 ずころで面積はどのように...
38,759
Score : 700 points Problem Statement Snuke has decided to use a robot to clean his room. There are N pieces of trash on a number line. The i -th piece from the left is at position x_i . We would like to put all of them in a trash bin at position 0 . For the positions of the pieces of trash, 0 < x_1 < x_2 < ... < x_{N} ...
38,760
Problem B: Matsuzaki Number Matsuzaki 教授は宇宙の真理を研究しおいる科孊者である人生宇宙すべおの答えは 42 であるず蚀われおいるがMatsuzaki 教授はこれだけでは宇宙の真理を解明するには䞍十分であるず考えおいるMatsuzaki 教授は宇宙の真理は 2 ぀のパラメヌタからなる関数で衚されるず考えおおり42 はその 1 ぀に過ぎないずいうのである Matsuzaki 教授の定矩した関数 M( N , P ) は N より倧きい玠数を 2 ぀遞んで同じ数を 2 ぀でも構わない和をずるこずで埗られる数の党䜓を小さいほうから順番に䞊べたずきに P 番目に珟れる数を衚す...
38,761
Problem G: Malfatti Circles The configuration of three circles packed inside a triangle such that each circle is tangent to the other two circles and to two of the edges of the triangle has been studied by many mathematicians for more than two centuries. Existence and uniqueness of such circles for an arbitrary triangl...
38,762
Problem C Casino Taro, who owes a debt of $n$ dollars, decides to make money in a casino, where he can double his wager with probability $p$ percent in a single play of a game. Taro is going to play the game repetitively. He can choose the amount of the bet in each play, as long as it is a positive integer in dollars a...
38,763
Problem E: The Most Powerful Spell Long long ago, there lived a wizard who invented a lot of "magical patterns." In a room where one of his magical patterns is drawn on the floor, anyone can use magic by casting magic spells! The set of spells usable in the room depends on the drawn magical pattern. Your task is to com...
38,764
D - むンビゞブル Problem Statement あなたは友達ず" むンビゞブル "ずいうカヌドゲヌムを遊がうずしおいる このカヌドゲヌムでは" 埗点カヌド "ず" 劚害カヌド "ずいう2皮類のカヌドを䜿う それぞれの埗点カヌドには正の倀が曞かれおいるこのカヌドゲヌムのルヌルは次の通りである ゲヌムはプレむダヌ1ずプレむダヌ2の2人のプレむダヌで行われるゲヌムはプレむダヌ1のタヌンから始たる 堎には1぀のスタックず2぀のデッキがあるスタックは2人のプレむダヌが眮いたカヌドからなるたたそれぞれのプレむダヌが持぀デッキはそのプレむダヌが持぀埗点カヌドず劚害カヌドからなるプレむダヌは自分もしくは盞手デ...
38,765
Area For a given polygon g , computes the area of the polygon. g is represented by a sequence of points p 1 , p 2 ,..., p n where line segments connecting p i and p i+1 (1 ≀ i ≀ n-1 ) are sides of g . The line segment connecting p n and p 1 is also a side of the polygon. Note that the polygon is not necessarily convex....
38,766
有益氏のオヌディオルヌム 数孊者である有益氏の趣味は音楜鑑賞で、家に念願のオヌディオルヌムを䜜りたした。完成したオヌディオルヌムで、友人を招いおお披露目䌚を開きたいず考えおいたす。党員にできるだけ良い音で聎いおもらいたいので、郚屋の䞭の䜕か所かで音を蚈枬し、友人たちの䜍眮での音の質を蚈算する぀もりです。 蚈枬点は、䞋の図の円匧ず線分の亀点である 1 番から 35 番たでの点から遞択したす。぀の線分䞊にある点は、オヌディオシステムからの距離が 100から 500たで 100ず぀離れお䞊んでいたす。぀の円匧状にある点は、もっずも右のもの1 番から 5 番たでの点から反時蚈回りに、0°から 180° の範囲で 30°床...
38,767
Lifeguard in the Pool プヌルの監芖員 English text is not available in this practice contest. Horton Moore はプヌルの監芖員ずしお働いおいる圌が芋回りのためにプヌルの瞁を歩いおいたずころプヌルの䞭で䞀人の少女がおがれおいるこずに気づいたもちろん圌は盎ちに救助に向かわなければならないしかも少女の身に䜕かあっおは倧倉であるから少しでも早く少女のもずにたどり着きたい あなたの仕事はプヌルの圢状頂点数が 3〜10 の凞倚角圢地䞊および氎䞭における監芖員の単䜍距離あたりの移動時間そしお監芖員ず少女の初期䜍眮が䞎えられたずきに監...
38,768
Score : 200 points Problem Statement You are given strings s and t , consisting of lowercase English letters. You will create a string s' by freely rearranging the characters in s . You will also create a string t' by freely rearranging the characters in t . Determine whether it is possible to satisfy s' < t' for the l...
38,769
Three-way Branch There is a grid that consists of W \times H cells. The upper-left-most cell is (1, 1) . You are standing on the cell of (1,1) and you are going to move to cell of (W, H) . You can only move to adjacent lower-left, lower or lower-right cells. There are obstructions on several cells. You can not move to ...
38,770
Problem F: Ballon Contest Problem 空の様子がい぀もず違う。色ずりどりの倚圩な熱気球が空を芆っおいた。今日は熱気球の倧䌚だ。 熱気球から萜ずされた埗点付きボヌルを参加者党員で取り合うらしい。 せっかくなので優勝者を予想しおみるこずにした。 レクリ゚ヌションにはN人参加する。 N 人の参加者はそれぞれ自分の䜍眮が䞎えられる。耇数の参加者に同じ䜍眮が䞎えられる事はない。 䞊空の熱気球からM個のボヌルが個ず぀萜䞋する。 参加者は党員同じタむミングで走り始め、ボヌルに向かっお同じ速床で䞀盎線に走る。 ボヌルの萜䞋䜍眮に䞀番早く蟿り着けた人がボヌルを取埗できる。同時に耇数人蟿り着いた堎合は、䞀様な確率で取埗で...
38,771
Score : 500 points Problem Statement We have a grid of squares with N rows and M columns. Let (i, j) denote the square at the i -th row from the top and j -th column from the left. We will choose K of the squares and put a piece on each of them. If we place the K pieces on squares (x_1, y_1) , (x_2, y_2) , ..., and (x_...
38,772
Score : 200 points Problem Statement There are N rectangular plate materials made of special metal called AtCoder Alloy. The dimensions of the i -th material are A_i \times B_i ( A_i vertically and B_i horizontally). Takahashi wants a rectangular plate made of AtCoder Alloy whose dimensions are exactly H \times W . He ...
38,773
Problem H: ねこ鍋改造蚈画仮 あなたは、自宅にたくさんのねこを飌っおいる。そんなあなたの日課は、飌っおいるねこが土鍋の䞭 に入っお昌寝しおいる様子通称ねこ鍋を撮圱するこずだ。䜕匹かのねこが、鍋の䞭でいっしょ に䞞くなっお眠る姿は、実に愛くるしい。 それぞれのねこには、「重さ」 m i ず「Cute」 c i が定矩されおいる。Cute ずは、そのねこ1 匹だけを芋たずきの、愛らしさ・あどけなさ・しなやかさ・やわらかさ・ういういしさ、などを総合的に評䟡した数倀であり、倧きければ倧きいほどそのねこは魅力的である。 たた、ねこ鍋に察しおは「UnCute」ずいう数倀が定矩される。これは、ねこ鍋党䜓ずしおのアンバラ ンスさ...
38,774
Score : 100 points Problem Statement On some day in January 2018 , Takaki is writing a document. The document has a column where the current date is written in yyyy/mm/dd format. For example, January 23 , 2018 should be written as 2018/01/23 . After finishing the document, she noticed that she had mistakenly wrote 2017...
38,775
Score : 200 points Problem Statement A shop sells N kinds of fruits, Fruit 1, \ldots, N , at prices of p_1, \ldots, p_N yen per item, respectively. (Yen is the currency of Japan.) Here, we will choose K kinds of fruits and buy one of each chosen kind. Find the minimum possible total price of those fruits. Constraints 1...
38,776
Problem A: Traffic Analysis There are two cameras which observe the up line and the down line respectively on the double lane (please see the following figure). These cameras are located on a line perpendicular to the lane, and we call the line 'monitoring line.' (the red line in the figure) Monitoring systems are conn...
38,777
C: Fractal Tree 問題 AORむカちゃんは、フラクタルな(自己盞䌌的な)構造を持぀根付き朚が奜きである。 $N$ 頂点から成る重み付き根付き朚 $T$ を甚いお、以䞋のようなフラクタル構造を持぀根付き朚 $T'$ を衚珟するこずを考える。 $T'$ は、$T$ の各頂点 $x$ に察しお、$x$ を根ずしお $T$ ず同様の朚構造 (コストも同じ) を持぀朚を付け加えたものである。 $T'$の根は $T$ のものず同じものである。 こうしお衚珟される朚は䟋えば䞋図のようになる。 AOR むカちゃんは、$T'$ に察しお深さ優先探玢をしようずしおいるが、党おの頂点を蟿るず時間がずおもかかるこずに気づいた。 そこで、深さ優...
38,778
Score : 600 points Problem Statement Snuke is standing on a two-dimensional plane. In one operation, he can move by 1 in the positive x -direction, or move by 1 in the positive y -direction. Let us define a function f(r, c) as follows: f(r,c) := (The number of paths from the point (0, 0) to the point (r, c) that Snuke ...
38,779
Score : 100 points Problem Statement Kode Festival is an anual contest where the hardest stone in the world is determined. (Kode is a Japanese word for "hardness".) This year, 2^N stones participated. The hardness of the i -th stone is A_i . In the contest, stones are thrown at each other in a knockout tournament. When...
38,780
Minimum Cost Sort You are given $n$ integers $w_i (i = 0, 1, ..., n-1)$ to be sorted in ascending order. You can swap two integers $w_i$ and $w_j$. Each swap operation has a cost, which is the sum of the two integers $w_i + w_j$. You can perform the operations any number of times. Write a program which reports the mini...
38,781
タむムセヌル より良い物を、より安く。今日もどこかのスヌパヌマヌケットで行われるタむムセヌルでは、激しい闘いが繰り広げられおいたす。ここ䌚接にある「LL堂」もそんなスヌパヌマヌケットのひず぀で、他のチェヌン店ず察抗すべく、少し倉わったタむムセヌルを実斜しおいたす。䞀般的なタむムセヌルでは耇数の商品が同じ時間に安くなるものですが、LL堂では察象ずなる商品によっお、タむムセヌルを開始する時間が別々に蚭定されおいたす。 坂井家はLL堂をよく利甚する家庭の䞀぀です。そんな坂井家では、奥様䞻導のもず、次の日曜に行われるタむムセヌルに向けお䜜戊䌚議を開き、どのような順番で買い物をすれば倀匕きが最倧ずなるかを分析するこずになりたした。店内を熟知し...
38,782
Score : 500 points Problem Statement There are N points on the 2D plane, i -th of which is located on (x_i, y_i) . There can be multiple points that share the same coordinate. What is the maximum possible Manhattan distance between two distinct points? Here, the Manhattan distance between two points (x_i, y_i) and (x_j...
38,783
Blur 図 1 のような 10×10 のマス目の「垃」があり、12のようにX座暙・Y座暙の倀の察でマス目を瀺すこずにしたす。座暙倀は 0 から始たる敎数ずしたす。䟋えば、図 1 の◎の座暙は (1, 2) です。 この「垃」に染料を少しず぀たらしお染物を䜜りたす。たらす染料の滎には「倧」「䞭」「小」の 3 サむズがあり、染料の滎の萜ちたマス目を䞭心に図 1 のように呚囲も色が぀きたす。図 1 で☆が䞭心、○が色のにじむ範囲です。 「垃」は、最初は「たっしろ」぀たり、どのマス目も色の濃さを瀺す倀が 0 ずしたす。染料の滎が萜ちるごずに倀が 1 ず぀増えおいきたす。「小」が1, 2、「䞭」が3, 2に萜ちた堎合、各マス目...
38,784
Problem I: Tree-Light Problem あなたはツリヌラむトずいうツリヌ状の照明噚具を買っおきた。 この照明噚具には n 個の接点があり、それぞれ 0 から n−1 たでの番号が぀いおいる。各接点は10段階の明るさを衚珟できる電球ず、電球の状態を切り替えるための装眮で構成されおいる。最初、すべおの接点の電球の明るさは 0 である。 たた、接点ず接点の間にはケヌブル線がある。すべおの接点は n−1 本のケヌブル線によっお繋がれおおり、接点 0 を䞊にしお吊り䞋げられる。ここで、接点 i から䞋方向に0本以䞊のケヌブル線を介しお、接点 i ず繋がる接点の集合を、接点 i を根ずした郚分朚ず呌ぶ。 あなたはこの照明噚具...
38,785
Score : 700 points Problem Statement There is a sequence X of length N , where every element is initially 0 . Let X_i denote the i -th element of X . You are given a sequence A of length N . The i -th element of A is A_i . Determine if we can make X equal to A by repeating the operation below. If we can, find the minim...
38,786
Problem C : War A囜ずB囜ずいう぀の囜が戊争をしおいる。A囜の軍人であるあなたは n 人の兵士を率いお、B囜の領土を占領する事になった。 B囜の領土は次元グリッドで衚されおいる。あなたが最初に占領する堎所は二次元グリッド䞊のあるマスである。 あなたが率いおいる兵士たちは、それぞれh_iの䜓力を持っおいる。 それぞれの兵士は䜓力を1を消費しお移動するこずができる。 珟圚いるマスを(a,b)ずするず、(a+1,b),(a-1,b),(a,b+1),(a,b-1)の4方向を移動先ずしお遞ぶこずが可胜である。 兵士は䜓力が0になったらそこから動くこずができなくなる。 䞀人以䞊の兵士が通過したマスはすべお占領するこずがで...
38,787
Problem Statement "Everlasting -One-" is an award-winning online game launched this year. This game has rapidly become famous for its large number of characters you can play. In this game, a character is characterized by attributes . There are $N$ attributes in this game, numbered $1$ through $N$. Each attribute takes ...
38,788
Problem C: Colored Cubes There are several colored cubes. All of them are of the same size but they may be colored differently. Each face of these cubes has a single color. Colors of distinct faces of a cube may or may not be the same. Two cubes are said to be identically colored if some suitable rotations of one of th...
38,789
Score : 600 points Problem Statement Given are N points (x_i, y_i) in a two-dimensional plane. Find the minimum radius of a circle such that all the points are inside or on it. Constraints 2 \leq N \leq 50 0 \leq x_i \leq 1000 0 \leq y_i \leq 1000 The given N points are all different. The values in input are all intege...
38,790
Score : 800 points Problem Statement There are N squares arranged in a row. The squares are numbered 1 , 2 , ... , N , from left to right. Snuke is painting each square in red, green or blue. According to his aesthetic sense, the following M conditions must all be satisfied. The i -th condition is: There are exactly x_...
38,791
Score : 700 points Problem Statement There are N strings arranged in a row. It is known that, for any two adjacent strings, the string to the left is lexicographically smaller than the string to the right. That is, S_1<S_2<...<S_N holds lexicographically, where S_i is the i -th string from the left. At least how many d...
38,792
問題 H あばれうなぎ 問題文 き぀ねのしえるはうなぎを食べるのが奜きである 2T+1 枚の鉄板が連続しお䞊んでおり順番に -T, -T+1, ..., T の番号が付いおいるしえるはこれらの鉄板に熱を加え生きたうなぎを焌こうずしおいるうなぎを焌く手順は以䞋のようなものである たず時刻 t=-1 のずきに各鉄板にどれだけの゚ネルギヌを加えるかを決め実際に゚ネルギヌを加える各鉄板に加える゚ネルギヌの総和は E 以䞋でなければならないすなわち i 番の鉄板に加える゚ネルギヌを E(i) ずしお E(i) ≥ 0, E(-T)+...+E(T) ≀ E でなければならないなお゚ネルギヌは敎数でなくおもよい ゚...
38,793
Score : 800 points Problem Statement We have 3N colored balls with IDs from 1 to 3N . A string S of length 3N represents the colors of the balls. The color of Ball i is red if S_i is R , green if S_i is G , and blue if S_i is B . There are N red balls, N green balls, and N blue balls. Takahashi will distribute these 3N...
38,794
Score : 700 points Problem Statement Takahashi is hosting an sports meet. There are N people who will participate. These people are conveniently numbered 1 through N . Also, there are M options of sports for this event. These sports are numbered 1 through M . Among these options, Takahashi will select one or more sport...
38,795
Spreadsheet Your task is to perform a simple table calculation. Write a program which reads the number of rows r , columns c and a table of r × c elements, and prints a new table, which includes the total sum for each row and column. Input In the first line, two integers r and c are given. Next, the table is given by r...
38,796
コむン集め(Coin Collecting) JOI 氏のコレクションルヌムには非垞に倧きな机がありその䞊には䜕枚もの貎重なコむンがある机の掃陀をするためにJOI 氏はコむンを敎理しお䞊べるこずにした 机は2 000 000 001 $\times$ 2 000 000 001 のマス目になっおいる列には巊から順に-1 000 000 000 から1 000 000 000たでの番号が぀けられおおり行には䞋から順に-1 000 000 000 から1 000 000 000 たでの番号が぀けられおいる列の番号が$x$行の番号が$y$ であるマスを($x, y$) で衚すこずにする コむンは$2N$ 枚あり珟圚$...
38,797
G: むルミネヌション 問題 $1 \leq x \leq h , 1 \leq y \leq w$ をみたす栌子点 $(x,y)$ に電球がある. 電源装眮は座暙 $(i+0.5,j+0.5) (1 \leq i < h,1 \leq j < w, i+j$ は偶数に蚭眮されおいる(14:21修正). 座暙 $(i+0.5,j+0.5)$ に蚭眮されおいる電源装眮をオンにするず, 座暙 $(i,j),(i+1,j),(i,j+1),(i+1,j+1)$ に存圚する $4$ ぀の電球が光る. $(i,j)$ にある電球がオンになっおいる電源装眮に $1$ ぀以䞊぀ながっおいるず, きれいさ $B_{i,j}$ を埗られる. あなた...
38,798
Score : 500 points Problem Statement There are N squares numbered 1 to N from left to right. Each square has a character written on it, and Square i has a letter s_i . Besides, there is initially one golem on each square. Snuke cast Q spells to move the golems. The i -th spell consisted of two characters t_i and d_i , ...
38,799
Sports Days 2.0 䌚接倧孊附属小孊校䌚接倧小は日本有数の競技プログラマヌ逊成校ずしお有名である。 もちろん、運動䌚に参加しおいるずきでさえアルゎリズムの修行を欠かせない。 競技プログラミング郚郚長のあなたはもちろんこの倧䌚でも勝利したい。 今回はある競技に泚目する。 ある競技ずは䌚接倧小で行われおいる䌝統的な競技だ。 校庭にコヌンが V 個眮いおある。 コヌンのいく぀かのペアは癜線で描かれた矢印で結ばれおいる。 矢印の先は片偎だけに぀いおおり、敎数が䜵蚘されおいる。 同じコヌンのペアがの耇数の矢印に結ばれおいる堎合もある。 競技者は任意にコヌンを遞び、移動開始する。 移動は競技者がいるコヌンから矢印の䞊をその向きに...
38,800
For Programming Excellence A countless number of skills are required to be an excellent programmer. Different skills have different importance degrees, and the total programming competence is measured by the sum of products of levels and importance degrees of his/her skills. In this summer season, you are planning to a...
38,801
Score : 400 points Problem Statement Give a pair of integers (A, B) such that A^5-B^5 = X . It is guaranteed that there exists such a pair for the given integer X . Constraints 1 \leq X \leq 10^9 X is an integer. There exists a pair of integers (A, B) satisfying the condition in Problem Statement. Input Input is given ...
38,802
Score : 200 points Problem Statement Kyoto University decided to build a straight wall on the west side of the university to protect against gorillas that attack the university from the west every night. Since it is difficult to protect the university at some points along the wall where gorillas attack violently, reinf...
38,803
Trampoline A plurality of trampolines are arranged in a line at 10 m intervals. Each trampoline has its own maximum horizontal distance within which the jumper can jump safely. Starting from the left-most trampoline, the jumper jumps to another trampoline within the allowed jumping range. The jumper wants to repeat jum...
38,804
The Secret Number Your job is to find out the secret number hidden in a matrix, each of whose element is a digit ('0'-'9') or a letter ('A'-'Z'). You can see an example matrix in Figure 1. Figure 1: A Matrix The secret number and other non-secret ones are coded in a matrix as sequences of digits in a decimal format. Yo...
38,805
Escape 頂点に正の倀を持぀無向グラフが䞎えられる。 頂点には 1 から N の番号が぀いおおり、 i 番目の頂点は w_i の倀を持っおいる。 1 番目の頂点からスタヌトし、盎前に通った蟺を通るこずができないずいう制玄のもずでグラフ䞊を移動するこずができる。 各頂点では初めお蚪れた時に限りその頂点が持぀倀の点数を埗られる。 取埗できる点数の総和の最倧倀を求めよ。 Constraints 1 ≀ N ≀ 100000 N − 1 ≀ M ≀ 100000 1 ≀ w_i ≀ 1000 1 ≀ u_i, v_i ≀ N 倚重蟺・自己蟺は存圚しない グラフは連結である Input Format 入力は以䞋の圢匏で暙準入力から䞎えら...
38,806
高速バス A 君は高校の䌑みを利甚しお、高速バス(以䞋、「バス」 )で䞀人旅をする蚈画を立おおいたす。たず、A 君は䞀番行っおみたい町を遞んでそこを目的地にしたした。次に出発地から目的地たでバスを乗り継いでいくルヌトを決めなければなりたせん。乗り継ぎをするずきは、バスを降りおから別のバスに乗り換えるので、それぞれのバスの乗車刞が必芁になりたす。 A 君は芪戚のおじさんからバスの割匕刞を䜕枚かもらいたした。 この刞を 1 枚䜿うず乗車刞 1 枚を半額で賌入できたす。䟋えば、図 1 の出発地5から目的地1ぞ行く堎合には、5→4→6→2→1ず5→3→1の二぀の経路が考えられたす。割匕刞が 2 枚あるずするず、亀通費を最も安くするには5→4...
38,808
Problem F: Ben Toh As usual, those who called wolves get together on 8 p.m. at the supermarket. The thing they want is only one, a box lunch that is labeled half price. Scrambling for a few discounted box lunch, they fiercely fight every day. And those who are blessed by hunger and appetite the best can acquire the box...
38,809
Endless BFS Mr. Endo wanted to write the code that performs breadth-first search (BFS), which is a search algorithm to explore all vertices on an undirected graph. An example of pseudo code of BFS is as follows: 1: $current \leftarrow \{start\_vertex\}$ 2: $visited \leftarrow current$ 3: while $visited \ne $ the set of...
38,810
Dice III Write a program which reads the two dices constructed in the same way as Dice I , and determines whether these two dices are identical. You can roll a dice in the same way as Dice I , and if all integers observed from the six directions are the same as that of another dice, these dices can be considered as ide...
38,811
Problem F: Farey Sequence slipは数字を眺めるのが奜きである。 ファむルをダりンロヌドしおいるずきの、残り時間を眺めおいるだけで、時間を朰せるほどである。 そんなslipが友人から面癜い数列を教えられた。 その数列の定矩は以䞋のずおりである。 䞀般項を F n ず衚わす。 F n ずは、 n 以䞋の分母を持぀0以䞊1以䞋のすべおの玄分された分数(既玄分数)を小さな順から䞊べたものである。 ただし、敎数0、1はそれぞれ分数0/1、1/1ずしお扱われる。 ぀たり F 3 は、 F 3 = (0/1, 1/3, 1/2, 2/3, 1/1) のように衚される。 F 5 であれば F 5 = (0/1, 1/5,...
38,812
Lucky Number Problem 0 から N -1 たでの数字がありたす。 M +1日間のラッキヌナンバヌを以䞋の方法で遞びたいず思いたす。 最初の日にラッキヌナンバヌをランダムに決めたす。 i 日埌のラッキヌナンバヌを A 、 i +1日埌のラッキヌナンバヌを B ずするず、 B = ( A + j ) % N ただし j は 0 ≀ j < N か぀  j / K  が偶数ずなる党おの敎数である ) で求められる B のうちのいずれかからランダムに決めたす。ただし、 a / b の結果は小数点以䞋を切り捚おた敎数ずし、 a % b は a を b で割った䜙りずしたす。 たた K は N / K が割り切れお...
38,813
Score : 700 points Problem Statement We have a grid with H rows and W columns of squares. We will represent the square at the i -th row from the top and j -th column from the left as (i,\ j) . Also, we will define the distance between the squares (i_1,\ j_1) and (i_2,\ j_2) as |i_1 - i_2| + |j_1 - j_2| . Snuke is paint...
38,814