task
stringlengths
0
154k
__index_level_0__
int64
0
39.2k
長方圢探玢 瞊に H 行、暪に W 列䞊べられた、合蚈 W × H のマス目がありたす。いく぀かのマス目には印が぀いおいたす。各マス目の印の状態を読み蟌み、印の぀いおいないマス目だけからなる最倧の長方圢の面積を出力するプログラムを䜜成しおください。 入力デヌタは 1 行 W 文字から構成され、 H 行が䞎えられたす。たずえば以䞋のようなデヌタが䞎えられたす。 ..*....**. .......... **....***. ....*..... ..*....... ...**..... .*.*...... .......... ..**...... .*..*..... 入力デヌタの䞀行が、䞀行のマス目を衚珟したす。入力デヌタの...
38,496
D: Nose And Lung 問題文 あなたは謎の敵察的な゚むリアンに぀いお研究しおいたす。 ゚むリアンには錻の穎が $N$ 個あり、肺が $1$ 個以䞊ありたす。 しかし、肺がいく぀あるか、および、どの錻の穎ずどの肺が繋がっおいるかが分かっおいたせん。 あなたぱむリアンに関しお、以䞋の仮説を立おたした: それぞれの肺は $1$ 個以䞊の錻の穎に぀ながっおいる それぞれ錻の穎は $0$ 個以䞊の肺に぀ながっおいる 党おの肺に察しお酞玠が䟛絊されないず死んでしたう。すなわち、ある肺に぀ながっおいる党おの錻の穎を塞がれるず、゚むリアンは死ぬ 政府はあなたの仮説を怜蚌するために、肺ず錻の穎の接続関係がわかっおいない゚むリアンを $1...
38,497
ゟンビ島 (Zombie Island) 問題 JOI 君が䜏んでいる島がゟンビに䟵略されおしたったJOI 君は島で䞀番安党な避難堎所ずしお蚭定されおいるシェルタヌに逃げ蟌むこずにした JOI 君が䜏んでいる島は町 1 から町 N たでの N 個の町からなり町ず町ずは道路で結ばれおいる島には M 本の道路がありすべおの道路は異なる 2 ぀の町を結んでいるJOI 君は道路を双方向に自由に移動できるが道路以倖を通っお町から別の町に行くこずはできない いく぀かの町はゟンビに支配されおおり蚪れるこずが出来ないゟンビに支配されおいる町から S 本以䞋の道路を䜿っお到達できる町を 危険な町 ずいうそれ以倖の町を 危険でない...
38,498
ねこたっしぐら あるずころに倧きな叀いお屋敷があり、匹のねこが䜏み着いおいたした。図のように、お屋敷は䞊空から芋るず凞倚角圢になっおおり、たっすぐな壁で囲たれたいく぀かの郚屋で造られおいたす。枚の壁はその䞡端にある柱によっお支えられおいたす。お屋敷はずおも叀いため、どの壁にもねこが通るこずができるくらいの穎が぀空いおいたす。ねこは壁の穎を通っおお屋敷の郚屋ず郚屋たたは郚屋ず倖を行き来するこずができたす。 お屋敷のご䞻人は、ねこに逌をあげるために、口笛を吹いおねこをお屋敷の倖ぞ呌び出したす。ねこはずおも賢く、ご䞻人が口笛を吹くず、「最良の遞択」でお屋敷の倖ぞ抜け出したす。぀たり、最も少ない回数だけ穎を通っお倖ぞ出たす。 ねこは...
38,499
Insertion Sort Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >= 0 and A[j] > key A[j+1] = A[j] j-- A[j+1]...
38,500
Problem E: Mirror Illusion A rich man has a square room with mirrors for security or just for fun. Each side of the room is eight meters wide. The floor, the ceiling and the walls are not special; however, the room can be equipped with a lot of mirrors on the walls or as vertical partitions. Every mirror is one meter w...
38,501
Best Matched Pair You are working for a worldwide game company as an engineer in Tokyo. This company holds an annual event for all the staff members of the company every summer. This year's event will take place in Tokyo. You will participate in the event on the side of the organizing staff. And you have been assigned ...
38,502
Problem B: Old Bridges Long long ago, there was a thief. Looking for treasures, he was running about all over the world. One day, he heard a rumor that there were islands that had large amount of treasures, so he decided to head for there. Finally he found n islands that had treasures and one island that had nothing. M...
38,503
Score: 600 points Problem Statement M-kun is a brilliant air traffic controller. On the display of his radar, there are N airplanes numbered 1, 2, ..., N , all flying at the same altitude. Each of the airplanes flies at a constant speed of 0.1 per second in a constant direction. The current coordinates of the airplane ...
38,504
Score : 2000 points Problem Statement You are given a rooted tree with N vertices. The vertices are numbered 0, 1, ..., N-1 . The root is Vertex 0 , and the parent of Vertex i (i = 1, 2, ..., N-1) is Vertex p_i . Initially, an integer a_i is written in Vertex i . Here, (a_0, a_1, ..., a_{N-1}) is a permutation of (0, 1...
38,506
Chicken or the Egg Time Limit: 8 sec / Memory Limit: 64 MB A: 卵が先か鶏が先か 2012/2/8 卵が先か鶏が先かずいう問題はいただか぀お誰もわからなかった しかし今回の琵琶湖遺跡で発掘で獲埗した文曞にはその答えが蚘されおいるずいう 2012/2/9 文曞はchickenずeggずいう単語のみで構成されおいたこのたたでは答えがわからない 2012/2/10 さらに文曞を読み進めるず文曞䞭の単語の順番は産たれた順番を衚しおいるこずがわかった "eggchicken"ずあった堎合は先に鶏が産たれその埌に鶏が卵を産んだずいうこずを瀺しおいる 2012/2/11...
38,507
Problem C: Tetrahedra Peter P. Pepper is facing a difficulty. After fierce battles with the Principality of Croode, the Aaronbarc Kingdom, for which he serves, had the last laugh in the end. Peter had done great service in the war, and the king decided to give him a big reward. But alas, the mean king gave him a hard q...
38,508
Score : 400 points Problem Statement There is a grid with H horizontal rows and W vertical columns, and there are obstacles on some of the squares. Snuke is going to choose one of the squares not occupied by an obstacle and place a lamp on it. The lamp placed on the square will emit straight beams of light in four card...
38,509
Problem B: Yu-kun Likes Letters in the English Alphabet Background 䌚接倧孊付属幌皚園はプログラミングが倧奜きな子䟛が集たる幌皚園である。園児の䞀人であるゆう君は、プログラミングず同じくらい英小文字が倧奜きだ。 そんなゆう君は玙ず䞞ず線、そしお英小文字を䜿う新しい遊びを考え、その採点甚プログラムを曞くこずにした。 Problem 初期状態ずしお、玙に V 個の䞞ず E 本の線が曞かれおいる。䞞には0から昇順に番号が぀けられおおり、各䞞の䞭には英小文字が1぀曞かれおいるか、䜕も曞かれおいない。 各線は異なる぀の䞞を結んでいる。1぀の䞞が26本以䞊の線で結ばれるこずはな...
38,510
Score : 100 points Problem Statement You are parking at a parking lot. You can choose from the following two fee plans: Plan 1 : The fee will be A×T yen (the currency of Japan) when you park for T hours. Plan 2 : The fee will be B yen, regardless of the duration. Find the minimum fee when you park for N hours. Constrai...
38,511
Problem A: Bicube Mary Thomas has a number of sheets of squared paper. Some of squares are painted either in black or some colorful color (such as red and blue) on the front side. Cutting off the unpainted part, she will have eight opened-up unit cubes. A unit cube here refers to a cube of which each face consists of o...
38,512
Score : 400 points Problem Statement A university student, Takahashi, has to take N examinations and pass all of them. Currently, his readiness for the i -th examination is A_{i} , and according to his investigation, it is known that he needs readiness of at least B_{i} in order to pass the i -th examination. Takahashi...
38,513
Tangent to a Circle Find the tangent lines between a point $p$ and a circle $c$. Input The input is given in the following format. $px \; py$ $cx \; cy \; r$ $px$ and $py$ represents the coordinate of the point $p$. $cx$, $cy$ and $r$ represents the center coordinate and radius of the circle $c$ respectively. All input...
38,514
壁 XXX幎、突然出珟した倩敵の䟵入を防ぐために、人類は壁を䜜りその䞭に逃げ蟌んだ。その結果、人類の掻動領域はその壁で囲たれた範囲に限定されおしたった。この領域は、䞊空から芋るず W × H の長方圢である。領域内郚には x 軞あるいは y 軞に察しお平行な壁がいく぀か蚭眮されおいる。掻動領域の䟋を䞋図に瀺す。 人類は掻動領域内を自由に移動するこずができるが、壁を越えるためには䞀定量の資源を消費しなければならない。ただし、壁を越えるこずはできるが図䞭の (1)、壁の亀点を越えるこず (2)、壁や掻動領域の境界の䞊を移動するこず (3)、掻動領域倖に出るこず (4) はできない。 領域内郚の壁の情報ずいく぀かの始点ず終点の組を入...
38,515
Score : 2100 points Problem Statement There are N jewelry shops numbered 1 to N . Shop i ( 1 \leq i \leq N ) sells K_i kinds of jewels. The j -th of these jewels ( 1 \leq j \leq K_i ) has a size and price of S_{i,j} and P_{i,j} , respectively, and the shop has C_{i,j} jewels of this kind in stock. A jewelry box is said...
38,516
Score : 100 points Problem Statement Given a lowercase English letter c , determine whether it is a vowel. Here, there are five vowels in the English alphabet: a , e , i , o and u . Constraints c is a lowercase English letter. Input The input is given from Standard Input in the following format: c Output If c is a vowe...
38,517
Score : 600 points Problem Statement Takahashi has N cards. The i -th of these cards has an integer A_i written on it. Takahashi will choose an integer K , and then repeat the following operation some number of times: Choose exactly K cards such that the integers written on them are all different, and eat those cards. ...
38,518
Score : 200 points Problem Statement Snuke is having a barbeque party. At the party, he will make N servings of Skewer Meal . Example of a serving of Skewer Meal He has a stock of 2N skewers, all of which will be used in Skewer Meal. The length of the i -th skewer is L_i . Also, he has an infinite supply of ingredients...
38,519
Problem C: Magical Dungeon Arthur C. Malory is a wandering valiant fighter (in a game world). One day, he visited a small village and stayed overnight. Next morning, the village mayor called on him. The mayor said a monster threatened the village and requested him to defeat it. He was so kind that he decided to help sa...
38,521
Score : 900 points Problem Statement Let N be an even number. There is a tree with N vertices. The vertices are numbered 1, 2, ..., N . For each i ( 1 \leq i \leq N - 1 ), the i -th edge connects Vertex x_i and y_i . Snuke would like to decorate the tree with ribbons, as follows. First, he will divide the N vertices in...
38,522
Problem D: Find the Outlier Professor Abacus has just built a new computing engine for making numerical tables. It was designed to calculate the values of a polynomial function in one variable at several points at a time. With the polynomial function f ( x ) = x 2 + 2 x + 1, for instance, a possible expected calculatio...
38,523
C: Project Management / プロゞェクト管理 あなたは凄腕のプロゞェクトマネヌゞャである 今回は超倧芏暡なプロゞェクトのマネゞメントを請け負った 図1: アロヌダむアグラム これたでの勘ず経隓からなんずか 図1 のようなアロヌダむアグラムを䜜成した 各ノヌドは䜜業の結合点を衚しおいる たたSはプロゞェクトの開始状態Tはプロゞェクトの終了状態を衚す結合点である 䟋えば結合点P3においお䜜業Gは䜜業Cず䜜業Eが終了しなければ開始できない プロゞェクトの蚈画は完璧であり党おの結合点はそこから出お再びその結合点に戻る䜜業経路を持たない たた党おの䜜業は前埌に結合点を持っおおり 開始状態ず終了状...
38,524
Range Min of Max Query 敎数の組の列 (a_1,b_1), (a_2,b_2),..,(a_N,b_N) が䞎えられたす。 二皮類のク゚リを凊理しおください。 䞀皮類目のク゚リでは、 a_L,a_{L+1},..,a_R に X を加算したす。 二皮類目のク゚リでは、 max(a_L,b_L),max(a_{L+1},b_{L+1}),..,max(a_R,b_R) の最小倀を求めたす。 入力 N Q a_1 b_1 a_2 b_2 : a_N b_N query_1 query_2 : query_Q i 番目のク゚リが䞀皮類目のク゚リの堎合、 query_i は 1 L_i R_i X_i ずなりたす。 i...
38,526
Least Common Multiple Find the least common multiple (LCM) of given n integers. Input n a 1 a 2 ... a n n is given in the first line. Then, n integers are given in the second line. Output Print the least common multiple of the given integers in a line. Constraints 2 ≀ n ≀ 10 1 ≀ a i ≀ 1000 Product of given integers a i...
38,527
ペンキの色 問題 情報オリンピックの宣䌝のために,長方圢のベニダ板にペンキを塗り看板を制䜜したい.ベニダ板には色を塗りたくないずころにあらかじめ䜕枚かの長方圢のマスキングテヌプが貌られおいる.そこでマスキングテヌプで区切られた領域ごずに別々の色を䜿いペンキを塗るこずにした.䟋えば,図 5-1 の堎合は 5 色のペンキを䜿う. 入力ずしおマスキングテヌプを貌る䜍眮が䞎えられた時,䜿うペンキの色の数を求めるプログラムを䜜成せよ.ただし,ベニダ板党䜓がマスキングテヌプで芆われるこずはなく,党おのマスキングテヌプの蟺はベニダ板のいずれかの蟺に平行である. 入力 入力は耇数のデヌタセットからなる各デヌタセットは以䞋の圢匏で䞎えられる 1 ...
38,528
C: オセロ 問題 オセロの盀面を甚意する. 盀面は巊䞊が $(1,1)$ , 右䞋が $(8,8)$ ず衚蚘する. ここで甚意する盀面は, 以䞋のように, $(5,4)$ の黒の石がない. ........ ........ ........ ...ox... ....o... ........ ........ ........ 黒石:x 癜石:o 8x8の盀面 この状態から, 黒が先手でオセロを開始する. AORむカちゃんは, 以䞋のルヌルで $q$ 回遊ぶ. 巊䞊を $a$ 行目 $b$ 列目のマス, 右䞋を $c$ 行目 $d$ 列目のマスずした, マス目に沿った長方圢領域が䞎えられる. AORむカちゃんは, この長方圢領...
38,529
Simultaneous Equation Write a program which solve a simultaneous equation: ax + by = c dx + ey = f The program should print x and y for given a , b , c , d , e and f (-1,000 ≀ a, b, c, d, e, f ≀ 1,000). You can suppose that given equation has a unique solution. Input The input consists of several data sets, 1 line for ...
38,530
問題 2 加枛乗陀の蚈算をする電卓プログラムを䜜りなさい 入力デヌタの各行には数ず蚘号 +, -, *, /, = のどれか1぀が亀互に曞いおある 行目は数である 挔算 +, -, *, / の優先順䜍乗陀算 *, / を加枛算 +, - よりも先に蚈算するこずは考えず入力の順序で蚈算し= の行になったら蚈算結果を出力する 入力デヌタの数倀は10 8 以䞋の正の敎数ずする 蚈算䞭および蚈算結果は0たたは負の数になるこずもあるが -10 8 〜10 8 の範囲は超えない 割り算は切り捚おずする したがっお100/3*3= は 99 になる 出力ファむルにおいおは 出力の最埌の行にも改行コヌドを入れるこ...
38,531
ぐるぐる暡様 「ぐるぐる暡様」を衚瀺するプログラムを䜜成するこずにしたした。「ぐるぐる暡様」は以䞋のようなものずしたす。 1 蟺の長さが n の堎合、 n 行 n 列の文字列ずしお衚瀺する。 巊䞋隅を基点ずし時蚈回りに回転する枊状の暡様ずする。 線のある郚分は #半角シャヌプ、空癜郚分は " "半角空癜で衚珟する。 線ず線の間は空癜を眮く。 敎数 n を入力ずし1 蟺の長さが n の「ぐるぐる暡様」を出力するプログラムを䜜成しおください。 Input 入力は以䞋の圢匏で䞎えられたす。 d n 1 n 2 : n d 行目にデヌタセットの数 d ( d ≀ 20)、続く d 行に i 個目のぐるぐる暡様の蟺の長さ n i...
38,532
Problem H: Eleven Lover Edward Leven loves multiples of eleven very much. When he sees a number, he always tries to find consecutive subsequences (or substrings) forming multiples of eleven. He calls such subsequences as 11-sequences. For example, he can find an 11-sequence 781 in a number 17819. He thinks a number whi...
38,533
Problem G: Network Mess Gilbert is the network admin of Ginkgo company. His boss is mad about the messy network cables on the floor. He finally walked up to Gilbert and asked the lazy network admin to illustrate how computers and switches are connected. Since he is a programmer, he is very reluctant to move throughout ...
38,534
すぬけ君は誕生日プレれントずしお蟺の長さが l 1 × . . . × l d の d 次元超盎方䜓をもらったすぬけ君はこの盎方䜓を i 番目の座暙の範囲が 0 以䞊 l i 以䞋ずなるようにおき x 1 + . . . + x d ≀ s をみたす郚分を食べおしたったただし x i は i 番目の座暙を衚すすぬけ君の食べた郚分の䜓積を V ずするず d!V ( V に d の階乗をかけた倀) は敎数ずなるこずが蚌明できる d!V を1,000,000,007 で割ったあたりを求めよ Constraints 2 ≀ d ≀ 300 1 ≀ l i ≀ 300 0 ≀ s ≀ $\sum l_{i}$ 入力は党お敎数...
38,535
Score : 600 points Problem Statement Ringo Mart, a convenience store, sells apple juice. On the opening day of Ringo Mart, there were A cans of juice in stock in the morning. Snuke buys B cans of juice here every day in the daytime. Then, the manager checks the number of cans of juice remaining in stock every night. If...
38,536
Score : 400 points Problem Statement You are given a sequence of positive integers of length N , A=a_1,a_2,
,a_{N} , and an integer K . How many contiguous subsequences of A satisfy the following condition? (Condition) The sum of the elements in the contiguous subsequence is at least K . We consider two contiguous subs...
38,537
Philosopher's Stone In search for wisdom and wealth, Alchemy, the art of transmutation, has long been pursued by people. The crucial point of Alchemy was considered to find the recipe for philosopher’s stone , which will be a catalyst to produce gold and silver from common metals, and even medicine giving eternal life....
38,538
Score : 700 points Problem Statement Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0 , and the coordinate of Takahashi is known to be x , but his coordinate afterwards cannot be known to Aoki. Time is divided into turns. In each turn, Aoki and Takahashi ...
38,540
Score : 200 points Problem Statement Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i ( 1\leq i \leq N ), you are given a string S_i representing the verdict for that test case. Find the numbers of test...
38,541
F: 玙の折りたたみ / Folding Paper 問題文 高さ $H$ マス、幅 $W$ マスの栌子状に区切られた長方圢の玙がある。 $0$ から数えお䞊から $i$ 行目、巊から $j$ 列目のマスには敎数 $i \times W+j$ が曞かれおいる。 $H=2, W=3$ の䟋を䞋の図に瀺す。 AOR むカちゃんは、この玙に察しお次のような操䜜を順に行った。 $1$ マス分の面積になるたでマスの区切り線に沿っお繰り返し折る。この時の折る線や山谷、順番などは任意である。玙を砎らない任意の折り方ができる。 $4$ 蟺を切り萜ずしお $H \times W$ 枚の玙に分割する。 䞊から順にめくっおいき、曞かれおいた敎数を䞊べた数...
38,542
Problem E: Pipeline Scheduling An arithmetic pipeline is designed to process more than one task simultaneously in an overlapping manner. It includes function units and data paths among them. Tasks are processed by pipelining : at each clock, one or more units are dedicated to a task and the output produced for the task...
38,543
Single Source Shortest Path II For a given weighted graph $G = (V, E)$, find the shortest path from a source to each vertex. For each vertex $u$, print the total weight of edges on the shortest path from vertex $0$ to $u$. Input In the first line, an integer $n$ denoting the number of vertices in $G$ is given. In the f...
38,544
H: われわれの努力に぀いお - About Our Effort - 問題 ※この問題はおたけの問題ず捉えおいただけるずありがたく、 できれば先に他の問題のほうをお楜しみいただければず思っおおりたしおですので他の問題を通し終えお暇になりか぀その暇を このコンテストで朰そうずいう気になっおくれた方に挑戊しおいただければず思いたす。 D問題のク゚リが遅くおすみたせんでした。 しかし我々ずいたしたしおも決しおただ怠慢をしおいたわけではないのです。 私たちなりに努力したのです。 その努力の片鱗を味わっおいただくため、このような問題を出題した次第でありたす。 問題: D問題のサヌバヌ偎の凊理をするプログラムを䜜成せよ。 なおこの問題は本...
38,545
Score : 100 points Problem Statement Joisino wants to evaluate the formula " A op B ". Here, A and B are integers, and the binary operator op is either + or - . Your task is to evaluate the formula instead of her. Constraints 1≩A,B≩10^9 op is either + or - . Input The input is given from Standard Input in the following...
38,546
Score : 400 points Problem Statement Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q) , an integer T_i is provided, which means the following:...
38,547
お財垃メタボ蚺断 月に消費皎がになっおから、お財垃が硬貚でパンパンになっおいたせんか。同じ金額を持ち歩くなら硬貚の枚数を少なくしたいですよね。硬貚の合蚈が円以䞊なら、硬貚をお札に䞡替しお、お財垃のメタボ状態を解消できたす。 お財垃の䞭の硬貚の枚数が皮類ごずに䞎えられたずき、硬貚をお札に䞡替できるかどうかを刀定するプログラムを䜜成しおください。 入力 入力は以䞋の圢匏で䞎えられる。 c1 c5 c10 c50 c100 c500 入力は行からなる。 c1 、 c5 、 c10 、 c50 、 c100 、 c500 (0 ≀ c1, c5, c10, c50, c100, c500 ≀ 50) は、それぞれ、1円、5円...
38,548
Incircle of a Triangle Write a program which prints the central coordinate ($cx$,$cy$) and the radius $r$ of a incircle of a triangle which is constructed by three points ($x_1$, $y_1$), ($x_2$, $y_2$) and ($x_3$, $y_3$) on the plane surface. Input The input is given in the following format $x_1$ $y_1$ $x_2$ $y_2$ $x_3...
38,549
Score : 300 points Problem Statement In a flower bed, there are N flowers, numbered 1,2,......,N . Initially, the heights of all flowers are 0 . You are given a sequence h=\{h_1,h_2,h_3,......\} as input. You would like to change the height of Flower k to h_k for all k (1 \leq k \leq N) , by repeating the following "wa...
38,550
Unequal Dice Time Limit: 8 sec / Memory Limit: 64 MB B: 䞍揃いなサむコロ パチンコや競銬などの賭け事にお金を䜿いすぎお借金たみれになったあなたは T愛グルヌプの地䞋監獄に収容されおしたった ここであなたは借金を返すたで奎隷のように働かなくおはならない たたこの監獄にはあなたず同じ境遇の人が倚く収容されおいるので いく぀かの班に分けられおいる ある班ではサむコロを3぀転がしおお怀にいれお楜しむ習慣がある 最近そこの班長が倧倉な目にあったずかいう話を聞いたがあなたに盎接関係はない あなたの所属する班ではひず぀のサむコロを振っお楜しむ習慣がある ルヌルはサ...
38,551
Score : 700 points Problem Statement Ringo has an undirected graph G with N vertices numbered 1,2,...,N and M edges numbered 1,2,...,M . Edge i connects Vertex a_{i} and b_{i} and has a length of w_i . Now, he is in the middle of painting these N vertices in K colors numbered 1,2,...,K . Vertex i is already painted in ...
38,552
A Point in a Triangle There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. Write a program which prints " YES " if a point $P$ $(x_p, y_p)$ is in the triangle and " NO " if not. Input Input consists of several datasets. Each dataset consists of: $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $...
38,553
最悪の蚘者 問題 あなたは JOI 新聞瀟の蚘者でありスポヌツ蚘事を担圓しおいる 昚日たでにクロアチアではn 個のサッカヌチヌムによる総圓りのリヌグ戊が行われた倧䌚実行委員䌚は詊合結果ず芏定に基づき各チヌムに 1 䜍から n 䜍たでの順䜍を぀けたようであるあなたには䞀郚の詊合の勝敗ずずもに次の情報が䌝えられた 情報 1 匕き分けの詊合はなかった 情報 2 党おのチヌムに異なる順䜍が぀いた 情報 3 党おの 1 ≀ a < b ≀ n に察しa 䜍のチヌムず b 䜍のチヌムの詊合においお必ず a 䜍のチヌムが勝利した あなたは蚘事を䜜成するために䞀郚の詊合の勝敗ず䌝えられた情報 1 3 をもずに順䜍...
38,554
D: Many Decimal Integers 問題 数字 ( 0 から 9 ) のみからなる文字列 S ず、数字 ず ? のみからなる文字列 T が䞎えられたす。 S ず T は同じ長さです。 T 内に存圚するそれぞれの ? に぀いお、 0 から 9 たでの数字のいずれか 1 ぀に倉曎し、数字のみからなる文字列 T' を䜜るこずを考えたす。このずき、 f(T') \leq f(S) である必芁がありたす。ここで f(t) は、文字列 t を 10 進数ずしお読んだずきの敎数倀を返す関数ずしたす。 たた、 T' の最䞊䜍の桁にある数字は 0 であっおもよいものずしたす。 あり埗る文字列 T' すべおに぀いお、 f(T') の倀の総...
38,555
さんぜ Problem Statement ねこのそらは散歩が倧奜きだ道を歩くず新しい発芋がある そらの䜏む町は N 個の広堎ず N-1 本の道からなる 道はちょうど二぀の広堎を぀ないでおり枝分かれしたり道どうしが亀わったりしない 道には歩くのにかかる時間 t 埗られる発芋の個数の䞊限 m および発芋䞀぀あたりの䟡倀 v が指定されおいる 道を䞀方の端からもう䞀方の端たで歩いたずき m 回目たでの通行では䟡倀 v の発芋が䞀぀埗られるが m+1 回目以降は発芋が埗られない 今日もそらは町内の散歩に出かけるようだ そらの散歩は広堎 1 から始たりいく぀かの道 ( 0 本かもしれない ) を通っお最埌に...
38,556
Problem H: Company Organization You started a company a few years ago and fortunately it has been highly successful. As the growth of the company, you noticed that you need to manage employees in a more organized way, and decided to form several groups and assign employees to them. Now, you are planning to form n group...
38,557
Problem D: Deadly Dice Game T.I. Financial Group, a world-famous group of finance companies, has decided to hold an evil gambling game in which insolvent debtors compete for special treatment of exemption from their debts. In this game, each debtor starts from one cell on the stage called the Deadly Ring. The Deadly Ri...
38,558
Score : 1400 points Problem Statement Snuke is having another barbeque party. This time, he will make one serving of Skewer Meal . He has a stock of N Skewer Meal Packs . The i -th Skewer Meal Pack contains one skewer, A_i pieces of beef and B_i pieces of green pepper. All skewers in these packs are different and disti...
38,559
Score : 1800 points Problem Statement There is a tree T with N vertices, numbered 1 through N . For each 1 ≀ i ≀ N - 1 , the i -th edge connects vertices a_i and b_i . Snuke is constructing a directed graph T' by arbitrarily assigning direction to each edge in T . (There are 2^{N - 1} different ways to construct T' .) ...
38,560
Score : 200 points Problem Statement It's now the season of TAKOYAKI FESTIVAL! This year, N takoyaki (a ball-shaped food with a piece of octopus inside) will be served. The deliciousness of the i -th takoyaki is d_i . As is commonly known, when you eat two takoyaki of deliciousness x and y together, you restore x \time...
38,561
Score: 200 points Problem Statement The number 105 is quite special - it is odd but still it has eight divisors. Now, your task is this: how many odd numbers with exactly eight positive divisors are there between 1 and N (inclusive)? Constraints N is an integer between 1 and 200 (inclusive). Input Input is given from S...
38,562
すぬけ君は初期状態では動くこずはできない i 番目のチケットの倀段は p i でありこれを買うず任意の (x, y) ず任意の非負実数 t に察し (x, y) から (x + ta i , y + tb i ) に移動するこずができるようになるすぬけ君が平面䞊の任意の二点間を(いく぀かのチケットを組み合わせお) 移動できるようになるために買わなければならないチケットの合蚈金額の最小倀を求めよ Constraints 1 ≀ n ≀ 200000 −10 9 ≀ a i , b i ≀ 10 9 1 ≀ p i ≀ 10 9 入力は党お敎数である Input n a 1 b 1 p 1 . . . a n b n p n ...
38,563
Problem A: And Then There Was One Let’s play a stone removing game. Initially, n stones are arranged on a circle and numbered 1, ... , n clockwise (Figure 1). You are also given two numbers k and m . From this state, remove stones one by one following the rules explained below, until only one remains. In step 1, remove...
38,564
Score : 700 points Problem Statement Given are positive integers N and K . Determine if the 3N integers K, K+1, ..., K+3N-1 can be partitioned into N triples (a_1,b_1,c_1), ..., (a_N,b_N,c_N) so that the condition below is satisfied. Any of the integers K, K+1, ..., K+3N-1 must appear in exactly one of those triples. F...
38,565
Problem C: Differential Pulse Code Modulation 差分パルス笊号倉調は䞻に音声信号を圧瞮する際に甚いられる圧瞮手法の䞀぀である 音声信号は蚈算機䞊では敎数列(むンパルス列)ずしお扱われる敎数列は入力信号を䞀定時間間隔で暙本化(サンプリング)し振幅を蚘録したものである䞀般にこの敎数列は前埌の倀が近いずいう傟向があるこれを利甚し前埌の倀の差分を笊号化し圧瞮率を向䞊させるのが差分パルス笊号倉調である 本問題では差分の倀をあらかじめ定められた倀の集合から遞ぶこずを考えるこの倀の集合をコヌドブックず呌ぶこずにする埩号化埌の音声信号 y n は以䞋の匏で定められる y n = y ...
38,566
マトリョヌシカ マトリョヌシカずは女性像をかたどった朚補の人圢で、ロシアの代衚的な民芞品です。マトリョヌシカは、倧きな人圢の䞭にそれより小さな人圢が入っおいる入れ子構造になっおおり、倧きさの異なる耇数の人圢で構成されおいたす。このような入れ子構造にするため、各人圢の胎䜓は䞊䞋で分割できる筒状の構造になっおいたす。マトリョヌシカは職人の手で手䜜りされるため、䞀぀䞀぀の人圢は䞖界に䞀぀しかない非垞に貎重なものになりたす。 兄匟である䞀郎君ず次郎君は、マトリョヌシカで遊ぶのが倧奜きで、各自がそれぞれ1組のマトリョヌシカを持っおいたした。䞀郎君のマトリョヌシカは n 個の人圢から構成されおおり、次郎君のマトリョヌシカは m 個の人圢から構成...
38,567
問題 3 入力ファむルの行目に正敎数 n n≧3が曞いおあり ぀づく n 行に異なる正敎数 a 1 , ..., a n が ぀ず぀曞いおある a 1 , ..., a n から異なる個を遞んで䜜られる 順列を数ずしお芋お小さい順に䞊べたずき 番目に来るものを出力せよ ただし 䟋えばa 1 = 1a 4 = 11 のような堎合も a 1 a 4 ず a 4 a 1 は異なる順列ずみなす たた 1≩a i ≩10000 (i=1, ..., n) か぀ 3≩n≩10 4 である 出力ファむルにおいおは 出力の最埌にも改行コヌドを入れるこず 入出力䟋 入力䟋 3 2 7 5 出力䟋 52 入...
38,568
C: サボテンク゚リ 問題文 単玔無向グラフで、任意の蟺が高々 $1$ ぀の単玔閉路にしか含たれないようなものをサボテングラフず呌ぶこずにしたす。 $N$ 頂点 $M$ 蟺の連結なサボテングラフ $G$ が䞎えられたす。 各頂点は $1$ から $N$ たで番号が付いおいたす。 たた、$i$ 個目の蟺は頂点 $a_i$ ず頂点 $b_i$ を結んでおり、コストは $c_i$ です。 グラフ $G$ 䞊の単玔パスのコストを、そのパス䞊に含たれる党おの蟺のコストの XOR ず定めたす。 以䞋のような圢匏の $Q$ 個のク゚リに答えおください。 x_i y_i k_i ― 頂点 $x_i$ ず頂点 $y_i$ を繋ぐすべおの単玔パスのコス...
38,569
倧圓たり! あいづ孊園倧孊附属高校の倧阿足あたる君は、スロットマシヌンで遊ぶこずにしたした。 このマシヌンは、メダルを投入するず、3 ぀のリヌルが回転を始め、各リヌルが自動的に止たりたす。通垞の1ゲヌム(通垞ゲヌム)は 3 枚のメダルを投入し、図柄が揃うず、その図柄に応じお次のずおりメダルが埗られたす。 図柄の揃い方によっおは特別なサヌビスが開始されたす。 7 の図柄が 3 ぀揃うずビッグボヌナスが始たり、ボヌナスゲヌムを 5 ゲヌム行うこずができたす。たた、BAR の図柄が 3 ぀揃うずレギュラヌボヌナスが始たり、ボヌナスゲヌムを 3 ゲヌム行うこずができたす。 スタヌの図柄が 3 ぀揃うず無料ゲヌムが開始され、メダルを埗るこずは...
38,570
Score : 1700 points Problem Statement We have a grid with N rows and N columns. The cell at the i -th row and j -th column is denoted ( i , j ). Initially, M of the cells are painted black, and all other cells are white. Specifically, the cells ( a_1 , b_1 ), ( a_2 , b_2 ), ... , ( a_M , b_M ) are painted black. Snuke ...
38,571
Score : 600 points Problem Statement Snuke, a water strider, lives in a rectangular pond that can be seen as a grid with H east-west rows and W north-south columns. Let (i,j) be the square at the i -th row from the north and j -th column from the west. Some of the squares have a lotus leaf on it and cannot be entered. ...
38,572
KND Warp Problem KND君は䌚接倧孊に圚籍する孊生プログラマだ。圌はその優秀な頭脳をもっおワヌプ装眮を開発したこずで有名である。ワヌプ装眮ずは䟿利なもので、ある堎所から別の堎所たで瞬時に移動するこずができる。圌はこれから地球䞊に点圚するワヌプ装眮を甚いお様々な堎所を可胜な限り早くめぐる旅を蚈画しおいる。 圌の隣人であるあなたの仕事は3次元空間 (xyz盎亀座暙系) 䞊に存圚する N 個のワヌプ装眮をうたく䜿甚しお、1から M たでの番号がふられた M 個の点を順に通っお、 M 番目の点たで移動するずきの最小の所芁時間を求めるこずだ。はじめは1番目の点にいるものずし、どのワヌプ装眮も任意のワヌプ装眮ぞ時間0で移動できる...
38,573
Points on a Straight Line The university of A stages a programming contest this year as has been the case in the past. As a member of the team in charge of devising the problems, you have worked out a set of input data for a problem, which is an arrangement of points on a 2D plane in the coordinate system. The problem ...
38,574
Problem B: Butterfly Claire is a man-eater. She's a real man-eater. She's going around with dozens of guys. She's dating all the time. And one day she found some conflicts in her date schedule. D'oh! So she needs to pick some dates and give the others up. The dates are set by hours like 13:00 to 15:00. She may have mor...
38,575
Score : 900 points Problem Statement We have an undirected weighted graph with N vertices and M edges. The i -th edge in the graph connects Vertex U_i and Vertex V_i , and has a weight of W_i . Additionally, you are given an integer X . Find the number of ways to paint each edge in this graph either white or black such...
38,576
Equivalent Vertices Background 䌚接倧孊付属幌皚園はプログラミングが倧奜きな子䟛が集たる幌皚園である。 園児の䞀人であるゆう君は,プログラミングず同じくらいお絵描きが倧奜きだ。 これたでゆう君は䞞ず六角圢ず矢印で沢山絵を曞いおきた。 ある日ゆう君はこれらの絵がグラフであるこずを知る。 䞞ず六角圢は頂点ず呌ばれ,矢印は蟺ず呌ばれおいるらしい。 ゆう君は2぀の頂点間を結ぶようにしお矢印を描き、曎にその䞊に0か1を曞く。 このように,蟺に重み(0たたは1)があり有向な蟺からなるグラフは重み付き有向グラフず呌ばれる。 たた,頂点ず数字 x (0たたは1)が䞎えられた時,その頂点から出おいる矢印のうち, x ず同...
38,577
Score : 800 points Problem Statement Takahashi and Aoki will play a game on a tree. The tree has N vertices numbered 1 to N , and the i -th of the N-1 edges connects Vertex a_i and Vertex b_i . At the beginning of the game, each vertex contains a coin. Starting from Takahashi, he and Aoki will alternately perform the f...
38,578
Problem B: Blame Game Alice and Bob are in a factional dispute. Recently a big serious problem arised in a project both Alice and Bob had been working for. This problem was caused by lots of faults of Alice's and Bob's sides; those faults are closely related. Alice and Bob started to blame each other. First, Alice clai...
38,579
ICPC Calculator In mathematics, we usually specify the order of operations by using parentheses. For example, 7 × (3 + 2) always means multiplying 7 by the result of 3 + 2 and never means adding 2 to the result of 7 × 3. However, there are people who do not like parentheses. International Counter of Parentheses Council...
38,580
Score : 200 points Problem Statement Takahashi received otoshidama (New Year's money gifts) from N of his relatives. You are given N values x_1, x_2, ..., x_N and N strings u_1, u_2, ..., u_N as input. Each string u_i is either JPY or BTC , and x_i and u_i represent the content of the otoshidama from the i -th relative...
38,582
短歌数 願はくは 花の䞋にお 春死なむ そのきさらぎの 望月のころ これは西行法垫が詠んだずされる有名な短歌の䞀぀である 短歌は日本においお叀くから芪したれおいる和歌の䞀皮でありその倚くは 5・7・5・7・7 の五句䞉十䞀音からなる ずころで57577 ずいう数は5 ず 7 の二皮類の数字からなる このような十進衚蚘がちょうど二皮類の数字からなる正の敎数を短歌数ず呌ぶこずにする 䟋えば10, 12, 57577, 25252 などは短歌数であるが5, 11, 123, 20180701 などは短歌数ではない 正の敎数 N が䞎えられる N 番目に小さい短歌数を求めよ Input 入力は最倧で 100...
38,583
Multi-column List Ever since Mr. Ikra became the chief manager of his office, he has had little time for his favorites, programming and debugging. So he wants to check programs in trains to and from his office with program lists. He has wished for the tool that prints source programs as multi-column lists so that each ...
38,584
RSQ and RAQ Write a program which manipulates a sequence A = { a 1 , a 2 , . . . , a n } with the following operations: add(s, t, x) : add x to a s , a s+1 , ..., a t . getSum(s, t) : report the sum of a s , a s+1 , ..., a t . Note that the initial values of a i ( i = 1, 2, . . . , n ) are 0. Input n q query 1 query 2 ...
38,585
Score : 100 points Problem Statement Smeke has decided to participate in AtCoder Beginner Contest (ABC) if his current rating is less than 1200 , and participate in AtCoder Regular Contest (ARC) otherwise. You are given Smeke's current rating, x . Print ABC if Smeke will participate in ABC, and print ARC otherwise. Con...
38,586
Score : 300 points Problem Statement You drew lottery N times. In the i -th draw, you got an item of the kind represented by a string S_i . How many kinds of items did you get? Constraints 1 \leq N \leq 2\times 10^5 S_i consists of lowercase English letters and has a length between 1 and 10 (inclusive). Input Input is ...
38,587
Score : 400 points Problem Statement Snuke lives in another world, where slimes are real creatures and kept by some people. Slimes come in N colors. Those colors are conveniently numbered 1 through N . Snuke currently has no slime. His objective is to have slimes of all the colors together. Snuke can perform the follow...
38,588
Score : 200 points Problem Statement When Mr. X is away from home, he has decided to use his smartwatch to search the best route to go back home, to participate in ABC. You, the smartwatch, has found N routes to his home. If Mr. X uses the i -th of these routes, he will get home in time t_i at cost c_i . Find the small...
38,589
Problem C: Save the Energy You were caught in a magical trap and transferred to a strange field due to its cause. This field is three- dimensional and has many straight paths of infinite length. With your special ability, you found where you can exit the field, but moving there is not so easy. You can move along the pa...
38,590
Score : 300 points Problem Statement Gotou just received a dictionary. However, he doesn't recognize the language used in the dictionary. He did some analysis on the dictionary and realizes that the dictionary contains all possible diverse words in lexicographical order. A word is called diverse if and only if it is a ...
38,591
Score : 1200 points Problem Statement We have N irregular jigsaw pieces. Each piece is composed of three rectangular parts of width 1 and various heights joined together. More specifically: The i -th piece is a part of height H , with another part of height A_i joined to the left, and yet another part of height B_i joi...
38,592
Problem Statement Chelsea is a modern artist. She decided to make her next work with ladders. She wants to combine some ladders and paint some beautiful pattern. A ladder can be considered as a graph called hashigo . There are n hashigos numbered from 0 to n-1 . Hashigo i of length l_i has 2 l_{i} + 6 vertices v_{i, 0}...
38,593
Problem A Rearranging a Sequence You are given an ordered sequence of integers, ($1, 2, 3, ..., n$). Then, a number of requests will be given. Each request specifies an integer in the sequence. You need to move the specified integer to the head of the sequence, leaving the order of the rest untouched. Your task is to f...
38,594
デゞット アむヅ赀べこ店では、デゞットず呌ばれるナニヌクな「くじ」を販売しおいたす。各くじには、巊から右ぞ向かっお1列に$N$個の数字が䞊んでいたす。ただし、曞かれおいるのはからたでの数字です。 くじの賌入者は、これらの数字から$K$個の数字を消去し、残った$N-K$個の数字を巊から順番に䞊べおできる数をポむントずしお獲埗するこずができたす。たずえば$K=3$のずき、くじに$1414213$ず曞かれおいれば、巊から$1$、$1$、$2$を遞択しお消去するこずで$4413$ポむントを獲埗するこずができたす。 数字の列ず敎数$K$が䞎えられたずき、獲埗できるポむントの最倧倀を出力するプログラムを䜜成せよ。 入力 入力は以䞋の圢匏...
38,595
Enumeration of Subsets II You are given a set $T$, which is a subset of $U$. The set $U$ consists of $0, 1, ... n-1$. Print all sets, each of which is a subset of $U$ and includes $T$ as a subset. Note that we represent $0, 1, ... n-1$ as 00...0001, 00...0010, 00...0100, ..., 10...0000 in binary respectively and the in...
38,596
Score : 100 points Problem Statement We have weather records at AtCoder Town for some consecutive three days. A string of length 3 , S , represents the records - if the i -th character is S , it means it was sunny on the i -th day; if that character is R , it means it was rainy on that day. Find the maximum number of c...
38,597
Sum and Average 販売単䟡ず販売数量を読み蟌んで、販売金額の総合蚈ず販売数量の平均を出力するプログラムを䜜成しおください。 Input 入力は以䞋の圢匏で䞎えられたす。 販売単䟡,販売数量 販売単䟡,販売数量 : : カンマで区切られた販売単䟡ず販売数量の組が、耇数行に枡っお䞎えられたす。入力される倀はすべお 0 以䞊 1,000 以䞋で、販売単䟡ず販売数量の組の数は 100 を超えたせん。 Output 行目に販売金額の総合蚈敎数、行目に販売数量の平均(敎数を出力しおください。 販売数量の平均に端数小数点以䞋の数が生じた堎合は小数点以䞋第 1 䜍を四捚五入しおください。 Sample Input 100...
38,598
A: Undo Swapping 問題文 $N$ 行 $N$ 列のマス目の䞊に $N$ 個の石が眮いおありたす。 $i$ 番目の石は $R_i$ 行 $C_i$ 列にありたす。同じマスに耇数の石が眮かれおいるこずはありたせん。 あなたは次の2皮類の操䜜を任意の順で任意の回数行うこずができたす。 2぀の行を遞び、それらを亀換する 2぀の列を遞び、それらを亀換する。 $N$ 個の石を、マス目の巊䞊から右䞋にかけおの察角線䞊に䞊べるこずが出来るかを刀定するプログラムを䜜成しおください。 可胜な堎合は必芁な最小の操䜜回数を出力しおください。䞍可胜な堎合は $-1$ を出力しおください。 ただし、 察角線䞊に䞊ぶ石の順番は関係無い こずに泚意...
38,599
鉄道運賃(Train Fare) JOI 囜には $N$ 個の郜垂がありそれぞれ $1, 2, ..., N$ の番号が付けられおいる郜垂 1 はJOI 囜の銖郜である たたJOI 囜には鉄道䌚瀟がひず぀だけありこの䌚瀟は $M$ 個の路線を運行しおいるこれらの路線にはそれぞれ $1, 2, ..., M$ の番号が付けられおおり$i$ 番目 $(1 \leq i \leq M)$ の路線は郜垂 $U_i$ ず郜垂 $V_i$ を双方向に結んでいる郜垂ず郜垂の間を鉄道以倖で移動するこずはできないたたどの郜垂からどの郜垂ぞもいく぀かの路線を乗り継いで移動するこずができるようになっおいる 珟圚どの路線の運賃も 1...
38,600