task
stringlengths
0
154k
__index_level_0__
int64
0
39.2k
Score : 300 points Problem Statement Takahashi made N problems for competitive programming. The problems are numbered 1 to N , and the difficulty of Problem i is represented as an integer d_i (the higher, the harder). He is dividing the problems into two categories by choosing an integer K , as follows: A problem with ...
37,960
Score: 300 points Problem Statement We have a canvas divided into a grid with H rows and W columns. The square at the i -th row from the top and the j -th column from the left is represented as (i, j) . Initially, all the squares are white. square1001 wants to draw a picture with black paint. His specific objective is ...
37,961
Score : 300 points Problem Statement 2N players are running a competitive table tennis training on N tables numbered from 1 to N . The training consists of rounds . In each round, the players form N pairs, one pair per table. In each pair, competitors play a match against each other. As a result, one of them wins and t...
37,962
Score : 100 points Problem Statement Takahashi is meeting up with Aoki. They have planned to meet at a place that is D meters away from Takahashi's house in T minutes from now. Takahashi will leave his house now and go straight to the place at a speed of S meters per minute. Will he arrive in time? Constraints 1 \leq D...
37,964
Problem J: Cluster Network Problem マむヅ倧孊にある倧芏暡クラスタ † 型スヌパヌコンピュヌタ通称「SAKURA」のクラスタは、$N$台のコンピュヌタノヌドず$M$本の盞互に通信が可胜な物理的通信路で構成される。たた、各ノヌドにはそれぞれ1から$N$たでの識別番号が割り圓おられおいる。 この床SAKURAの利甚を倧孊関係者だけでなく、県内の䌁業にも認めるこずずなった。それに䌎い、SAKURAを構成する各ノヌドを点怜する必芁がある。しかし、SAKURAの利甚スケゞュヌルは数ヶ月先たで埋たっおいるので、点怜䞭もシステム党䜓を停止させるこずはできない。そこで、ノヌドを1日に1台ず぀順番に点怜する。...
37,965
Problem I: Shuffle 2 Problem $n$枚のカヌドからなる束があり、䞋から$i$番目のカヌドには$i$が曞かれおいる。この束に察しお、以䞋のように定矩されるシャッフルを$q$回行う。 束を䞋から芋たずき、奇数番目のカヌドを䞊に重ねおいっお䜜られる束$x$、偶数番目のカヌドを䞊に重ねおいっお䜜られる束$y$を考える。その埌以䞋の$2$぀のうち、奜きな操䜜を行う。 操䜜 $0$ 束$x$の䞊に束$y$をのせお$1$぀の束にする。 操䜜 $1$ 束$y$の䞊に束$x$をのせお$1$぀の束にする。 䟋えば、$6$枚のカヌドからなる束(䞋から123456)に察しお$1$回のシャッフルを行うこずを考えたずき、操䜜$0...
37,966
最高のピザ (Best Pizza) 問題 K 理事長はJOI 垂の䞭心郚にある JOI ピザ店の垞連客である圌はある事情により今月から節玄生掻を始めるこずにしたそこで圌はJOI ピザ店で泚文できるピザのうち1 ドルあたりのカロリヌが最倧ずなるようなピザを泚文したいず思ったこのようなピザを「最高のピザ」ず呌ぶこずにしよう「最高のピザ」は 1 皮類ずは限らない JOI ピザでは N 皮類のトッピングから䜕皮類かを自由に遞び基本の生地の䞊に茉せたものを泚文するこずができる同皮のトッピングを 2 ぀以䞊茉せるこずはできない生地にトッピングを 1 皮類も茉せないピザも泚文できる生地の倀段は A ドルでありトッピン...
37,967
Score: 200 points Problem Statement Takahashi, who works at DISCO, is standing before an iron bar. The bar has N-1 notches, which divide the bar into N sections. The i -th section from the left has a length of A_i millimeters. Takahashi wanted to choose a notch and cut the bar at that point into two parts with the same...
37,968
Problem F: Traveling Cube On a small planet named Bandai, a landing party of the starship Tadamigawa discovered colorful cubes traveling on flat areas of the planet surface, which the landing party named beds. A cube appears at a certain position on a bed, travels on the bed for a while, and then disappears. After a lo...
37,969
Score : 500 points Problem Statement You are given a connected undirected simple graph, which has N vertices and M edges. The vertices are numbered 1 through N , and the edges are numbered 1 through M . Edge i connects vertices A_i and B_i . Your task is to find a path that satisfies the following conditions: The path ...
37,970
Problem I: Tatami A tatami mat, a Japanese traditional floor cover, has a rectangular form with aspect ratio 1:2. When spreading tatami mats on a floor, it is prohibited to make a cross with the border of the tatami mats, because it is believed to bring bad luck. Your task is to write a program that reports how many po...
37,971
Score : 200 points Problem Statement Let S(n) denote the sum of the digits in the decimal notation of n . For example, S(101) = 1 + 0 + 1 = 2 . Given an integer N , determine if S(N) divides N . Constraints 1 \leq N \leq 10^9 Input Input is given from Standard Input in the following format: N Output If S(N) divides N ,...
37,972
Score: 300 points Problem Statement Takahashi has decided to hold fastest-finger-fast quiz games. Kizahashi, who is in charge of making the scoreboard, is struggling to write the program that manages the players' scores in a game, which proceeds as follows. A game is played by N players, numbered 1 to N . At the beginn...
37,973
Score : 700 points Problem Statement We have a tree with N vertices. Vertex 1 is the root of the tree, and the parent of Vertex i ( 2 \leq i \leq N ) is Vertex P_i . To each vertex in the tree, Snuke will allocate a color, either black or white, and a non-negative integer weight. Snuke has a favorite integer sequence, ...
37,974
Problem C: Towns along a Highway There are several towns on a highway. The highway has no forks. Given the distances between the neighboring towns, we can calculate all distances from any town to others. For example, given five towns (A, B, C, D and E) and the distances between neighboring towns like in Figure C.1, we ...
37,975
Problem E Cost Performance Flow Yayoi is a professional of money saving. Yayoi does not select items just because they are cheap; her motto is "cost performance". This is one of the reasons why she is good at cooking with bean sprouts. Due to her saving skill, Yayoi often receives requests to save various costs. This t...
37,976
Score : 400 points Problem Statement You are given positive integers N and M . How many sequences a of length N consisting of positive integers satisfy a_1 \times a_2 \times ... \times a_N = M ? Find the count modulo 10^9+7 . Here, two sequences a' and a'' are considered different when there exists some i such that a_i...
37,977
Problem I. Sum of QQ You received a card with an integer $S$ and a multiplication table of infinite size. All the elements in the table are integers, and an integer at the $i$-th row from the top and the $j$-th column from the left is $A_{i,j} = i \times j$ ($i,j \geq 1$). The table has infinite size, i.e., the number ...
37,978
ゎヌルドバッハ予想 ゎヌルドバッハ予想ずは「6 以䞊のどんな偶数も、2 ぀の玠数 (*1) の和ずしお衚わすこずができる」ずいうものです。 たずえば、偶数の 12 は 12 = 5 + 7 、18 は 18 = 5 + 13 = 7 + 11 などず衚すこずができたす。 和が 134 ずなる 2 ぀の玠数の組み合せをすべお曞き出すず、以䞋の通りずなりたす。 134 = 3+131 = 7+127 = 31+103 = 37+97 = 61+73 = 67+67 = 131+3 = 127+7 = 103+31 = 97+37 = 73+61 䞎えられた数が倧きくなるず、いくらでも玠数の組み合せが芋぀かるような気がしたす。しかし、珟代...
37,979
Lexicographical Comparison Compare given two sequence $A = \{a_0, a_1, ..., a_{n-1}\}$ and $B = \{b_0, b_1, ..., b_{m-1}$ lexicographically. Input The input is given in the following format. $n$ $a_0 \; a_1, ..., \; a_{n-1}$ $m$ $b_0 \; b_1, ..., \; b_{m-1}$ The number of elements in $A$ and its elements $a_i$ are give...
37,980
Princess, a Cryptanalyst お姫様の暗号解読 English text is not available in this practice contest. ある貧乏な囜のおおんばで勇敢なお姫様はお忍びで出かけた町である日本語で曞かれた叀文曞を手に入れたお姫様は日本語ができるためさっそくこの叀文曞を読んでみたするず驚くべき事が分かったこの叀文曞は叀の秘宝の圚凊を瀺しおいたのであるずころが秘宝の圚凊は暗号になっおおり容易には分からないようになっおいたそこでお姫様は埓者であるあなたに暗号の解読を手䌝うように呜什を䞋した あなたはお姫様を助けるため昌倜を問わず調査を行ったその結果Shor...
37,982
The Enemy of My Enemy is My Friend 敵の敵は味方 English text is not available in this practice contest. 時は XXXX 幎。戊乱の䞖である。 土地や資源を巡っお、隣り合った囜同士の衝突がそこかしこで起こり、䞖の䞭の先行きは非垞に䞍透明であった。そんな䞭ずある囜が、様々な囜ず軍事同盟を結んでこの乱䞖を生き延びようず考えた。軍事同盟は次の条件をみたすように行うこずが出来る。 自囜の隣囜ずは同盟を結ぶこずは出来ない。 同盟をした囜の隣囜ずは同盟を結ぶこずは出来ない。 ただし、囜ごずにその軍事的な匷さは異なっおいる。軍事的に匷くない耇数の囜ず同盟を結...
37,983
Reflection For given three points p1, p2, p , find the reflection point x of p onto p1p2 . Input x p1 y p1 x p2 y p2 q x p 0 y p 0 x p 1 y p 1 ... x p q−1 y p q−1 In the first line, integer coordinates of p1 and p2 are given. Then, q queries are given for integer coordinates of p . Output For each query, print the coor...
37,984
And Then, How Many Are There? To Mr. Solitarius, who is a famous solo play game creator, a new idea occurs like every day. His new game requires discs of various colors and sizes. To start with, all the discs are randomly scattered around the center of a table. During the play, you can remove a pair of discs of the sam...
37,985
Score : 500 points Problem Statement Snuke received a triangle as a birthday present. The coordinates of the three vertices were (x_1, y_1) , (x_2, y_2) , and (x_3, y_3) . He wants to draw two circles with the same radius inside the triangle such that the two circles do not overlap (but they may touch). Compute the max...
37,986
F - 土地盞続 Problem Statement ある $N$ 人の兄匟は芪の遺産盞続の話し合いをしおいた 圌らの芪の残した莫倧な遺産の䞭には広倧な土地も含たれおいた その土地は南北に $H$ km, 東西に $W$ km に広がる長方圢の圢をしおいる この土地は 1 km 四方の区画単䜍で管理されおおり 土地の北端から $i$ 〜 $i+1$ km か぀西端から $j$ 〜 $j+1$ km の範囲にある 1 km 四方の区画を区画 $(i, j)$ ず呌ぶ $i$, $j$ は $0 \leq i < H$, $0 \leq j < W$ を満たす敎数である 土地の䟡栌は区画ごずに決たっおおり区画 $(i,...
37,987
かぐや いよいよ今月末に「はやぶさ」が打ち䞊げられたす。幎前に「はやぶさ」が垰っおきたずきは、日本䞭が盛り䞊がったのを芚えおいる人も倚いず思いたす。幎前には、「かぐや」が打ち䞊げられ、月の呚りを回りながらたくさんの鮮明な画像を地球に送っおくれたした。 䞊の図は、地球を原点ずした空間座暙z軞は玙面から垂盎に䞋から䞊に向いおいるものずしたすに、月の軌道ずいく぀かの月の䜍眮、月の呚りを回るかぐやの軌道を描いたものです。月の軌道は、x軞ずy軞を通る平面䞊にある、原点を䞭心ずする円ずしたす。月の呚りを回るかぐやの軌道は、x軞ずz軞を通る平面に平行な平面䞊にある円ずし、その䞭心は月の䞭心ず䞀臎したす。月は、その軌道に沿っお描かれた矢印...
37,988
Problem I: A Piece of Cake In the city, there are two pastry shops. One shop was very popular because its cakes are pretty tasty. However, there was a man who is displeased at the shop. He was an owner of another shop. Although cause of his shop's unpopularity is incredibly awful taste of its cakes, he never improved i...
37,989
D: 日焌け - Suntan - 物語 あいずにゃんは若ヶ束高校のプログラミングコンテスト郚、通称ぷろこん郚に所属する2幎生である。倩䜿のようにかわいい。 あいずにゃんは今幎の倏フェスに参加する予定なので、聎きに行くバンドのスケゞュヌルを立おた。 ここで心配なのが日焌けだ。 ラむブはすべお野倖で行われるが、あいずにゃんは日焌けしやすい䜓質なので長時間野倖で玫倖線を济びすぎるずすぐ日焌けしおしたう。 ラむブがない間は屋内に避難するこずでできるだけ玫倖線を回避する぀もりだが、ラむブ䞭はどうしおも日に圓たっおしたう。 そこであいずにゃんは日焌け止めを塗るこずで玫倖線察策をするこずを考えた。 問題 日焌け止めを塗るず、塗った時間から T ...
37,990
塗り぀ぶしゲヌム 指で画面にタッチしお操䜜するこずのできるタブレットむンタヌフェヌスの技術は、ゲヌムの分野でも応甚され、新しい操䜜感を持぀様々な皮類のゲヌムが䜜られおいたす。珟圚、瀟が開発しおいるゲヌムもその䞀぀です。 この゜フトりェアゲヌムの芁件は以䞋の通りです。 画面には X 列× Y 行の2次元グリッドがありたす。 グリッドのセルは赀(R)、緑(G)、茶(B)の3色のいずれかで塗られおいたす。 セルの色を倉曎するボタンR、G、Bがあり、このボタンが抌䞋されるず䞀番巊䞊(0,0)のセルがその色に倉曎されたす。 䞀番巊䞊のセルの色が倉曎されるず、そのセルの元の色ず同じ色に塗られた隣接するすべおのセルが指定された色に倉わりた...
37,991
Score : 200 points Problem Statement Raccoon is fighting with a monster. The health of the monster is H . Raccoon can use N kinds of special moves. Using the i -th move decreases the monster's health by A_i . There is no other way to decrease the monster's health. Raccoon wins when the monster's health becomes 0 or bel...
37,992
Score : 100 points Problem Statement There are N persons, conveniently numbered 1 through N . They will take 3y3s Challenge for N-1 seconds. During the challenge, each person must look at each of the N-1 other persons for 1 seconds, in some order. If any two persons look at each other during the challenge, the challeng...
37,993
Problem D: Smartphone Game Problem 人気のスマフォゲヌムの䞀機胜を実装しおみよう。ゲヌムは以䞋の仕様に基づく。 5*5のマスに、5皮類のブロックが蚭眮されおいる。 それぞれの皮類のブロックには埗点が蚭定されおいる。 埗点には、ブロックの埗点の他に、ボヌナス埗点が蚭定されおいる。最初のボヌナス埗点は1である。 ブロックを任意に1぀だけ決めお、最倧で n 回たで䞊䞋巊右に移動できる。移動先のブロックは移動元のブロックのあった堎所に移動する。぀たり、隣接したブロックを亀換する事になる。 移動した埌、同じ皮類のブロックが瞊3個以䞊又は暪3個以䞊に䞊んだ堎合、䞊んだブロックは党お消える。 消えるべきブロックが...
37,994
Problem F: 歳の動的蚈画 ある日の倕方。い぀ものようにあなたが居間でテレビを芋おいるず、小孊幎生の効から盞談を持ち かけられた。話を聞いおみるず、今日孊校で出された算数の問題が難しくお理解できなかったので、 あなたに解き方を教えおほしいのだずいう。 効を悩たせおいる問題は、「道が碁盀目状に通っおいる街においお、家(0, 0) から孊校( N , M ) たで最短距離で進む方法は䜕通りあるか」ずいうものだった。もちろん、あなたにずっおは赀子の手をひねるよりも簡単な問題である。すぐに䞊のような図を曞いお「家(0, 0) から順番に足し算しおいけば解けるよ」ず教えおあげた。 ずころが、それを聞いおもただ、効はなにやら䞋を...
37,995
Problem E : Connect r × c のグリッドが䞎えられる。 グリッドのいく぀かのマスには1から8たでの数字が曞かれおいる。 数字が曞かれおいるマスず他の数字が曞かれおいるマスを線で結ぶ必芁がある。 数字が曞かれおいるマスに぀いお、そのマスに曞かれおいる本数だけ、他のマスずの間に線を結ぶ必芁がある。 ただし、線を結べるのは䞊䞋巊右方向だけで、䞀぀の方向に぀いお、最倧本たでである。 他の数字を跚いで線で結ぶこずはできない。 たた、次のように亀差しおしたう結び方をするこずはできない。 グリッドが入力ずしお䞎えられるので、数字が曞かれおいるマス党おを正しく結ぶ方法が、䜕通りあるのかを数えお欲しい。 Input 入力は以䞋...
37,997
Problem Statement You are given a rectangular board divided into square cells. The number of rows and columns in this board are $3$ and $3 M + 1$, respectively, where $M$ is a positive integer. The rows are numbered $1$ through $3$ from top to bottom, and the columns are numbered $1$ through $3 M + 1$ from left to righ...
37,998
Score : 400 points Problem Statement Takahashi has a maze, which is a grid of H \times W squares with H horizontal rows and W vertical columns. The square at the i -th row from the top and the j -th column is a "wall" square if S_{ij} is # , and a "road" square if S_{ij} is . . From a road square, you can move to a hor...
38,000
Score : 100 points Problem Statement Based on some criterion, Snuke divided the integers from 1 through 12 into three groups as shown in the figure below. Given two integers x and y ( 1 ≀ x < y ≀ 12 ), determine whether they belong to the same group. Constraints x and y are integers. 1 ≀ x < y ≀ 12 Input Input is given...
38,001
敎数の和 II 0 から 100 の数字から異なる n 個の数を取り出しお合蚈が s ずなる組み合わせの数を出力するプログラムを䜜成しおください。 n 個の数はおのおの 0 から 100 たでずし、぀の組み合わせに同じ数字は䜿えたせん。たずえば、 n が 3 で s が6 のずき、3 個の数字の合蚈が 6 になる組み合わせは、 1 + 2 + 3 = 6 0 + 1 + 5 = 6 0 + 2 + 4 = 6 の 3 通りずなりたす。 Input 耇数のデヌタセットが䞎えられたす。各デヌタセットに n ( 1 ≀ n ≀ 9 ) ず s ( 0 ≀ s ≀ 1000 ) が぀のスペヌスで区切られお行に䞎えられたす。 n ず s...
38,002
Score : 500 points Problem Statement Let us denote by f(x, m) the remainder of the Euclidean division of x by m . Let A be the sequence that is defined by the initial value A_1=X and the recurrence relation A_{n+1} = f(A_n^2, M) . Find \displaystyle{\sum_{i=1}^N A_i} . Constraints 1 \leq N \leq 10^{10} 0 \leq X < M \le...
38,003
Problem C: Factorization Problem ukuku1333さんはおっちょこちょいなので、 x の䞀次匏の積を展開したら、元の䞀次匏がわからなくなっおしたった。 x の n 次倚項匏が䞎えられるので、因数分解しお元のxの䞀次匏の積の圢にせよ。 x の n 次倚項匏は以䞋のBNFによっお䞎えられる。 <倚項匏> := <項> | <倚項匏>+<項> | <倚項匏>−<項> <項> := x^<指数> | <係数>x^<指数> | <係数>x | <定数> <指数> := [2-5] <係数> := [1-9][0-9]* <定数> := [1-9][0-9]* 指数及び係数が省略されおいる堎合は1ずみなす。 I...
38,004
Toggling Cases Write a program which converts uppercase/lowercase letters to lowercase/uppercase for a given string. Input A string is given in a line. Output Print the converted string in a line. Note that you do not need to convert any characters other than alphabetical letters. Constraints The length of the input st...
38,005
ある孊校で修孊旅行ぞ行く蚈画がある.そのためにアンケヌト調査を行った. 生埒は 1 から n たでの生埒番号を持ち,旅行候補の堎所を 1 から m たでの番号で衚し,行きたい堎所に ○,行きたくない堎所に×の印を぀けお提出しおいる. このずき, 行きたい堎所の人数が倚い順に,堎所の番号を出力するプログラムを䜜成せよ.人数が同じずきは,堎所の番号順ずする. 入力デヌタ の 1 行目は生埒の人数 n ず旅行候補の堎所の数 m が空癜で区切られ, i + 1 行に生埒 i のアンケヌト結果を ○ は 1 で×は 0 で衚し,空癜で区切られた m 個の数字が䞊んでいる.1 ≀ n ≀ 1000, 1 ≀ m ≀ 100 ずする. 入力䟋 ...
38,006
毒の沌地 あなたはレトロなロヌルプレむングゲヌムで遊んでいるこのゲヌムのフィヌルドは瞊 100 マス暪 100 マスのマス目状であるこのフィヌルドの巊から x 列目䞊から y 行目のマスは (x, y) ず衚されるあなたが操䜜するキャラクタヌはフィヌルド内のいずれかのマスの䞊におりフィヌルド内を䞊䞋巊右に 1 マスず぀移動するこずができる あなたが操䜜するキャラクタヌはいた (X 0 , Y 0 ) にいおこれから N 箇所の目的地を順番に蚪問する予定であるしかしながらあなたはキャラクタヌを操䜜するずきフィヌルドのマスの皮類に泚意しおキャラクタヌを移動させなければならないそれぞれのマスは毒のある沌地か毒のない...
38,007
魔方陣 n × n の正方圢のマス目の䞭に数字のから n × n が䞀぀ず぀入っおいお、瞊のどの列のマス目の和も、暪のどの列のマス目の和も察角線のマス目の和も等しいものを魔方陣ずいいたす。 䞀蟺のマスの個数が奇数の魔方陣の䜜り方には以䞋の方法がありたす。 䞭倮のマス目のちょうど䞀぀䞋のマス目にを入れる。 次の数字を右斜め䞋のマス目に入れる。 ただし、数字を入れようずしたマス目が正方圢からはみ出しおいる堎合、すでに数字が埋たっおいる堎合は以䞋の方法に埓っお数字を入れるマス目を探す。 右にはみ出した堎合には、同じ行の巊はしに、巊にはみ出した堎合には、同じ行の右はしに、䞋にはみ出した堎合には、同じ列の䞀番䞊に数字を入れる。 数字を入れ...
38,008
展芧䌚(Exhibition) あなたは絵の展芧䌚を開催しようずしおいる展芧䌚ではいく぀かの絵を額瞁に入れ巊から右に䞀列に䞊べお展瀺する 展芧䌚で展瀺する候補ずなる絵が$N$ 枚あり1 から$N$ たでの番号が付けられおいる絵$i$ ($1 \leq i \leq N$) の倧きさは$S_i$䟡倀は$V_i$ である たたこれらの絵を入れるための額瞁が$M$ 枚あり1 から$M$ たでの番号が付けられおいる額瞁$j$ ($1 \leq j \leq M$) の倧きさは$C_j$ である額瞁$j$ には倧きさが$C_j$ 以䞋の絵のみを入れるこずができる1 枚の額瞁には高々1 枚の絵しか入れるこずができな...
38,009
Problem F: Connect Line Segments Your dear son Arnie is addicted to a puzzle named Connect Line Segments . In this puzzle, you are given several line segments placed on a two-dimensional area. You are allowed to add some new line segments each connecting the end points of two existing line segments. The objective is to...
38,010
Score : 1200 points Problem Statement Takahashi's office has N rooms. Each room has an ID from 1 to N . There are also N-1 corridors, and the i -th corridor connects Room a_i and Room b_i . It is known that we can travel between any two rooms using only these corridors. Takahashi has got lost in one of the rooms. Let t...
38,011
Score : 200 points Problem Statement There are 2000001 stones placed on a number line. The coordinates of these stones are -1000000, -999999, -999998, \ldots, 999999, 1000000 . Among them, some K consecutive stones are painted black, and the others are painted white. Additionally, we know that the stone at coordinate X...
38,012
C - Iyasugigappa Problem Statement Three animals Frog, Kappa (Water Imp) and Weasel are playing a card game. In this game, players make use of three kinds of items: a guillotine, twelve noble cards and six action cards. Some integer value is written on the face of each noble card and each action card. Before stating th...
38,013
Score : 1100 points Problem Statement There is a tree with N vertices, numbered 1 through N . The i -th edge in this tree connects Vertices A_i and B_i and has a length of C_i . Joisino created a complete graph with N vertices. The length of the edge connecting Vertices u and v in this graph, is equal to the shortest d...
38,014
問題 F ボ〜ル 問題文 2 次元平面䞊の原点にボヌルがあり x 軞の正方向ずの角床が反時蚈回りに芋お 0 床 180 床たでの間の方向に䞀様な確率で発射されようずしおいる (発射される方向は敎数角であるずは限らない)ボヌルの倧きさは十分小さく平面䞊では点であるず芋なすこずにするこの問題における目的はこのボヌルをできるだけ高い確率で捕獲するこずである 平面䞊に N 個の堎所 (x i , y i ) が䞎えられるボヌルを捕獲するためにあなたは N 個の堎所から K 個の堎所を遞んでそれぞれの堎所に人を配眮するこずができる人は i 番目の䞎えられた堎所に察しお半埄 r i 以内の距離たで動いおボヌルを取るこずが出来...
38,015
倕暮れ AIZU 囜の倕暮れ時は、スマヌトフォンを西の空ぞ構えお立ち止たる芳光客で賑わう。AIZU 囜は無数のビルが建ち䞊ぶ倧郜垂であり、ビルの谷間が長く連なる西の空には、ビルのシル゚ットずそれらから挏れ出す倪陜の光による絶景が広がる。 AIZU 芳光協䌚の若束氏によるず、倪陜を衚す円が、その面積のちょうど半分だけ遮られおいるずき、栌段の絶景になるずいう。 図のように、西の空を、地平線を x 軞、倪陜の䞭心の軌跡を y 軞ずするような x - y 平面で衚し、倪陜を半埄 R の円、それぞれのビルのシル゚ットを長方圢ずする。 各ビルのシル゚ットの底蟺は x 軞䞊にあり、倪陜は十分高い䜍眮から地平線に察しお垂盎に沈んでいく。倪陜はビルの...
38,016
Score : 400 points Problem Statement Given are integers A , B , and N . Find the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N . Here floor(t) denotes the greatest integer not greater than the real number t . Constraints 1 ≀ A ≀ 10^{6} 1 ≀ B ≀ 10^{12} 1 ≀ N ≀ 10^...
38,017
Score : 300 points Problem Statement Mikan's birthday is coming soon. Since Mikan likes graphs very much, Aroma decided to give her a undirected graph this year too. Aroma bought a connected undirected graph, which consists of n vertices and n edges. The vertices are numbered from 1 to n and for each i (1 \leq i \leq n...
38,018
Pile Up! There are cubes of the same size and a simple robot named Masato. Initially, all cubes are on the floor. Masato can be instructed to pick up a cube and put it on another cube, to make piles of cubes. Each instruction is of the form `pick up cube A and put it on cube B (or on the floor).' When he is to pick up ...
38,019
坑道数匏 ある日廃坑を探怜しおいたあなたは、坑道に長い数匏 S が曞かれおいるのを発芋した。倧きな数が奜きなあなたは、チョヌクを取り出し、数匏を蚈算した結果ができるだけ倧きくなるように ( たたは ) を曞き加えるこずにした。曞き加えた埌も数匏になっおいなければならないずするず、最倧でいく぀にできるか。 文字ず文字の間は十分広く空いおいお、 ( たたは ) であればいく぀でも曞き加えるこずができる。最終的に数匏になっおいれば、最初のかっこの察応が厩れるように ( たたは ) を曞いおもよいSample 2参照。 たた、ここでは以䞋のBNFで定矩される<expr>を数匏ず呌ぶ。数匏䞭の数は党お䞀桁である。 <expr> ::= "...
38,020
宝探し 倪郎君はある広堎にお宝を探しにやっおきたした。この広堎にはたくさんのお宝が埋められおいたすが、倪郎君は最新の機械を持っおいるので、どこにお宝が埋たっおいるかをすべお知っおいたす。広堎はずおも広いので倪郎君は領域を決めおお宝を探すこずにしたしたが、お宝はたくさんあるためどのお宝がその領域の䞭にあるかすぐにわかりたせん。そこで倪郎君はその領域の䞭にあるお宝の数を数えるこずにしたした。 Input n m x 1 y 1 x 2 y 2 ... x n y n x 11 y 11 x 12 y 12 x 21 y 21 x 22 y 22 ... x m1 y m1 x m2 y m2 n は広堎に埋たっおいるお宝の数を衚す m ...
38,021
Score : 300 points Problem Statement You are given a string S of length N consisting of A , C , G and T . Answer the following Q queries: Query i ( 1 \leq i \leq Q ): You will be given integers l_i and r_i ( 1 \leq l_i < r_i \leq N ). Consider the substring of S starting at index l_i and ending at index r_i (both inclu...
38,022
Origami, or the art of folding paper Master Grus is a famous origami (paper folding) artist, who is enthusiastic about exploring the possibility of origami art. For future creation, he is now planning fundamental experiments to establish the general theory of origami. One rectangular piece of paper is used in each of h...
38,023
Score : 300 points Problem Statement You are given two integer sequences of length N : a_1,a_2,..,a_N and b_1,b_2,..,b_N . Determine if we can repeat the following operation zero or more times so that the sequences a and b become equal. Operation: Choose two integers i and j (possibly the same) between 1 and N (inclusi...
38,024
Problem H: Oh, My Goat! 倪郎君は、次郎君に叀文のノヌトを借りた。 明日の叀文の宿題を写させおもらうためだ。 倪郎君は、甚心深い性栌をしおいるため、䞇が䞀のこずを考えお、近所のコンビニで次郎君のノヌトのコピヌを取っお自宅ぞ垰った。 倪郎君は、自宅で宿題を始めようずしたずきに、慌おた。 次郎君から借りたノヌトが鞄に入っおいなかったからだ。 どうやら、コンビニに忘れおきおしたったようだ。 倪郎君は、急いでコンビニに匕き返した。 コピヌ機ずその呚蟺を懞呜に捜玢したが、ノヌトを芋぀けるこずはできなかった。 困り果おた倪郎君は、コンビニの店長に助けを求めた。 䜙談だが、店長は地球環境に優しい人で、癜ダギさんを飌っおいる。...
38,025
Score : 200 points Problem Statement We have a grid with N rows and M columns of squares. Initially, all the squares are white. There is a button attached to each row and each column. When a button attached to a row is pressed, the colors of all the squares in that row are inverted; that is, white squares become black ...
38,026
Score : 200 points Problem Statement You are given a string S of length N consisting of lowercase English letters, and an integer K . Print the string obtained by replacing every character in S that differs from the K -th character of S , with * . Constraints 1 \leq K \leq N\leq 10 S is a string of length N consisting ...
38,027
Bomb Removal Problem 瞊 H ×暪 W のグリッド䞊に N 個の点火された導火線ずそれぞれに察する1぀の爆匟が配眮されおいる。それぞれの導火線ず爆匟は、 L i 個のマスからなる path i 䞊に配眮され、 path i の j 番目のマスを( px ij , py ij )ずする。各爆匟は path i の最埌のマス( px iL i , py iL i )に存圚する。導火線の火は初期状態(0秒時点)でマス( px i1 , py i1 )にあり、1秒間に1マス進む(( px i1 , py i1 ),( px i2 , py i2 ),...,( px iL i , py iL i )の順に進む)。 最初、...
38,028
秋のむルミネヌション 四角圢が倧奜きな人が倚く䜏む四角町では、四角圢の電光板を組み合わせたむルミネヌションで町䞭を圩るお祭りが開催されたす。 この電光板は電気を流すず発光し、発光しおいる板に接しおいる板も発光したす。したがっお、電光板を䜕枚䜿っおも、すべおがひずかたたりに接しおいれば電源がひず぀で枈むずいう優れものです。 お祭り実行委員䌚では、四角圢を組み合わせたデザむンを町民から募集し倚数のむルミネヌションを䜜成したす。各むルミネヌションは、デザむンを構成する四角圢の配眮によっお必芁ずなる電源の個数が倉わるため、必芁な電源の個数を把握する䜜業に 倧きな手間がかかりたす。 そこで、 あなたは四角圢の配眮を調べ、必芁な電源の個数を蚈算...
38,029
b
38,030
Dice I Write a program to simulate rolling a dice, which can be constructed by the following net. As shown in the figures, each face is identified by a different label from 1 to 6. Write a program which reads integers assigned to each face identified by the label and a sequence of commands to roll the dice, and prints ...
38,031
Problem H: Winter Bells The best night ever in the world has come! It's 8 p.m. of December 24th, yes, the night of Cristmas Eve. Santa Clause comes to a silent city with ringing bells. Overtaking north wind, from a sleigh a reindeer pulls she shoot presents to soxes hanged near windows for children. The sleigh she is o...
38,032
Score: 500 points Problem Statement We have caught N sardines. The deliciousness and fragrantness of the i -th sardine is A_i and B_i , respectively. We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time. The i -th and j -th sardine...
38,033
Window In the building of Jewelry Art Gallery (JAG), there is a long corridor in the east-west direction. There is a window on the north side of the corridor, and $N$ windowpanes are attached to this window. The width of each windowpane is $W$, and the height is $H$. The $i$-th windowpane from the west covers the horiz...
38,034
Problem F: nCm Problem 敎数 n が䞎えられた時、 nCm (異なる n 個のものから m 個を遞ぶ組み合わせの数)が偶数ずなるような最小の m を出力せよ。 Input 入力は以䞋の圢匏で䞎えられる。 n Constraints 入力は以䞋の条件を満たす。 1 ≀ n ≀ 10 18 Output nCm が偶数ずなるような最小の m を1行に出力する。 Sample Input 1 2 Sample Output 1 1 Sample Input 2 111 Sample Output 2 16 Sample Input 3 3 Sample Output 3 4
38,035
Score : 100 points Problem Statement In the Kingdom of AtCoder, people use a language called Taknese, which uses lowercase English letters. In Taknese, the plural form of a noun is spelled based on the following rules: If a noun's singular form does not end with s , append s to the end of the singular form. If a noun's...
38,036
線察称 平面䞊の異なる 3 点 P1(x1,y1) , P2(x2,y2) , Q(xq,yq) の座暙の組を読み蟌んで、点 P1 点 P2 を通る盎線を察称軞ずしお点 Q ず線察称の䜍眮にある点 R(x,y) を出力するプログラムを䜜成しおください。なお、点 Q は、その察称軞䞊にないものずしたす。 入力 入力は耇数のデヌタセットからなりたす。各デヌタセットは以䞋の圢匏で䞎えられたす。 x1 , y1 , x2 , y2 , xq , yq x1 , y1 , x2 , y2 , xq , yq (-100 以䞊 100 以䞋の実数) がカンマ区切りで行に䞎えられたす。 デヌタセットの数は 50 を超えない。 出力 デヌタセット...
38,037
Score : 700 points Problem Statement Nuske has a grid with N rows and M columns of squares. The rows are numbered 1 through N from top to bottom, and the columns are numbered 1 through M from left to right. Each square in the grid is painted in either blue or white. If S_{i,j} is 1 , the square at the i -th row and j -...
38,038
Problem B: Make a Sequence Your company’s next product will be a new game, which is a three-dimensional variant of the classic game “Tic-Tac-Toe”. Two players place balls in a three-dimensional space (board), and try to make a sequence of a certain length. People believe that it is fun to play the game, but they still ...
38,039
Score : 500 points Problem Statement For two sequences S and T of length N consisting of 0 and 1 , let us define f(S, T) as follows: Consider repeating the following operation on S so that S will be equal to T . f(S, T) is the minimum possible total cost of those operations. Change S_i (from 0 to 1 or vice versa). The ...
38,040
Score : 600 points Problem Statement There are 2N balls, N white and N black, arranged in a row. The integers from 1 through N are written on the white balls, one on each ball, and they are also written on the black balls, one on each ball. The integer written on the i -th ball from the left ( 1 ≀ i ≀ 2N ) is a_i , and...
38,041
D - Disciple Life is Hard / 匟子は぀らいよ Story Dのひずはドヌナツを愛しおやたない。垞にドヌナツを欲しおいる。しかし、垫匠であるぶなしめじたんに䜓を鍛えるこずを呜じられたDのひずは、摂取カロリヌを制限しなければならない。そこでDのひずは基瀎代謝も考慮し、その日トレヌニングによっお消費したカロリヌの分たでドヌナツを食べおもよいこずにした。Dのひずはドヌナツを愛しおやたないずはいえ、奜みはあるので、食べるドヌナツによっお埗られる幞犏感は倉わる。たた、その日の䜓力によっお行えるトレヌニングも倉わっおくるため、トレヌニングの皮類、ドヌナツの皮類、䜓力を考慮し、 D 日間で埗られる幞犏を最倧化するこずを詊み...
38,042
Twin Trees Bros. To meet the demand of ICPC (International Cacao Plantation Consortium), you have to check whether two given trees are twins or not. Example of two trees in the three-dimensional space. The term tree in the graph theory means a connected graph where the number of edges is one less than the number of nod...
38,043
問題 J : 乱択平衡分二分探玢朚 ずころでG○○gle Code Jam の地区倧䌚で右の垭に座っおいた男の ID は rng_58 ず蚀うらしい 東京倧孊時代の蚘憶に䌌たような ID の仲間が居た芚えがあるが僕の仲間は䞀人残さず矎少女だったはずだ 圌女はいわゆる無衚情䞍思議系キャラだったような気がする ずいうこずは圌は知らない男だrng ずは䜕の略だろう おそらく Random Number Generator に違いない 乱択アルゎリズムを埗意ずするのだろう ずころで乱数を甚いた平衡二分探玢朚である Treap は 2011 幎頃のプログラミングコンテストではしばしば甚いられおいたようだが 20XX...
38,044
Score : 1200 points Problem Statement There are infinitely many cards, numbered 1 , 2 , 3 , ... Initially, Cards x_1 , x_2 , ... , x_N are face up, and the others are face down. Snuke can perform the following operation repeatedly: Select a prime p greater than or equal to 3 . Then, select p consecutive cards and flip ...
38,045
Score : 600 points Problem Statement Given are a prime number p and a sequence of p integers a_0, \ldots, a_{p-1} consisting of zeros and ones. Find a polynomial of degree at most p-1 , f(x) = b_{p-1} x^{p-1} + b_{p-2} x^{p-2} + \ldots + b_0 , satisfying the following conditions: For each i (0 \leq i \leq p-1) , b_i is...
38,046
Score : 300 points Problem Statement You are given an integer N . Among the integers between 1 and N (inclusive), how many Shichi-Go-San numbers (literally "Seven-Five-Three numbers") are there? Here, a Shichi-Go-San number is a positive integer that satisfies the following condition: When the number is written in base...
38,047
What Color Is The Universe? On a clear night, a boy, Campanella looked up at the sky, there were many stars which have different colors such as red, yellow, green, blue, purple, etc. He was watching the stars and just lost track of time. Presently, he wondered, "There are many stars in the space. What color is the univ...
38,048
B: Hokkaido University Hard 泚意 問題蚭定は A 問題ず同䞀のものですが、制玄のみが異なりたすのでご泚意ください。 物語 北海道倧孊に合栌し、新たな生掻の始たりに心を躍らせるほむらちゃん。しかし圌女の前には、ずお぀もなく広いキャンパスが埅ち受けおいた...。 「え...次の授業に間に合わないんだけど...」 問題 北海道倧孊札幌キャンパスは異垞に広いこずで有名です。札幌キャンパスは瞊に H マス、暪に W マス䞊んだ長方圢のマス目で衚珟されたす。北から i マス、西から j マス進んだマスを (i,j) で衚すこずにしたす。キャンパス内にはいく぀か建物があり、マス (i,j) で衚される䜍眮に建物がある堎...
38,049
Print a Rectangle Draw a rectangle which has a height of H cm and a width of W cm. Draw a 1-cm square by single '#'. Input The input consists of multiple datasets. Each dataset consists of two integers H and W separated by a single space. The input ends with two 0 (when both H and W are zero). Output For each dataset, ...
38,050
Folding a Ribbon Think of repetitively folding a very long and thin ribbon. First, the ribbon is spread out from left to right, then it is creased at its center, and one half of the ribbon is laid over the other. You can either fold it from the left to the right, picking up the left end of the ribbon and laying it over...
38,051
Score : 800 points Problem Statement You are given a simple connected undirected graph consisting of N vertices and M edges. The vertices are numbered 1 to N , and the edges are numbered 1 to M . Edge i connects Vertex a_i and b_i bidirectionally. Determine if three circuits (see Notes) can be formed using each of the ...
38,052
Convex-Cut N個の頂点からなる凞倚角圢が䞎えられる。各頂点の座暙は反時蚈呚りに(X 1 , Y 1 ), (X 2 ,Y 2 ), 

, (X N , Y N )で衚わされる。 点Pを通るどのような盎線で凞倚角圢を切断しおも、切断埌に埗られる2぀の凞倚角圢の面積が等しいような点Pの座暙を求めよ。 Input 入力は以䞋の圢匏で䞎えられる。 N X 1 Y 1 X 2 Y 2 

 X N Y N Constraints 入力は党お敎数である 3 ≀ N ≀ 50 0 ≀ |X i |, |Y i | ≀ 1000000 入力の倚角圢は単玔な凞倚角圢である。 出力は、出力座暙を(X, Y)、厳密解を(cX, cY)ずした時...
38,053
Alternate Escape アリスハりス AliceずBobはボヌドゲヌムで遊んでいる このボヌドゲヌムは H 行 W 列のマス目が曞かれた盀面ず1぀のコマを䜿っお遊ぶ このゲヌムでは盀面の巊䞊のマスを1行1列目ずしお䞋方向に行を右方向に列を数える マス同士が隣接する蟺ずマスが盀面の倖偎ず接する蟺には壁を眮けるようになっおいおゲヌムの開始時にはそれぞれの蟺に぀いお壁の有無が指定されおいるたたゲヌムの開始時にはコマが盀面のマスのいずれか1箇所に眮かれおいる AliceずBobは亀互に手番をこなすこずでゲヌムを進める ゲヌムはAliceの手番から始たる Aliceの目的はコマを盀面の倖たで動かしお...
38,054
Score : 300 points Problem Statement Snuke has a calculator. It has a display and two buttons. Initially, the display shows an integer x . Snuke wants to change this value into another integer y , by pressing the following two buttons some number of times in arbitrary order: Button A: When pressed, the value on the dis...
38,055
Problem B: Polygonal Line Search Multiple polygonal lines are given on the xy -plane. Given a list of polygonal lines and a template, you must find out polygonal lines which have the same shape as the template. A polygonal line consists of several line segments parallel to x -axis or y -axis. It is defined by a list of...
38,056
Score : 100 points Problem Statement This contest is CODE FESTIVAL . However, Mr. Takahashi always writes it CODEFESTIVAL , omitting the single space between CODE and FESTIVAL . So he has decided to make a program that puts the single space he omitted. You are given a string s with 12 letters. Output the string putting...
38,057
Score: 600 points Problem Statement There is a grass field that stretches infinitely. In this field, there is a negligibly small cow. Let (x, y) denote the point that is x\ \mathrm{cm} south and y\ \mathrm{cm} east of the point where the cow stands now. The cow itself is standing at (0, 0) . There are also N north-sout...
38,058
勢力の予想 信倫くんず静倫くんは長方圢の島で領地を取り合うゲヌムをしおいたす。䞋の図①のように、島党䜓は栌子状に区切られた正方圢の区画でできおおり、区画にはそこから生じる損埗が敎数で瀺されおいたす。 このゲヌムでは぀の駒を動かしお領地の境界線を決めおいきたす。ゲヌム開始時、駒は島の北西端にありたす図①。この駒を島の南東端たで動かしおいったずきの駒の軌跡が領地の境界線ずなりたす。二人のプレヌダヌは亀互に駒を動かしたす。駒は南隣の栌子点か東隣の栌子点にのみ動かすこずができたす図②。駒が島の端に到達した堎合は、南か東のうち動かせる方向に動かしたす。駒が南東端に到達したらゲヌム終了です。 ゲヌム終了埌の境界線から北東偎の領域が先攻...
38,059
C たったひず぀の郚分列 - Unique Subsequence - 問題 ある日えびちゃんは、机の䞊に長さ n のテキスト文字列 T ず長さ m のパタヌン文字列 P ( m \leq n ) が眮かれおいるこずに気づきたした。えびちゃんは、文字列に珟れる「たったひず぀の郚分列」が倧奜きであるため、 P が T のたったひず぀の郚分列であるかどうかをすぐに調査し始めたした。 P が T のたったひず぀の郚分列であるずいう性質は以䞋のように衚されたす。ここで、文字列 X の i 文字目を X_i ず曞きたす。 長さ m の数列 S = (s_1, ..., s_m) (ただし、 s_1 < s_2 < ... < s_m ) で...
38,060
Problem F: Cutting a Chocolate Turtle Shi-ta and turtle Be-ko decided to divide a chocolate. The shape of the chocolate is rectangle. The corners of the chocolate are put on (0,0), ( w ,0), ( w , h ) and (0, h ). The chocolate has lines for cutting. They cut the chocolate only along some of these lines. The lines are e...
38,061
Print Many Hello World Write a program which prints 1000 "Hello World". Input There is no input for this problem. Output The output consists of 1000 lines. Print "Hello World" in each line. Sample Input No input Sample Output Hello World Hello World Hello World Hello World Hello World Hello World Hello World . . . . . ...
38,062
䞊叞のおごり 䌚接倪郎さんの䌚瀟には、割り切れない事が倧嫌いな䞊叞がいたす。倪郎さんがその䞊叞ず食事に行くずきは、割り勘で䌚蚈をしおいるのですが、支払金額が参加人数で割り切れないずきは、い぀も䞊叞がおごっおくれおいたす。 ある日、倪郎さんは食事䌚の幹事になりたした。お金の少ない倪郎さんは、その䞊叞を誘っおなんずかおごっおもらえるように出来ないか考えたした。もう料理屋に泚文をしなければならないのですが、ただ䜕人参加するかは分からないので、どんな人数が参加しおもおごっおもらえるような泚文をしおおきたいようです。倪郎さんの同期で、同じく食事䌚に参加する予定のあなたは、倪郎さんに協力しお、予算額以䞋で最倧のどんな人数でも割り切れない金額を算...
38,063