task
stringlengths
0
154k
__index_level_0__
int64
0
39.2k
Score : 700 points Problem Statement In the final of CODE FESTIVAL in some year, there are N participants. The height and power of Participant i is H_i and P_i , respectively. Ringo is hosting a game of stacking zabuton (cushions). The participants will line up in a row in some order, and they will in turn try to add z...
37,750
Score : 100 points Problem Statement There are N flowers arranged in a row. For each i ( 1 \leq i \leq N ), the height and the beauty of the i -th flower from the left is h_i and a_i , respectively. Here, h_1, h_2, \ldots, h_N are all distinct. Taro is pulling out some flowers so that the following condition is met: Th...
37,751
Score : 900 points Problem Statement Takahashi has an N \times N grid. The square at the i -th row and the j -th column of the grid is denoted by (i,j) . Particularly, the top-left square of the grid is (1,1) , and the bottom-right square is (N,N) . An integer, 0 or 1 , is written on M of the squares in the Takahashi's...
37,752
Score : 300 points Problem Statement A game is played on a strip consisting of N cells consecutively numbered from 1 to N . Alice has her token on cell A . Borys has his token on a different cell B . Players take turns, Alice moves first. The moving player must shift his or her token from its current cell X to the neig...
37,753
Score : 500 points Problem Statement There is an infinitely long street that runs west to east, which we consider as a number line. There are N roadworks scheduled on this street. The i -th roadwork blocks the point at coordinate X_i from time S_i - 0.5 to time T_i - 0.5 . Q people are standing at coordinate 0 . The i ...
37,754
Score : 600 points Problem Statement Silver Fox is fighting with N monsters. The monsters are standing in a row, and we can assume them to be standing on a number line. The i -th monster, standing at the coordinate X_i , has the health of H_i . Silver Fox can use bombs to attack the monsters. Using a bomb at the coordi...
37,755
Merge Sort Write a program of a Merge Sort algorithm implemented by the following pseudocode. You should also report the number of comparisons in the Merge function. Merge(A, left, mid, right) n1 = mid - left; n2 = right - mid; create array L[0...n1], R[0...n2] for i = 0 to n1-1 do L[i] = A[left + i] for i = 0 to n2-1 ...
37,756
Score : 200 points Problem Statement Given are strings S and T . Consider changing S to T by repeating the operation below. Find the minimum number of operations required to do so. Operation: Choose one character of S and replace it with a different character. Constraints S and T have lengths between 1 and 2\times 10^5...
37,757
Max Score: $300$ Points Problem Statement We are playing a puzzle. An upright board with $H$ rows by $W$ columns of cells, is used in this puzzle. A stone in $i$-th row and $j$-th column engraved with a digit, one of 1 through 9, is placed in each of the cells. You can erase 1 cell in the board. The game process is fol...
37,758
Problem G: 倩䜓芳枬 2012幎のある日のこず。 北の田舎町に䜏むあなたは、愛嚘を連れお展望台で星芋をするこずにした。 この町は郜䌚ず違っお街明かりが少なく、空気も柄んでいるので、晎れた日は満倩の星空が広がっおいる。 倩文にそこそこ詳しいあなたは季節ごずの有名な星や星座、それにた぀わる神話ぐらいは知っおいるのだが、 なにせここは星降る町、名前のわからない星座もたくさん芋えおいる。 この前の星芋のずきにそういった星々に関する嚘の質問に答えられなかったあなたは、 星芋の時刻にいったいどの星座が芋えるのかを調べたいず思った。 特定の日時にどの星が芋えるのかを知るには、星座早芋盀ずいうアむテムが有甚である。 最近では携垯端末のGP...
37,759
Problem B: Expected Allowance Hideyuki is allowed by his father Ujisato some 1000 yen bills every month for his pocket money. In the first day of every month, the number of bills is decided as follows. Ujisato prepares n pieces of m -sided dice and declares the cutback k . Hideyuki rolls these dice. The number of bills...
37,760
Score: 900 points Problem Statement In 2937 , DISCO creates a new universe called DISCOSMOS to celebrate its 1000 -th anniversary. DISCOSMOS can be described as an H \times W grid. Let (i, j) (1 \leq i \leq H, 1 \leq j \leq W) denote the square at the i -th row from the top and the j -th column from the left. At time 0...
37,761
F: Disordered Data Detection / 異垞怜知 物語 宮守あかねは歊蔵野゜フトりェアに務める゚ンゞニアである今日は顧客から受けた䞍具合報告に頭を悩たせおいる「倉な話この前䜜っおもらった゜フトの挙動がぷるんぷるんしおるんでぇそちらでチェックしおもらえたすか保守するのもおたくらの仕事でしょ」い぀も無理難題ばかり抌し付けおくるこの顧客だが今回ばかりはこちらに非があるなぜならい぀も適圓な仕事ばかりのゞロヌがテストに通っおいないコヌドをそのたた攟眮しお補品に組み蟌んだこずを告癜したからである普通の人間ならゞロヌに殎りかかりそうなものだがもはやい぀ものこずだあかねは怒りを通り越しすでに悟りを開き...
37,762
財宝 (Treasures) 問題 盗賊の Anna ず Bruno は倧富豪の邞宅に忍び蟌み財宝 1 から財宝 N たでの N 個の財宝を芋぀けたこれらの財宝を Anna ず Bruno で分配するこずになった財宝のうちのいく぀かを Anna が取り残りの財宝のうちのいく぀かを Bruno が取る同じ財宝を 2 人が取るこずはできないAnna や Bruno は財宝を 1 個も取らなくおもよいたた残った財宝は邞宅に残しおおくので2 人ずも取らない財宝があっおもよい それぞれの財宝には「垂堎䟡倀」ず「貎重床」ずいう 2 ぀の倀が定たっおいるAnna が取った財宝の垂堎䟡倀の合蚈ず Bruno が取った財宝の垂堎...
37,763
倚角圢の面積 ぀の円に内接する぀の倚角圢の頂点情報を入力ずし、それらの面積の倧小関係を出力するプログラムを䜜成しおください。 X 角圢の各頂点には反時蚈回りに 1 から X たで番号が振っおあるものずしたす図は、 X = 4 の堎合の䟋を瀺しおいたす。ただし、䞎えられる倚角圢は円の䞭心を内郚に含むものずし、頂点 i の䜍眮に関するデヌタは、頂点 i から頂点 i+1 たで反時蚈回りに蚈った䞭心角の角床 v (1 ≀ v < 180 の敎数) で䞎えられたす。たた、出力する倧小関係に぀いおは、第の倚角圢の面積が倧きい堎合は 1 (半角数字)、第の倚角圢の面積が倧きい堎合は 2 (半角数字)、それぞれの面積が等しい堎合は 0...
37,764
お菓子の分割 問題 長さ N ミリメヌトルの棒状のお菓子が 1 本ある(ここで N は偶数). 2 人の JOI 関係者が,このお菓子を耇数本に切断しお,合蚈 N/2 ミリメヌトルず぀に分けるこず にした. 理由は䞍明であるが,このお菓子は堎所によっお切断のしやすさが異なっおいる. 2 人は,お菓子を巊から 1 ミリメヌトルごずに調べ,各堎所で切断に䜕秒かかるか を割り出した.2 人がお菓子を分けるための切断にかかる秒数の最小倀を求めるプ ログラムを䜜成せよ. 入力 入力の 1 行目には,棒の長さ N(2 ≀ N ≀ 10000 ,ただし N は偶数) が曞かれおい る.入力の i + 1 行目 (1 ≀ i ≀ N − 1) には...
37,765
䟿利な町 来春卒業するAさんは、就職を機に匕越しをするこずにしたした。就職する䌚瀟は、オフィスがいく぀かの町にあっお、日によっお出勀するオフィスが違いたす。そこでAさんは,どこのオフィスに 行くにも時間の短い町に䜏もうず考えたした。 そこであなたは、Aさんを助けるため、䜏むのに䞀番䟿利な町を探すこずになりたした。 町には 0 から始たる番号が振られおおり、町ず町の間には道がありたす。それぞれの道に察しお通勀時間が決たっおいたす。Aさんがある町に䜏んでいる堎合に、自分の町のオフィスたでの通勀時間は 0 ずしたす。このずきに党おの町たでの通勀時間の総和を考えたす。䟋えば、町ず道の配眮が䞊の図のようになっおいお、Aさんが町1に䜏んだ堎合に...
37,766
Circles Intersection You are given circle $A$ with radius $r_a$ and with central coordinate $(x_a, y_a)$ and circle $B$ with radius $r_b$ and with central coordinate $(x_b, y_b)$. Write a program which prints: "2" if $B$ is in $A$, "-2" if $A$ is in $B$, "1" if circumference of $A$ and $B$ intersect, and "0" if $A$ and...
37,767
Problem C: Adaptive Time Slicing Quantization Nathan O. Davis is a student at the department of integrated systems. Today he learned digital quanti- zation in a class. It is a process that approximates analog data (e.g. electrical pressure) by a finite set of discrete values or integers. He had an assignment to write a...
37,768
Problem I Midpoint One day, you found $L + M + N$ points on a 2D plane, which you named $A_1, ..., A_L, B_1, ...,B_M, C_1,...,C_N$. Note that two or more points of them can be at the same coordinate. These were named after the following properties: the points $A_1,...,A_L$ were located on a single straight line, the po...
37,769
Problem G: Longest Chain Let us compare two triples a = (x a , y a , z a ) and b = (x b , y b , z b ) by a partial order ∠ defined as follows. a ∠ b ⇔ x a < x b and y a < y b and z a < z b Your mission is to find, in the given set of triples, the longest ascending series a 1 ∠ a 2 ∠ ... ∠ a k . Input The input is a seq...
37,770
Problem F: 自転車 Problem Statement 菊地君は、倧の自転車奜きである。今日も圌は、お気に入りの自転車に乗っおサむクリングロヌドぞず走り出そうずしおいる。 圌が䜏む地域には、N個の町が存圚する。各町を町1、町2...、町Nず呌ぶこずずする。圌が䜏む町は、町1である。この地域には、サむクリングを趣味ずしおいる人が倚く、最近では頻繁に町ず町を結ぶサむクリングロヌドが䜜られおいる。サむクリングロヌドを䜿うず、2぀の町を双方向に移動できる。入力では、どの町ずどの町が新しくサむクリングロヌドで繋がれたかが時系列順に入力される。 菊地君は、新しいサむクリングロヌドが1぀完成したずきに、次に瀺す条件を満たすずきだけサむク...
37,771
Score : 1600 points Problem Statement We constructed a rectangular parallelepiped of dimensions A \times B \times C built of ABC cubic blocks of side 1 . Then, we placed the parallelepiped in xyz -space as follows: For every triple i, j, k ( 0 \leq i < A, 0 \leq j < B, 0 \leq k < C ), there exists a block that has a di...
37,773
Score : 200 points Problem Statement A string S of an odd length is said to be a strong palindrome if and only if all of the following conditions are satisfied: S is a palindrome. Let N be the length of S . The string formed by the 1 -st through ((N-1)/2) -th characters of S is a palindrome. The string consisting of th...
37,774
Score : 800 points Problem Statement N contestants participated in a competition. The total of N-1 matches were played in a knockout tournament. For some reasons, the tournament may not be "fair" for all the contestants. That is, the number of the matches that must be played in order to win the championship may be diff...
37,775
Score : 700 points Problem Statement Aoki loves numerical sequences and trees. One day, Takahashi gave him an integer sequence of length N , a_1, a_2, ..., a_N , which made him want to construct a tree. Aoki wants to construct a tree with N vertices numbered 1 through N , such that for each i = 1,2,...,N , the distance...
37,776
The Maximum Number of Overlaps Given a set of $N$ axis-aligned rectangular seals, find the number of overlapped seals on the region which has the maximum number of overlapped seals. Input The input is given in the following format. $N$ $x1_1$ $y1_1$ $x2_1$ $y2_1$ $x1_2$ $y1_2$ $x2_2$ $y2_2$ : $x1_N$ $y1_N$ $x2_N$ $y2_N...
37,777
Score: 100 points Problem Statement The cat Snuke wants to play a popular Japanese game called ÅtCoder, so Iroha has decided to teach him Japanese. When counting pencils in Japanese, the counter word "本" follows the number. The pronunciation of this word varies depending on the number. Specifically, the pronunciation o...
37,778
Problem B: Watchin' TVA Animation is one of methods for making movies and in Japan, it is popular to broadcast as a television program or perform as a movie. Many people, especially the young, love one. And here is an anime lover called Jack. We say he is an mysterious guy with uncertain age. He likes anime which are b...
37,779
Problem description is available from here.
37,781
クラス分け 䌚接進孊塟では、生埒が塟に入る際に実力テストを行っおクラス分けをしたす。テストは数孊、英語、囜語の 3 科目行い、生埒を A,B,C クラスにクラス分けしたす。A クラスのレベルが䞀番高く、順に䜎くなっおいきたす。 クラス分けの刀断は以䞋の衚に基づきたす。 条件 クラス 100 点の科目がある A 数孊ず英語の平均点が 90 点以䞊 A 3 科目の平均点が 80 点以䞊 A 3 科目の平均点が 70 点以䞊 B 3 科目の平均点が 50 点以䞊で数孊か英語が 80 点以䞊 B 䞊の条件を満たさない C 耇数の条件を満たす堎合は、よりレベルの高いクラスに分けられたす。 生埒の人数 n (1 ≀ n ≀ 10000)、各生埒...
37,782
Gossip Problem 1から n たでの番号が順番に割り圓おられおいる n 人のアむドルが暪䞀列に䞊んでいる。 アむドル i は単䜍時間でアむドル i -1ずアむドル i +1に情報を䌝達するこずができる。ただし、アむドル1はアむドル2にしか情報を䌝達できず、アむドル n はアむドル n -1にしか情報を䌝達できない。 時刻0の時点で、番号が a 1 , a 2 , ..., a m である m 人のアむドルが秘密の情報を持っおいる。すべおのアむドルが秘密の情報を埗るこずのできる最小の時間を求めよ。 Input 入力は以䞋の圢匏で䞎えられる。 n m a 1 a 2 ... a m 1行目に2぀の敎数 n ず m が空癜区切...
37,783
C: Common Palindromes ICPC で良い成瞟を収めるには修行が欠かせないうさぎは ICPC で勝ちたいので今日も修行をするこずにした 今日の修行は文字列䞭にある回文を探すこずによっお文章から隠れたメッセヌゞを読解する胜力を高めようずいうものである回文はたくさんあるかもしれないので探す぀いでに個数も数えおしたいたい 2 ぀の文字列 S , T が䞎えられるので以䞋を満たす敎数の組 ( i , j , k , l ) の個数を求めたい 1 ≀ i ≀ j ≀ ( S の長さ) 1 ≀ k ≀ l ≀ ( T の長さ) S の i 文字目から j 文字目たでを取り出した郚分文字列は T の k...
37,785
Score: 200 points Problem Statement We have N cards. A number a_i is written on the i -th card. Alice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first. The game ends when all the cards are taken by the two players, and the score of each player is the su...
37,786
博士の光電管 博士 : ピヌタヌ君。やったよ。 ピヌタヌ : たたですか。今床はどんなくだらない発明ですか。 博士 : あの幻の玠粒子アキシオンの怜出噚を発明したんじゃ。 ピヌタヌ : アキシオンずいえば、欧州合同原子栞研究機構 (CERN) をはじめずする研究者たちが血県で远っかけおいるずいう、あれですよね。本圓ですかぁ? 博士 : 本圓だっおばよ。现かい説明は省くが、非垞に匷力な磁堎を内蔵する特殊な光電管が光るこずによっお、通過するアキシオンを怜出する。 ピヌタヌ : 他 に先んじお怜出すれば、小柎先生のニュヌトリノ怜出に匹敵するノヌベル賞玚の研究ですよ。 これで圹立たずの研究ばかりしおいる「ダメ研究宀」などずいう汚名も返䞊でき...
37,787
Kingdom of JOIOI The Kingdom of JOIOI is a rectangular grid of $H \times W$ cells. In the Kingdom of JOIOI, in order to improve efficiency of administrative institutions, the country will be divided into two regions called "JOI" and "IOI." Since we do not want to divide it in a complicated way, the division must satisf...
37,788
Problem F: Dice Puzzle Let’s try a dice puzzle. The rules of this puzzle are as follows. Dice with six faces as shown in Figure 1 are used in the puzzle. Figure 1: Faces of a die With twenty seven such dice, a 3 × 3 × 3 cube is built as shown in Figure 2. Figure 2: 3 × 3 × 3 cube When building up a cube made of dice, t...
37,789
むクタ君は、無向グラフに぀いお異垞なほどの思い入れを持っおいる。むクタ君は、無向グラフ G ずその 2 点 s,t の組 (G,s,t) のうち、その「う぀くしさ」が倧きいものが奜きである。 組 (G,s,t) の「う぀くしさ」ずは、蟺 e = \{u, v\} ( u ず v は G の異なる 2 点) で、 G における s から t ぞの最短路の長さが、 G に e を぀けくわえた無向グラフにおける s から t ぞの最短路の長さより 1 だけ倧きいものの個数である。 あなたの仕事は、組 (G,s,t) が䞎えられたずき、その「う぀くしさ」を求めるプログラムを曞くこずである。 Input 入力は以䞋の圢匏で䞎えられる。 N M...
37,790
ブレむブ・フォヌス・ストヌリヌ English text is not available in this practice contest. 「最果おの地ナむン・アむランドには特別な力を持぀ものが生きおいた ある者は火ある者は氷ある者は颚ある者は土を意のたたに操るこずができた 人はこれらの術者をこう呌んだ『Brave Force』ず・・・時は戊囜時代暩力者たちはBrave Forceを私欲のために䜿わんずBrave Force狩りを始めた Brave Forceを巡る戊いが今始たろうずしおいる」 以䞊はあなたが今぀くろうずしおいる戊略シミュレヌションゲヌムのプロロヌグであるこのプロロヌグは本問題には党く関...
37,791
Problem I : RMQ n 個の数字 a 0 , a 1 , ... , a n-1 ず q が䞎えられる。 q 個のク゚リヌに察しお適切な凊理を行なっお欲しい。 ク゚リヌは以䞋の3皮類の操䜜が存圚する。 倀のシフトを行う l ず r のペアが䞎えられる。( l < r ) a l から a r たでの倀を Circular Shiftさせる。 0 1 2 3 4 5 6 7 8 9 に察しおl=2,r=5ずいうク゚リヌが䞎えられたずする。 シフトを行った数字列は 0 1 5 2 3 4 6 7 8 9 ずなる。 最小倀を求める l ず r のペアが䞎えられる。( l ≀ r ) a l から a r たでの倀の䞭で最小の倀...
37,792
Colorful Tree A tree structure with some colors associated with its vertices and a sequence of commands on it are given. A command is either an update operation or a query on the tree. Each of the update operations changes the color of a specified vertex, without changing the tree structure. Each of the queries asks th...
37,793
Score : 200 points Problem Statement Snuke has N sticks. The length of the i -th stick is l_i . Snuke is making a snake toy by joining K of the sticks together. The length of the toy is represented by the sum of the individual sticks that compose it. Find the maximum possible length of the toy. Constraints 1 \leq K \le...
37,794
J - タむル眮き サむズ H × W の盀面にサむズ1×2のタむルをマス目にそっお N 個配眮する方法が䜕通りあるか求めたい. タむルは重なっおはいけない. たた瞊暪どちらの向きに眮いおも構わない. タむルは党お同じ芋た目であり互いに区別しないものずする. タむルは180床回転しおも同じ芋た目であり、区別しないものずする. 答えは倧きくなる可胜性があるので1,000,000,007で割った䜙りを答えよ 入力圢匏 入力は以䞋の圢匏で䞎えられる H W N 出力圢匏 タむルの眮き方の総数を 1,000,000,007 で割った䜙りを出力せよ 制玄 1 ≀ H ≀ 1,000,000,000 1 ≀ W ≀ 1,000,000,00...
37,795
Problem Statement There are N piles of candies on the table. The piles are numbered 1 through N . At first, pile i contains a_i candies. Snuke and Ciel are playing a game. They take alternating turns. Snuke goes first. In each turn, the current player must perform one of the following two operations: Choose a pile with...
37,796
Score : 300 points Problem Statement In some other world, today is Christmas Eve. There are N trees planted in Mr. Takaha's garden. The height of the i -th tree (1 \leq i \leq N) is h_i meters. He decides to choose K trees from these trees and decorate them with electric lights. To make the scenery more beautiful, the ...
37,797
Problem B: Electrophoretic Scientist Frank, majoring in electrochemistry, has developed line-shaped strange electrodes called F-electrodes . During being activated, each F-electrode causes a special potential on and between the two lines touching the F-electrode’s endpoints at a right angle. Then electrically-charged p...
37,798
ビデオテヌプ 暙準録画で 120 分のビデオテヌプがありたす。テヌプを完党に巻き戻した状態でビデオデッキのカりンタを 00:00:00 にし、暙準録画モヌドで録画したずころ、あるカりンタ倀になりたした。このカりンタ倀時、分、秒を入力し、残りのテヌプの長さ録画可胜時間を求め、時分秒の圢匏で出力するプログラムを䜜成しお䞋さい。 ただし、2 時間120分以内の入力ずしたす。なお、テヌプ残量は暙準録画モヌドず 3 倍録画モヌドの堎合の通りを蚈算し、出力䟋のように時、分、秒ずも 2 桁ず぀出力したす。たた "05" のように 10 の䜍が 0 の堎合は、"0" を぀けおください。 入力 耇数のデヌタセットが䞎えられたす。各デ...
37,799
党宇宙生呜ゲノムデヌタベヌス リタヌンズ 西暊2301幎宇宙連邊共和囜の生呜科孊局では宇宙生物のゲノム配列の研究を行っおいた近幎の研究の結果ゲノム配列に特定のパタヌンが䜕回珟れるかが生物の性質に倧きく圱響するこずが分かっおきた 宇宙生物のゲノム配列は英倧文字からなる文字列で衚される研究員たちはゲノム配列の䞭にある特定のパタヌンが䜕回珟れるかを数え䞊げるこずにしたしかしながら宇宙生物のゲノム配列は非垞に長いため埌述する方法で繰り返しがある郚分文字列を圧瞮しおデヌタベヌスに保存しおいる あなたの仕事は圧瞮されたゲノム配列 S から文字列 Q の出珟回数を数え䞊げるプログラムを䜜成するこずであるただし Q の出珟...
37,800
䞎えられた倉換衚にもずづきデヌタを倉換するプログラムを䜜成しなさい デヌタに䜿われおいる文字は英字か数字で英字は倧文字ず小文字を区別する倉換衚に珟れる文字の順序に芏則性はない 倉換衚は空癜をはさんで前ず埌ろの 2 ぀の文字がある(文字列ではない)倉換方法は倉換衚のある行の前の文字がデヌタに珟れたらそのたびにその文字を埌ろの文字に倉換し出力する倉換は 1 床だけで倉換した文字がたた倉換察象の文字になっおも倉換しない倉換衚に珟れない文字は倉換せずそのたた出力する 入力ファむルには倉換衚最初の n + 1 行に続き倉換するデヌタn + 2 行目以降が曞いおある 1 行目に倉換衚の行数 n続く n 行...
37,801
Finding a Word Write a program which reads a word W and a text T , and prints the number of word W which appears in text T T consists of string T i separated by space characters and newlines. Count the number of T i which equals to W . The word and text are case insensitive. Constraints The length of W ≀ 10 W consists ...
37,802
Maximum Flow A flow network is a directed graph which has a $source$ and a $sink$. In a flow network, each edge $(u, v)$ has a capacity $c(u, v)$. Each edge receives a flow, but the amount of flow on the edge can not exceed the corresponding capacity. Find the maximum flow from the $source$ to the $sink$. Input A flow ...
37,803
Score : 100 points Problem Statement As a New Year's gift, Dolphin received a string s of length 19 . The string s has the following format: [five lowercase English letters],[seven lowercase English letters],[five lowercase English letters] . Dolphin wants to convert the comma-separated string s into a space-separated ...
37,804
幟䜕問題を解こう A君は今日も幟䜕の問題を解いおいる。 幟䜕の問題を解く時は浮動小数点誀差に気を぀けるこずが倧事である。 浮動小数点誀差ずは、2進法の有限小数で数を衚す際におこる䞞めによっお起きる誀差である。 䟋えば、10進法での 0.1 は2進法では 0.00011001100110011 ... ずいう無限小数になるが、 これを有限の桁で䞞める際に誀差が発生しおしたう。 正の敎数 p , q が10進法で䞎えられる。 有理数 p / q を有限桁数の小数で衚珟するこずができるような b 進法 b は2以䞊の敎数を求めよ。 耇数ある堎合は最も小さいものを出力せよ。 Constraints 0 < p < q < 10^9 In...
37,805
Score : 400 points Problem Statement We have an undirected graph G with N vertices numbered 1 to N and N edges as follows: For each i=1,2,...,N-1 , there is an edge between Vertex i and Vertex i+1 . There is an edge between Vertex X and Vertex Y . For each k=1,2,...,N-1 , solve the problem below: Find the number of pai...
37,806
Score : 100 points Problem Statement Snuke built an online judge to hold a programming contest. When a program is submitted to the judge, the judge returns a verdict, which is a two-character string that appears in the string S as a contiguous substring. (The judge can return any two-character substring of S .) Determi...
37,807
Score : 300 points Problem Statement We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by r...
37,808
Score : 900 points Problem Statement Takahashi and Aoki are playing a stone-taking game. Initially, there are N piles of stones, and the i -th pile contains A_i stones and has an associated integer K_i . Starting from Takahashi, Takahashi and Aoki take alternate turns to perform the following operation: Choose a pile. ...
37,809
Score : 200 points Problem Statement A group of people played a game. All players had distinct scores, which are positive integers. Takahashi knows N facts on the players' scores. The i -th fact is as follows: the A_i -th highest score among the players is B_i . Find the maximum possible number of players in the game. ...
37,810
Score : 200 points Problem Statement There are N mountains ranging from east to west, and an ocean to the west. At the top of each mountain, there is an inn. You have decided to choose where to stay from these inns. The height of the i -th mountain from the west is H_i . You can certainly see the ocean from the inn at ...
37,811
Fibonacci Number Write a program which prints $n$-th fibonacci number for a given integer $n$. The $n$-th fibonacci number is defined by the following recursive formula: \begin{equation*} fib(n)= \left \{ \begin{array}{ll} 1 & (n = 0) \\ 1 & (n = 1) \\ fib(n - 1) + fib(n - 2) & \\ \end{array} \right. \end{equation*} In...
37,812
A/B Problem Write a program which reads two integers a and b , and calculates the following values: a ÷ b : d (in integer) remainder of a ÷ b : r (in integer) a ÷ b : f (in real number) Input Two integers a and b are given in a line. Output Print d , r and f separated by a space in a line. For f , the output should not...
37,813
Score : 200 points Problem Statement There are N participants in the CODE FESTIVAL 2016 Qualification contests. The participants are either students in Japan, students from overseas, or neither of these. Only Japanese students or overseas students can pass the Qualification contests. The students pass when they satisfy...
37,814
Score : 100 points Problem Statement In this problem, we use the 24 -hour clock. Takahashi gets up exactly at the time H_1 : M_1 and goes to bed exactly at the time H_2 : M_2 . (See Sample Inputs below for clarity.) He has decided to study for K consecutive minutes while he is up. What is the length of the period in wh...
37,815
Problem H: Road Construction King Mercer is the king of ACM kingdom. There are one capital and some cities in his kingdom. Amazingly, there are no roads in the kingdom now. Recently, he planned to construct roads between the capital and the cities, but it turned out that the construction cost of his plan is much higher...
37,816
You and your grandma are playing with graph automata, which is generalization of cell automata. A graph automaton is expressed by a graph. The vertices of the graph have a time-dependent value, which can be either 0 or 1. There is no more than one edge between any of two vertices, but self-loops might exist. The values...
37,817
Score: 300 points Problem Statement Find the minimum prime number greater than or equal to X . Notes A prime number is an integer greater than 1 that cannot be evenly divided by any positive integer except 1 and itself. For example, 2 , 3 , and 5 are prime numbers, while 4 and 6 are not. Constraints 2 \le X \le 10^5 Al...
37,818
Problem F: Gap Let’s play a card game called Gap. You have 28 cards labeled with two-digit numbers. The first digit (from 1 to 4) represents the suit of the card, and the second digit (from 1 to 7) represents the value of the card. First, you shuffle the cards and lay them face up on the table in four rows of seven car...
37,819
マルバツスタンプ (Circle Cross Stamps) 問題文 JOI 君はマルスタンプバツスタンプマルバツスタンプの3皮類のスタンプをそれぞれ 0 個以䞊持っおいるこれらはマルやバツのマヌクを玙に印字するこずができるスタンプである マルスタンプを䜿うずマルが 1 ぀印字されバツスタンプを䜿うずバツが 1 ぀印字されるマルバツスタンプを䜿うずマルずバツが暪䞀列に 1 ぀ず぀印字されスタンプの向きを倉えるこずでマルの右にバツが来るようにもバツの右にマルが来るようにも印字できる JOI 君は持っおいるスタンプをそれぞれちょうど 1 回ず぀適圓な順番で䜿い玙に暪䞀列にマルずバツを印字した印字されたマルずバツ...
37,820
ポケベル打ち ある日、たろう君は、本文に「519345213244」ずいう数字だけが曞いおあるおかしなメヌルを受け取り たした。そのメヌルは、10 歳幎䞊の埓姉からだったので電話しお聞いおみるず、「あ、急いでたから ポケベル打ちで送っちゃった。䟿利よね。よろしくねっ!」ずいっお切られおしたいたした。い぀も せわしなく、少し匷匕なずころのあるこの埓姉をよく知るたろう君は、仕方なく自分で「ポケベル打 ち」に぀いお調べおみるず、10 幎ぐらい前に䞀䞖を颚靡したかな入力の方法だずいうこずが分かりたし た。 「ポケベル打ち」では、図 1 のような倉換衚に埓い‘あ’は 11、‘お’は 15 ずいう具合に、2 ぀の数字 で䞀぀の文字を入力しおいき...
37,821
平面に長方圢のシヌトが䜕枚か眮かれおいる. これらのシヌトで芆われおいる郚分の面積や呚長を求めるプログラムを䜜成せよ. ただし, 平面を座暙平面ずみなしたずき, シヌトの配眮は次の条件 (1), (2) を満たすものずする. (1) 各シヌトの長方圢の 4 頂点の x , y 座暙は党お 0 以䞊 10000 以䞋の敎数であり, 長方圢の各蟺は x 軞, たたは y 軞に平行である. (2) シヌトの枚数は高々 10000 枚以䞋である. 入力デヌタ の 1 行目に長方圢の個数 n ず問題の皮類を衚す敎数 r が空癜で区切っお曞かれおいる. 2 行目以降の各行には, 各シヌトの巊䞋頂点座暙 ( x 1 , y 1 ) ず右䞊頂点座暙...
37,822
䞀番䞋の行の数字は? 次のような数字のパタヌンを䜜るこずを考えたす。 4 8 2 3 1 0 8 3 7 6 2 0 5 4 1 8 1 0 3 2 5 9 5 9 9 1 3 7 4 4 4 8 0 4 1 8 8 2 8 4 9 6 0 0 2 5 6 0 2 1 6 2 7 8 5 このパタヌンは以䞋の芏則に埓っおいたす。 A B C ずいう数字の䞊びにおいお、C は A + B の 1 の䜍の数字である。たずえば、 9 5 4 では、9 + 5 = 14 の 1 の䜍の数字、すなわち 4 が 9 ず 5 の斜め䞋に䞊べられたす。たた、 2 3 5 では、2 + 3 = 5 の 1 の䜍の数字、すなわち 5 が 2 ず 3 の...
37,823
Problem D: Operations with Finite Sets Let A, B, C, D, E be sets of integers and let U is a universal set that includes all sets under consideration. All elements in any set are different (no repetitions). u - union of two sets, AuB = { x ∈ U : x ∈ A or x ∈ B } is the set of all elements which belong to A or B . i - in...
37,824
Problem A: サむゟり ある囜で「サむゟり」ずいうテレビ番組が流行しおいる この番組は参加者がフィヌルドアスレチックに挑戊し 芋事攻略すれば賞金をもらえるずいうものである フィヌルドアスレチックは高さが異なるブロックを䞀列に䞊べお䜜られおいお 攻略のためにはいかにしお段差を登り降りするかが重芁になる 図1 この番組に参加するこずになったあなたの友人は フィヌルドアスレチックの構造が䞎えられたずきに 登らなければならない最倧の段差ず降りなければならない最倧の段差を 蚈算するプログラムを曞いおほしいず 凄腕プログラマヌであるあなたに䟝頌しおきた 図1: アスレチックの構造の䟋入力䟋の最初のデヌタセット...
37,825
Score : 600 points Problem Statement Snuke got an integer sequence of length N from his mother, as a birthday present. The i -th (1 ≩ i ≩ N) element of the sequence is a_i . The elements are pairwise distinct. He is sorting this sequence in increasing order. With supernatural power, he can perform the following two ope...
37,826
G - Revenge of Minimum Cost Flow Problem Statement Flora is a freelance carrier pigeon. Since she is an excellent pigeon, there are too much task requests to her. It is impossible to do all tasks, so she decided to outsource some tasks to Industrial Carrier Pigeon Company. There are N cities numbered from 0 to N-1 . Th...
37,827
Problem E Black or White Here lies a row of a number of bricks each painted either black or white. With a single stroke of your brush, you can overpaint a part of the row of bricks at once with either black or white paint. Using white paint, all the black bricks in the painted part become white while originally white b...
37,828
問題 B 蝉 問題文 N 君は毎日孊校に通っおいるがその道のりはずおも長いさらに今は暑い倏である道䞭蝉が五月蝿い出来れば避けたいものであるずころで情報化が発達した珟代瀟䌚においおは家に居ながらにしおどこに䜕匹の蝉がいるか調べるこずが出来るその情報を䜿い途䞭で出䌚う蝉の数が最も少ない道で孊校に行くこずに決めた 家ず孊校が描かれた地図は長方圢状になっおおり H × W 個のブロックに分割される䞀番巊䞊のブロックに N 君の家があり䞀番右䞋に孊校がある圌は孊校ぞたっすぐ登校したいので家の方に逆戻りするこずはない (地図においお右か䞋のブロックにしか移動しない)各ブロックにおいおそこにいる蝉の数だけ䞍快にな...
37,829
Score : 100 points Problem Statement There are N stones, numbered 1, 2, \ldots, N . For each i ( 1 \leq i \leq N ), the height of Stone i is h_i . There is a frog who is initially on Stone 1 . He will repeat the following action some number of times to reach Stone N : If the frog is currently on Stone i , jump to Stone...
37,830
Score : 1600 points Problem Statement In some place in the Arctic Ocean, there are H rows and W columns of ice pieces floating on the sea. We regard this area as a grid, and denote the square at the i -th row and j -th column as Square (i,j) . The ice piece floating in each square is either thin ice or an iceberg, and ...
37,831
Score : 500 points Problem Statement There is a string s of length 3 or greater. No two neighboring characters in s are equal. Takahashi and Aoki will play a game against each other. The two players alternately performs the following operation, Takahashi going first: Remove one of the characters in s , excluding both e...
37,832
Score: 100 points Problem Statement A triple of numbers is said to be poor when two of those numbers are equal but the other number is different from those two numbers. You will be given three integers A , B , and C . If this triple is poor, print Yes ; otherwise, print No . Constraints A , B , and C are all integers b...
37,833
Huge Knapsack Problem You have N items that you want to put them into a knapsack. Item i has value v i and weight w i . You want to find a subset of items to put such that: The total value of the items is as large as possible. The items have combined weight at most W , that is capacity of the knapsack. Find the maximum...
37,834
Score : 1600 points Problem Statement There are N squares in a row, numbered 1 through N from left to right. Snuke and Rng are playing a board game using these squares, described below: First, Snuke writes an integer into each square. Each of the two players possesses one piece. Snuke places his piece onto square 1 , a...
37,835
Problem E: Amazing Graze In 2215 A.D., a war between two planets, ACM and ICPC, is being more and more intense. ACM introduced new combat planes. These planes have a special system that is called Graze, and fighting power of a plane increases when it is close to energy bullets that ICPC combat planes shoot. Both combat...
37,836
Score : 600 points Problem Statement We have a grid with A horizontal rows and B vertical columns, with the squares painted white. On this grid, we will repeatedly apply the following operation: Assume that the grid currently has a horizontal rows and b vertical columns. Choose "vertical" or "horizontal". If we choose ...
37,837
有限䜓電卓 0以倖のすべおの実数の逆数は実数になりたすが、敎数の逆数が敎数になるずは限りたせん。蚀語などで 3.0/2.0*2.0 = 3.0 なのに 3/2*2 = 2 になっおしたうのはこのためです。ですが、玠数で割った䜙りが等しい敎数を同じものずみなすず、0以倖のすべおの敎数が逆数をも぀ようにできたす。 敎数 x ず y を p で割った䜙りが等しいずき、x ≡ y (mod p) ず曞きたす。p が玠数のずき、このような x ず y を同じものずみなすなら、すべおの敎数 n は0から p−1 たでのどれかの敎数 x に察しお x ≡ n (mod p) ずなるので、けっきょく { 0, 1, 2, ..., p−1 } ず...
37,838
There are n processes in a queue. Each process has name i and time i . The round-robin scheduling handles the processes in order. A round-robin scheduler gives each process a quantum (a time slot) and interrupts the process if it is not completed by then. The process is resumed and moved to the end of the queue, then t...
37,839
Score : 500 points Problem Statement Takahashi and Aoki will play a game. They will repeatedly play it until one of them have N wins in total. When they play the game once, Takahashi wins with probability A %, Aoki wins with probability B %, and the game ends in a draw (that is, nobody wins) with probability C %. Find ...
37,840
Problem C: Warping Girl Problem 䌚接魔法孊校は, 魔法を䜿える者が集たる孊校である. その孊校の生埒の䞀人であるハルカは, 魔法陣の䞊でワヌプの魔法を䜿う事ができる. 圌女の家から孊校には, 長さ L の䞀盎線状の道がある. たた, この道には所々魔法陣が描かれおいる. 圌女は毎日この道を䜿っお孊校に通っおいるため, できるだけ短い時間で孊校に蟿り着きたいず思っおいる. そこでプログラマヌであるあなたは, 圌女に孊校たで行くずきにかかる最小の時間を教えおあげるこずにした. ハルカは, 1 分で距離 1 だけ歩いお先に進むこずができる ( 戻るこずはできない)たた, ワヌプの魔法陣が曞いおある䜍眮 ...
37,841
Score : 300 points Problem Statement A railroad running from west to east in Atcoder Kingdom is now complete. There are N stations on the railroad, numbered 1 through N from west to east. Tomorrow, the opening ceremony of the railroad will take place. On this railroad, for each integer i such that 1≀i≀N-1 , there will ...
37,842
Problem B: 友だちの誘い方 明日から、埅ちに埅った倏䌑みが始たりたす。なのでわたしは、友だちを誘っお、海に遊びに行くこ ずに決めたした。 けれども、わたしの友だちには、恥ずかしがりやさんが倚いです。その人たちは、あたり倚くの人が いっしょに来るず知ったら、きっず嫌がるでしょう。 ほかにも、わたしの友だちには、目立ちたがりやさんも倚いです。その人たちは、いっしょに来る人 があたり倚くないず知れば、きっず嫌がるでしょう。 それず、わたしの友だちには、い぀もは目立ちたがりやなのに実は恥ずかしがりやさんな人もいた す。その人たちは、いっしょに来る人が倚すぎおも少なすぎおも、きっず嫌がるでしょう。 こういうのは、倧勢で行った方が楜し...
37,843
ランチ お昌に食べるお匁圓を䜜るために、お店で食べ物を買いたした。お店では、食べ物を入れるのに现長い袋しかもらえなかったので、すべおの食べ物を瞊に積んで袋に入れる必芁がありたす。袋が倒れにくいように、できるだけ重い物を䞋にしお詰めたいのですが、食べ物の䞭にはやわらかい物もあっお、䞊に重い物を乗せるず぀ぶれおしたいたす。 そこで、食べ物の情報を入力ずし、党おの食べ物が぀ぶれず、か぀党䜓の重心が最も䜎くなるような積み方を出力するプログラムを䜜成しおください。それぞれの食べ物ごずに、名前 f 、重さ w 、䞊に茉せお耐えられる重さ s が指定されたす。 「党おの食べ物が぀ぶれない」ずいうのは、䞋から順に、 f 1 、 f 2 、... ...
37,844
問題 6: 小籠包 (Xiao Long Bao) 問題 JOI 君はお昌ごはんに䞭華料理屋で小籠包を食べるこずにした 小籠包ずは具ず熱いスヌプを小麊粉の皮で包んだ料理であり食べるずきにスヌプが呚囲に飛び散るこずで知られおいる JOI 君が泚文した小籠包のセットは具やスヌプの異なる N 個の小籠包からなる N 個の小籠包は等間隔に䞀列に䞊んでおり順番に 1 から N の番号が぀けられおいる i 番目の小籠包ず j 番目の小籠包の間の距離は絶察倀 |i - j| である JOI 君は小籠包をある順番で食べおいく 最初すべおの小籠包のおいしさは 0 である i 番目の小籠包を食べるず呚囲にその汁が飛び散りた...
37,845
B : Books / 本 Problem 倧孊生のいづあ君はかなりの読曞家である。面癜そうだず思った本は迷わず買うため、蔵曞が増えすぎお管理できなくなっおいるのが悩みである。そこでいづあ君は、持っおいる本の䞭から目的の本を怜玢するシステムを䜜るこずにした。 党おの本は次の 3 ぀の属性を持぀。 title : 本のタむトルを衚す文字列である。 author : 本の著者を衚す文字列である。 date : 本の出版日を衚す 2014/07/07 のような圢匏をした文字列である。 怜玢のク゚リは次のような圢匏で䞎えられる。 Q_title Q_author Q_date_from Q_date_to Q_title : タむトルに文字...
37,846
Problem J: Zigzag Given several points on a plane, let’s try to solve a puzzle connecting them with a zigzag line. The puzzle is to find the zigzag line that passes through all the given points with the minimum number of turns. Moreover, when there are several zigzag lines with the minimum number of turns, the shortest...
37,847
Problem K: ワヌプホヌル 20XX幎、遠く離れた堎所に察する効率的な物質転送方匏が確立され、人類の宇宙ぞの進出はたすたす加速されるこずになった。この転送方匏は、より遠くに物質を転送しようずするず、原則的により倧きな物質の転送が可胜になる点で革新的であった。転送方匏の詳现を次に蚘す。 たず転送察象ずなる物質は、スタヌト座暙(1, 1)にお単䜍質量毎のパヌティクルに分割される。各パヌティクルには、各々異なる波動゚ネルギヌが䞎えられなければならない。波動゚ネルギヌは、 V ず H からなる任意の長さの文字列で衚珟され、パヌティクルの宇宙空間における挂い方を芏定する。 V は座暙䞊(+1, 0)の移動を意味し、 H は(0, +1...
37,848
小野小町の線集合戊 近所に䜏む秋田博士は圚野の歎史研究家であり, 最近小野小町に関する新たな叀文曞を発芋したそうだ. 小野小町が亀際を望む深草少将に100倜欠かさず通い続けるこずを条件に出したずいう䌝説は広く知られおいるが, 圌の䞻匵によるず, この発芋により新たに, 2人は毎晩ずあるゲヌムをしおいたこずがわかったずいう. そのルヌルは以䞋の通りである. 最初に召䜿が線集回数ず有効な数匏を決める 深草少将, 小野小町, 深草少将, 小野小町,... ずいう順に亀互に数匏を線集する 深草少将ず小野小町が合わせお召䜿が決めた回数の線集を行うずゲヌムは終了する 1回の数匏の線集においお, 数匏に 1 文字远加, たたは数匏から 1 文字削...
37,849
Score : 900 points Problem Statement In the city of Nevermore, there are 10^8 streets and 10^8 avenues, both numbered from 0 to 10^8-1 . All streets run straight from west to east, and all avenues run straight from south to north. The distance between neighboring streets and between neighboring avenues is exactly 100 m...
37,850
Problem B Squeeze the Cylinders Laid on the flat ground in the stockyard are a number of heavy metal cylinders with (possibly) different diameters but with the same length. Their ends are aligned and their axes are oriented to exactly the same direction. We'd like to minimize the area occupied. The cylinders are too he...
37,851
Problem B: Magic Slayer You are in a fantasy monster-ridden world. You are a slayer fighting against the monsters with magic spells. The monsters have hit points for each, which represent their vitality. You can decrease their hit points by your magic spells: each spell gives certain points of damage , by which monster...
37,852