task
stringlengths
0
154k
__index_level_0__
int64
0
39.2k
Problem J: Hanimon ハニカムモンスタヌはハニカム暡様の六角圢状の䞍思議な生き物である。 ハニカムモンスタヌには様々なサむズのものがあり、䞀蟺が N 個の正六角圢のマスから成るハニカムモンスタヌをサむズ N のハニカムモンスタヌずする。 䞀方、聖なる暡様はハニカムモンスタヌず同じく、六角圢ずしお定矩され1蟺が P 個の正六角圢のマスから成る聖なる暡様をサむズ P の聖なる暡様ずする。 ハニカムモンスタヌず聖なる暡様の圢の䟋を以䞋に瀺す。サむズは1蟺の正六角圢のマスの数に察応する。 図1: サむズの䟋 図2: ハニカムモンスタヌず聖なる暡様の䟋 (Sample Input 1) ハニカムモンスタヌず聖なる暡様の各マスに...
38,284
Score : 600 points Problem Statement You are given a string s consisting of A , B and C . Snuke wants to perform the following operation on s as many times as possible: Choose a contiguous substring of s that reads ABC and replace it with BCA . Find the maximum possible number of operations. Constraints 1 \leq |s| \leq...
38,285
問題文 1぀の陰関数 $Ax^2+Bxy+Cy^2+Dx+Ey+F=0$ で䞎えられる曲線ず、 $N$ 個の陰関数 $A_ix+B_iy+C_i=0$ で䞎えられる盎線がある。 これらの曲線ず盎線によっお平面がいく぀の領域に分割されおいるか求めよ。 以䞋はSample Inputのデヌタセットを図瀺したものである。 入力 入力は以䞋の圢匏に埓う。䞎えられる数は党お敎数である。 $N$ $A$ $B$ $C$ $D$ $E$ $F$ $A_1$ $B_1$ $C_1$ $...$ $A_N$ $B_N$ $C_N$ 制玄 $1 \leq N \leq 20$ $-100 \leq A,B,C,D,E,F \leq 100$ $-100...
38,286
Score : 200 points Problem Statement You have A 500 -yen coins, B 100 -yen coins and C 50 -yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total? Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for so...
38,287
Score : 400 points Problem Statement Let \mathrm{popcount}(n) be the number of 1 s in the binary representation of n . For example, \mathrm{popcount}(3) = 2 , \mathrm{popcount}(7) = 3 , and \mathrm{popcount}(0) = 0 . Let f(n) be the number of times the following operation will be done when we repeat it until n becomes ...
38,288
Problem 08: Provident Housewife 䞻婊の琎子はこの䞍況のさなか食費を抑えるこずに闘志を燃やしおいたした。毎朝新聞広告を必ずチェック。買う物リストず最も安く売られおいるお店をしっかりリストアップしお、お店をはしごしながら、゚プロン・サンダルずいう戊闘スタむルで自転車をこぎこぎ買い物に行きたす。 そこで倫のあなたは少しでも琎子の圹に立ずうず、埗意のプログラミングで家蚈簿プログラムを䜜成するこずにしたした。プログラムは、各スヌパヌに売っおいる品物の名前ず倀段円、琎子が必芁な品物を入力し、党おの品物を集めるための最小金額を出力したす。 琎子は家を出お必芁な品物を集め、家に戻っおこなければなりたせん。 そこで...
38,289
ゲヌムバランス あなたは冒険ゲヌムを䜜成しおいるこのゲヌムのプレむダヌは䞻人公を操䜜しお敵モンスタヌを倒し䞻人公のレベルを䞊げるこずで冒険を進めおいく䞻人公の初期レベルは 1 である このゲヌムには N 皮類の敵モンスタヌが甚意されおおり匱い順で i 番目の皮類の敵モンスタヌの匷さは s i である䞻人公が 1 回の戊闘を行うずきには次に戊う敵モンスタヌの皮類を自由に遞びちょうど 1 䜓の敵モンスタヌず戊闘を行う䞻人公は同じ皮類の敵モンスタヌず䜕回でも戊うこずができ䜕回でも倒すこずができる あなたはいたこのゲヌムのバランスを調敎するためにあるパラメヌタヌ X を決めようずしおいるパラメヌタヌ X は正の...
38,290
Bubble Sort Write a program of the Bubble Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: BubbleSort(A) 1 for i = 0 to A.length-1 2 for j = A.length-1 downto i+1 3 if A[j] < A[j-1] 4 swap A[j] and A[j-1] Note that, indices for array elements are bas...
38,291
颚よ、私の梅の銙りを届けおおくれ 匕っ越しが決たり、この地を去るこずになった。この土地自䜓に未緎は無いが、぀だけ気になるこずがある。それは、庭に怍えた梅の朚のこずだ。私は毎幎、この梅が花を咲かすこずを楜しみにしおいた。ここを離れた埌は春の楜しみが぀枛っおしたう。私の梅の銙りだけでも颚に乗っお匕っ越し先の家たで届き、春を楜したせおはくれないものか。 日本には春を象城する぀の花がある。梅・桃・桜の぀だ。匕っ越し先には、私の梅以倖にも、これらの花の銙りが届くだろう。しかし、私の梅の銙りだけが届く日数が最も倚い家に䜏みたい。 図のように、花の銙りは扇状に広がり、その領域は颚の向かう方向ず匷さによっお決たる。扇圢は颚の向かう方向 w...
38,292
Anchored Balloon A balloon placed on the ground is connected to one or more anchors on the ground with ropes. Each rope is long enough to connect the balloon and the anchor. No two ropes cross each other. Figure E-1 shows such a situation. Figure E-1: A balloon and ropes on the ground Now the balloon takes off, and you...
38,293
F: みこみヌ文字列 - Miko Mi String - 物語 みっこみっこみ〜みんなのアむドル田柀みこみこ今日は〜みこず䞀緒に〜文字列アルゎリズムの緎習しよ☆ みこのずっおおきの キャラ䜜り 合蚀葉「みっこみっこみ〜」はロヌマ字にするず “MikoMikoMi” になるみこ぀たり A= “Mi”, B= “Ko” ずするず ABABA の圢で曞けるっおこずなのこんな颚に適切に A ず B を決めるず ABABA の圢に分解できる文字列のこずを「みこみヌ文字列」っお蚀うわ文字列の名前にたでなっちゃうなんおみこはみんなの人気者みこね みんなでみこみヌ文字列をも〜っず䜿っおいくために䞎えられた文字列が...
38,294
関連商品 むンタヌネット通販サむトでは、ナヌザが珟圚芋おいる商品ず同じペヌゞに、過去に他のナヌザによっお、珟圚芋おいる商品ず䞀緒に買われた別の商品をいく぀か衚瀺しおくれたす。関連性の高いず思われる商品を提瀺するこずで、売り䞊げを䌞ばすこずができるず考えられおいるからです。 䌌たようなこずは、䞀緒に買われるこずが倚い商品を近くに配眮する、ずいう工倫ずしお、近所のスヌパヌマヌケットでも目にするこずができたす䟋えば、パンずゞャムのような。あなたの仕事は、商品配眮の工倫を助けるプログラムを曞くこずです。今回は、ある基準ずなる回数を蚭定し、䞀緒に買われた回数が基準回数以䞊である、぀の商品の組み合わせを求めたいず思いたす。 䞀緒に買われた...
38,295
Problem F: It Prefokery Pio You are a member of a secret society named Japanese Abekobe Group , which is called J. A. G. for short. Those who belong to this society often exchange encrypted messages. You received lots of encrypted messages this morning, and you tried to decrypt them as usual. However, because you recei...
38,296
K - XOR回廊 問題文 KU倧孊では䞀颚倉わったラリヌゲヌムが人気である このゲヌムの舞台であるサヌキットには N 個の䌑憩所ず M 個の道があり i 番目の道は f i 番目の䌑憩所ず t i 番目の䌑憩所の間にある すべおの道にはチェックポむントが䞀぀ず぀存圚し道 i のチェックポむントを通過するずどちらの向きで通っおも p i の埗点がXORで加算される XORで 加算される倧事なこずなので2回蚀いたした このゲヌムでは同じ䌑憩所や道を䜕床通っおも良いし ゎヌルにたどり着いおもそのたたラリヌを続行するこずができるが 道の途䞭にあるチェックポむントを迂回しお別の䌑憩所ぞ行くこずは犁止されおいる そのた...
38,297
Score : 300 points Problem Statement There are N cities on a number line. The i -th city is located at coordinate x_i . Your objective is to visit all these cities at least once. In order to do so, you will first set a positive integer D . Then, you will depart from coordinate X and perform Move 1 and Move 2 below, as ...
38,299
Score : 200 points Problem Statement Alice and Bob are controlling a robot. They each have one switch that controls the robot. Alice started holding down her button A second after the start-up of the robot, and released her button B second after the start-up. Bob started holding down his button C second after the start...
38,300
Score : 600 points Problem Statement We have one slime. You can set the health of this slime to any integer value of your choice. A slime reproduces every second by spawning another slime that has strictly less health. You can freely choose the health of each new slime. The first reproduction of our slime will happen i...
38,301
Min Element 数列 a_1,a_2,..,a_N が䞎えられたす。 この数列の最小倀の番号を求めおください。 最小倀が耇数の堎所にあるずきは、番号の最も小さいものを答えおください。 入力 N a_1 a_2...a_N 出力 a_i が数列の最小倀ずなるような i のうち、最も小さいものを出力せよ。 制玄 1 \leq N \leq 10^5 1 \leq a_i \leq 10^9 入力䟋 6 8 6 9 1 2 1 出力䟋 4
38,302
Difference of Big Integers Given two integers $A$ and $B$, compute the difference, $A - B$. Input Two integers $A$ and $B$ separated by a space character are given in a line. Output Print the difference in a line. Constraints $-1 \times 10^{100000} \leq A, B \leq 10^{100000}$ Sample Input 1 5 8 Sample Output 1 -3 Sampl...
38,303
I: 砎壊 (Ravage) サンタクロヌスは、街のむルミネヌションに匕っかかり、壊した。 むルミネヌションにはN個の電球があり、$i$ 番目の電球は電圧が $A_i$ 以䞊 $B_i$ 以䞋のずきにしか付かなくなっおしたった。 電圧はむルミネヌションのどこでも同じにする必芁がある。 電圧を調節するこずで、最倧いく぀の電球を同時に光らせるこずができるか求めよ。 入力 1 行目には敎数 $N$ が䞎えられる。 続く $N$ 行のうち $i$ 行目には $A_i, B_i$ が空癜区切りで䞎えられる。 出力 同時に光らせるこずができる電球の個数の最倧倀を出力せよ。 制玄 $N$ は $1$ 以䞊 $100 \ 000$ 以䞋の敎数 $A...
38,304
Score : 300 points Problem Statement There are N cities numbered 1 through N , and M bidirectional roads numbered 1 through M . Road i connects City A_i and City B_i . Snuke can perform the following operation zero or more times: Choose two distinct cities that are not directly connected by a road, and build a new road...
38,305
Problem E: Cyclic Shift Sort Problem 長さ $N$ の順列 $P = \{ P_1, P_2, \ldots, P_N \} $ ず敎数 $K$ が䞎えられる。 以䞋の操䜜を $0$ 回以䞊任意の回数繰り返すこずで、順列 $P$ を単調増加にするこずができるかどうか刀定せよ。 敎数 $x \ (0 \le x \le N-K)$ を遞ぶ。 $ P_{x+1}, \ldots, P_{x+K} $ を巡回右シフトする ただし、郚分列 $U=U_1, \ldots, U_M$ の巡回右シフトずは、 $U=U_1, \ldots, U_M$ を $U=U_M, U_1, \ldots, U_{M-1}$...
38,306
Score : 100 points Problem Statement Decades have passed since the beginning of AtCoder Beginner Contest. The contests are labeled as ABC001 , ABC002 , ... from the first round, but after the 999 -th round ABC999 , a problem occurred: how the future rounds should be labeled? In the end, the labels for the rounds from t...
38,307
Score : 100 points Problem Statement Two deer, AtCoDeer and TopCoDeer, are playing a game called Honest or Dishonest . In this game, an honest player always tells the truth, and an dishonest player always tell lies. You are given two characters a and b as the input. Each of them is either H or D , and carries the follo...
38,308
Score : 100 points Problem Statement How many ways are there to choose two distinct positive integers totaling N , disregarding the order? Constraints 1 \leq N \leq 10^6 N is an integer. Input Input is given from Standard Input in the following format: N Output Print the answer. Sample Input 1 4 Sample Output 1 1 There...
38,309
Problem E: Geometric Map Your task in this problem is to create a program that finds the shortest path between two given locations on a given street map, which is represented as a collection of line segments on a plane. Figure 4 is an example of a street map, where some line segments represent streets and the others ar...
38,310
チケットの売り䞊げ 今日は、アむヅ・゚ンタヌテむンメント瀟むチオシのアむドルグルヌプ「アカベココボりシ」のチケット発売日です。チケットには以䞋の皮類がありたす。 垭 6000円 垭 4000円 垭 3000円 垭 2000円 販売責任者のあなたは、ドキドキしながら発売開始を埅っおいたす。いよいよ発売開始。売れ行き絶奜調です 発売開始からしばらく経ったずころで、それたでの泚文をたずめた衚を受け取りたした。衚の各行には、それたでに売れたチケットの皮類ず枚数が曞いおありたす。ただし、チケットの皮類がの順に珟れるずは限りたせん。この衚の行ごずの売䞊金額を求めるプログラムを䜜成しおください。 入力 入力デヌタは以䞋...
38,311
Problem A: Rational Irrationals Rational numbers are numbers represented by ratios of two integers. For a prime number p , one of the elementary theorems in the number theory is that there is no rational number equal to √ p . Such numbers are called irrational numbers. It is also known that there are rational numbers a...
38,312
Big Maze あなたは Jumbo Amusement Garden略しお「JAG」ず呌ばれる巚倧な遊園地で働いおいるこの遊園地の敷地は広倧でアトラクションもこずごずく巚倧なものが蚭眮される この床JAGに新たな巚倧迷路アトラクション「Big Maze」が導入されるこずになった Big Maze の圢状は平面図で芋るず瞊暪共に N マスの正方圢状の迷路 M 個を隣接する巊右の蟺同士を繋ぎ合わせ瞊 N マス暪 NM マスの長方圢状になる予定である M 個の迷路を巊からどの順番で繋ぎ合わせるかはあらかじめ決たっおいるが隣り合う迷路のどの蟺同士を繋ぎ合わせるかは未定である M 個の迷路を繋ぎ合わせる前に各...
38,313
Problem B: Monster Factory 株匏䌚瀟南倩堂は, Packet Monster ずいうゲヌム゜フトを発売しおいる. このゲヌムはモンスタヌを捕たえ, 育お, 戊わせるずいう趣旚のもので, 䞖界䞭で倧人気のゲヌムであった. このゲヌムには埓来のゲヌムには無い特城があった. このゲヌムには Red ず Green ずいう2぀のバヌゞョンがあり, それぞれのゲヌムで捕たえられるモンスタヌが異なるのだ. Red でしか捕たえられないモンスタヌを Green で入手するには, 通信亀換ずいうシステムを䜿う. ぀たり, 自分の゜フト内のモンスタヌず友達の゜フト内のモンスタヌを亀換するこずができるのだ. このシステムは P...
38,314
Runaway Domino ``Domino effect'' is a famous play using dominoes. A player sets up a chain of dominoes stood. After a chain is formed, the player topples one end of the dominoes. The first domino topples the second domino, the second topples the third and so on. You are playing domino effect. Before you finish to set u...
38,315
Flame of Nucleus Year 20XX — a nuclear explosion has burned the world. Half the people on the planet have died. Fearful. One city, fortunately, was not directly damaged by the explosion. This city consists of N domes (numbered 1 through N inclusive) and M bidirectional transportation pipelines connecting the domes. In ...
38,316
Problem F: Coupling Problem 愛接倧孊では毎幎倧芏暡な合コンが行われおいたす。 今幎は N 人の男性ず M 人の女性が参加したす。 それぞれ男性は0から順に N −1たでIDが割り振られおり、女性は0から順に M −1たでIDが割り振られおいたす。 この合コンでは自分の「倧奜きな人」ず「そこそこ奜きな人」のIDを提瀺したす。 男性はそれぞれ女性のIDを、女性はそれぞれ男性のIDを提瀺したす。 その埌、以䞋のルヌルに埓っおカップルが成立したす。 男性は耇数の女性、女性は耇数の男性ずカップルになっおはいけない。 互いに「倧奜きな人」ず提瀺した男性ず女性でペアができる。 そこから、任意のペアを遞びカップルを䜜るこ...
38,317
G - 村 問題文 き぀ねのしえるは䌑暇でずある小さな村を蚪れおいる圌女が驚いたのはその村の衚札がも぀性質である 村には N 個の家屋があるここでは簡単のため村は 2 次元平面であるずし家屋はこの平面䞊の点であるず芋なす それぞれの家屋には衚札が 1 個蚭けられおおりその家の苗字を衚しおいたしえるは村の䞭を蚪問するに぀れおこの村の衚札が次のような性質を持っおいるこずに気付いた ある実数 R が存圚する もし 2 ぀の家屋の距離が R 以䞋であるならその 2 ぀の家屋は同じ衚札を持぀ もし 2 ぀の家屋の距離が 3R 以䞊であるならその 2 ぀の家屋は異なる衚札を持぀ 任意の 2 ぀の家屋の距離は R...
38,318
Problem F: Controlled Tournament National Association of Tennis is planning to hold a tennis competition among professional players. The competition is going to be a knockout tournament, and you are assigned the task to make the arrangement of players in the tournament. You are given the detailed report about all parti...
38,319
村の道路蚈画 䌚接囜の若束平野に、集萜が点圚しおいたした。いく぀かの集萜の間はたっすぐで互いに行き来できる道で繋がっおいお、平野にあるどの集萜の間も道を蟿っお行き来ができたす。それぞれの道には長さに応じた維持費がかかりたすが、すべおの集萜が資金を出し合っお道を維持しおいたした。 あるずき、すべおの集萜が䞀぀の村にたずたるこずが決たり、村を囲む境界線を匕くこずになりたした。囜の決たりでは、村を構成するどの぀の集萜を結んだたっすぐな線も、村の倖を通っおはいけたせん境界線䞊を通るこずは蚱されたす。さらに、䌚接囜では村を囲む境界線䞊に道がなければなりたせん。境界線䞊に道がない堎所には、囜が新たに道を䜜っおくれたす。 しかし、道の維持費...
38,320
D: Complex Oracle - Complex Oracle - 問題 ※この問題はリアクティブ問題ですすなわちサヌバヌ偎に甚意されたプログラムず察話的に応答するこずで正答を導くプログラムを䜜成する必芁がありたす たた、サヌバヌ偎のプログラムも蚈算機資源を共有する関係䞊、サヌバヌだけで最倧 3 sec皋床の実行時間、最倧 300 MB皋床のメモリを䜿甚する堎合がありたすので、TLE・MLEにお気を぀けください。 あいずにゃんは若ヶ束高校のプログラミングコンテスト郚、通称ぷろこん郚に所属する2幎生である。芋目麗しい。あいずにゃんはその小さな䜓も無限に存圚するチャヌムポむントの1぀であるが、本人はコンプレックスを感じおいる...
38,322
Integral Rectangles Let us consider rectangles whose height, h , and width, w , are both integers. We call such rectangles integral rectangles . In this problem, we consider only wide integral rectangles, i.e., those with w > h . We define the following ordering of wide integral rectangles. Given two wide integral rect...
38,323
Problem Statement Have you experienced $10$-by-$10$ grid calculation? It's a mathematical exercise common in Japan. In this problem, we consider the generalization of the exercise, $N$-by-$M$ grid calculation. In this exercise, you are given an $N$-by-$M$ grid (i.e. a grid with $N$ rows and $M$ columns) with an additio...
38,324
血液型 ある孊玚の生埒の出垭番号ず ABO 血液型を保存したデヌタを読み蟌んで、おのおのの血液型の人数を出力するプログラムを䜜成しおください。なお、ABO 血液型には、A 型、B 型、AB 型、O 型の皮類の血液型がありたす。 Input カンマで区切られた出垭番号ず血液型の組が、耇数行に枡っお䞎えられたす。出垭番号は 1 以䞊 50 以䞋の敎数、血液型は文字列 "A", "B", "AB" たたは "O" のいずれかです。生埒の人数は 50 を超えたせん。 Output 行目に A 型の人数 行目に B 型の人数 行目に AB 型の人数 行目に O 型の人数 を出力したす。 Sample Input 1,B 2,A 3,...
38,325
Bit Operation II Given two non-negative decimal integers $a$ and $b$, calculate their AND (logical conjunction), OR (logical disjunction) and XOR (exclusive disjunction) and print them in binary representation of 32 bits. Input The input is given in the following format. $a \; b$ Output Print results of AND, OR and XOR...
38,326
山ぞ垰そう 近幎むズア囜では、山から街に降りおくる動物に悩たされおいる。あなたは動物を山ぞ垰そうず研究を重ね、以䞋のこずを明らかにした。 それぞれの動物には固有の名前が぀いおいる。 䜓の動物に぀いお、䞀方の動物の名前のどこかの䜍眮に文字を挿入するず、もう䞀方の動物の名前ず䞀臎する堎合、これらをペアにしお山ぞ垰すこずができる。 䞀床山ぞ垰った動物が、再び街に降りおくるこずはない。 あなたは、街に降りおきた動物を、この方法でどのくらい山ぞ垰すこずができるかを蚈算するこずにした。 街に降りおきた動物の名前が䞎えられたずき、この方法で最倧いく぀のペアを山ぞ垰すこずができるかを求めるプログラムを䜜成せよ。 入力 入力は以䞋の圢匏で䞎えられ...
38,327
C - チョコレヌト 目の前に M \times N 個のピヌスでできた板チョコがある ピヌスには甘いピヌスず蟛いピヌスの2皮類がありできるだけ倚くの甘いピヌスを食べたい しかし板チョコの食べ方にはルヌルがあり以䞋のルヌルを守らなければならない あるピヌスを食べるためにはそのピヌスの真䞊に隣接するピヌスが存圚せず加えおそのピヌスの少なくずも巊右どちらかにはピヌスが存圚しない必芁がある 䟋えば図のような圢のチョコレヌトでは赀く色付けされたピヌスを次に食べるこずができる たた奇劙なこずにあるピヌスを食べるずそのピヌスの䞊䞋巊右に隣接しおいおか぀ただ食べられおいないピヌスの味が倉化する (甘いピヌスは蟛く蟛い...
38,328
Score : 200 points Problem Statement There are N bags of biscuits. The i -th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congr...
38,329
Score : 700 points Problem Statement You are given an integer N . Determine if there exists a tree with 2N vertices numbered 1 to 2N satisfying the following condition, and show one such tree if the answer is yes. Assume that, for each integer i between 1 and N (inclusive), Vertex i and N+i have the weight i . Then, fo...
38,330
Problem B: Turn Left Taro got a driver’s license with a great effort in his campus days, but unfortunately there had been no opportunities for him to drive. He ended up obtaining a gold license. One day, he and his friends made a plan to go on a trip to Kyoto with you. At the end of their meeting, they agreed to go aro...
38,331
Score : 1400 points Problem Statement You are given P , a permutation of (1,\ 2,\ ...\ N) . A string S of length N consisting of 0 and 1 is a good string when it meets the following criterion: The sequences X and Y are constructed as follows: First, let X and Y be empty sequences. For each i=1,\ 2,\ ...\ N , in this or...
38,332
Score : 200 points Problem Statement There are N cities and M roads. The i -th road (1≀i≀M) connects two cities a_i and b_i (1≀a_i,b_i≀N) bidirectionally. There may be more than one road that connects the same pair of two cities. For each city, how many roads are connected to the city? Constraints 2≀N,M≀50 1≀a_i,b_i≀N ...
38,333
Score : 400 points Problem Statement We have N bricks arranged in a row from left to right. The i -th brick from the left (1 \leq i \leq N) has an integer a_i written on it. Among them, you can break at most N-1 bricks of your choice. Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer...
38,334
Score : 600 points Problem Statement There are N dots in a two-dimensional plane. The coordinates of the i -th dot are (x_i, y_i) . We will repeat the following operation as long as possible: Choose four integers a , b , c , d (a \neq c, b \neq d) such that there are dots at exactly three of the positions (a, b) , (a, ...
38,335
Score : 200 points Problem Statement Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1 , Doughnut 2 , ..., Doughnut N . In order to make one Doughnut i (1 ≀ ...
38,336
Problem H: Hth Number Problem 長さ$N$の文字列$S$がある。$S$に含たれる文字はすべお0以䞊9以䞋の数字である。 $S$のすべおの郚分文字列から䜜られる数を党列挙しおできた項数$\frac{N\times(N+1)}{2}$の数列を䜜った時、 その数列の䞭で$H$番目に小さい倀を求めよ。 Input 入力は以䞋の圢匏で䞎えられる。 $N$ $H$ $S$ 入力はすべお敎数で䞎えられる。 1行目に$N$ず$H$が空癜区切りで䞎えられる。 2行目に長さ$N$の文字列$S$が䞎えられる。 Constraints 入力は以䞋の条件を満たす。 $1 \leq N \leq 10^5$ $1 \leq H \l...
38,337
Score : 100 points Problem Statement You are given a grid of N rows and M columns. The square at the i -th row and j -th column will be denoted as (i,j) . Some of the squares contain an object. All the remaining squares are empty. The state of the grid is represented by strings S_1,S_2,\cdots,S_N . The square (i,j) con...
38,338
Score : 100 points Problem Statement A biscuit making machine produces B biscuits at the following moments: A seconds, 2A seconds, 3A seconds and each subsequent multiple of A seconds after activation. Find the total number of biscuits produced within T + 0.5 seconds after activation. Constraints All values in input ar...
38,339
Array Update 2 Problem 項数 N 、初項 a 、公差 d の等差数列 A がある。 以䞋の圢匏で、数列を曞き換える M 個の呜什文が䞎えられるので、䞎えられた順序で M 回 数列 A を曞き換えたずきの数列 A の K 項目の倀を求めなさい。 i 番目の呜什文は3぀の敎数 x i , y i , z i で䞎えられる。(1 ≀ i ≀ M ) x i が0だった堎合、 y i 項目から z i 項目たでの区間においお、倀の順序を反転する。 x i が1だった堎合、 y i 項目から z i 項目たでの区間においお、それぞれの倀を1増加させる。 x i が2だった堎合、 y i 項目から z i 項目たでの区間に...
38,340
問題文 委員長の魔女 PATRICIA は蜘蛛のような糞を吐き結界の䞭で暮らしおいる䜿い魔の MATHIEU は委員長の魔女が吐いた糞を匕っぱり自圚に空を飛んでいる糞は空間䞊の線分ずみなすこずにする 暁矎ほむら は委員長の魔女に察しお攻撃を仕掛けようずし爆匟ず間違えお花火玉を投げ蟌んでしたったその結果それぞれの糞に぀いお魔女から距離 p_1, ..., p_M の䜍眮にある郚分が切れるだけずなっおしたった花火玉を投げる前それぞれの糞に぀いお糞の 2 ぀の端点ず魔女はこの順番で同䞀盎線䞊に䞊んでおり端点のどちらか䞀方を䜿い魔が匕っ匵っおいた爆発で糞は切れ䜿い魔が持っおいた郚分ずそこから䞀぀眮きの郚分を残し...
38,342
A沢山の皮類の林檎 (Many Kinds of Apples) Problem Statement Apple Farmer Mon has two kinds of tasks: "harvest apples" and "ship apples". There are N different species of apples, and N distinguishable boxes. Apples are labeled by the species, and boxes are also labeled, from 1 to N . The i -th species of apples are stored in th...
38,343
Problem G: Sports Days 䌚接倧孊附属小孊校䌚接倧小は日本有数の競技プログラマヌ逊成校ずしお有名である。 もちろん、運動䌚に参加しおいるずきでさえアルゎリズムの修行を欠かせない。 競技プログラミング郚郚長のあなたはもちろんこの倧䌚でも勝利したい。 今回はある競技に泚目する。 ある競技ずは䌚接倧小で行われおいる䌝統的な競技だ。 校庭にコヌンがn個眮いおある。 コヌンは4色甚意されおいる。 コヌンのいく぀かのペアは癜線で描かれた矢印で結ばれおいる。 矢印は片偎だけに぀いおおり、敎数が䜵蚘されおいる。 競技者はk人1チヌムずしお行動する。 あるスタヌト地点のコヌンからゎヌル地点のコヌンたで矢印の䞊をその向きに移動す...
38,344
Score : 700 points Problem Statement We have a rooted binary tree with N vertices, where the vertices are numbered 1 to N . Vertex 1 is the root, and the parent of Vertex i ( i \geq 2 ) is Vertex \left[ \frac{i}{2} \right] . Each vertex has one item in it. The item in Vertex i has a value of V_i and a weight of W_i . N...
38,345
こぶたぬき぀ねこ A子さんの家に芪戚のB男君がやっおきたした。圌は3歳で歌が倧奜きです。圌は幌皚園でならった「こぶたぬき぀ねこ」(山本盎玔䜜詞・䜜曲)ずいう歌を䞀生懞呜に歌っおいたす。この歌では、4぀のこずば「こぶた」 「たぬき」 「き぀ね」「ねこ」が順にしりずりになっおいお、さらに最埌の音ず最初の音が同じになっおいたす。B男君は、A子さんに、同じようなしりずりが、B男君が蚀った単語から䜜れるか教えお欲しいず蚀われたした。 そこで、A子さんを助けるために、䞎えられた単語から、その単語をすべお䜿っお、順にしりずりを぀くり、その䞊で、 第1 の単語の最初の文字ず最終の単語の最埌の文字が同じであるようにできるか吊かを刀定するプログラムを䜜...
38,346
G: 䞀番遠い町 問題文 $N$ 個の町ず $N-1$ 個の道がありたす。 すべおの町ず道にはそれぞれ $1$ から $N$, $1$ から $N-1$ の番号が぀いおいたす。 道 $i$ は町 $a_i$ ず町 $b_i$ を距離 $d_i$ で双方向に぀ないでいたす。 最初はすべおの道が通行可胜な状態であり、どの町からもいく぀かの道を通るこずですべおの町に行くこずができたす。 すいばかくんは最初、町 $1$ にいたす。 $Q$ 個のク゚リが䞎えられるので順番に凊理しおください。ク゚リは $3$ 皮類あり、以䞋の圢匏で䞎えられたす。 ク゚リ $1$ : 1 x ― すいばかくんが町 $x$ に移動する。ただし、このク゚リ時点で、す...
38,347
Problem E: Enclose Points There are $N$ points and $M$ segments on the $xy$-plane. Each segment connects two of these points and they don't intersect each other except at the endpoints. You are also given $Q$ points as queries. Your task is to determine for each query point whether you can make a polygon that encloses ...
38,348
Problem C: Cut the Cake Today is the birthday of Mr. Bon Vivant, who is known as one of the greatest pâtissiers in the world. Those who are invited to his birthday party are gourmets from around the world. They are eager to see and eat his extremely creative cakes. Now a large box-shaped cake is being carried into the ...
38,349
Swapping Characters You are given a string and a number k . You are suggested to generate new strings by swapping any adjacent pair of characters in the string up to k times. Write a program to report the lexicographically smallest string among them. Input The input is given in the following format. s k The first line ...
38,350
NINJA GAME 新䜜ゲヌム "NIN JA G AME" が぀いに発売ずなったこのゲヌムではプレむダヌは二次元マップ䞊の忍者を操䜜しお移動を行う二次元マップは x 軞たたは y 軞のどちらか䞀方に平行な蟺のみからなる自己亀差のない倚角圢で衚されるいた倚角圢の内郚に存圚するスタヌト地点からゎヌル地点ぞず移動する必芁がある 移動は䞊䞋巊右ず斜め45°の8方向が可胜でいずれかの察応するコマンドを入力するず指定した方向に自動で進み続けるこの自動移動の最䞭の任意のタむミングで別のコマンドを入力した堎合即座に移動方向の転換が可胜であるあなたの目暙はこのゲヌムでの実瞟を解陀するため最小のコマンド入力回数でスタヌト...
38,351
Cube Surface Puzzle Given a set of six pieces, “Cube Surface Puzzle” is to construct a hollow cube with filled surface. Pieces of a puzzle is made of a number of small unit cubes laid grid-aligned on a plane. For a puzzle constructing a cube of its side length n , unit cubes are on either of the following two areas. Co...
38,352
Problem A: Adhoc Translation One day, during daily web surfing, you encountered a web page which was written in a language you've never seen. The character set of the language was the same as your native language; moreover, the grammar and words seemed almost the same. Excitedly, you started to "decipher" the web page....
38,353
A : Soccer / サッカヌ 問題文 A囜ずB囜の間でAIサッカヌの詊合をした。あなたの手元には、ある時刻にボヌルを持っおいた遞手ずその䜍眮を蚘録した衚がある。衚は N 行からなり、䞊から i 番目の行は次に瀺す芁玠からなる。 フレヌム数 f_i ボヌルを持っおいる遞手の背番号 a_i その遞手が属するチヌム t_i その遞手の䜍眮を衚す座暙 x_i , y_i フレヌム数ずは、ゲヌムの開始時刻に 0 に蚭定され、 1 / 60 秒ごずに 1 加算される敎数のこずである。䟋えば、ゲヌム開始からちょうど 1.5 秒埌のフレヌム数は 90 である。 背番号は各チヌム内の 11 人の遞手に䞀意にふられる敎数である。さらに、衚䞭の連続...
38,354
Score : 300 points Problem Statement Takahashi has come to an integer shop to buy an integer. The shop sells the integers from 1 through 10^9 . The integer N is sold for A \times N + B \times d(N) yen (the currency of Japan), where d(N) is the number of digits in the decimal notation of N . Find the largest integer tha...
38,355
Problem A: Cubist Artwork International Center for Picassonian Cubism is a Spanish national museum of cubist artworks, dedicated to Pablo Picasso. The center held a competition for an artwork that will be displayed in front of the facade of the museum building. The artwork is a collection of cubes that are piled up on ...
38,356
Problem D: THE BYDOLM@STER Description THE BYDOLM@STER(バむドルマスタヌ)ずは1rem瀟より2010/4/1にEXIDNAで発売が予定されおいる育成シミュレヌションゲヌムである。䞀応断っおおくが、今月初めにネットワヌク接続サヌビスが停止した某アヌケヌドゲヌムずはたぶん関係が無い。 このゲヌムはバむドルたちからプロデュヌスするナニット(線隊)のメンバヌを遞択し、メンバヌたちずのレッスンやコミュニケヌションを通じお、圌女(圌)らをバむドルの頂点、トップバむドルに育お䞊げるゲヌムである。 各バむドルには胜力倀ずしおボヌカル、ダンス、ルックスの3぀のパラメヌタを持ち、ナニットの胜力倀はナ...
38,357
郜垂間の距離 地球䞊の2 郜垂の北緯ず東経を入力ずし、地衚距離を蚈算しお出力するプログラムを䜜成しおください。ただし、地球は半埄 6,378.1 km の球ずし、2 点間の地衚距離ずはこの球面に沿った最短距離です。たた、南半球でも南緯は甚いずに北緯 0 ~ -90 床を甚い、グリニッゞ子午線の西でも西経は甚いずに東経 180 ~ 360 床を甚いるこずずしたす。地衚距離は km 単䜍で求め、小数点以䞋は四捚五入し、敎数倀ずしお出力しおください。 以䞋に䞻芁郜垂の北緯、東経の䟋を瀺したす。 地名 北緯(床) 東経(床) 東京 35.68 139.77 シンガポヌル 1.37 103.92 シドニヌ -33.95 151.18 シカゎ...
38,358
IOI 列車で行こう(Take the 'IOI' train) IOI 囜ではこのたび新たに鉄道を敷蚭したIOI 囜の鉄道を走る列車はいく぀かの車䞡が連結されたものであり車䞡には I , O の 2 皮類がある車䞡はそれぞれ異なる皮類の車䞡ずしか連結できないたた列車に運転垭を蚭ける関係䞊列車の䞡端の車䞡は皮類 I でなければならない列車は車䞡の皮類を衚す文字を順に぀なげた文字列で衚され列車の長さはその文字列の長さであるずするたずえば IOIOI の順に車䞡を連結するず長さ 5 の列車を線成できたた車䞡 I は単独で長さ 1 の列車である車䞡を OIOI や IOOI ずいった順に䞊べおも列車を線成するこずは...
38,359
プラスティック板 機械に蟺・察角線の長さのデヌタを入力し、プラスティック板の型抜きをしおいる工堎がありたす。この工堎では、サむズは様々ですが、平行四蟺圢の型のみを切り出しおいたす。あなたは、切り出される平行四蟺圢のうち、長方圢ずひし圢の補造個数を数えるように䞊叞から呜じられたした。 「機械に入力するデヌタ」を読み蟌んで、長方圢ずひし圢の補造個数を出力するプログラムを䜜成しおください。 Input 入力は以䞋の圢匏で䞎えられたす。 a 1 , b 1 , c 1 a 2 , b 2 , c 2 : 機械に入力するデヌタが耇数行に䞎えられたす。 i 行目に i 番目の平行四蟺圢の隣り合う蟺の長さを衚す敎数 a i , b i ず察角線...
38,360
ピザ 問題 JOI ピザでは,垂の䞭心郚を通る党長 d メヌトルの環状線の沿線䞊でピザの宅配販 売を行っおいる. JOI ピザは,環状線䞊に n 個の店舗 S 1 , ... , S n を持぀.本店は S 1 である. S 1 から S i たで,時蚈回りに環状線を移動したずきの道のりを d i メヌトルずおく. d 2 , ... , d n は 1 以䞊 d - 1 以䞋の敎数である. d 2 , ... , d n は党お異なる. ピザの泚文を受けるず, ピザが冷めないように, 宅配先たでの移動距離がもっずも短い店舗でピザを焌き宅配する. 宅配先の䜍眮は 0 以䞊 d - 1 以䞋の敎数 k で衚される.これは, 本店 S ...
38,361
立方䜓の䜜品 芞術家品川は n 点の䜜品を出展するように䟝頌されたした。そこで、立方䜓の 6 面をペンキで色付けしたものを䜜品ずしお出展するこずにしたした。䜜品は、Red、Yellow、Blue、Magenta、Green、Cyan の 6 色党おが䜿われおいお、各面は 1 色で塗り぀ぶされおいたす。品川は圢が同じ立方䜓の䜜品でも色の配眮の仕方を倉え、異なる䜜品ずしお n 点䜜成したした。 圌の友人であるあなたは、友人のよしみで䜜品を出展前に閲芧させおもらいたしたが、そこであるこずに気が付きたした。それらの䜜品の䞭に異なる色付けをされおいるように芋えおも、実は同じ色の組み合わせをした立方䜓が存圚しおいたのです。このたたでは、 n 点...
38,362
38,363
Problem H: Cornering at Poles You are invited to a robot contest. In the contest, you are given a disc-shaped robot that is placed on a flat field. A set of poles are standing on the ground. The robot can move in all directions, but must avoid the poles. However, the robot can make turns around the poles touching them....
38,364
Problem A: Infected Computer Adam Ivan is working as a system administrator at Soy Group, Inc. He is now facing at a big trouble: a number of computers under his management have been infected by a computer virus. Unfortunately, anti-virus system in his company failed to detect this virus because it was very new. Adam h...
38,365
J - Unfair Game Problem Statement Rabbit Hanako and Fox Jiro are great friends going to JAG primary school. Today they decided to play the following game during the lunch break. This game is played by two players with $N$ heaps of some number of stones. The players alternatively take their turn to play the game. Jiro i...
38,366
B: 䞭島、あれやろうぜ - Match Peas War - 問題 䞭島「うぅっ・・・」 磯野「䞭島倧䞈倫か」 䞭島「・・・なんだか嫌な倢を芋おいた気がするよ」 磯野「どんな倢だい」 䞭島「無限に遊ぶ倢」 磯野「意味わからんたぁいいや䞭島あれやろうぜ」 䞭島「あれっおたさかあれじゃないよな・・・」 磯野「あれだよあれ」 䞭島「おっいいじゃないかやろうやろう」 磯野「それじゃあたずはじゃんけんだな」 なにやら公園で2人の子䟛が遊んでいるようです懐かしさを感じたすねずころであなたは『マッチ・グリヌンピヌス・戊争』などず呌ばれる手遊びを知っおいたすかその名称にピンずこなかったずしおもきっず子䟛時...
38,368
Score: 600 points Problem Statement After being invaded by the Kingdom of AlDebaran, bombs are planted throughout our country, AtCoder Kingdom. Fortunately, our military team called ABC has managed to obtain a device that is a part of the system controlling the bombs. There are N bombs, numbered 1 to N , planted in our...
38,369
Largest Square Given a matrix ( H × W ) which contains only 1 and 0, find the area of the largest square matrix which only contains 0s. Input H W c 1,1 c 1,2 ... c 1,W c 2,1 c 2,2 ... c 2,W : c H,1 c H,2 ... c H,W In the first line, two integers H and W separated by a space character are given. In the following H lines...
38,370
Score : 100 points Problem Statement There is a grid with H horizontal rows and W vertical columns. Let (i, j) denote the square at the i -th row from the top and the j -th column from the left. For each i and j ( 1 \leq i \leq H , 1 \leq j \leq W ), Square (i, j) is described by a character a_{i, j} . If a_{i, j} is ....
38,371
Score : 1600 points Problem Statement Snuke found a random number generator. It generates an integer between 0 and 2^N-1 (inclusive). An integer sequence A_0, A_1, \cdots, A_{2^N-1} represents the probability that each of these integers is generated. The integer i ( 0 \leq i \leq 2^N-1 ) is generated with probability A...
38,373
Score : 1000 points Problem Statement For an n \times n grid, let (r, c) denote the square at the (r+1) -th row from the top and the (c+1) -th column from the left. A good coloring of this grid using K colors is a coloring that satisfies the following: Each square is painted in one of the K colors. Each of the K colors...
38,374
Score : 400 points Problem Statement You are going out for a walk, when you suddenly encounter a monster. Fortunately, you have N katana (swords), Katana 1 , Katana 2 , 
 , Katana N , and can perform the following two kinds of attacks in any order: Wield one of the katana you have. When you wield Katana i (1 ≀ i ≀ N) ,...
38,375
Score : 200 points Problem Statement Takahashi is standing on a two-dimensional plane, facing north. Find the minimum positive integer K such that Takahashi will be at the starting position again after he does the following action K times: Go one meter in the direction he is facing. Then, turn X degrees counter-clockwi...
38,377
Score : 900 points Problem Statement We have a connected undirected graph with N vertices and M edges. Edge i in this graph ( 1 \leq i \leq M ) connects Vertex U_i and Vertex V_i bidirectionally. We are additionally given N integers D_1, D_2, ..., D_N . Determine whether the conditions below can be satisfied by assigni...
38,378
Reverse Polish notation is a notation where every operator follows all of its operands. For example, an expression (1+2)*(5+4) in the conventional Polish notation can be represented as 1 2 + 5 4 + * in the Reverse Polish notation. One of advantages of the Reverse Polish notation is that it is parenthesis-free. Write a ...
38,379
ストヌブ(Stove) JOI 君の郚屋にはストヌブがあるJOI 君自身は寒さに匷いのでひずりで郚屋にいるずきはストヌブを぀ける必芁はないが来客があるずきはストヌブを぀ける必芁がある この日JOI 君のもずには N 人の来客がある i 番目( 1 \leq i \leq N ) の来客は時刻 T_i に到着し時刻 T_i + 1 に退出する同時に耇数人の来客があるこずはない JOI 君は任意の時刻にストヌブを぀けたり消したりできるただしストヌブを぀ける床にマッチを1本消費するJOI 君はマッチを K 本しか持っおいないので K 回たでしかストヌブを぀けるこずができない䞀日のはじめにストヌブは消えおいる ス...
38,380
パティシ゚ ケヌキ屋さんが、たちたちな倧きさのロヌルケヌキをたくさん䜜りたした。あなたは、このケヌキを箱に䞊べる仕事を任されたした。 ロヌルケヌキはずおもやわらかいので、他のロヌルケヌキが䞊に乗るず぀ぶれおしたいたす。ですから、図(a) のように党おのロヌルケヌキは必ず箱の底面に接しおいるように䞊べなければなりたせん。䞊べ替えるず必芁な幅も倉わりたす。 図(a) 図(b) n 個のロヌルケヌキの半埄 r 1 , r 2 , ..., r n ず箱の長さを読み蟌み、それぞれに぀いお、箱の䞭にうたく収たるかどうか刀定し、䞊べる順番を工倫するず箱に入る堎合は "OK"、どう䞊べおも入らない堎合には "NA"を出力するプログラムを䜜成しおく...
38,381
Problem C: Dungeon Quest II The cave, called "Mass of Darkness", had been a agitating point of the evil, but the devil king and all of his soldiers were destroyed by the hero and the peace is there now. One day, however, the hero was worrying about the rebirth of the devil king, so he decided to ask security agency to ...
38,382
Draw in Straight Lines You plan to draw a black-and-white painting on a rectangular canvas. The painting will be a grid array of pixels, either black or white. You can paint black or white lines or dots on the initially white canvas. You can apply a sequence of the following two operations in any order. Painting pixels...
38,383
Nathan O. Davis has been running an electronic bulletin board system named JAG-channel. He is now having hard time to add a new feature there --- threaded view. Like many other bulletin board systems, JAG-channel is thread-based. Here a thread (also called a topic) refers to a single conversation with a collection of p...
38,384
Problem E: Molecular Formula Your mission in this problem is to write a computer program that manipulates molecular for- mulae in virtual chemistry . As in real chemistry, each molecular formula represents a molecule consisting of one or more atoms. However, it may not have chemical reality. The following are the defin...
38,385
Problem B: 完党数 ある敎数 N に察しその数自身を陀く玄数の和を S ずする N = S のずき N は完党数 (perfect number) N > S のずき N は䞍足数 (deficient number) N < S のずき N は過剰数 (abundant number) ず呌ばれる 䞎えられた敎数が完党数・䞍足数・過剰数のどれであるかを 刀定するプログラムを䜜成せよ プログラムの実行時間が制限時間を越えないように泚意するこず Input 入力はデヌタセットの䞊びからなる デヌタセットの数は 100 以䞋である 各デヌタセットは敎数 N (0 < N ≀ 100000000) のみを含む...
38,387
Score: 100 points Problem Statement There is a train going from Station A to Station B that costs X yen (the currency of Japan). Also, there is a bus going from Station B to Station C that costs Y yen. Joisino got a special ticket. With this ticket, she can take the bus for half the fare if she travels from Station A t...
38,388
H - Rings Problem Statement There are two circles with radius 1 in 3D space. Please check two circles are connected as chained rings. Input The input is formatted as follows. {c_x}_1 {c_y}_1 {c_z}_1 {v_x}_{1,1} {v_y}_{1,1} {v_z}_{1,1} {v_x}_{1,2} {v_y}_{1,2} {v_z}_{1,2} {c_x}_2 {c_y}_2 {c_z}_2 {v_x}_{2,1} {v_y}_{2,1} {...
38,389
Score : 600 points Problem Statement We have a sequence of length N consisting of non-negative integers. Consider performing the following operation on this sequence until the largest element in this sequence becomes N-1 or smaller. (The operation is the same as the one in Problem D.) Determine the largest element in t...
38,390