task stringlengths 0 154k | __index_level_0__ int64 0 39.2k |
|---|---|
Score : 400 points Problem Statement We have a grid with H rows and W columns. At first, all cells were painted white. Snuke painted N of these cells. The i -th ( 1 \leq i \leq N ) cell he painted is the cell at the a_i -th row and b_i -th column. Compute the following: For each integer j ( 0 \leq j \leq 9 ), how many subrectangles of size 3Ã3 of the grid contains exactly j black cells, after Snuke painted N cells? Constraints 3 \leq H \leq 10^9 3 \leq W \leq 10^9 0 \leq N \leq min(10^5,HÃW) 1 \leq a_i \leq H (1 \leq i \leq N) 1 \leq b_i \leq W (1 \leq i \leq N) (a_i, b_i) \neq (a_j, b_j) (i \neq j) Input The input is given from Standard Input in the following format: H W N a_1 b_1 : a_N b_N Output Print 10 lines. The (j+1) -th ( 0 \leq j \leq 9 ) line should contain the number of the subrectangles of size 3Ã3 of the grid that contains exactly j black cells. Sample Input 1 4 5 8 1 1 1 4 1 5 2 3 3 1 3 2 3 4 4 4 Sample Output 1 0 0 0 2 4 0 0 0 0 0 There are six subrectangles of size 3Ã3 . Two of them contain three black cells each, and the remaining four contain four black cells each. Sample Input 2 10 10 20 1 1 1 4 1 9 2 5 3 10 4 2 4 7 5 9 6 4 6 6 6 7 7 1 7 3 7 7 8 1 8 5 8 10 9 2 10 4 10 9 Sample Output 2 4 26 22 10 2 0 0 0 0 0 Sample Input 3 1000000000 1000000000 0 Sample Output 3 999999996000000004 0 0 0 0 0 0 0 0 0 | 36,403 |
Problem H Rotating Cutter Bits The machine tool technology never stops its development. One of the recent proposals is more flexible lathes in which not only the workpiece but also the cutter bit rotate around parallel axles in synchronization. When the lathe is switched on, the workpiece and the cutter bit start rotating at the same angular velocity, that is, to the same direction and at the same rotational speed. On collision with the cutter bit, parts of the workpiece that intersect with the cutter bit are cut out. To show the usefulness of the mechanism, you are asked to simulate the cutting process by such a lathe. Although the workpiece and the cutter bit may have complex shapes, focusing on cross sections of them on a plane perpendicular to the spinning axles would suffice. We introduce an $xy$-coordinate system on a plane perpendicular to the two axles, in which the center of rotation of the workpiece is at the origin $(0, 0)$, while that of the cutter bit is at $(L, 0)$. You can assume both the workpiece and the cutter bit have polygonal cross sections, not necessarily convex. Note that, even when this cross section of the workpiece is divided into two or more parts, the workpiece remain undivided on other cross sections. We refer to the lattice points (points with both $x$ and $y$ coordinates being integers) strictly inside, that is, inside and not on an edge, of the workpiece before the rotation as points of interest, or POI in short. Our interest is in how many POI will remain after one full rotation of 360 degrees of both the workpiece and the cutter bit. POI are said to remain if they are strictly inside the resultant workpiece. Write a program that counts them for the given workpiece and cutter bit configuration. Figure H.1(a) illustrates the workpiece (in black line) and the cutter bit (in blue line) given in Sample Input 1. Two circles indicate positions of the rotation centers of the workpiece and the cutter bit. The red cross-shaped marks indicate the POI. Figure H.1(b) illustrates the workpiece and the cutter bit in progress in case that the rotation direction is clockwise. The light blue area indicates the area cut-off. Figure H.1(c) illustrates the result of this sample. Note that one of POI is on the edge of the resulting shape. You should not count this point. There are eight POI remained. Figure H.1. The workpiece and the cutter bit in Sample 1 Input The input consists of a single test case with the following format. $M$ $N$ $L$ $x_{w1}$ $y_{w1}$ ... $x_{wM}$ $y_{wM}$ $x_{c1}$ $y_{c1}$ ... $x_{cN}$ $y_{cN}$ The first line contains three integers. $M$ is the number of vertices of the workpiece $(4 \leq M \leq 20)$ and $N$ is the number of vertices of the cutter bit $(4 \leq N \leq 20)$. $L$ specifies the position of the rotation center of the cutter bit $(1 \leq L \leq 10000)$. Each of the following $M$ lines contains two integers. The $i$-th line has $x_{wi}$ and $y_{wi}$, telling that the position of the $i$-th vertex of the workpiece has the coordinates $(x_{wi}, y_{wi})$. The vertices are given in the counter-clockwise order. $N$ more following lines are positions of the vertices of the cutter bit, in the same manner, but the coordinates are given as offsets from its center of rotation, $(L, 0)$. That is, the position of the $j$-th vertex of the cutter bit has the coordinates $(L + x_{cj} , y_{cj} )$. You may assume $-10000 \leq x_{wi}, y_{wi}, x_{cj} , y_{cj} \leq 10000$ for $1 \leq i \leq M$ and $1 \leq j \leq N$. All the edges of the workpiece and the cutter bit at initial rotation positions are parallel to the $x$-axis or the $y$-axis. In other words, for each $i$ $(1 \leq i \leq M), x_{wi} = x_{wi'}$ or $y_{wi} = y_{wi'}$ holds, where $i' = (i $ mod$ M) + 1$. Edges are parallel to the $x$- and the $y$-axes alternately. These can also be said about the cutter bit. You may assume that the cross section of the workpiece forms a simple polygon, that is, no two edges have common points except for adjacent edges. The same can be said about the cutter bit. The workpiece and the cutter bit do not touch or overlap before starting the rotation. Note that $(0, 0)$ is not always inside the workpiece and $(L, 0)$ is not always inside the cutter bit. Output Output the number of POI remaining strictly inside the workpiece. Sample Input 1 4 6 5 -2 5 -2 -1 2 -1 2 5 -2 1 -2 0 0 0 0 -2 2 -2 2 1 Sample Output 1 8 Sample Input 2 14 14 6000 -3000 3000 -3000 -3000 3000 -3000 3000 -2000 2000 -2000 2000 -1000 1000 -1000 1000 0 0 0 0 1000 -1000 1000 -1000 2000 -2000 2000 -2000 3000 3000 3000 -3000 3000 -3000 2000 -2000 2000 -2000 1000 -1000 1000 -1000 0 0 0 0 -1000 1000 -1000 1000 -2000 2000 -2000 2000 -3000 3000 -3000 Sample Output 2 6785772 Sample Input 3 12 12 11 -50 45 -50 -45 40 -45 40 25 -10 25 -10 -5 0 -5 0 15 30 15 30 -35 -40 -35 -40 45 50 -45 50 45 -40 45 -40 -25 10 -25 10 5 0 5 0 -15 -30 -15 -30 35 40 35 40 -45 Sample Output 3 966 Sample Input 4 20 4 11 -5 5 -5 -10 -4 -10 -4 -1 -3 -1 -3 -10 1 -10 1 -4 0 -4 0 -1 1 -1 1 0 4 0 4 -1 10 -1 10 3 1 3 1 4 10 4 10 5 0 0 3 0 3 3 0 3 Sample Output 4 64 | 36,404 |
Problem Statement There is a maze which can be described as a W \times H grid. The upper-left cell is denoted as (1, 1), and the lower-right cell is (W, H) . You are now at the cell (1, 1) and have to go to the cell (W, H) . However, you can only move to the right adjacent cell or to the lower adjacent cell. The following figure is an example of a maze. ...#...... a###.##### .bc...A... ##.#C#d#.# .#B#.#.### .#...#e.D. .#A..###.# ..e.c#..E. ####d###.# #....#.#.# ##E...d.C. In the maze, some cells are free (denoted by . ) and some cells are occupied by rocks (denoted by # ), where you cannot enter. Also there are jewels (denoted by lowercase alphabets) in some of the free cells and holes to place jewels (denoted by uppercase alphabets). Different alphabets correspond to different types of jewels, i.e. a cell denoted by a contains a jewel of type A, and a cell denoted by A contains a hole to place a jewel of type A. It is said that, when we place a jewel to a corresponding hole, something happy will happen. At the cells with jewels, you can choose whether you pick a jewel or not. Similarly, at the cells with holes, you can choose whether you place a jewel you have or not. Initially you do not have any jewels. You have a very big bag, so you can bring arbitrarily many jewels. However, your bag is a stack, that is, you can only place the jewel that you picked up last. On the way from cell (1, 1) to cell (W, H) , how many jewels can you place to correct holes? Input The input contains a sequence of datasets. The end of the input is indicated by a line containing two zeroes. Each dataset is formatted as follows. H W C_{11} C_{12} ... C_{1W} C_{21} C_{22} ... C_{2W} ... C_{H1} C_{H2} ... C_{HW} Here, H and W are the height and width of the grid. You may assume 1 \leq W, H \leq 50 . The rest of the datasets consists of H lines, each of which is composed of W letters. Each letter C_{ij} specifies the type of the cell (i, j) as described before. It is guaranteed that C_{11} and C_{WH} are never # . You may also assume that each lowercase or uppercase alphabet appear at most 10 times in each dataset. Output For each dataset, output the maximum number of jewels that you can place to corresponding holes. If you cannot reach the cell (W, H) , output -1. Sample Input 3 3 ac# b#C .BA 3 3 aaZ a#Z aZZ 3 3 ..# .#. #.. 1 50 abcdefghijklmnopqrstuvwxyYXWVUTSRQPONMLKJIHGFEDCBA 1 50 aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyY 1 50 abcdefghijklmnopqrstuvwxyABCDEFGHIJKLMNOPQRSTUVWXY 1 50 aaaaaaaaaabbbbbbbbbbcccccCCCCCBBBBBBBBBBAAAAAAAAAA 10 10 ...#...... a###.##### .bc...A... ##.#C#d#.# .#B#.#.### .#...#e.D. .#A..###.# ..e.c#..E. ####d###.# ##E...D.C. 0 0 Output for the Sample Input 2 0 -1 25 25 1 25 4 | 36,405 |
Score : 1600 points Problem Statement Taichi thinks a binary string X of odd length N is beautiful if it is possible to apply the following operation \frac{N-1}{2} times so that the only character of the resulting string is 1 : Choose three consecutive bits of X and replace them by their median. For example, we can turn 00110 into 010 by applying the operation to the middle three bits. Taichi has a string S consisting of characters 0 , 1 and ? . Taichi wants to know the number of ways to replace the question marks with 1 or 0 so that the resulting string is beautiful, modulo 10^{9} + 7 . Constraints 1 \leq |S| \leq 300000 |S| is odd. All characters of S are either 0 , 1 or ? . Input Input is given from Standard Input in the following format: S Output Print the number of ways to replace the question marks so that the resulting string is beautiful, modulo 10^{9} + 7 . Sample Input 1 1??00 Sample Output 1 2 There are 4 ways to replace the question marks with 0 or 1 : 11100 : This string is beautiful because we can first perform the operation on the last 3 bits to get 110 and then on the only 3 bits to get 1 . 11000 : This string is beautiful because we can first perform the operation on the last 3 bits to get 110 and then on the only 3 bits to get 1 . 10100 : This string is not beautiful because there is no sequence of operations such that the final string is 1 . 10000 : This string is not beautiful because there is no sequence of operations such that the final string is 1 . Thus, there are 2 ways to form a beautiful string. Sample Input 2 ? Sample Output 2 1 In this case, 1 is the only beautiful string. Sample Input 3 ?0101???10???00?1???????????????0????????????1????0 Sample Output 3 402589311 Remember to output your answer modulo 10^{9} + 7 . | 36,406 |
ç®çãã®ãªãã¹ããããŠã©ãã å³ã®ãããªã¹ããããŠã©ããããããŸãããã®ã¹ããããŠã©ããã«ã¯ïŒã瀺ãç®å°ãäžã€ããã ãã§ãç®çãããããŸãããèµ·åããç¬éãéã¯ç®å°ãæããããããéã¯è»žãäžå¿ã«äžå®ã®å²åã§æèšåãã«å転ããŸããç®çãããªãã®ã§ãèµ·åããã®çµéæéãçŽæ¥èªã¿åãããšã¯ã§ããŸããããã®ä»£ãããéãç®å°ããæèšåãã«$a$床åã£ããšãã®çµéæéã$t$ç§ã§ããããšãããã£ãŠããŸãããã ãã$a$ã¯360åºŠæªæºãšããŸãã è§åºŠ$a$ãšçµéæé$t$ãäžãããããšããã¹ããããŠã©ããèµ·ååŸã«èªã¿åã£ãéã®è§åºŠrã衚ãçµéæéãæ±ããããã°ã©ã ãäœæããããã ããéãïŒåšããŠããªãããšã¯ããã£ãŠãããã®ãšããã å
¥å å
¥åã¯ä»¥äžã®åœ¢åŒã§äžããããã $a$ $t$ $r$ ïŒè¡ã«è§åºŠ$a$ ($1 \leq a \leq 359$)ãšè§åºŠ$a$ã®ãšãã®çµéæé$t$ ($1 \leq t \leq 1,000$)ãèªã¿åã£ãè§åºŠ$r$ ($0 \leq r \leq 359$)ããã¹ãп޿°ã§äžããããããã ãã$a$ãš$r$ã®åäœã¯åºŠã$t$ã®åäœã¯ç§ãšããã åºå èªã¿åã£ãéã®è§åºŠã衚ãçµéæéãç§ã§ïŒè¡ã«å®æ°ã§åºåããããã ãã誀差ããã©ã¹ãã€ãã¹0.001ãè¶
ããŠã¯ãªããªãã å
¥åºåäŸ å
¥åäŸïŒ 180 120 90 åºåäŸïŒ 60.0 å
¥åäŸïŒ 90 100 120 åºåäŸïŒ 133.333333 | 36,407 |
åŒ äžãããã 4 ã€ã® 1 ãã 9 ã®æŽæ°ã䜿ã£ãŠãçãã 10 ã«ãªãåŒãã€ãããŸãã 4 ã€ã®æŽæ° a, b, c, d ãå
¥åãããšããäžèšã®æ¡ä»¶ã«åŸããçãã 10 ã«ãªãåŒãåºåããããã°ã©ã ãäœæããŠãã ããããŸããçããè€æ°ããæã¯ãæåã«èŠã€ãã£ãçãã ããåºåãããã®ãšããŸããçãããªãæã¯ã0 ãšåºåããŠãã ããã æŒç®åãšããŠãå ç® (+)ãæžç® (-)ãä¹ç® (*) ã ãã䜿ããŸããé€ç® (/) ã¯äœ¿ããŸããã䜿çšã§ããæŒç®åã¯ïŒåã§ãã æ°ã4ã€ãšã䜿ããªããã°ãããŸããã 4ã€ã®æ°ã®é çªã¯èªç±ã«å
¥ãæããŠããŸããŸããã ã«ãã³ã䜿ã£ãŠãããŸããŸããã䜿çšã§ããã«ãã³ã¯ïŒçµïŒïŒåïŒä»¥äžã§ãã Input è€æ°ã®ããŒã¿ã»ãããäžããããŸããåããŒã¿ã»ããã®åœ¢åŒã¯ä»¥äžã®ãšããïŒ a b c d å
¥åã¯ïŒã€ã® 0 ã§çµäºããŸããããŒã¿ã»ããã®æ°ã¯ 40 ãè¶
ããŸããã Output åããŒã¿ã»ããã«ã€ããŠãäžãããã 4 ã€ã®æŽæ°ãšäžèšã®æŒç®èšå·ããã³ã«ãã³ãçµã¿åãããŠå€ã 10 ãšãªãåŒãŸã㯠0 ãïŒè¡ã«åºåããŠãã ãããåŒã®æååã 1024 æåãè¶
ããŠã¯ãããŸããã Sample Input 8 7 9 9 4 4 4 4 5 5 7 5 0 0 0 0 Output for the Sample Input ((9 * (9 - 7)) - 8) 0 ((7 * 5) - (5 * 5)) | 36,408 |
Score : 500 points Problem Statement There are K items placed on a grid of squares with R rows and C columns. Let (i, j) denote the square at the i -th row ( 1 \leq i \leq R ) and the j -th column ( 1 \leq j \leq C ). The i -th item is at (r_i, c_i) and has the value v_i . Takahashi will begin at (1, 1) , the start, and get to (R, C) , the goal. When he is at (i, j) , he can move to (i + 1, j) or (i, j + 1) (but cannot move to a non-existent square). He can pick up items on the squares he visits, including the start and the goal, but at most three for each row. It is allowed to ignore the item on a square he visits. Find the maximum possible sum of the values of items he picks up. Constraints 1 \leq R, C \leq 3000 1 \leq K \leq \min(2 \times 10^5, R \times C) 1 \leq r_i \leq R 1 \leq c_i \leq C (r_i, c_i) \neq (r_j, c_j) (i \neq j) 1 \leq v_i \leq 10^9 All values in input are integers. Input Input is given from Standard Input in the following format: R C K r_1 c_1 v_1 r_2 c_2 v_2 : r_K c_K v_K Output Print the maximum possible sum of the values of items Takahashi picks up. Sample Input 1 2 2 3 1 1 3 2 1 4 1 2 5 Sample Output 1 8 He has two ways to get to the goal: Visit (1, 1) , (1, 2) , and (2, 2) , in this order. In this case, the total value of the items he can pick up is 3 + 5 = 8 . Visit (1, 1) , (2, 1) , and (2, 2) , in this order. In this case, the total value of the items he can pick up is 3 + 4 = 7 . Thus, the maximum possible sum of the values of items he picks up is 8 . Sample Input 2 2 5 5 1 1 3 2 4 20 1 2 1 1 3 4 1 4 2 Sample Output 2 29 We have four items in the 1 -st row. The optimal choices are as follows: Visit (1, 1) (1, 2) , (1, 3) , (1, 4) , (2, 4) , and (2, 5) , in this order, and pick up all items except the one on (1, 2) . Then, the total value of the items he picks up will be 3 + 4 + 2 + 20 = 29 . Sample Input 3 4 5 10 2 5 12 1 5 12 2 3 15 1 2 20 1 1 28 2 4 26 3 2 27 4 5 21 3 5 10 1 3 10 Sample Output 3 142 | 36,409 |
Problem J: Substring Expression Trees are sometimes represented in the form of strings. Here is one of the most popular ways to represent unlabeled trees: Leaves are represented by " () ". Other nodes (i.e. internal nodes) are represented by " ( S 1 S 2 ... S n ) ", where S i is the string representing the i -th subnode. For example, the tree depicted in the figure below is represented by a string " ((()())()) ". A strange boy Norward is playing with such strings. He has found that a string sometimes remains valid as the representation of a tree even after one successive portion is removed from it. For example, removing the underlined portion from the string " ((() ())( )) " results in " ((())) ", which represents the tree depicted below. However, he has no way to know how many ways of such removal there are. Your task is to write a program for it, so that his curiosity is fulfilled. Input The input contains a string that represents some unlabeled tree. The string consists of up to 100,000 characters. Output Print the number of portions of the given string such that removing them results in strings that represent other valid trees. Sample Input 1 ((()())()) Output for the Sample Input 1 10 | 36,410 |
Score : 200 points Problem Statement It is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas numbers. You are given an integer N . Find the N -th Lucas number. Here, the i -th Lucas number L_i is defined as follows: L_0=2 L_1=1 L_i=L_{i-1}+L_{i-2} (iâ¥2) Constraints 1â€Nâ€86 It is guaranteed that the answer is less than 10^{18} . N is an integer. Input Input is given from Standard Input in the following format: N Output Print the N -th Lucas number. Sample Input 1 5 Sample Output 1 11 L_0=2 L_1=1 L_2=L_0+L_1=3 L_3=L_1+L_2=4 L_4=L_2+L_3=7 L_5=L_3+L_4=11 Thus, the 5 -th Lucas number is 11 . Sample Input 2 86 Sample Output 2 939587134549734843 | 36,411 |
Problem L: RedBlue Story 倩空éœåžAIZUã®UZIA髿 ¡ã§ã¯ãç«¶æããã°ã©ãã³ã°ã®éšæŽ»åããšãŠãçãã§ããã ãã®éšæŽ»ã«ã¯ã n 人ã®Red Coderãš n 人ã®Blue Coderãæå±ããŠããã ããæ¥ã®éšæŽ»ã®æéã«ãRed CoderãšBlue Coderã§ãã¢ãçµã¿ããã®éšæŽ»ãã n çµãKCPãšããã³ã³ãã¹ãã«åå ããããšãšãªã£ãããã®é«æ ¡ã§ã¯ããã¢ãçµãåŠçåå£«ã¯æ¡æãããšããç¿ãããããã®ã§ãéšå¡ãã¡ã¯ä»ããèªåã®ããŒãããŒãèŠã€ããããšã«ããã éšå¡ãã¡ã¯å
šéåã§èµ°ãããããŸã£ããã«ããé²ããªãããŸããéšå¡ãã¡ã¯ãããããã®éšå¡ãç§»åããè·é¢ã®ç·åãã§ããã ãå°ããããããšæã£ãŠããã ãªããéšå®€ã«ã¯2ã€ã®å圢ã®ããŒãã«ã眮ããŠããã Problem äºæ¬¡å
å¹³é¢äžã«2ã€ã®åã n åã®èµ€è²ã®ç¹ã n åã®éè²ã®ç¹ãããã 2ã€ã®åã®äžå¿åº§æšã¯ãããã( x 1 , y 1 ), ( x 2 , y 2 )ã§ãããååŸã¯ãããã r 1 , r 2 ã§ããã èµ€ãç¹ i ã¯ã座æš( rx i , ry i )ã«ãããéãç¹ j ã¯ã座æš( bx j , by j )ã«ããã ããªãã¯ã以äžã®æäœã n åç¹°ãè¿ãå¿
èŠãããã ãŸã éžã°ããŠããªãç¹ã®äžãããèµ€è²ã®ç¹ãšéè²ã®ç¹ãïŒã€ãã€éžãã§ã2ç¹ã®å
±éã®ç®çå°ãèšå®ãããã®ç®çå°ã«åãã£ãŠ2ç¹ããããããŸã£ããç§»åãããã ç®çå°ã¯äºæ¬¡å
å¹³é¢äžã§ããã°ãã©ãã«èšå®ããŠãæ§ããªãããã ããéžãã 2ç¹ã¯ç§»åã®éã«åã®å
éšãééããããšã¯ã§ããªãã®ã§ããã®ãããªç§»åãçºçããç®çå°ãèšå®ããããšã¯ã§ããªãã n åã®æäœããããšãã®ç§»åè·é¢ã®ç·åãæå°åããã n åã®æäœãè¡ããªãå Žåã¯ã代ããã«"Impossible" (""ã¯é€ã) ãšåºåããã Input å
¥åã¯ä»¥äžã®åœ¢åŒã§äžããããã n x 1 y 1 r 1 x 2 y 2 r 2 rx 1 ry 1 rx 2 ry 2 ... rx n ry n bx 1 by 1 bx 2 by 2 ... bx n by n å
¥åã¯å
šãп޿°ã§äžããããã 1è¡ç®ã« n ãäžããããã 2è¡ç®ã« x 1 , y 1 , r 1 ã空çœåºåãã§äžããããã 3è¡ç®ã« x 2 , y 2 , r 2 ã空çœåºåãã§äžããããã 4ãã3+ n è¡ã«èµ€ãç¹ã®åº§æš( rx i , ry i )ã空çœåºåãã§äžããããã 4+ n ãã3+2à n è¡ã«éãç¹ã®åº§æš( bx j , by j )ã空çœåºåãã§äžããããã Constraints å
¥åã¯ä»¥äžã®æ¡ä»¶ãæºããã 1 †n †100 -1000 †x i , y i †1000 1 †r i †50 -1000 †rx i , ry i , bx i , by i †1000 åã座æšã«è€æ°ã®ç¹ãååšããŠããããšã¯ãªã ä»»æã®åã®ååŸã絶察å€10 -9 以å
ã§å€åãããŠããé«ã
絶察å€10 -3 ããå€åããªã ä»»æã®åã®ååŸã絶察å€10 -9 以å
ã§å€åãããŠãã"Impossible"ãªã±ãŒã¹ã¯"Impossible"ã®ãŸãŸã§ãã è§£ã¯10000ãè¶
ããªã ã©ã®ç¹ããåãã10 -3 以äžé¢ããŠããŠãç¹ãååšäžã«ååšããããç¹ãåã«å
å
ãããããšã¯ãªã 2ã€ã®åã¯å
±éé¢ç©ãæããã10 -3 以äžé¢ããŠããããšãä¿èšŒããã Output n åã®æäœããããšãã®ç§»åè·é¢ã®ç·åã®æå°å€ã1è¡ã«åºåããããªããåºåã¯ãžã£ããžè§£ã®åºåãšã®çµ¶å¯Ÿèª€å·®ã10 -2 以å
ã§ããã°èš±å®¹ãããã n åã®æäœãè¡ããªãå Žåã¯ã代ããã«"Impossible" (""ã¯é€ã) ãšåºåããã Sample Input 1 2 3 3 2 8 3 2 0 3 3 7 8 0 8 7 Sample Output 1 13.8190642862 Sample Input 2 2 3 3 2 8 3 2 3 0 3 7 8 0 8 7 Sample Output 2 10.0000000000 Sample Input 3 2 3 3 2 8 3 2 0 0 0 5 11 0 11 5 Sample Output 3 22.0000000000 Sample Input 4 1 10 10 10 31 10 10 15 19 26 1 Sample Output 4 Impossible ç¹å士ãã€ãªãããšã¯ã§ããŸããã | 36,412 |
Data Center on Fire ä»ããå°ãæªæ¥ã®è©±ã§ããïŒé«å¯åºŠèšæ¶ããã³é·æä¿åå¯èœã§ããèšé²ããã€ã¹ãéçºãããŠãããïŒã³ã³ãã³ããçã¿åºãããé床ãç°åžžãªã»ã©ã«éãã£ãããïŒããŒã¿ã»ã³ã¿ãŒãèšç«ããïŒããŒã¿ã»ã³ã¿ãŒãèšç«ããåœåã¯å°ããªå»ºç©ã ã£ããïŒå¢ãç¶ããããŒã¿ã«ããããŠäœåºŠãæ¡åŒµå·¥äºãããããïŒæ§èœã®ç°ãªããšã¬ããŒã¿ãäœåºãæã€ããšãšãªã£ãïŒ ãšãããïŒããŒã¿ã»ã³ã¿ãŒã§ç«çœãçºçããïŒç«ã¯äžå®æéã ãçµéãããšäžã®éãªããäžã®éã«çãåºããïŒãŸãïŒç«ãã€ããŠããäžå®æéã ãçµéãããšãã®éã¯çŒå€±ããŠããŸãïŒããã§ãšã¬ããŒã¿ã䜿ã£ãŠããã€ã¹ãéã³åºãããšãšããïŒãã®ãšã¬ããŒã¿ã¯èç«æ§èœãå®ç§ã§ããããïŒéã®çŒå€±ã«é¢ãããä»»æã®éãžç§»åã§ããïŒãŸãïŒéåžžã«åŒ·åãªå éæžéè£
眮ãæã€ããšããïŒå éããã³æžéã«ãããæéã¯ç¡èŠã§ããã»ã©å°ããããïŒäžç¬ã«ããŠå®åžžé床ã«å éããããšïŒãããã¯åæ¢ããããšãã§ããïŒãŸãïŒç·æ¥æã«ãããŠã¯ãããããéããã¿ã³ãæ©èœããªãããã«ããã°ã©ã ãããŠããããïŒãšã¬ããŒã¿ã®åæ¢æéã¯éã³åºãïŒãããã¯éããïŒããã€ã¹ã®åæ°ã«ãããããäžå®ã§ããïŒãŸãïŒéã®çŒå€±åã«å°çãããšã¬ããŒã¿ã«ãã£ãŠéã³åºãããããã€ã¹ã«ã€ããŠã¯ïŒããšããšã¬ããŒã¿ã®åºçºåã«éãçŒå€±ãããšããŠãïŒçŒå€±ã®åœ±é¿ãåããªãïŒãã ãïŒãšã¬ããŒã¿ã«ä¹ããããšãã§ããªãã£ãããã€ã¹ã¯åœç¶ãªããçŒå€±ããïŒ ãšã¬ããŒã¿ã¯ã©ã®éããååããŠãããåãããªãããïŒããã€ã¹ã®ããæäžéãç®æãããã«ããã°ã©ã ãããŠããïŒãã ãïŒãšã¬ããŒã¿å士ã¯éä¿¡å¯èœã§ããïŒå¥ã®ãšã¬ããŒã¿ãç®çéã«å°çããç¬éã«æ
å ±ãéä¿¡ãããïŒå°çãããšã¬ããŒã¿ã«å
šãŠã®ããã€ã¹ãç©ã¿ãããããšãããã£ããšãã¯ïŒç®çéãããäžã«ããïŒååå¯èœãªããã€ã¹ãæ®ã£ãŠããéã®ãã¡ã§æäžéã«ç®çéã倿ŽããïŒãŸãïŒçŒå€±ã®ããã«ç®çéã«åããå¿
èŠæ§ã倱ããããšããïŒåæ§ã«ããŠç®çéã倿ŽããïŒç®çéã倿Žãããšãã«ïŒç§»åæ¹åã倿Žããå¿
èŠããããšãã¯ïŒå³åº§ã«ç§»åæ¹åã倿ŽããïŒãŸãïŒãšã¬ããŒã¿ãæºæ¯ã«ãªã£ãŠãã以äžã®ããã€ã¹ãç©ã¿ããããšãã§ããªããšãïŒãããã¯ååå¯èœãªããã€ã¹ãæ®ã£ãŠããªããšã㯠1 éãç®æãïŒ ããªãã®ä»äºã¯ïŒäžèšã®æ¡ä»¶ã®ããšã§ïŒéé¿ãããããšã®ã§ããããã€ã¹ã®åæ°ããã³å°çæå»ãæ±ããããã°ã©ã ãäœæããããšã§ããïŒ Input å
¥åã¯è€æ°ã®ããŒã¿ã»ããããæ§æãããïŒããããã®ããŒã¿ã»ããã¯æ¬¡ã®åœ¢åŒã§äžããããïŒ N M d n 1 n 2 ... n N c 1 v 1 ts 1 x 1 c 2 v 2 ts 2 x 2 ... c M v M ts M x M k tx ty tz èšå·ã®æå³ã¯æ¬¡ã®ãšããã§ããïŒå
¥åäžã®å€ã¯ãã¹ãп޿°ã§ããïŒ N (2 <= N <= 30)ïŒ M (1 <= M <= 10)ã¯ãããããã«ã®éæ°ïŒãšã¬ããŒã¿ã®åºæ°ã衚ãïŒ d (1000 <= d <= 10000)ã¯éãšéã®éã®è·é¢ã衚ãïŒ n i (0 <= n i <= 100) 㯠i éã«ããããã€ã¹ã®åæ°ã衚ãïŒ c i (1 <= c i <= 50)ïŒ v i (1 <= v i <= 2000)ïŒ ts i (1 <= ts i <= 20)ïŒ x i (1 <= x i <= N )ã¯ãããã i çªç®ã®ãšã¬ããŒã¿ã®å®¹éïŒé床ïŒåæ¢æéïŒåæäœçœ®ãããããïŒåæäœçœ®ã¯äœéã«ãããã§è¡šãããïŒ k (2 <= k <= N )ïŒ tx (30 <= tx <= 300)ïŒ ty (30 <= ty <= 300)ïŒ tz (30 <= tz <= 300)ã¯ããããç«å
ã®éïŒç«ãã€ããŠããçŒå€±ãããŸã§ã®æéïŒäžã«çãç§»ããŸã§ã®æéïŒäžã«çãç§»ããŸã§ã®æéã衚ãïŒ å
¥åã®çµäºã¯ 2 ã€ã® 0 ãå«ãè¡ã«ãã£ãŠããããããïŒããã¯ããŒã¿ã»ããã®äžéšã§ã¯ãªãïŒ ããããã®ããŒã¿ã»ããã¯æ¬¡ã®æ¡ä»¶ãæºãããšä»®å®ããŠããïŒ åäœæéã® 1/1000 ãããçãæéã®éã«è€æ°ã®éã®æ¶å€±ãèµ·ããããšã¯ãªãïŒ åäœæéã® 1/1000 ãããçãæéã®éã«è€æ°ã®ãšã¬ããŒã¿ãåäžã®éã§ 1 éããäžã«ããéã«å°çããããšãªãïŒ åäœæéã® 1/1000 ãããçãæéã®éã«ãšã¬ããŒã¿ã®å°çãšãã®ãšã¬ããŒã¿ãå°çããããšããéã®çŒå€±ãèµ·ããããšã¯ãªãïŒ Output ããããã®ãã¹ãã±ãŒã¹ã«ã€ããŠïŒååãããããã€ã¹ã®åæ°ïŒããã³æåŸã«ååãããããã€ã¹ã 1 éã«å°çããŠãšã¬ããŒã¿ããéãããããŸã§ã®æéãïŒåäžã®ç©ºçœã§åºåã£ãŠ 1 è¡ã§åºåããªããïŒãã ãïŒæéã«ã€ããŠã¯ïŒå°æ°ç¹ä»¥äžã«äœåã®æ°åãåºåããŠãæ§ããªããïŒ0.001 ãè¶
ãã誀差ãå«ããŠã¯ãªããªãïŒãŸãïŒ1 éã«ããããã€ã¹ä»¥å€ã¯ååã§ããªãã£ããšãã¯æéãšããŠãŒããåºåããªããïŒ Sample Input 5 2 5000 10 20 0 30 5 10 1000 6 1 20 500 8 1 3 40 25 30 0 0 Output for the Sample Input 50 84.000 | 36,413 |
Score : 1400 points Problem Statement Count the number of strings S that satisfy the following constraints, modulo 10^9 + 7 . The length of S is exactly N . S consists of digits ( 0 ... 9 ). You are given Q intervals. For each i (1 \leq i \leq Q) , the integer represented by S[l_i \ldots r_i] (the substring of S between the l_i -th ( 1 -based) character and the r_i -th character, inclusive) must be a multiple of 9 . Here, the string S and its substrings may have leading zeroes. For example, 002019 represents the integer 2019 . Constraints 1 \leq N \leq 10^9 1 \leq Q \leq 15 1 \leq l_i \leq r_i \leq N Input Input is given from Standard Input in the following format: N Q l_1 r_1 : l_Q r_Q Output Print the number of strings that satisfy the conditions, modulo 10^9 + 7 . Sample Input 1 4 2 1 2 2 4 Sample Output 1 136 For example, S = 9072 satisfies the conditions because both S[1 \ldots 2] = 90 and S[2 \ldots 4] = 072 represent multiples of 9 . Sample Input 2 6 3 2 5 3 5 1 3 Sample Output 2 2720 Sample Input 3 20 10 2 15 5 6 1 12 7 9 2 17 5 15 2 4 16 17 2 12 8 17 Sample Output 3 862268030 | 36,414 |
The Smallest Window II For a given array $a_1, a_2, a_3, ... , a_N$ of $N$ elements and an integer $K$, find the smallest sub-array size (smallest window length) where the elements in the sub-array contains all integers in range [$1, 2, ..., K$]. If there is no such sub-array, report 0. Constraints $1 \leq N \leq 10^5$ $1 \leq K \leq 10^5$ $1 \leq a_i \leq 10^5$ Input The input is given in the following format. $N$ $K$ $a_1$ $a_2$ ... $a_N$ Output Print the smallest sub-array size in a line. Sample Input 1 6 2 4 1 2 1 3 5 Sample Output 1 2 Sample Input 2 6 3 4 1 2 1 3 5 Sample Output 2 3 Sample Input 3 3 4 1 2 3 Sample Output 3 0 | 36,415 |
Checkered Pattern You have a cross-section paper with W x H squares, and each of them is painted either in white or black. You want to re-arrange the squares into a neat checkered pattern, in which black and white squares are arranged alternately both in horizontal and vertical directions (the figure shown below is a checkered patter with W = 5 and H = 5 ). To achieve this goal, you can perform the following two operations as many times you like in an arbitrary sequence: swapping of two arbitrarily chosen columns, and swapping of two arbitrarily chosen rows. Create a program to determine, starting from the given cross-section paper, if you can re-arrange them into a checkered pattern. Input The input is given in the following format. W H 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 The first line provides the number of squares in horizontal direction W (2†W â€1000) and those in vertical direction H (2†H â€1000). Each of subsequent H lines provides an array of W integers c i,j corresponding to a square of i -th row and j -th column. The color of the square is white if c i,j is 0, and black if it is 1. Output Output "yes" if the goal is achievable and "no" otherwise. Sample Input 1 3 2 1 1 0 0 0 1 Sample Output 1 yes Sample Input 2 2 2 0 0 1 1 Sample Output 2 no | 36,416 |
Patience As the proverb says, "Patience is bitter, but its fruit is sweet." Writing programs within the limited time may impose some patience on you, but you enjoy it and win the contest, we hope. The word "patience" has the meaning of perseverance, but it has another meaning in card games. Card games for one player are called "patience" in the UK and "solitaire" in the US. Let's play a patience in this problem. In this card game, you use only twenty cards whose face values are positive and less than or equal to 5 (Ace's value is 1 as usual). Just four cards are available for each face value. At the beginning, the twenty cards are laid in five rows by four columns (See Figure 1). All the cards are dealt face up. An example of the initial layout is shown in Figure 2. Figure 1: Initial layout Figure 2: Example of the initial layout The purpose of the game is to remove as many cards as possible by repeatedly removing a pair of neighboring cards of the same face value. Let us call such a pair a matching pair . The phrase "a pair of neighboring cards" means a pair of cards which are adjacent to each other. For example, in Figure 1, C 6 is adjacent to any of the following eight cards: C 1 , C 2 , C 3 , C 5 , C 7 , C 9 , C 10 and C 11 . In contrast, C 3 is adjacent to only the following three cards: C 2 , C 6 and C 7 . Every time you remove a pair, you must rearrange the remaining cards as compact as possible. To put it concretely, each remaining card C i must be examined in turn in its subscript order to be shifted to the uppermost-leftmost space. How to play: Search a matching pair. When you find more than one pair, choose one. In Figure 3, you decided to remove the pair of C 6 and C 9 . Remove the pair. (See Figure 4) Shift the remaining cards to the uppermost-leftmost space (See Figure 5, 6). Repeat the above procedure until you cannot remove any pair. Figure 3: A matching pair found Figure 4: Remove the matching pair Figure 5: Shift the remaining cards Figure 6: Rearranged layout If you can remove all the twenty cards, you win the game and your penalty is 0. If you leave some cards, you lose the game and your penalty is the number of the remaining cards. Whenever you find multiple matching pairs, you must choose one pair out of them as in the step 2 of the above procedure. The result of the game depends on these choices. Your job is to write a program which answers the minimal penalty for each initial layout. Input The input consists of multiple card layouts. The input is given in the following format. N Layout 0 Layout 1 ... Layout N -1 N is the number of card layouts. Each card layout gives the initial state of a game. A card layout is given in the following format. C 0 C 1 C 2 C 3 C 4 C 5 C 6 C 7 C 8 C 9 C 10 C 11 C 12 C 13 C 14 C 15 C 16 C 17 C 18 C 19 C i (0 <= i <= 19) is an integer from 1 to 5 which represents the face value of the card. Output For every initial card layout, the minimal penalty should be output, each in a separate line. Sample Input 4 1 4 5 2 3 1 4 3 5 4 2 2 4 5 2 3 1 1 3 5 5 1 5 1 4 5 3 2 3 2 1 4 1 4 5 3 2 3 4 2 1 2 1 2 5 4 5 4 2 1 2 1 3 5 3 4 3 3 5 4 4 2 3 1 2 5 3 1 3 5 4 2 1 5 4 1 4 5 3 2 Output for the Sample Input 0 4 12 0 | 36,417 |
G: ãšã¬ããŒã¿ åé¡ æ ªåŒäŒç€ŸAOR㯠$N$ é建ãŠã®ãã«ã§ãããå°äžéã¯ååšããªãã AORã€ã«ã¡ããã¯ã€ã«ã§ãããããéæ®µãäžããããšã¯å¯èœã ããäžãããšã¯äžå¯èœã§ããã äžã®éã«ç»ããªããšäžäŸ¿ãªããã$M$ åã®ãšã¬ããŒã¿ããã«ã«èšçœ®ããããšã«ããã ãšã¬ããŒã¿ãèšçœ®ããã«ã¯æéããããã$i$ çªç®ã®ãšã¬ããŒã¿ã¯ $D_i$ æ¥åŸã®å€ã«èšçœ®ãå®äºãã $A_i$ éä»¥äž $B_i$ é以äžã®å
šãŠã®éãç§»åå¯èœã«ããã ããªãã¯AORã€ã«ã¡ããã« $Q$ åã®è³ªåããããã$i$ çªç®ã®è³ªåã¯ã $E_i$ æ¥åŸã®æŒã«ã$S_i$ éãã $T_i$ éã«ç§»åå¯èœãïŒããšãã質åã§ããã ç§»åã«äœ¿ããææ®µã¯é段ãšãšã¬ããŒã¿ã®ã¿ã§ããããŸãç§»åã«ãããæéã¯ç¡èŠã§ãããã®ãšããã å¶çŽ $2 \le N \le 10^5$ $1 \le M \le 10^5$ $1 \le Q \le 10^5$ $1 \le D_i , E_i \le 10^9$ $1 \le A_i < B_i \le N$ $1 \le S_i , T_i \le N$ å
¥åã¯å
šãп޿° å
¥å $N \ M\ Q$ $D_1 \ A_1 \ B_1$ $\vdots$ $D_M \ A_M \ B_M$ $E_1 \ S_1 \ T_1$ $\vdots$ $E_Q \ S_Q \ T_Q$ åºå å質åããšã«äžè¡ã§ Yes ãŸã㯠No ãåºåããããã ã質åãããé ã«çããããšããŸãæ«å°Ÿã«æ¹è¡ãåºåããã ãµã³ãã« ãµã³ãã«å
¥å 1 5 1 2 3 1 5 3 1 5 4 1 5 ãµã³ãã«åºå 1 No Yes ãšã¬ããŒã¿ãèšçœ®ãããã®ã¯äžæ¥ç®ã®å€ã§ãããããäžæ¥ç®ã®æŒã«ç§»åããããšã¯ã§ããªãã ãµã³ãã«å
¥å 2 8 6 5 30 6 7 21 3 8 5 2 4 10 1 2 2 7 8 15 5 7 16 5 8 11 1 3 22 3 7 30 6 7 15 5 8 ãµã³ãã«åºå 2 Yes Yes Yes Yes No | 36,418 |
Score : 100 points Problem Statement Print the circumference of a circle of radius R . Constraints 1 \leq R \leq 100 All values in input are integers. Input Input is given from Standard Input in the following format: R Output Print the circumference of the circle. Your output is considered correct if and only if its absolute or relative error from our answer is at most 10^{-2} . Sample Input 1 1 Sample Output 1 6.28318530717958623200 Since we accept an absolute or relative error of at most 10^{-2} , 6.28 is also an acceptable output, but 6 is not. Sample Input 2 73 Sample Output 2 458.67252742410977361942 | 36,419 |
Problem E: Roll-A-Big-Ball ACM University holds its sports day in every July. The "Roll-A-Big-Ball" is the highlight of the day. In the game, players roll a ball on a straight course drawn on the ground. There are rectangular parallelepiped blocks on the ground as obstacles, which are fixed on the ground. During the game, the ball may not collide with any blocks. The bottom point of the ball may not leave the course. To have more fun, the university wants to use the largest possible ball for the game. You must write a program that finds the largest radius of the ball that can reach the goal without colliding any obstacle block. The ball is a perfect sphere, and the ground is a plane. Each block is a rectangular parallelepiped. The four edges of its bottom rectangle are on the ground, and parallel to either x- or y-axes. The course is given as a line segment from a start point to an end point. The ball starts with its bottom point touching the start point, and goals when its bottom point touches the end point. The positions of the ball and a block can be like in Figure E-1 (a) and (b). Figure E-1: Possible positions of the ball and a block Input The input consists of a number of datasets. Each dataset is formatted as follows. N sx sy ex ey minx 1 miny 1 maxx 1 maxy 1 h 1 minx 2 miny 2 maxx 2 maxy 2 h 2 ... minx N miny N maxx N maxy N h N A dataset begins with a line with an integer N , the number of blocks (1 †N †50). The next line consists of four integers, delimited by a space, indicating the start point ( sx , sy ) and the end point ( ex , ey ). The following N lines give the placement of blocks. Each line, representing a block, consists of five integers delimited by a space. These integers indicate the two vertices ( minx , miny ), ( maxx , maxy ) of the bottom surface and the height h of the block. The integers sx , sy , ex , ey , minx , miny , maxx , maxy and h satisfy the following conditions. -10000 †sx , sy , ex , ey †10000 -10000 †minx i < maxx i †10000 -10000 †miny i < maxy i †10000 1 †h i †1000 The last dataset is followed by a line with a single zero in it. Output For each dataset, output a separate line containing the largest radius. You may assume that the largest radius never exceeds 1000 for each dataset. If there are any blocks on the course line, the largest radius is defined to be zero. The value may contain an error less than or equal to 0.001. You may print any number of digits after the decimal point. Sample Input 2 -40 -40 100 30 -100 -100 -50 -30 1 30 -70 90 -30 10 2 -4 -4 10 3 -10 -10 -5 -3 1 3 -7 9 -3 1 2 -40 -40 100 30 -100 -100 -50 -30 3 30 -70 90 -30 10 2 -400 -400 1000 300 -800 -800 -500 -300 7 300 -700 900 -300 20 3 20 70 150 70 0 0 50 50 4 40 100 60 120 8 130 80 200 200 1 3 20 70 150 70 0 0 50 50 4 40 100 60 120 10 130 80 200 200 1 3 20 70 150 70 0 0 50 50 10 40 100 60 120 10 130 80 200 200 3 1 2 4 8 8 0 0 10 10 1 1 1 4 9 9 2 2 7 7 1 0 Output for the Sample Input 30 1 18.16666666667 717.7857142857 50.5 50 18.16666666667 0 0 | 36,420 |
Score : 300 points Problem Statement Snuke has decided to play with a six-sided die. Each of its six sides shows an integer 1 through 6 , and two numbers on opposite sides always add up to 7 . Snuke will first put the die on the table with an arbitrary side facing upward, then repeatedly perform the following operation: Operation: Rotate the die 90° toward one of the following directions: left, right, front (the die will come closer) and back (the die will go farther). Then, obtain y points where y is the number written in the side facing upward. For example, let us consider the situation where the side showing 1 faces upward, the near side shows 5 and the right side shows 4 , as illustrated in the figure. If the die is rotated toward the right as shown in the figure, the side showing 3 will face upward. Besides, the side showing 4 will face upward if the die is rotated toward the left, the side showing 2 will face upward if the die is rotated toward the front, and the side showing 5 will face upward if the die is rotated toward the back. Find the minimum number of operation Snuke needs to perform in order to score at least x points in total. Constraints 1 ⊠x ⊠10^{15} x is an integer. Input The input is given from Standard Input in the following format: x Output Print the answer. Sample Input 1 7 Sample Output 1 2 Sample Input 2 149696127901 Sample Output 2 27217477801 | 36,421 |
äºçåã®ã±ãŒã (Divide Cake into Five) Segtree åã¯äºã€åã®å®¶åºæåž«ãããŠããŸãã仿¥ã¯ã¯ãªã¹ãã¹ã€ããªã®ã§ãäºã€åã®ããã«å圢ã®ã±ãŒããäºçåããããšããŠããŸãã ã±ãŒãã¯äžå¿ããæåœ¢ç¶ã« $N$ åã®ããŒã¹ã«åããããŠããã $i$ çªç®ãš $i + 1$ çªç®($1 \leq i \leq N - 1$) ã $N$ çªç®ãš $1$ çªç®ã®ããŒã¹ã¯é£ãåã£ãŠããŸãã $i$ çªç®ã®ããŒã¹ã®å€§ãã㯠$A_i$ ã§ããå
šãŠã®ããŒã¹ã®å€§ããã®åã $S$ ãšãããšãå
šãŠã®å
¥åã«ã€ã㊠$S$ ã $5$ ã®åæ°ã§ããããšãä¿èšŒãããŸãã ããéè² æŽæ° $Y$ ãäžããããŸãã以äžã®æ¡ä»¶ãæºãããããªã±ãŒãã®äºã€åãžã®åãæ¹ãããã±ãŒãã®äºçåããšåŒã³ãŸãã å
šãŠã®äººã1ã€ä»¥äžã®ããŒã¹ãåãã ã±ãŒãã®äžã§ãããããåãããŒã¹ãã¡ã¯é£çµã§ãããã€ãŸããåã人ã§ããŒã¹ãã°ã«ãŒãåããããšããåãã°ã«ãŒããã€é£ãåã£ãŠããããŒã¹ã«ç§»åããããšãç¹°ãè¿ããŠèŸ¿ãçããªããããªåãã°ã«ãŒãå
ã®ããŒã¹ã®çµã¯ååšããªãã 誰ãåããªãããŒã¹ã¯ååšããªãã å
šãŠã®äººã«ã€ããŠãåãããŒã¹ã®å€§ããã $X$ ãšãããšããå¿
ã $X + Y \geq S / 5$ ãæºããã ãã±ãŒãã®äºçåãã«ãªããããªã±ãŒãã®åãæ¹ã®éãæ°ãäœéããããæ±ããŠãã ããã å
¥å å
¥åã¯ä»¥äžã®åœ¢åŒã§æšæºå
¥åããäžããããã $N$ $Y$ $A_1$ $A_2$ $\ldots$ $A_N$ åºå ãã±ãŒãã®äºçåãã«ãªããããªã±ãŒãã®åãæ¹ã®éãæ°ãåºåããŠãã ããã ãã ããæåŸã«ã¯æ¹è¡ãå
¥ããããšã å¶çŽ $5 \leq N \leq 300$ $1 \leq A_i \leq 10^9$ $0 \leq Y \leq 10^9$ å
¥åã¯å
šãп޿°ã§ããã å
¥åäŸ1 5 0 1 1 1 1 1 åºåäŸ1 1 å
¥åäŸ2 10 27 3 1 4 1 5 9 2 6 5 4 åºåäŸ2 252 | 36,422 |
Party Dress Yae joins a journey plan, in which parties will be held several times during the itinerary. She wants to participate in all of them and will carry several dresses with her. But the number of dresses she can carry with her may be smaller than that of the party opportunities. In that case, she has to wear some of her dresses more than once. Fashion-conscious Yae wants to avoid that. At least, she wants to reduce the maximum number of times she has to wear the same dress as far as possible. Given the number of dresses and frequency of parties, make a program to determine how she can reduce the maximum frequency of wearing the most reused dress. Input The input is given in the following format. $A$ $B$ The input line provides the number of dresses $A$ ($1 \leq A \leq 10^5$) and frequency of parties $B$ ($1 \leq B \leq 10^5$). Output Output the frequency she has to wear the most reused dress. Sample Input 1 3 5 Sample Output 1 2 Sample Input 2 25 10 Sample Output 2 1 | 36,423 |
Score : 200 points Problem Statement There are some animals in a garden. Each of them is a crane with two legs or a turtle with four legs. Takahashi says: "there are X animals in total in the garden, and they have Y legs in total." Determine whether there is a combination of numbers of cranes and turtles in which this statement is correct. Constraints 1 \leq X \leq 100 1 \leq Y \leq 100 All values in input are integers. Input Input is given from Standard Input in the following format: X Y Output If there is a combination of numbers of cranes and turtles in which the statement is correct, print Yes ; otherwise, print No . Sample Input 1 3 8 Sample Output 1 Yes The statement "there are 3 animals in total in the garden, and they have 8 legs in total" is correct if there are two cranes and one turtle. Thus, there is a combination of numbers of cranes and turtles in which the statement is correct. Sample Input 2 2 100 Sample Output 2 No There is no combination of numbers of cranes and turtles in which this statement is correct. Sample Input 3 1 2 Sample Output 3 Yes We also consider the case in which there are only cranes or only turtles. | 36,424 |
Score : 400 points Problem Statement We have a pyramid with N steps, built with blocks. The steps are numbered 1 through N from top to bottom. For each 1â€iâ€N , step i consists of 2i-1 blocks aligned horizontally. The pyramid is built so that the blocks at the centers of the steps are aligned vertically. A pyramid with N=4 steps Snuke wrote a permutation of ( 1 , 2 , ... , 2N-1 ) into the blocks of step N . Then, he wrote integers into all remaining blocks, under the following rule: The integer written into a block b must be equal to the median of the three integers written into the three blocks directly under b , or to the lower left or lower right of b . Writing integers into the blocks Afterwards, he erased all integers written into the blocks. Now, he only remembers that the integer written into the block of step 1 was x . Construct a permutation of ( 1 , 2 , ... , 2N-1 ) that could have been written into the blocks of step N , or declare that Snuke's memory is incorrect and such a permutation does not exist. Constraints 2â€Nâ€10^5 1â€xâ€2N-1 Input The input is given from Standard Input in the following format: N x Output If no permutation of ( 1 , 2 , ... , 2N-1 ) could have been written into the blocks of step N , print No . Otherwise, print Yes in the first line, then print 2N-1 lines in addition. The i -th of these 2N-1 lines should contain the i -th element of a possible permutation. Sample Input 1 4 4 Sample Output 1 Yes 1 6 3 7 4 5 2 This case corresponds to the figure in the problem statement. Sample Input 2 2 1 Sample Output 2 No No matter what permutation was written into the blocks of step N , the integer written into the block of step 1 would be 2 . | 36,425 |
Score : 300 points Problem Statement There are N sightseeing spots on the x -axis, numbered 1, 2, ..., N . Spot i is at the point with coordinate A_i . It costs |a - b| yen (the currency of Japan) to travel from a point with coordinate a to another point with coordinate b along the axis. You planned a trip along the axis. In this plan, you first depart from the point with coordinate 0 , then visit the N spots in the order they are numbered, and finally return to the point with coordinate 0 . However, something came up just before the trip, and you no longer have enough time to visit all the N spots, so you decided to choose some i and cancel the visit to Spot i . You will visit the remaining spots as planned in the order they are numbered. You will also depart from and return to the point with coordinate 0 at the beginning and the end, as planned. For each i = 1, 2, ..., N , find the total cost of travel during the trip when the visit to Spot i is canceled. Constraints 2 \leq N \leq 10^5 -5000 \leq A_i \leq 5000 ( 1 \leq i \leq N ) All input values are integers. Input Input is given from Standard Input in the following format: N A_1 A_2 ... A_N Output Print N lines. In the i -th line, print the total cost of travel during the trip when the visit to Spot i is canceled. Sample Input 1 3 3 5 -1 Sample Output 1 12 8 10 Spot 1 , 2 and 3 are at the points with coordinates 3 , 5 and -1 , respectively. For each i , the course of the trip and the total cost of travel when the visit to Spot i is canceled, are as follows: For i = 1 , the course of the trip is 0 \rightarrow 5 \rightarrow -1 \rightarrow 0 and the total cost of travel is 5 + 6 + 1 = 12 yen. For i = 2 , the course of the trip is 0 \rightarrow 3 \rightarrow -1 \rightarrow 0 and the total cost of travel is 3 + 4 + 1 = 8 yen. For i = 3 , the course of the trip is 0 \rightarrow 3 \rightarrow 5 \rightarrow 0 and the total cost of travel is 3 + 2 + 5 = 10 yen. Sample Input 2 5 1 1 1 2 0 Sample Output 2 4 4 4 2 4 Sample Input 3 6 -679 -2409 -3258 3095 -3291 -4462 Sample Output 3 21630 21630 19932 8924 21630 19288 | 36,426 |
Problem F: Magnum Tornado We have a toy that consists of a small racing circuit and a tiny car. For simplicity you can regard the circuit as a 2-dimensional closed loop, made of line segments and circular arcs. The circuit has no branchings. All segments and arcs are connected smoothly, i.e. there are no sharp corners. The car travels on this circuit with one distinct feature: it is capable of jumping, which enables short cuts. It can jump at any time for any distance. The constraints are that 1) the traveling direction will never change during each jump, 2) the jumping direction needs to match the traveling direction at the time of take-off, and 3) the car must land on the circuit in parallel to the tangent at the landing point. Note that, however, the traveling direction at the landing point may be the opposite of the forward direction (we define forward direction as the direction from the starting point to the ending point of each line segment in the circuit.) That is, the car can traverse part of the circuit in the reverse direction. Your job is to write a program which, given the shape of the circuit, calculates the per-lap length of the shortest route. You can ignore the height of the jump, i.e. just project the route onto the plane on which the circuit resides. The car must start from the starting point of the first line segment, heading towards the ending point of that segment, and must come back to the same starting point heading in the same direction. Figure 1 shows the solution for the first sample input. Figure 1: The solution for the first sample input Input The input begins with a line that solely consists of an integer N (2 <= N <= 100), the number of line segments in the circuit. This is followed by N lines, where the i -th line corresponds to the i -th line segment (1 <= i <= N ). Each of these N lines contains 4 integers x 0 , y 0 , x 1 and y 1 (-100 <= x 0 , y 0 , x 1 , y 1 <= 100) in this order, separated by a space. Here ( x 0 , y 0 ) is the starting point and ( x 1 , y 1 ) is the ending point of the i -th line segment. For each i , the i -th and (i+1) -th line segments are connected smoothly by a circular arc, which you may assume exists uniquely (for simplicity, we consider the (N+1) -th line as the 1st line). You may also assume that, while two line segments or circular arcs may cross each other, they will never overlap nor be tangent to each other. Output For each test case, output one line that solely consists of a decimal value, representing the per-lap length. The output value should be in a decimal fraction and should not contain an error greater than 0.001. Sample Input 1 5 0 1 0 2 1 3 2 3 2 2 1 2 1 1 2 1 2 0 1 0 Output for the Sample Input 1 9.712 Sample Input 2 12 4 5 4 6 3 7 1 7 0 8 0 10 1 11 3 11 4 10 4 9 5 8 99 8 100 7 100 4 99 3 4 3 3 2 3 1 2 0 1 0 0 1 0 3 1 4 3 4 Output for the Sample Input 2 27.406 | 36,427 |
Score : 800 points Problem Statement The beauty of a sequence a of length n is defined as a_1 \oplus \cdots \oplus a_n , where \oplus denotes the bitwise exclusive or (XOR). You are given a sequence A of length N . Snuke will insert zero or more partitions in A to divide it into some number of non-empty contiguous subsequences. There are 2^{N-1} possible ways to insert partitions. How many of them divide A into sequences whose beauties are all equal? Find this count modulo 10^{9}+7 . Constraints All values in input are integers. 1 \leq N \leq 5 \times 10^5 0 \leq A_i < 2^{20} Input Input is given from Standard Input in the following format: N A_1 A_2 \ldots A_{N} Output Print the answer. Sample Input 1 3 1 2 3 Sample Output 1 3 Four ways of dividing A shown below satisfy the condition. The condition is not satisfied only if A is divided into (1),(2),(3) . (1,2,3) (1),(2,3) (1,2),(3) Sample Input 2 3 1 2 2 Sample Output 2 1 Sample Input 3 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Sample Output 3 147483634 Find the count modulo 10^{9}+7 . Sample Input 4 24 1 2 5 3 3 6 1 1 8 8 0 3 3 4 6 6 4 0 7 2 5 4 6 2 Sample Output 4 292 | 36,428 |
Problem F: Power Calculus Starting with x and repeatedly multiplying by x , we can compute x 31 with thirty multiplications: x 2 = x à x , x 3 = x 2 à x , x 4 = x 3 à x , ... , x 31 = x 30 à x . The operation of squaring can appreciably shorten the sequence of multiplications. The following is a way to compute x 31 with eight multiplications: x 2 = x à x , x 3 = x 2 à x , x 6 = x 3 à x 3 , x 7 = x 6 à x , x 14 = x 7 à x 7 , x 15 = x 14 à x , x 30 = x 15 à x 15 , x 31 = x 30 à x . This is not the shortest sequence of multiplications to compute x 31 . There are many ways with only seven multiplications. The following is one of them: x 2 = x à x , x 4 = x 2 à x 2 , x 8 = x 4 à x 4 , x 10 = x 8 à x 2 , x 20 = x 10 à x 10 , x 30 = x 20 à x 10 , x 31 = x 30 à x . There however is no way to compute x 31 with fewer multiplications. Thus this is one of the most eficient ways to compute x 31 only by multiplications. If division is also available, we can find a shorter sequence of operations. It is possible to compute x 31 with six operations (five multiplications and one division): x 2 = x à x , x 4 = x 2 à x 2 , x 8 = x 4 à x 4 , x 16 = x 8 à x 8 , x 32 = x 16 à x 16 , x 31 = x 32 ÷ x . This is one of the most eficient ways to compute x 31 if a division is as fast as a multiplication. Your mission is to write a program to find the least number of operations to compute x n by multiplication and division starting with x for the given positive integer n . Products and quotients appearing in the sequence of operations should be x to a positive integer's power. In other words, x -3 , for example, should never appear. Input The input is a sequence of one or more lines each containing a single integer n . n is positive and less than or equal to 1000. The end of the input is indicated by a zero. Output Your program should print the least total number of multiplications and divisions required to compute x n starting with x for the integer n . The numbers should be written each in a separate line without any superfluous characters such as leading or trailing spaces. Sample Input 1 31 70 91 473 512 811 953 0 Output for the Sample Input 0 6 8 9 11 9 13 12 | 36,429 |
ãã¬ãåã®èŸæžã«ã¯ïŒ n åã®è±å°æåãããªãåèª s 1 , . . ., s n ãã®ã£ãŠããïŒããã¯èŸæžé ã§æ¯èŒãããšã s 1 < . . . < s n ãã¿ããïŒæ®å¿µãªããããã€ãã®æåã¯ããããŠèªããªããªã£ãŠããŸã£ãŠããïŒèªããªããªã£ãæå㯠? ã§è¡šãããïŒ ? ãè±å°æåã§çœ®ãæããŠèŸæžã埩å
ããæ¹æ³ã¯äœéããããïŒmod 1,000,000,007 ã§ããšããïŒ Constraints 1 †n †50 1 †|s i | †20 s i ã«çŸããæåã¯è±å°æåãŸã㯠? ã§ãã Input n s 1 . . . s n Output çããäžè¡ã«åºåããïŒ Sample Input 1 2 ?sum??mer c??a??mp Sample Output 1 703286064 Sample Input 2 3 snuje ????e snule Sample Output 2 1 | 36,430 |
Score : 200 points Problem Statement La Confiserie d'ABC sells cakes at 4 dollars each and doughnuts at 7 dollars each. Determine if there is a way to buy some of them for exactly N dollars. You can buy two or more doughnuts and two or more cakes, and you can also choose to buy zero doughnuts or zero cakes. Constraints N is an integer between 1 and 100 , inclusive. Input Input is given from Standard Input in the following format: N Output If there is a way to buy some cakes and some doughnuts for exactly N dollars, print Yes ; otherwise, print No . Sample Input 1 11 Sample Output 1 Yes If you buy one cake and one doughnut, the total will be 4 + 7 = 11 dollars. Sample Input 2 40 Sample Output 2 Yes If you buy ten cakes, the total will be 4 \times 10 = 40 dollars. Sample Input 3 3 Sample Output 3 No The prices of cakes ( 4 dollars) and doughnuts ( 7 dollars) are both higher than 3 dollars, so there is no such way. | 36,431 |
Problem J: ããæ³¥æ£ãšéææ¥ã®ã屿· ãªã€ãã¯å€§ã®ãã奜ãã§ããããªã€ãã®éåŠè·¯ã«ã¯éç§°ãã屿·ãšåŒã°ããŠããå®¶ãããããã®å®¶ã¯ããããã®ããã飌ã£ãŠããããšã§æåã§ããªã€ãã¯éåŠéäžã«ãããã®å®¶ã®åã§é£Œãããã«ééããäžç·ã«éãã§ããããããªããæ¥ããªã€ãã¯è¡æçãªäºå®ãç¥ã£ãŠããŸã£ããããã¯ãå®ã¯ãã屿·ã®äž»äººã¯ãæ©å«ãæªããªããšãã飌ããããã¡ãèåŸ
ããŠããããšããããšã ã£ãããã屿·ã®äž»äººãèš±ããªããªã£ããªã€ãã¯ããããã¡ãæãããã䞻人ã®å±
ãªãéã«ãããã¡ãçã¿ã ãããšã«ããã ãªã€ãã¯ãã屿·ã®äž»äººã®è¡åãã¿ãŒã³ã芳å¯ããæ¯é±æ±ºãŸã£ãŠåºæããŠããã¿ã€ãã³ã°ãããã£ãŠãããã¡ãçã¿ã ãããšã«ããããã屿·ã¯äºæ¬¡å
å¹³é¢ãšããŠè¡šããããŠããããªã€ãã屿·ã®äžã«å¿ã³ããæç¹ã§ã®ããããã®ããã®äœçœ®ã¯åãã£ãŠããããããã¡ã¯ããããæ±ºãŸã£ãã«ãŒããåžžã«50ã¡ãŒãã«æ¯åã®ã¹ããŒãã§ãŸãã£ãŠãããäžæ¹ããªã€ãã¯æå€§80ã¡ãŒãã«æ¯åã®ã¹ããŒãã§ç§»åã§ããããªã€ãã¯å±æ·ã®ãšããå Žæãã䟵å
¥ãã屿·å
ãç§»åãã䞻人ãåž°ã£ãŠãããŸã§ã«è±åºå£ããåºãããªã€ãããããšåãå°ç¹ã«å°éãããšããªã€ãã¯ãããæ±ããããšãã§ããããããè¡ãªãã®ã«ãããæéã¯ç¡èŠã§ããããªã€ãã¯äœå¹ã§ããããæ±ããããšãã§ããããäœå¹æ±ããŠããŠãç§»åé床ãèœã¡ãããšã¯ãªãããå¿
ã䞻人ãåž°ã£ãŠããåã«å±æ·ãè±åºããªããã°ãªããªãã æ®å¿µãªããããªã€ãã¯ãã屿·ã®ãããå
šå¡çã¿ã ãããšã¯ã§ããªããããããªãããããã1å¹ã§ãå€ãã®ããã幞ãã«ããããã«ãã§ããã ãå€ãã®ãããçã¿ã ãããšã«ããããŸããåãæ°ã®ãããçã¿ã ããã®ã§ããã°ã屿·ã®äž»äººã«æãŸããªã¹ã¯ãæãããããã§ããã ãæ©ãæéã«å±æ·ããè±åºããã ãªã€ãã屿·ã«äŸµå
¥ããæå»ãšäœçœ®ã屿·ã®äž»äººãæ»ã£ãŠããæå»ãè±åºå£ã®å Žæãããã³ããã®åæäœçœ®ãšå·¡åã«ãŒããäžããããããªã€ããäœå¹ã®ãããçã¿ã ããŠãã©ã®æå»ã«å±æ·ãè±åºã§ããããçããããã°ã©ã ãæžããŠã»ããã Input å
¥åã®1è¡ç®ã«ã¯ã䟵å
¥å£ã® x , y 座æšã1ã€ã®ç©ºçœæåã§åºåãããŠäžããããã2è¡ç®ã«ã¯åæ§ã«è±åºå£ã®äœçœ®ãäžããããã3è¡ç®ã«ã¯ãªã€ãã屿·ã«äŸµå
¥ããæå»ã4è¡ç®ã«ã¯å±æ·ã®äž»äººãåž°ã£ãŠããæå»ã24æéå¶ã®HH:MM:SSã®åœ¢åŒã§äžããããã 5è¡ç®ã¯ããã®ç·æ° m ã§ãããç¶ã m è¡ã«åããã®è¡åãã¿ãŒã³ãäžããããã5+ i è¡ç® ( i = 1, 2, ..., m ) ã i çªç®ã®ããã®å·¡åã«ãŒãã«å¯Ÿå¿ããŠãããåè¡ã®åãã«ã¯èªç¶æ° k i ãäžããããç¶ããŠããã®å·¡åã«ãŒãã k i åã® x , y 座æšå€ã䞊ã¹ããã®ãšããŠäžãããããããã®å·¡åã«ãŒãã¯ããããã®é£ç¶ããç¹ããã³æåŸãšæåã®ç¹ãç·åã§ã€ãªãã ãã®ã§ããããªã€ãã屿·ã«äŸµå
¥ããæç¹ã§ãããã¯äžããããæåã®ç¹ã«ããã以éãã£ãšå·¡åã«ãŒãäžãçéã§ç§»åãããäžããããã«ãŒãã®é£ç¶ããç¹ãåã座æšã§ããããšã¯ãªãã ãªããã¹ã¿ãŒãæéãšãŽãŒã«æéã¯åãæ¥ã§ã®ãã®ã§ããããšãä¿èšŒãããŠããïŒãªã€ãã䞻人ã®åž°ã£ãŠããåã«è±åºããæ¹æ³ã¯å¿
ãååšãããåãè¡ã«ããæ°ã¯å
šãŠ1ã€ã®ç©ºçœæåã§åºåãããŠããã ããã®æ°ã¯1以äž14以äžãããã®å·¡åã«ãŒãã衚ããç¹ã®æ°ã¯2以äž1000以äžã§ãããå
šãŠã®åº§æšå€ã¯çµ¶å¯Ÿå€ã100000ãè¶ããªãæŽæ°ã§ããããšãä¿èšŒãããŠããã 座æšå€ã®åäœã¯å
šãŠã¡ãŒãã«ã§ããã Output 1è¡ç®ã«ããªã€ããçã¿åºãããšã®ã§ããããã®æå€§æ°ãåºåããã2è¡ç®ã«ã¯ããªã€ãããªãã¹ãå€ãæ°ã®ãããçã¿ã ãæ¹æ³ã®äžã§ãæãæ©ãè±åºå£ã«å°éã§ããæå»ããHH MM SS.nnnnnn (空çœåºåã)ã®åœ¢åŒã§çãããç§ã®å°æ°ç¹ä»¥äžã¯6æ¡åºåããããªãã10 -6 ç§ãè¶ãã誀差ããã£ãŠã¯ãªããªãã ãªãã䞻人ã®åž°ã£ãŠããæéã±1mså€åããŠããæå€ééå¯èœæ°ã¯å€åããªãããšãä¿èšŒãããŠããã Notes on Submission äžèšåœ¢åŒã§è€æ°ã®ããŒã¿ã»ãããäžããããŸããå
¥åããŒã¿ã® 1 è¡ç®ã«ããŒã¿ã»ããã®æ°ãäžããããŸããåããŒã¿ã»ããã«å¯Ÿããåºåãäžèšåœ¢åŒã§é çªã«åºåããããã°ã©ã ãäœæããŠäžããã Sample Input 2 0 0 0 0 15:00:00 18:00:00 1 4 0 7199 1125 7199 1125 8324 0 8324 0 0 0 0 15:00:00 18:00:00 1 4 0 7201 1125 7201 1125 8326 0 8326 Output for the Sample Input 1 17 59 59.076923 0 15 00 00.000000 | 36,432 |
äžè§åœ¢ãšå å¹³é¢äžã«ããäžè§åœ¢ãšåã®äœçœ®é¢ä¿ãå€å®ããããã°ã©ã ãäœæããŠãã ããã察象ãšãªãå³åœ¢ã¯ããããå¢çãå«ããã®ãšããŸãã äžè§åœ¢ã¯ 3 é ç¹ã®äœçœ®ãäžããããåã¯äžå¿ã®äœçœ®ãšååŸãäžããããŸããäœçœ®ã¯çŽäº€åº§æšç³»ã«ããïŒã€ã®æŽæ°ã®çµã«ãã£ãŠäžããããŸããååŸãæŽæ°ã§äžããããŸãã Input è€æ°ã®ããŒã¿ã»ããã®äžŠã³ãå
¥åãšããŠäžããããŸããå
¥åã®çµããã¯ãŒããµãã€ã®è¡ã§ç€ºãããŸãã åããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããŸãã x 1 y 1 x 2 y 2 x 3 y 3 x c y c r ïŒè¡ç®ããïŒè¡ç®ã«ãäžè§åœ¢ã®ç¬¬ i ã®é ç¹åº§æš x i , y i ãäžããããŸããïŒè¡ç®ã«åã®äžå¿ã®åº§æš x c , y c ãïŒè¡ç®ã«åã®ååŸ r ãäžããããŸããäžããããå
¥åã¯ãã¹ãŠã1 ä»¥äž 10,000 以äžã®æŽæ°ãšããŸãã ããŒã¿ã»ããã®æ°ã¯ 100 ãè¶
ããŸããã Output å
¥åããŒã¿ã»ããããšã«ä»¥äžã®åœ¢åŒã§å€å®çµæãïŒè¡ã«åºåããŸãã åãäžè§åœ¢ã«å«ãŸããå Žå a äžè§åœ¢ãåã«å«ãŸããå Žå b ãã以å€ã®å Žåã§ãå
±ééšåãããå Žåã«ã¯ c å
±ééšåããªãå Žåã«ã¯ d Sample Input 1 1 3 1 3 3 3 2 3 3 12 9 3 11 12 8 7 5 15 3 17 7 22 5 7 6 4 6 11 8 2 16 9 10 8 2 0 0 Output for the Sample Input b c d a | 36,433 |
éã®çæ¯ç¯å² (Fish) åé¡ ãªãŒã¹ãã©ãªã¢å€§éžã®è¥¿ã«ã¯ïŒåºãã€ã³ãæŽãåºãã£ãŠããïŒæµ·æŽç ç©¶è
ã§ãã JOI æ°ã¯ïŒã€ã³ãæŽã«çæ¯ããŠãããã N çš®é¡ã®éã®æ§è³ªã«ã€ããŠç ç©¶ããŠããïŒ ããããã®éã®çš®é¡ã«å¯ŸããŠïŒæµ·ã®äžã«çŽæ¹äœç¶ã®çæ¯ç¯å²ãå®ãŸã£ãŠããïŒéã¯å¢çãå«ããŠçæ¯ç¯å²ã®äžã®ã©ã®å Žæã«ãç§»åã§ãããïŒçæ¯ç¯å²ã®å€ã«åºãããšã¯æ±ºããŠãªãïŒæµ·ã®äžã®ç¹ã¯ïŒ3 ã€ã®å®æ° (x, y, d) ã«ãã£ãŠè¡šãããïŒ (x, y, d) ã¯ïŒäžç©ºããèŠããšãã«ããå°ç¹ãåºæºã«ããŠæ±ã« xïŒåã« y é²ãã äœçœ®ã§ããïŒæµ·é¢ããã®æ·±ãã d ã®ç¹ã衚ãïŒãã ãïŒæµ·é¢ã¯å¹³é¢ã§ãããšããïŒ JOI æ°ã¯ïŒK çš®é¡ä»¥äžã®éã®çæ¯ç¯å²ãéãªãå Žæãã©ã®ãããããããç¥ãããïŒãã®ãããªå Žæå
šäœã®äœç©ãæ±ããããã°ã©ã ãäœæããïŒ å
¥å å
¥å㯠1 + N è¡ãããªãïŒ 1 è¡ç®ã«ã¯ïŒ2 ã€ã®æŽæ° N, K (1 ⊠K ⊠N ⊠50) ã空çœãåºåããšããŠæžãããŠããïŒããã¯ïŒéã N çš®é¡ã§ããïŒK çš®é¡ä»¥äžã®éã®çæ¯ç¯å²ãéãªãå Žæã®äœç©ãæ±ãããããšã衚ãïŒ ç¶ã N è¡ã®ãã¡ã® i è¡ç® (1 ⊠i ⊠N) ã«ã¯ïŒ6 ã€ã®æŽæ° X i,1 , Y i,1 , D i,1 , X i,2 , Y i,2 , D i,2 (0 ⊠X i,1 ïŒ X i,2 ⊠1000000 (= 10 6 )ïŒ0 ⊠Y i,1 ïŒ Y i,2 ⊠1000000 (= 10 6 )ïŒ0 ⊠D i,1 ïŒ D i,2 ⊠1000000 (= 10 6 )) ãæžãããŠããïŒããã¯ïŒi çš®é¡ç®ã®éã®çæ¯ç¯å²ã 8 ç¹ (X i,1 , Y i,1 , D i,1 ), (X i,2 , Y i,1 , D i,1 ), (X i,2 , Y i,2 , D i,1 ), (X i,1 , Y i,2 , D i,1 ), (X i,1 , Y i,1 , D i,2 ), (X i,2 , Y i,1 , D i,2 ), (X i,2 , Y i,2 , D i,2 ), (X i,1 , Y i,2 , D i,2 ) ãé ç¹ãšããçŽæ¹äœã§ããããšã衚ãïŒ åºå K çš®é¡ä»¥äžã®éã®çæ¯ç¯å²ãéãªãå Žæå
šäœã®äœç©ã 1 è¡ã§åºåããïŒ å
¥åºåäŸ å
¥åäŸ 1 3 2 30 50 0 50 70 100 10 20 20 70 90 60 40 60 20 90 90 70 åºåäŸ 1 49000 å
¥åºåäŸ 1 ã«ãããŠïŒäŸãã°ïŒç¹ (45, 65, 65) 㯠1 çš®é¡ç®ã®éãš 3 çš®é¡ç®ã®éã®çæ¯ç¯å²ã§ããã®ã§ïŒæ¡ä»¶ãæºããå Žæã§ããïŒäžæ¹ïŒç¹ (25, 35, 45) 㯠2 çš®é¡ç®ã®éã®ã¿ã®çæ¯ç¯å²ã§ããã®ã§ïŒæ¡ä»¶ãæºããå Žæã§ã¯ãªãïŒãŸãïŒéã®çæ¯ç¯å²ã¯äžã®å³ã®ããã«ãªã£ãŠããïŒç¹ O ã¯æµ·é¢äžã®åºæºã®å°ç¹ã衚ãïŒ å
¥åäŸ 2 1 1 0 0 0 1000000 1000000 1000000 åºåäŸ 2 1000000000000000000 å顿ãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã | 36,434 |
Treasure Hunt When a boy was cleaning up after his grand father passing, he found an old paper: In addition, other side of the paper says that "go ahead a number of steps equivalent to the first integer, and turn clockwise by degrees equivalent to the second integer". His grand mother says that Sanbonmatsu was standing at the center of town. However, now buildings are crammed side by side and people can not walk along exactly what the paper says in. Your task is to write a program which hunts for the treature on the paper. For simplicity, 1 step is equivalent to 1 meter. Input consists of several pairs of two integers d (the first integer) and t (the second integer) separated by a comma. Input ends with "0, 0". Your program should print the coordinate ( x , y ) of the end point. There is the treature where x meters to the east and y meters to the north from the center of town. You can assume that d †100 and -180 †t †180. Input A sequence of pairs of integers d and t which end with " 0,0 ". Output Print the integer portion of x and y in a line respectively. Sample Input 56,65 97,54 64,-4 55,76 42,-27 43,80 87,-86 55,-6 89,34 95,5 0,0 Output for the Sample Input 171 -302 | 36,435 |
G: AOR-String åé¡ $N$ åã®æåå $S_i$ ãäžãããã. $S_i$ ãä»»æã®é ã«ç¹ããŠåŸãããæååã«å«ãŸãã "AOR" ã®æ°ã®æå€§å€ãæ±ãã. å¶çŽ $1 \leq N \leq 10^5$ $1 \leq |S_i| \leq 20$ $S_i$ ã¯å€§æåã¢ã«ãã¡ãããã®ã¿ãããªã å
¥ååœ¢åŒ å
¥åã¯ä»¥äžã®åœ¢åŒã§äžãããã. $N$ $S_1$ ⊠$S_N$ åºå $S_i$ ãä»»æã®é ã«ç¹ããŠåŸãããæååã«å«ãŸãã "AOR" ã®æ°ã®æå€§å€ãåºåãã. ãŸã, æ«å°Ÿã«æ¹è¡ãåºåãã. ãµã³ãã« ãµã³ãã«å
¥å 1 2 AORA OR ãµã³ãã«åºå 1 2 ãµã³ãã«å
¥å 2 5 AB CA ORA XX AOR ãµã³ãã«åºå 2 2 | 36,436 |
ã«ãŒãã²ãŒã åé¡ æ¬¡ã®ãããª2人ã§è¡ãã«ãŒãã²ãŒã ãããïŒ ãã®ã²ãŒã ã§ã¯ïŒ 1ãã2nãŸã§ã®åæŽæ°ãæžãããå
šéšã§2næã®ã«ãŒãã䜿çšããïŒ ããã§ïŒnã¯1以äž100以äžã®æŽæ°ã§ããïŒ ãã®ã«ãŒãã2人ã«næãã€é
ãïŒ æ¬¡ã®ã«ãŒã«ã«åŸã£ãŠäº€äºã«ã«ãŒãã1æãã€å Žã«åºãïŒ å Žã«ã«ãŒããåºãŠããªããªãã°ïŒ 奜ããªã«ãŒããåºãããšãã§ããïŒ å Žã«ã«ãŒããåºãŠãããªãã°ïŒ æåŸã«å Žã«åºãã«ãŒãããã倧ããæ°ã®æžãããã«ãŒããåºãããšãã§ããïŒ ã«ãŒããåºããå Žåã¯ïŒå¿
ãå Žã«ã«ãŒããåºãå¿
èŠãããïŒ åºããã«ãŒããç¡ãå Žåã¯ãã¹ãšãªãïŒçžæã®çªã«ãªãïŒ ãã®ãšãïŒå Žã«åºãŠããã«ãŒãã¯ç¡ããªãïŒ ã²ãŒã ã¯å Žã«ã«ãŒããåºãŠããªãç¶æ
ã§å§ããïŒ ã©ã¡ããã®ææã¡ã®ã«ãŒããç¡ããªã£ãæç¹ã§ã²ãŒã ã¯çµäºããïŒ ã²ãŒã çµäºæã«çžæã®æã£ãŠããã«ãŒãã®ææ°ãåŸç¹ãšããïŒ å€ªéãšè±åã¯ïŒãã®ã²ãŒã ã§å¯ŸæŠããããšã«ãªã£ãïŒã²ãŒã ã¯å€ªéã®çªããå§ããïŒ 2人ã¯å
±ã«ïŒåºãããšã®ã§ããã«ãŒãã®ãã¡å¿
ãäžçªå°ããæ°ãæžãããã«ãŒããåºãããšã«ããŠããïŒ å€ªéã«é
ãããã«ãŒããå
¥åããããšãïŒå€ªéãšè±åã®åŸç¹ãåºåããããã°ã©ã ãäœæããïŒ å
¥å å
¥åã¯è€æ°ã®ããŒã¿ã»ãããããªãïŒåããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããïŒ å
¥å㯠n+1 è¡ããïŒ 1è¡ç®ã«ã¯æŽæ°nãæžãããŠããïŒ 2è¡ç®ããn+1è¡ç®ãŸã§ã®åè¡ã«ã¯æŽæ°ã1ã€ãã€æžãããŠããïŒå€ªéã«é
ãããã«ãŒãã«æžãããæŽæ°ã衚ãïŒ n ã 0 ã®ãšãå
¥åã®çµäºã瀺ã. ããŒã¿ã»ããã®æ°ã¯ 5 ãè¶
ããªãïŒ åºå ããŒã¿ã»ããããšã« 1è¡ç®ã«ã¯å€ªéã®åŸç¹ãïŒ 2è¡ç®ã«ã¯è±åã®åŸç¹ãåºåããïŒ å
¥åºåäŸ å
¥åäŸ 5 1 7 9 6 10 10 8 7 14 18 4 11 3 17 5 19 0 åºåäŸ 3 0 2 0 äžèšå顿ãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã | 36,437 |
Problem B: The Last Ant A straight tunnel without branches is crowded with busy ants coming and going. Some ants walk left to right and others right to left. All ants walk at a constant speed of 1 cm/s. When two ants meet, they try to pass each other. However, some sections of the tunnel are narrow and two ants cannot pass each other. When two ants meet at a narrow section, they turn around and start walking in the opposite directions. When an ant reaches either end of the tunnel, it leaves the tunnel. The tunnel has an integer length in centimeters. Every narrow section of the tunnel is integer centimeters distant from the both ends. Except for these sections, the tunnel is wide enough for ants to pass each other. All ants start walking at distinct narrow sections. No ants will newly enter the tunnel. Consequently, all the ants in the tunnel will eventually leave it. Your task is to write a program that tells which is the last ant to leave the tunnel and when it will. Figure B.1 shows the movements of the ants during the first two seconds in a tunnel 6 centimeters long. Initially, three ants, numbered 1, 2, and 3, start walking at narrow sections, 1, 2, and 5 centimeters distant from the left end, respectively. After 0.5 seconds, the ants 1 and 2 meet at a wide section, and they pass each other. Two seconds after the start, the ants 1 and 3 meet at a narrow section, and they turn around. Figure B.1 corresponds to the first dataset of the sample input. Figure B.1. Movements of ants Input The input consists of one or more datasets. Each dataset is formatted as follows. n l d 1 p 1 d 2 p 2 ... d n p n The first line of a dataset contains two integers separated by a space. n (1 †n †20) represents the number of ants, and l ( n + 1 †l †100) represents the length of the tunnel in centimeters. The following n lines describe the initial states of ants. Each of the lines has two items, d i and p i , separated by a space. Ants are given numbers 1 through n . The ant numbered i has the initial direction d i and the initial position p i . The initial direction d i (1 †i †n ) is L (to the left) or R (to the right). The initial position p i (1 †i †n ) is an integer specifying the distance from the left end of the tunnel in centimeters. Ants are listed in the left to right order, that is, 1 †p 1 < p 2 < ... < p n †l - 1. The last dataset is followed by a line containing two zeros separated by a space. Output For each dataset, output how many seconds it will take before all the ants leave the tunnel, and which of the ants will be the last. The last ant is identified by its number. If two ants will leave at the same time, output the number indicating the ant that will leave through the left end of the tunnel. Sample Input 3 6 R 1 L 2 L 5 1 10 R 1 2 10 R 5 L 7 2 10 R 3 L 8 2 99 R 1 L 98 4 10 L 1 R 2 L 8 R 9 6 10 R 2 R 3 L 4 R 6 L 7 L 8 0 0 Output for the Sample Input 5 1 9 1 7 1 8 2 98 2 8 2 8 3 | 36,438 |
Score : 300 points Problem Statement We have a sequence of N integers A~=~A_0,~A_1,~...,~A_{N - 1} . Let B be a sequence of K \times N integers obtained by concatenating K copies of A . For example, if A~=~1,~3,~2 and K~=~2 , B~=~1,~3,~2,~1,~3,~2 . Find the inversion number of B , modulo 10^9 + 7 . Here the inversion number of B is defined as the number of ordered pairs of integers (i,~j)~(0 \leq i < j \leq K \times N - 1) such that B_i > B_j . Constraints All values in input are integers. 1 \leq N \leq 2000 1 \leq K \leq 10^9 1 \leq A_i \leq 2000 Input Input is given from Standard Input in the following format: N K A_0 A_1 ... A_{N - 1} Output Print the inversion number of B , modulo 10^9 + 7 . Sample Input 1 2 2 2 1 Sample Output 1 3 In this case, B~=~2,~1,~2,~1 . We have: B_0 > B_1 B_0 > B_3 B_2 > B_3 Thus, the inversion number of B is 3 . Sample Input 2 3 5 1 1 1 Sample Output 2 0 A may contain multiple occurrences of the same number. Sample Input 3 10 998244353 10 9 8 7 5 6 3 4 2 1 Sample Output 3 185297239 Be sure to print the output modulo 10^9 + 7 . | 36,439 |
éæ³é£ Problem Statement ãéæ³é£ã®æãæ¹ã åååºããŠçã£çœãªåºãçšæããŸãïŒ åºã®åº§æš (0,0) ã®ç¹ãäžå¿ã«ããŠïŒååŸ 1, 2, ..., R ã®åãæããŸãïŒ ååŸ 1 ã®åãšååŸ 2 ã®åã®éïŒååŸ 3 ã®åãšååŸ 4 ã®åã®éïŒ ... ãéè²ã§å¡ããŸãïŒãªãïŒååŸ R ã®åã®å€ã«ã¯è²ãå¡ã£ãŠã¯ãããŸããïŒ åºã«é ç¹æ° N ã®å€è§åœ¢ãäžã€æããŸãïŒ å€è§åœ¢ã®å
éšã®çœè²ã®é åãéè²ã§ïŒéè²ã®é åãçœè²ã§å¡ããªãããŸãïŒ éæ³é£ã®åã¯ïŒéæ³é£ã«éè²ãå€ãå«ãŸããã»ã©åŒ·ããªããšããïŒ ããã§ããªãã«ã¯ïŒéæ³é£ã«å«ãŸããéãé åã®é¢ç©ãæ±ããŠã»ããïŒ æ¬¡ã®å³ã¯ãã®æé ã§æãããšã®ã§ããéæ³é£ã®äžäŸã§ããïŒ Input å
¥åã¯ä»¥äžã®åœ¢åŒã«åŸãïŒäžããããæ°ã¯å
šãп޿°ã§ããïŒ N R x_1 y_1 ... x_N y_N (x_i, y_i) ã¯å€è§åœ¢ã® i çªç®ã®é ç¹ã§ããïŒ Constraints 3 ⊠N ⊠100 1 ⊠R ⊠100 å€è§åœ¢ã¯ååŸ R ã®åã®å
éšãŸãã¯ååšäžã«å«ãŸããïŒ å€è§åœ¢ã¯èªå·±äº€å·®ããããªãïŒ å€è§åœ¢ã®é ç¹ã¯åæèšåãã®é çªã§äžããããïŒ Output éãé åã®é¢ç©ã 1 è¡ã«åºåããïŒ åºåããå€ã¯ïŒçã®å€ãšã®çµ¶å¯Ÿèª€å·®ãŸãã¯çžå¯Ÿèª€å·®ã 10^{-8} æªæºã§ãªããã°ãªããªãïŒ Sample Input 1 3 1 0 0 1 0 0 1 Output for the Sample Input 1 0.500000000 Sample Input 2 3 2 0 0 2 0 0 2 Output for the Sample Input 2 8.995574288 Sample Input 3 3 2 1 -1 1 1 -2 0 Output for the Sample Input 3 11.123246567 Sample Input 4 4 3 1 1 -1 1 -1 -1 1 -1 Output for the Sample Input 4 11.707963268 | 36,440 |
Score : 400 points Problem Statement Takahashi has a water bottle with the shape of a rectangular prism whose base is a square of side a~\mathrm{cm} and whose height is b~\mathrm{cm} . (The thickness of the bottle can be ignored.) We will pour x~\mathrm{cm}^3 of water into the bottle, and gradually tilt the bottle around one of the sides of the base. When will the water be spilled? More formally, find the maximum angle in which we can tilt the bottle without spilling any water. Constraints All values in input are integers. 1 \leq a \leq 100 1 \leq b \leq 100 1 \leq x \leq a^2b Input Input is given from Standard Input in the following format: a b x Output Print the maximum angle in which we can tilt the bottle without spilling any water, in degrees. Your output will be judged as correct when the absolute or relative error from the judge's output is at most 10^{-6} . Sample Input 1 2 2 4 Sample Output 1 45.0000000000 This bottle has a cubic shape, and it is half-full. The water gets spilled when we tilt the bottle more than 45 degrees. Sample Input 2 12 21 10 Sample Output 2 89.7834636934 This bottle is almost empty. When the water gets spilled, the bottle is nearly horizontal. Sample Input 3 3 1 8 Sample Output 3 4.2363947991 This bottle is almost full. When the water gets spilled, the bottle is still nearly vertical. | 36,441 |
Score : 1700 points Problem Statement There is a railroad in Takahashi Kingdom. The railroad consists of N sections, numbered 1 , 2 , ..., N , and N+1 stations, numbered 0 , 1 , ..., N . Section i directly connects the stations i-1 and i . A train takes exactly A_i minutes to run through section i , regardless of direction. Each of the N sections is either single-tracked over the whole length, or double-tracked over the whole length. If B_i = 1 , section i is single-tracked; if B_i = 2 , section i is double-tracked. Two trains running in opposite directions can cross each other on a double-tracked section, but not on a single-tracked section. Trains can also cross each other at a station. Snuke is creating the timetable for this railroad. In this timetable, the trains on the railroad run every K minutes, as shown in the following figure. Here, bold lines represent the positions of trains running on the railroad. (See Sample 1 for clarification.) When creating such a timetable, find the minimum sum of the amount of time required for a train to depart station 0 and reach station N , and the amount of time required for a train to depart station N and reach station 0 . It can be proved that, if there exists a timetable satisfying the conditions in this problem, this minimum sum is always an integer. Formally, the times at which trains arrive and depart must satisfy the following: Each train either departs station 0 and is bound for station N , or departs station N and is bound for station 0 . Each train takes exactly A_i minutes to run through section i . For example, if a train bound for station N departs station i-1 at time t , the train arrives at station i exactly at time t+A_i . Assume that a train bound for station N arrives at a station at time s , and departs the station at time t . Then, the next train bound for station N arrives at the station at time s+K , and departs the station at time t+K . Additionally, the previous train bound for station N arrives at the station at time s-K , and departs the station at time t-K . This must also be true for trains bound for station 0 . Trains running in opposite directions must not be running on the same single-tracked section (except the stations at both ends) at the same time. Constraints 1 \leq N \leq 100000 1 \leq K \leq 10^9 1 \leq A_i \leq 10^9 A_i is an integer. B_i is either 1 or 2 . Partial Score In the test set worth 500 points, all the sections are single-tracked. That is, B_i = 1 . In the test set worth another 500 points, N \leq 200 . Input The input is given from Standard Input in the following format: N K A_1 B_1 A_2 B_2 : A_N B_N Output Print an integer representing the minimum sum of the amount of time required for a train to depart station 0 and reach station N , and the amount of time required for a train to depart station N and reach station 0 . If it is impossible to create a timetable satisfying the conditions, print -1 instead. Sample Input 1 3 10 4 1 3 1 4 1 Sample Output 1 26 For example, the sum of the amount of time in question will be 26 minutes in the following timetable: In this timetable, the train represented by the red line departs station 0 at time 0 , arrives at station 1 at time 4 , departs station 1 at time 5 , arrives at station 2 at time 8 , and so on. Sample Input 2 1 10 10 1 Sample Output 2 -1 Sample Input 3 6 4 1 1 1 1 1 1 1 1 1 1 1 1 Sample Output 3 12 Sample Input 4 20 987654321 129662684 2 162021979 1 458437539 1 319670097 2 202863355 1 112218745 1 348732033 1 323036578 1 382398703 1 55854389 1 283445191 1 151300613 1 693338042 2 191178308 2 386707193 1 204580036 1 335134457 1 122253639 1 824646518 2 902554792 2 Sample Output 4 14829091348 | 36,442 |
Problem H: Vending Machine There has been marketing warfare among beverage vendors, and they have been working hard for in- crease of their sales. The Kola-Coqua Company is one of the most successful vendors among those: their impressive advertisements toward the world has brought the overwhelming market share of their representative product called Koque. This time, Kola-Coqua is focusing on vending machines. They think cusomters will be more pleasant as the machines respond more quickly, so they have improved many parts of the machines. In particular, they have developed a new device of change return. The new device can give one or more kinds of coins at a time (in a single operation), although it can give only one coin for each kind at once. For example, suppose there are 500-yen, 100-yen, 50-yen and 10-yen coins, change of 6540 yen can be made by four operations of giving 500-yen and 10-yen coins and nine operations of giving 500-yen coins. In conclusion, 6540 yen can be returned by thirteen operations. It is supposed that the new device allows customers to make their purchase more quickly and so helps Kola-Coquaâs market share grow up. However, the project leader says âNo, itâs not optimal yet.â His suggesion is as follows: the real opti- mization is to minimize the number of operations. For example, change of 6540 yen should be made with ten of 500-yen coins, ten of 100-yen coins, ten of 50-yen coins, and four of 10-yen coins. This way, 6540 yen can be returned only with ten operations. This allows full speed-up in giving back change, even though it sometimes results in a huge amount of coins. Given which kinds of coins are available and how much change should be given back, you are to write a program that calculates the minimum number of operations according to the above suggestion. You may assume that there are enough amount of coins inside the vending machines. Input The input consists of multiple data sets. Each dataset is described by two lines. The first line contains N ( N †10) and M ( M †100000) indicating the number of kinds of coins and the amount of change to be made, respectively. The second line contains N integers representing the value of each kind of coin. The input is terminated by a dataset of N = M = 0. This dataset must not be processed. Output For each dataset, output in a line the minimum number of operations needed to give back exactly the specified amount of change. Sample Input 6 330 1 5 10 50 100 500 7 127 1 2 4 8 16 32 64 2 10000 1000 2000 0 0 Output for the Sample Input 2 1 4 | 36,443 |
ãããããŒãã¥ãŒã ãããããŒãã¥ãŒããããã°ã©ãã³ã°ã§è§£ããŠã¿ãŸãããããããããŒãã¥ãŒãã¯å³ã®ããã«è¡šé¢ã«è²ã®ã€ããïŒåã®ç«æ¹äœããæ§æãããŠããç«äœããºã«ã§ããã¥ãŒãã®åãå転ãããããšã«ãã£ãŠãïŒã€ã®åé¢ã®è²ãããããŸãã ãããããŒãã¥ãŒãã«å¯ŸããŠã¯äžå³ã®ãããªïŒçš®é¡ã®æäœãè¡ãããšãã§ããäžåã®æäœã§ã端ã«ããïŒã€ã®é£æ¥ãããã¥ãŒããïŒïŒïŒåºŠå転ããããšãã§ããŸããããããããããã«ãå³ã§ã¯ãäžé¢ã«ïŒ(èµ€è²)ãäžé¢ã«ïŒ(ç·è²)ãå³åé¢ã«â¡(é»è²)ãå·Šåé¢ã«â(éè²)ãå³å¥¥é¢ã«â(æ°Žè²)ã巊奥é¢ã«â 玫è²) ã®èšå·ãä»ããŠããç¶æ
ãåæç¶æ
ãšããŠããŸãã ãããããŒãã¥ãŒãã®åæç¶æ
ãäžããããã®ã§ãããºã«ãè§£ãããã«å¿
èŠãªæå°ã®æäœåæ°ãæ±ããããã°ã©ã ãäœæããŠãã ããã å
¥å å
¥åã¯ä»¥äžã®åœ¢åŒã§äžããããã N puzzle 1 puzzle 2 : puzzle N ïŒè¡ç®ã® N (1 †N †30) ã¯æäœåæ°ãèšç®ãããããºã«ã®æ°ã§ãããç¶ãNè¡ã«åãããããŒãã¥ãŒãã®åæç¶æ
puzzle i ãäžããããã puzzle i ã¯ä»¥äžã®åœ¢åŒã§äžããããã p 1 p 2 p 3 p 4 p 5 p 6 p 7 p 8 p 9 p 10 p 11 p 12 p 13 p 14 p 15 p 16 p 17 p 18 p 19 p 20 p 21 p 22 p 23 p 24 p 25 p 26 p 27 p 28 p 29 p 30 åãããããŒãã¥ãŒãã®æ
å ±ã¯ 30 åã®æŽæ° p i (1 †p i †6) ãããªãã p i ã¯ãäžå³ã®ããã«ãããããŒãã¥ãŒãã®åé¢ã«çªå· i ãæ¯ã£ããšãã®ããã®ãã¥ãŒãã®é¢ã®è²ã衚ãã ããºã«ã¯ãå€ããšãïŒåã®æäœã§è§£ãããšãã§ãããšä»®å®ããŠããã åºå ããºã«ããšã«ãæå°ã®æäœåæ°ãïŒè¡ã«åºåããã å
¥åºåäŸ å
¥åäŸ 4 1 1 1 1 1 1 1 1 1 2 2 2 4 4 4 6 6 6 5 5 5 3 3 3 3 3 3 3 3 3 3 3 3 1 1 1 1 1 1 2 2 2 4 4 6 4 6 6 5 5 5 3 3 3 3 3 3 1 1 1 3 3 3 1 1 3 1 1 1 2 2 5 6 4 4 4 6 6 2 5 5 3 3 3 1 3 3 1 1 1 1 3 1 3 1 3 3 1 3 2 2 2 6 4 4 6 6 4 5 5 5 1 3 1 1 3 1 3 1 3 åºåäŸ 0 1 2 7 | 36,444 |
Score : 1100 points Problem Statement We have a tree G with N vertices numbered 1 to N . The i -th edge of G connects Vertex a_i and Vertex b_i . Consider adding zero or more edges in G , and let H be the graph resulted. Find the number of graphs H that satisfy the following conditions, modulo 998244353 . H does not contain self-loops or multiple edges. The diameters of G and H are equal. For every pair of vertices in H that is not directly connected by an edge, the addition of an edge directly connecting them would reduce the diameter of the graph. Constraints 3 \le N \le 2 \times 10^5 1 \le a_i, b_i \le N The given graph is a tree. Input Input is given from Standard Input in the following format: N a_1 b_1 \vdots a_{N-1} b_{N-1} Output Print the answer. Sample Input 1 6 1 6 2 1 5 2 3 4 2 3 Sample Output 1 3 For example, adding the edges (1, 5), (3, 5) in G satisfies the conditions. Sample Input 2 3 1 2 2 3 Sample Output 2 1 The only graph H that satisfies the conditions is G . Sample Input 3 9 1 2 2 3 4 2 1 7 6 1 2 5 5 9 6 8 Sample Output 3 27 Sample Input 4 19 2 4 15 8 1 16 1 3 12 19 1 18 7 11 11 15 12 9 1 6 7 14 18 2 13 12 13 5 16 13 7 1 11 10 7 17 Sample Output 4 78732 | 36,445 |
Score : 600 points Problem Statement A tetromino is a figure formed by joining four squares edge to edge. We will refer to the following seven kinds of tetromino as I-, O-, T-, J-, L-, S- and Z-tetrominos, respectively: Snuke has many tetrominos. The number of I-, O-, T-, J-, L-, S- and Z-tetrominos in his possession are a_I , a_O , a_T , a_J , a_L , a_S and a_Z , respectively. Snuke will join K of his tetrominos to form a rectangle that is two squares tall and 2K squares wide. Here, the following rules must be followed: When placing each tetromino, rotation is allowed, but reflection is not. Each square in the rectangle must be covered by exactly one tetromino. No part of each tetromino may be outside the rectangle. Snuke wants to form as large a rectangle as possible. Find the maximum possible value of K . Constraints 0â€a_I,a_O,a_T,a_J,a_L,a_S,a_Zâ€10^9 a_I+a_O+a_T+a_J+a_L+a_S+a_Zâ¥1 Input The input is given from Standard Input in the following format: a_I a_O a_T a_J a_L a_S a_Z Output Print the maximum possible value of K . If no rectangle can be formed, print 0 . Sample Input 1 2 1 1 0 0 0 0 Sample Output 1 3 One possible way to form the largest rectangle is shown in the following figure: Sample Input 2 0 0 10 0 0 0 0 Sample Output 2 0 No rectangle can be formed. | 36,446 |
Convex Cut As shown in the figure above, cut a convex polygon g by a line p1p2 and print the area of the cut polygon which is on the left-hand side of the line. g is represented by a sequence of points p 1 , p 2 ,..., p n where line segments connecting p i and p i+1 (1 †i †nâ1 ) are sides of the convex polygon. The line segment connecting p n and p 1 is also a side of the polygon. Input The input is given in the following format: g (the sequence of the points of the polygon) q (the number of queries = the number of target lines) 1st query 2nd query : q th query g is given as a sequence of points p 1 ,..., p n in the following format: n x 1 y 1 x 2 y 2 : x n y n The first integer n is the number of points. The coordinate of the i -th point p i is given by two integers x i and y i . The coordinates of points are given in the order of counter-clockwise visit of them. Note that all interior angles of given convex polygons are less than or equal to 180. For each query, a line represented by two points p1 and p2 is given. The coordinates of the points are given by four integers p1x , p1y , p2x and p2y . Output For each query, print the area of the cut polygon. The output values should be in a decimal fraction with an error less than 0.00001. Constraints 3 †n †100 1 †q †100 -10000 †x i , y i †10000 -10000 †p1x , p1y , p2x , p2y †10000 No point in g will occur more than once. p1 â p2 Sample Input 4 1 1 4 1 4 3 1 3 2 2 0 2 4 2 4 2 0 Sample Output 2.00000000 4.00000000 | 36,447 |
Icy Composer Time Limit: 8 sec / Memory Limit: 64 MB F: æ°·ã®äœæ²å®¶ 岡éšé¬å€ªé(æç§°ãªã«ã¬ã³)ã¯ïŒè¥¿æŽé³æ¥œã®ç¬¬äžäººè
ã§ããïŒ åœŒã¯ïŒ5æ³ããäœæ²ãè¡ãããšãã§ãã倩æã§ããïŒåœŒãäœè©ã»äœæ²ãããæ»åã®æ§ãã¯ãšãŠãæåã§ããïŒ æèœããµãããªã«ã¬ã³ã ãïŒæ®å¿µãªããšã«ïŒåœŒã¯ïŒã¬ã¹ãã©ã³ã§é£ã¹ãéã«ããã£ãŠäº¡ããªã£ãŠããïŒ ã»ã»ã»å°ãªããšãïŒãã®äžçç·ã§ã¯ïŒããããããšã«ãªã£ãŠããïŒ äžçç·ãšã¯äœãïŒ äžã€ã®æŽå²ã¯ïŒäžã€ã®äžçç·ã«å¯Ÿå¿ããïŒ æã
ãæ©ãã§ããæŽå²ãšã¯ïŒç¡éã«ååšããäžçç·ã®ãã¡ã®äžã€ã«éããïŒ å¥ã®äžçç·ã§ã¯ïŒãŸãéã£ãæŽå²ãå»ãŸããŠããïŒ ãªã«ã¬ã³ã¯ïŒèªããåŸ
ã¡ãããéé
·ãªæªæ¥ã«ç«ã¡åããããã«ïŒå¥ã®äžçç·ãžãšæ
ç«ã€ããšã決æããã®ã ã£ãïŒ ãªã«ã¬ã³ãç®æãäžçç·ã¯ïŒãã®æåãªäžçç·ããã£ãã€ã³ãºã²ãŒããã§ããïŒ ããã£ãã€ã³ãºã²ãŒããã§ã¯ïŒå
šãŠã®éã¯æ°·ã®éæ³ãçšããŠæ°é®®ãªãŸãŸå·åä¿åãããããïŒéã«ããã人ã¯ããªãïŒ äžçç·ã¯ïŒã¢ã«ãã¡ãããã®å°æåãããªãæååã§è¡šãããïŒ ããã£ãã€ã³ãºã²ãŒããã衚ãæååã¯æ¢ã«è§£æãããŠãããïŒéåžžã«é·ãæååã§è¡šãããïŒ ãããç°¡æœã«è¡šèšããããïŒæåå seq ã® N åã®ç¹°ãè¿ãã N ( seq ) ãšå§çž®ããŠè¡šãïŒ ããã§ïŒ N ã¯ïŒ1以äžã®èªç¶æ°ã§ããïŒ seq ã¯å°æåãããªãæååãïŒå§çž®ããŠè¡šãããæååïŒãŸãã¯ïŒããããããã€ãé£çµããæååã§ããïŒ äŸãã°ïŒä»¥äžã®è¡šèšã¯ïŒæåå bbbababababxbbbababababx ã衚ãïŒ 2(3(b)4(ab)x) ãªã«ã¬ã³ã¯ïŒåœŒã®ãã€ãéçŒãªãŒãã£ã³ã°ãã£ãã€ããŒãã«ãã£ãŠïŒåœŒãããäžçç·ããæ¬¡ã«ç§»åã§ããäžçç·ãèªã¿ãšãããšãã§ããïŒ åœŒãããäžçç·ã¯ïŒããã£ãã€ã³ãºã²ãŒããããé ãé¢ããŠããããïŒçŽæ¥ããã£ãã€ã³ãºã²ãŒãããžç§»åããããšã¯ã§ããªãïŒ ãªã«ã¬ã³ã¯ïŒããã£ãã€ã³ãºã²ãŒããã«ã§ããã ãè¿ã¥ãããã«ïŒããã£ãã€ã³ãºã²ãŒããã«å¯Ÿããé¡äŒŒåºŠãé«ãäžçç·ãžãšç§»åããããšã«ããïŒ ããã£ãã€ã³ãºã²ãŒããã衚ãæååã x ïŒããäžçç·ã衚ãæååã y ãšããå ŽåïŒ x ã«å¯Ÿãã y ã®é¡äŒŒåºŠã¯ïŒ y ã®éšåæååã®ãã¡ïŒ x ã«ãéšåæååãšããŠçŸãããã®ã®æ°ã§ããïŒ ãã ãïŒ y ã®éšåæååãšããŠåãæååãè€æ°åçŸãããšããŠãïŒãããã¯ïŒå¥ã
ã«æ°ãããã®ãšããïŒ é¡äŒŒåºŠãåãäžçç·ãè€æ°ããå Žåã¯ïŒå
ã«å
¥åãšããŠäžããããäžçç·ã®æ¹ãé¡äŒŒåºŠãé«ããšã¿ãªããã®ãšããïŒ è«žåã«ã¯ïŒäžçç·ããã£ãã€ã³ãºã²ãŒããã衚ãæååãšãªã«ã¬ã³ã次ã«ç§»åã§ããäžçç·ã«å¯Ÿå¿ããæååãè€æ°äžãããããšãã«ïŒããã£ãã€ã³ãºã²ãŒããã«å¯Ÿããé¡äŒŒåºŠãæãé«ãäžçç·ãæ±ããŠãããããïŒ å¥éãç¥ãïŒ ãšã«ã»ããµã€ã»ã³ã³ã¬ãªã£ïŒ Input å
¥åã¯ä»¥äžã®åœ¢åŒã§äžããããïŒ n m k s t 1 t 2 ... t k å
¥å圢åŒã®å倿°ã®æå³ã¯ä»¥äžã®éãã§ããïŒ n ã¯ãã£ãã€ã³ãºã²ãŒãã衚ãæåå s ã®é·ã (1 <= n <= 250) m ã¯ãªã«ã¬ã³ãç§»åã§ããäžçç·ã衚ãæååã®é·ã (1 <= m <= 400) k ã¯ãªã«ã¬ã³ãç§»åã§ããäžçç·ã衚ãæååã®æ° (1 <= k <= 5) s ã¯ãã£ãã€ã³ãºã²ãŒãã衚ãæåå t i ã¯ãªã«ã¬ã³ãç§»åã§ããäžçç·ã衚ãæåå (1 <= i <= k ) Output æåå s ã«æãé¡äŒŒããæåå t i ã®çªå· i ãšé¡äŒŒåºŠã空çœåºåãã§äžè¡ã§åºåããïŒ Sample Input 1 5 3 2 aaaaa aaa aab Sample Output 1 1 6 Sample Input 2 10 3 3 2(ab)3(bc) abc bcb cbc Sample Output 2 2 6 Sample Input 3 13 24 1 2(3(b)4(ab)x) bbbababababxbbbababababx Sample Output 3 1 300 Sample Input 4 12 7 5 hyadainsgate hyadain mahyado behoimi megante moshyas Sample Output 4 1 28 Sample Input 5 44 6 5 sh1000(1000(1000(1000(ee))))t100(a)paz100(u) sheeta pazuuu romusk apalou rlaput Sample Output 5 2 21 | 36,448 |
Score : 800 points Problem Statement There is a connected undirected graph with N vertices and M edges. The vertices are numbered 1 to N , and the edges are numbered 1 to M . Also, each of these vertices and edges has a specified weight. Vertex i has a weight of X_i ; Edge i has a weight of Y_i and connects Vertex A_i and B_i . We would like to remove zero or more edges so that the following condition is satisfied: For each edge that is not removed, the sum of the weights of the vertices in the connected component containing that edge, is greater than or equal to the weight of that edge. Find the minimum number of edges that need to be removed. Constraints 1 \leq N \leq 10^5 N-1 \leq M \leq 10^5 1 \leq X_i \leq 10^9 1 \leq A_i < B_i \leq N 1 \leq Y_i \leq 10^9 (A_i,B_i) \neq (A_j,B_j) ( i \neq j ) The given graph is connected. All values in input are integers. Input Input is given from Standard Input in the following format: N M X_1 X_2 ... X_N A_1 B_1 Y_1 A_2 B_2 Y_2 : A_M B_M Y_M Output Find the minimum number of edges that need to be removed. Sample Input 1 4 4 2 3 5 7 1 2 7 1 3 9 2 3 12 3 4 18 Sample Output 1 2 Assume that we removed Edge 3 and 4 . In this case, the connected component containing Edge 1 contains Vertex 1, 2 and 3 , and the sum of the weights of these vertices is 2+3+5=10 . The weight of Edge 1 is 7 , so the condition is satisfied for Edge 1 . Similarly, it can be seen that the condition is also satisfied for Edge 2 . Thus, a graph satisfying the condition can be obtained by removing two edges. The condition cannot be satisfied by removing one or less edges, so the answer is 2 . Sample Input 2 6 10 4 4 1 1 1 7 3 5 19 2 5 20 4 5 8 1 6 16 2 3 9 3 6 16 3 4 1 2 6 20 2 4 19 1 2 9 Sample Output 2 4 Sample Input 3 10 9 81 16 73 7 2 61 86 38 90 28 6 8 725 3 10 12 1 4 558 4 9 615 5 6 942 8 9 918 2 7 720 4 7 292 7 10 414 Sample Output 3 8 | 36,449 |
Score : 100 points Problem Statement There are N islands floating in Ringo Sea, and M travel agents operate ships between these islands. For convenience, we will call these islands Island 1, 2, âŠ, N, and call these agents Agent 1, 2, âŠ, M . The sea currents in Ringo Sea change significantly each day. Depending on the state of the sea on the day, Agent i (1 †i †M) operates ships from Island a_i to b_i , or Island b_i to a_i , but not both at the same time. Assume that the direction of the ships of each agent is independently selected with equal probability. Now, Takahashi is on Island 1 , and Hikuhashi is on Island 2 . Let P be the probability that Takahashi and Hikuhashi can travel to the same island in the day by ships operated by the M agents, ignoring the factors such as the travel time for ships. Then, P à 2^M is an integer. Find P à 2^M modulo 10^9 + 7 . Constraints 2 †N †15 1 †M †N(N-1)/2 1 †a_i < b_i †N All pairs (a_i, b_i) are distinct. Input Input is given from Standard Input in the following format: N M a_1 b_1 : a_M b_M Output Print the value P à 2^M modulo 10^9 + 7 . Sample Input 1 4 3 1 3 2 3 3 4 Sample Output 1 6 The 2^M = 8 scenarios shown above occur with equal probability, and Takahashi and Hikuhashi can meet on the same island in 6 of them. Thus, P = 6/2^M and P à 2^M = 6 . Sample Input 2 5 5 1 3 2 4 3 4 3 5 4 5 Sample Output 2 18 Sample Input 3 6 6 1 2 2 3 3 4 4 5 5 6 1 6 Sample Output 3 64 | 36,450 |
Score : 300 points Problem Statement There are N balls in a two-dimensional plane. The i -th ball is at coordinates (x_i, y_i) . We will collect all of these balls, by choosing two integers p and q such that p \neq 0 or q \neq 0 and then repeating the following operation: Choose a ball remaining in the plane and collect it. Let (a, b) be the coordinates of this ball. If we collected a ball at coordinates (a - p, b - q) in the previous operation, the cost of this operation is 0 . Otherwise, including when this is the first time to do this operation, the cost of this operation is 1 . Find the minimum total cost required to collect all the balls when we optimally choose p and q . Constraints 1 \leq N \leq 50 |x_i|, |y_i| \leq 10^9 If i \neq j , x_i \neq x_j or y_i \neq y_j . All values in input are integers. Input Input is given from Standard Input in the following format: N x_1 y_1 : x_N y_N Output Print the minimum total cost required to collect all the balls. Sample Input 1 2 1 1 2 2 Sample Output 1 1 If we choose p = 1, q = 1 , we can collect all the balls at a cost of 1 by collecting them in the order (1, 1) , (2, 2) . Sample Input 2 3 1 4 4 6 7 8 Sample Output 2 1 If we choose p = -3, q = -2 , we can collect all the balls at a cost of 1 by collecting them in the order (7, 8) , (4, 6) , (1, 4) . Sample Input 3 4 1 1 1 2 2 1 2 2 Sample Output 3 2 | 36,451 |
Score : 200 points Problem Statement AtCoDeer the deer has found two positive integers, a and b . Determine whether the concatenation of a and b in this order is a square number. Constraints 1 †a,b †100 a and b are integers. Input Input is given from Standard Input in the following format: a b Output If the concatenation of a and b in this order is a square number, print Yes ; otherwise, print No . Sample Input 1 1 21 Sample Output 1 Yes As 121 = 11 à 11 , it is a square number. Sample Input 2 100 100 Sample Output 2 No 100100 is not a square number. Sample Input 3 12 10 Sample Output 3 No | 36,452 |
Grated Radish Grated radish (daikon-oroshi) is one of the essential spices in Japanese cuisine. As the name shows, itâs made by grating white radish. You are developing an automated robot for grating radish. You have finally finished developing mechan- ical modules that grates radish according to given instructions from the microcomputer. So you need to develop the software in the microcomputer that controls the mechanical modules. As the first step, you have decided to write a program that simulates the given instructions and predicts the resulting shape of the radish. Input The input consists of a number of test cases. The first line on each case contains two floating numbers R and L (in centimeters), representing the radius and the length of the cylinder-shaped radish, respectively. The white radish is placed in the xyz -coordinate system in such a way that cylinderâs axis of rotational symmetry lies on the z axis. Figure 1: The placement of the white radish The next line contains a single integer N , the number of instructions. The following N lines specify instructions given to the grating robot. Each instruction consists of two floating numbers Ξ and V , where Ξ is the angle of grating plane in degrees, and V (in cubic centimeters) is the volume of the grated part of the radish. You may assume the following conditions: the direction is measured from positive x axis (0 degree) to positive y axis (90 degrees), 1 †R †5 (in centimeters), 1 †L †40 (in centimeters), 0 †Ξ < 360, and the sum of V âs is the smaller than the volume of the given white radish. Figure 2: An example of grating Output For each test case, print out in one line two numbers that indicate the shape of the base side (the side parallel to xy -plane) of the remaining radish after the entire grating procedure is finished, where the first number of the total length is the linear (straight) part and the second is the total length of the curved part. You may output an arbitrary number of digits after the decimal points, provided that difference from the true answer is smaller than 10 -6 centimeters. Sample Input 2 1 2 1 42 3.141592653589793 5 20 3 0 307.09242465218927 180 307.09242465218927 90 728.30573874452591 Output for the Sample Input 2.0 3.141592653589793 8.660254038 5.235987756 | 36,453 |
Score : 600 points Problem Statement We have a tree with N vertices and N-1 edges, respectively numbered 1, 2,\cdots, N and 1, 2, \cdots, N-1 . Edge i connects Vertex u_i and v_i . For integers L, R ( 1 \leq L \leq R \leq N ), let us define a function f(L, R) as follows: Let S be the set of the vertices numbered L through R . f(L, R) represents the number of connected components in the subgraph formed only from the vertex set S and the edges whose endpoints both belong to S . Compute \sum_{L=1}^{N} \sum_{R=L}^{N} f(L, R) . Constraints 1 \leq N \leq 2 \times 10^5 1 \leq u_i, v_i \leq N The given graph is a tree. All values in input are integers. Input Input is given from Standard Input in the following format: N u_1 v_1 u_2 v_2 : u_{N-1} v_{N-1} Output Print \sum_{L=1}^{N} \sum_{R=L}^{N} f(L, R) . Sample Input 1 3 1 3 2 3 Sample Output 1 7 We have six possible pairs (L, R) as follows: For L = 1, R = 1 , S = \{1\} and we have 1 connected component. For L = 1, R = 2 , S = \{1, 2\} and we have 2 connected components. For L = 1, R = 3 , S = \{1, 2, 3\} and we have 1 connected component, since S contains both endpoints of each of the edges 1, 2 . For L = 2, R = 2 , S = \{2\} and we have 1 connected component. For L = 2, R = 3 , S = \{2, 3\} and we have 1 connected component, since S contains both endpoints of Edge 2 . For L = 3, R = 3 , S = \{3\} and we have 1 connected component. The sum of these is 7 . Sample Input 2 2 1 2 Sample Output 2 3 Sample Input 3 10 5 3 5 7 8 9 1 9 9 10 8 4 7 4 6 10 7 2 Sample Output 3 113 | 36,454 |
AïŒ A-Z- åé¡ 26 ãã¹ã®åç°ç¶ã®ããŒãããããåãã¹ã«ã¯å€§æåã®ã¢ã«ãã¡ããã 1 æåããã¢ã«ãã¡ãããé ã«æèšåãã«æžãããŠããŸããããªãã¡ã 'A' ã®ãã¹ã®æèšåãé£ã¯ 'B' ã®ãã¹ã§ã 'B' ã®ãã¹ã®é£ã¯ 'C' ã®ãã¹ã§ãã»ã»ã»ã 'Z' ã®ãã¹ã®æèšåãé£ã¯ 'A' ã®ãã¹ã§ãã ãŸããããŒãã«ã¯ 'A' ã®ãã¹ã«é§ã 1 ã€çœ®ãããŠããŸãã ããªãã¯ãæåå S ãåãåãã S ã®å
é ãã 1 æåãã€èŠãŠé§ãæäœããŸãã i åç®ã®æäœã¯ä»¥äžã®ããã«ãªããŸãã ãã®æç¹ã§é§ã®ãããã¹ãã S ã® i æåç®ã®ã¢ã«ãã¡ãããã®ãã¹ãç®æããŠãé§ãæèšåãã« 1 ãã¹ãã€ç§»åãããããã®ãšãå°ãªããšã 1 ãã¹ã¯ç§»åãããšããããããã£ãŠãäŸãã° 'A' ã®ãã¹ãã 'A' ã®ãã¹ã«ç§»åããéã¯ãããŒãã 1 åšããªããŠã¯ãªããªãã äžèšã®æäœã®çµæãé§ã 'A' ã®ãã¹ãäœåèžãã ããçããŠãã ããããªãã 'A' ã®ãã¹ãèžãããšã¯ã 'Z' ã®ãã¹ãã 'A' ã®ãã¹ã«é§ãé²ããããšãèšããŸãã å
¥ååœ¢åŒ å
¥å㯠1 è¡ã§äžããããã S S ã¯ããªããåãåãæååã衚ãã å¶çŽ 1 \leq |S| \leq 100 S ã¯è±å€§æåã®ã¿ã§æ§æãããã åºååœ¢åŒ 'A' ã®ãã¹ãäœåèžãã ãã 1 è¡ã§åºåããã å
¥åäŸ1 AIZU åºåäŸ1 2 A -> A (ããã§ 1 å) A -> I (ãããŸã§ 1 å) I -> Z (ãããŸã§ 1 å) Z -> U (ãããŸã§ 2 å) å
¥åäŸ2 HOKKAIDO åºåäŸ2 4 | 36,455 |
Score : 1500 points Problem Statement There is an undirected connected graph with N vertices numbered 1 through N . The lengths of all edges in this graph are 1 . It is known that for each i (1âŠiâŠN) , the distance between vertex 1 and vertex i is A_i , and the distance between vertex 2 and vertex i is B_i . Determine whether there exists such a graph. If it exists, find the minimum possible number of edges in it. Constraints 2âŠNâŠ10^5 0âŠA_i,B_iâŠN-1 Input The input is given from Standard Input in the following format: N A_1 B_1 A_2 B_2 : A_N B_N Output If there exists a graph satisfying the conditions, print the minimum possible number of edges in such a graph. Otherwise, print -1 . Sample Input 1 4 0 1 1 0 1 1 2 1 Sample Output 1 4 The figure below shows two possible graphs. The graph on the right has fewer edges. Sample Input 2 3 0 1 1 0 2 2 Sample Output 2 -1 Such a graph does not exist. | 36,456 |
Naive String Search Find places where a string P is found within a text T . Print all indices of T where P found. The indices of T start with 0. Input In the first line, a text T is given. In the second line, a string P is given. output Print an index of T where P found in a line. Print the indices in ascending order. Constraints 1 †length of T †1000 1 †length of P †1000 The input consists of alphabetical characters and digits Sample Input 1 aabaaa aa Sample Output 1 0 3 4 Sample Input 2 xyzz yz Sample Output 2 1 Sample Input 3 abc xyz Sample Output3 The ouput should be empty. | 36,457 |
Problem A: Goldbach's Conjecture Goldbach's Conjecture: For any even number n greater than or equal to 4, there exists at least one pair of prime numbers p 1 and p 2 such that n = p 1 + p 2 . This conjecture has not been proved nor refused yet. No one is sure whether this conjecture actually holds. However, one can find such a pair of prime numbers, if any, for a given even number. The problem here is to write a program that reports the number of all the pairs of prime numbers satisfying the condition in the conjecture for a given even number. A sequence of even numbers is given as input. Corresponding to each number, the program should output the number of pairs mentioned above. Notice that we are intereseted in the number of essentially different pairs and therefore you should not count ( p 1 , p 2 ) and ( p 2 , p 1 ) separately as two different pairs. Input An integer is given in each input line. You may assume that each integer is even, and is greater than or equal to 4 and less than 2 15 . The end of the input is indicated by a number 0. Output Each output line should contain an integer number. No other characters should appear in the output. Sample Input 6 10 12 0 Output for the Sample Input 1 2 1 | 36,458 |
B: ã€ã«ã£ã㌠/ SNS å顿 AOR ã€ã«ã¡ããã¯æè¿å°ãæ©å«ãæªãã ã©ããããâã€ã«ã£ããŒâã®ãã©ããŒæ°ãšãã©ãã¯ãŒæ°ã®æ¯ãæ°ã«å
¥ããªãããã ãçŸåšãAOR ã€ã«ã¡ããã®ãã©ããŒæ°ã¯ $A$ 人ããã©ãã¯ãŒæ°ã¯ $B$ 人ã§ãããæ¯ã¯ $A:B$ ã§ããã ããã§ãAOR ã€ã«ã¡ããã¯ãã©ããŒæ°ãšãã©ãã¯ãŒæ°ã®æ¯ãæ°ã«å
¥ã£ãæŽæ°æ¯ã«ãªãããã«ã ãã©ããŒæ° ã墿žãããããšã«ããã ãªãæ°ã«å
¥ã£ãæŽæ°æ¯ãšã¯ãæ¯ã«å«ãŸããã©ã¡ãã®å€ã $1$ ä»¥äž $N$ 以äžã®æŽæ°ãšãªãããã«è¡šããæ¯ã§ããã ããããAOR ã€ã«ã¡ããã¯ã§ããã ããã©ããŒæ°ã倿Žããããªãã®ã§ã倿Žåãšã®å·®ã®çµ¶å¯Ÿå€ãã§ããã ãå°ãããããã AOR ã€ã«ã¡ããã®æ©å«ãè¯ãããããã«ãå°ãªããšããã©ããŒæ°ãããã€å€æŽããå¿
èŠãããããæ±ããããã°ã©ã ãäœæããã å
¥å $A \ B \ N$ å
¥åã®å¶çŽ $1 \le A, \ B \le 10^{12}$ $1 \leq N \leq 100 $ åºå æ°ã«å
¥ã£ãæŽæ°æ¯ã«ã§ããã$A$ ã®å€åéã®çµ¶å¯Ÿå€ã®æå°å€ãåºåããã ãµã³ãã« ãµã³ãã«å
¥å1 19 30 3 ãµã³ãã«åºå1 1 ãµã³ãã«å
¥å2 3 7 7 ãµã³ãã«åºå2 0 ãµã³ãã«å
¥å3 3 7 1 ãµã³ãã«åºå3 4 ãµã³ãã«å
¥å4 102 30 3 ãµã³ãã«åºå4 12 ãã©ããŒã $12$ 人æžããããšã§ $90:30 \ (=3:1)$ ã«ãªããæ¯ã®å€§ããæ¹ã®æ°åã $3$ 以äžãšãªããŸãã ãã®ãšããå€åé㯠$12$ ã§ãã ãµã³ãã«å
¥å5 3 4 2 ãµã³ãã«åºå5 1 äžäººãã©ããŒãå€ããš $2:4 \ (=1:2)$ ã«ããã©ããŒãããš $4:4 \ (=1:1)$ ã«ãªããã©ã¡ãã墿žã®çµ¶å¯Ÿå€ã¯ $1$ ã§ãããçãã§ãã ãµã³ãã«å
¥å6 1 100 2 ãµã³ãã«åºå6 49 æäœã§ã $1$ 人ã¯ãã©ããŒããŠããªããã°ãããªãäºã«æ³šæããŠãã ããã | 36,459 |
åé¡ 1: å¹³åç¹ (Average Score) åé¡ JOI 髿 ¡ã®ææ¥ã«ã¯ïŒå€ªéåïŒæ¬¡éåïŒäžéåïŒåéåïŒè±åããã® 5 人ã®çåŸãåå ããïŒ ãã®ææ¥ã§ã¯ïŒææ«è©Šéšã宿œããïŒææ«è©Šéšã¯ïŒ5 人å
šå¡ãåéšããïŒææ«è©Šéšã®ç¹æ°ã 40 ç¹ä»¥äžã®çåŸã¯ïŒææ«è©Šéšã®ç¹æ°ããã®ãŸãŸæçžŸã«ãªã£ãïŒææ«è©Šéšã®ç¹æ°ã 40 ç¹æªæºã®çåŸã¯å
šå¡ïŒè£ç¿ãåãïŒæçžŸã 40 ç¹ã«ãªã£ãïŒ 5 人ã®çåŸã®ææ«è©Šéšã®ç¹æ°ãäžãããããšãïŒ5 äººã®æçžŸã®å¹³åç¹ãèšç®ããããã°ã©ã ãäœæããïŒ å
¥å å
¥å㯠5 è¡ãããªãïŒ1 è¡ã« 1 ã€ãã€æŽæ°ãæžãããŠããïŒ 1 è¡ç®ã«ã¯ 倪éåã®ææ«è©Šéšã®ç¹æ°ãæžãããŠããïŒ 2 è¡ç®ã«ã¯ 次éåã®ææ«è©Šéšã®ç¹æ°ãæžãããŠããïŒ 3 è¡ç®ã«ã¯ äžéåã®ææ«è©Šéšã®ç¹æ°ãæžãããŠããïŒ 4 è¡ç®ã«ã¯ åéåã®ææ«è©Šéšã®ç¹æ°ãæžãããŠããïŒ 5 è¡ç®ã«ã¯ è±åããã®ææ«è©Šéšã®ç¹æ°ãæžãããŠããïŒ çåŸã®ææ«è©Šéšã®ç¹æ°ã¯ãã¹ãŠ 0 ç¹ä»¥äž 100 ç¹ä»¥äžã®æŽæ°ã§ããïŒ çåŸã®ææ«è©Šéšã®ç¹æ°ã¯ãã¹ãŠ 5 ã®åæ°ã§ããïŒ 5 人ã®çåŸã®æçžŸã®å¹³åç¹ã¯å¿
ãæŽæ°ã«ãªãïŒ åºå 5 人ã®çåŸã®æçžŸã®å¹³åç¹ãããããæŽæ°ã 1 è¡ã§åºåããïŒ å
¥åºåäŸ å
¥åäŸ 1 10 65 100 30 95 åºåäŸ 1 68 å
¥åºåäŸ 1 ã§ã¯ïŒå€ªéåãšåéåã®ææ«è©Šéšã®ç¹æ°ã¯ 40 ç¹æªæºãªã®ã§ïŒå€ªéåãšåéåã®æçžŸã¯ 40 ç¹ã«ãªãïŒæ¬¡éåãšäžéåãšè±åããã®ææ«è©Šéšã®ç¹æ°ã¯ 40 ç¹ä»¥äžãªã®ã§ïŒæ¬¡éåã®æçžŸã¯ 65 ç¹ïŒäžéåã®æçžŸã¯ 100 ç¹ïŒè±åããã®æçžŸã¯ 95 ç¹ãšãªãïŒ5 äººã®æçžŸã®åèšã¯ 340 ãªã®ã§ïŒå¹³åç¹ã¯ 68 ç¹ãšãªãïŒ å
¥åäŸ 2 40 95 0 95 50 åºåäŸ 2 64 å顿ãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã | 36,460 |
D: Walking åé¡ $1$ ãã $N$ ã®çªå·ãã€ããããŠãã $N$ åã®å³¶ããã. ããããã®å³¶ã¯ $N-1$ åã®æ©ã«ãã£ãŠãã©ã® $2$ ã€ã®å³¶ãäœæ¬ãã®æ©ãæž¡ã£ãŠäºãã«ç§»åããããšãã§ãã. ããããã®æ©ã«ã¯èä¹
床ããããå
¥åãäžããããæç¹ã§ã® $i$ çªç®ã®æ©ã®èä¹
床㯠$w_i$ ã§ãã. ããããã®å³¶ã«ã¯ãå®ã $1$ ã€ãã€çœ®ããŠãããå³¶ã«æ»åšããŠãããšãã«ãå®ãæŸãããšãã§ãã. çŸåšå³¶ $S$ ã«ããyebiããã¯ãå³¶ $E$ ã«ããåç©é€šã«å
šãŠã®ãå®ãéã³ãã. yebiããã¯âéåâãæã£ãŠããã®ã§ãå³¶ $v$ ã«èšªåãããã³ã«ã $v$ ããåºãå
šãŠã®æ©ã®èä¹
床ã $T$ æžå°ãã. æ©ã®èä¹
床ã $0$ 以äžã«ãªã£ããšããæ©ã¯åŽ©å£ãããã以éã«ã¯æž¡ãããšãã§ããªããªã. yebiããã¯åç©é€šã«å
šãŠã®ãå®ãå±ããããšãã§ãããïŒ ãã ããyebiããã¯åæã¡ãªã®ã§åæã«ããã€ã§ããå®ãæã¡éã¶ããšãã§ãã. å¶çŽ å
¥åå€ã¯å
šãп޿°ã§ãã $2 \leq N \leq 10^5$ $1 \leq S, E \leq N$ $0 \leq T \leq 10^9$ $1 \leq w_i \leq 10^9$ $1 \leq a_i, b_i \leq N$ å
¥ååœ¢åŒ å
¥åã¯ä»¥äžã®åœ¢åŒã§äžãããã $N\ T\ S\ E$ $a_1\ b_1\ w_1$ : : $a_{N-1}\ b_{N-1}\ w_{N-1}$ åºå åç©é€šã«å
šãŠã®ãå®ãå±ããããšãã§ãããªã "Yes"ãããã§ãªããã° "No" ãåºåãã. ãŸããæ«å°Ÿã«æ¹è¡ãåºåãã. ãµã³ãã« ãµã³ãã«å
¥å 1 4 10 1 4 1 2 52 1 3 68 3 4 45 ãµã³ãã«åºå 1 Yes ãµã³ãã«å
¥å 2 4 10 1 4 1 2 15 1 3 60 3 4 10 ãµã³ãã«åºå 2 No ãµã³ãã«å
¥å 3 3 0 1 3 1 2 5 2 3 5 ãµã³ãã«åºå 3 Yes yebiããã®éåã¯è²§åŒ±ãããŠãæ©ã®èä¹
åºŠãæžããããšã¯ã§ããªã. | 36,461 |
ã«ãŒã æ£ã®æŽæ°ãæžãããäžçµã®ã«ãŒãããããŸããã«ãŒããç©ãã§å±±ãããã€ãäœããããããæšªäžåã«äžŠã¹ãŸãããã®äžããé£ãåã£ã 2 ã€ã®ã«ãŒãã®å±±ãéžã³ãå³åŽã®å±±ã®äžã«å·ŠåŽã®å±±ããã®ãŸãŸéããŸãããã®æäœãã«ãŒãã®å±±ãäžã€ã«ãªããŸã§ç¹°ãè¿ããŠãããŸãã 2 ã€ã®ã«ãŒãã®å±±ãéããæã«ãããã®äžçªäžãšäžã®ã«ãŒãã«æžãããæ°ããã¹ãŠæãåãããŸããããããŠåŸãããæ°ãã«ãŒãã®éãåããã®ã³ã¹ããšåŒã¶ããšã«ããŸããã«ãŒãã®å±±ãäžã€ã«ããããã®ã³ã¹ãã¯ãã¹ãŠã®éãåããã®ã³ã¹ããè¶³ãåããããã®ãšããŸãã ã©ã®ãããªé çªã§ã«ãŒãã®å±±ãéãããã§ã³ã¹ãã¯å€ãããŸããããšãã°ã3 ã€ã®ã«ãŒãã®å±±ãããå ŽåãèããŸãããããã®äžçªäžãšäžã®ã«ãŒãã«æžãããæ°ãïŒå·ŠåŽã®å±±ããé ã«ãããã 3 ãš 5, 2 ãš 8, 5 ãš4 ã ã£ããšããŸãããã®ãšãïŒã¯ããã«å·Šãšçãäžã®å±±ãéãããšãã®ã³ã¹ãã¯ã3 à 5 à 2 à 8 = 240 ã§ãããã®éãåããã«ãã£ãŠãäžçªäžã®ã«ãŒãã 3 ã§äžçªäžã®ã«ãŒãã 8 ã§ããå±±ãã§ããŸãã ãã®å±±ãå³ã®å±±ã®äžã«éãããšããã®ã³ã¹ã㯠3 à 8 à 5 à 4 = 480 ã«ãªããŸãããããã£ãŠããã®é çªã§ã«ãŒãã®å±±ãäžã€ã«ãŸãšãããšãã®ã³ã¹ã㯠240 + 480 = 720 ã§ããïŒå³1ïŒ äžæ¹ãã¯ããã«çãäžãšå³ã®å±±ãéããŠããæåŸã«å·Šã®å±±ãéããããšã«ãããšããã®ãšãã®ã³ã¹ã㯠2 à 8 à 5 à 4 + 3 à 5 à 2 à 4 = 440 ã«ãªããŸãããããã£ãŠïŒåŸã®å Žåã®ããã«éããæ¹ãã³ã¹ããå°ãããªããŸããïŒå³2ïŒ ã«ãŒãã®å±±ã®åæ°ãšããããã®å±±ã®äžçªäžãšäžã®ã«ãŒãã«æžãããæ°ãå
¥åãšããã«ãŒãã®å±±ãäžã€ã«ãŸãšããã®ã«å¿
èŠãªæå°ã®ã³ã¹ããåºåããããã°ã©ã ãäœæããŠãã ããããã ããå±±ã®åæ°ã¯ 100 å以äžãšããå
¥åãããããŒã¿ã¯ã©ã®ãããªé çªã§ã³ã¹ããèšç®ããŠã 2 31 -1 ãè¶
ããããšã¯ãããŸããã Input å
¥åã¯ä»¥äžã®åœ¢åŒã§äžããããŸãã n a 1 b 1 a 2 b 2 : a n b n 1 è¡ç®ã«ã«ãŒãã®å±±ã®åæ° n ( n †100)ãç¶ã n è¡ã«å·Šãã i çªç®ã®å±±ã® 1 çªäžã®ã«ãŒãã«æžãããæ° a i (1 †a i †200) ãš 1 çªäžã®ã«ãŒãã«æžãããæ° b i (1 †b i †200) ãäžããããŸãã Output ã«ãŒãã®å±±ãäžã€ã«ãŸãšããã®ã«å¿
èŠãªæå°ã®ã³ã¹ããïŒè¡ã«åºåããŠãã ããã Sample Input 3 3 5 2 8 5 4 Output for the Sample Input 440 | 36,462 |
Problem B: å¹³å®äº¬ãŠã©ãŒãã³ã° å¹³å®äº¬ã¯ãéãæ Œåç¶ã«ãªã£ãŠããçºãšããŠç¥ãããŠããã å¹³å®äº¬ã«äœãã§ããããã®ãã¯ãµã€ã¯ãããããŒã«ã®ããã«æ¯æ¥èªå®
ããçºã¯ããã®ç§å¯ã®å ŽæãŸã§è¡ããªããã°ãªããªããããããæ¯æ¥åãéãéãã®ã¯é£œããããåŸãä»ããããå±éºãããã®ã§ããã¯ãµã€ã¯ã§ããã ãæ¯æ¥ç°ãªãçµè·¯ã䜿ãããããã®äžæ¹ã§ããã¯ãµã€ã¯é¢åèãããªã®ã§ãç®çå°ããé ããããããªéã¯éããããªãã å¹³å®äº¬ã®ãã¡ãã¡ã®éã«ã¯ãã¿ã¿ããèœã¡ãŠããŠããã¯ãµã€ã¯ãã¿ã¿ããèœã¡ãŠããéãéãããšãã§ããªãããã®ãããªéãéããšããããã«ãªã£ãŠããŸãããã§ããã幞ããªããšã«ã亀差ç¹ã«ã¯ãã¿ã¿ãã¯èœã¡ãŠããªãã ãã¯ãµã€ã¯ãèªå®
ããç§å¯ã®å ŽæãŸã§ã®å¯èœãªçµè·¯ã®æ°ãç¥ããããããã§ããã¯ãµã€ã®èªå®
㯠(0, 0) ã«ãããç§å¯ã®å Žæã¯( g x , g y )ã«ãããé㯠x = i ( i ã¯æŽæ°), y = j ( j ã¯æŽæ°) ã«æ Œåç¶ã«æ·ãããŠããã Input å
¥åã®1è¡ç®ã«ã¯ãç§å¯ã®å Žæã®åº§æš ( g x , g y ) ãäžããããããããã¯ãããã1以äž15以äžã®æŽæ°ã§ã空çœ1åã§åºåãããŠäžããããã 2è¡ç®ã«ã¯ãã¿ã¿ããèœã¡ãŠããåºéã®æ° p (0 †p †100) ãäžããããç¶ã p è¡ã«ã¯ãã¿ã¿ããèœã¡ãŠããåºéã1è¡ã«1åºéãã€äžããããã p åã®åºéã¯äºãã«ç°ãªãã 1åºé㯠x 1 y 1 x 2 y 2 ã®åœ¢ã§è¡šããã( x 1 , y 1 ) ãš ( x 2 , y 2 ) ã端ç¹ãšããã x 軞ãŸã㯠y 軞ã«å¹³è¡ãªé·ã1ã®ç·åã§ããã x 1 , x 2 㯠[0, g x ] ã®ç¯å²ã«ããã y 1 , y 2 㯠[0, g y ] ã®ç¯å²ã«ããã Output å¯èœãªçµè·¯ã®æ°ãåºåãããå¯èœãªçµè·¯ã1ã€ããªãå Žå㯠"Miserable Hokusai!" ãš1è¡ã«åºåããã Notes on Submission äžèšåœ¢åŒã§è€æ°ã®ããŒã¿ã»ãããäžããããŸããå
¥åããŒã¿ã® 1 è¡ç®ã«ããŒã¿ã»ããã®æ°ãäžããããŸããåããŒã¿ã»ããã«å¯Ÿããåºåãäžèšåœ¢åŒã§é çªã«åºåããããã°ã©ã ãäœæããŠäžããã Sample Input 4 2 2 0 1 1 2 0 0 0 1 0 0 1 0 4 3 4 1 0 0 0 3 3 4 3 4 1 4 0 0 2 0 3 15 15 0 Output for the Sample Input 6 Miserable Hokusai! 5 155117520 | 36,463 |
Score : 300 points Problem Statement There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N . The i -th person from the west is facing east if S_i = E , and west if S_i = W . You will appoint one of the N people as the leader, then command the rest of them to face in the direction of the leader. Here, we do not care which direction the leader is facing. The people in the row hate to change their directions, so you would like to select the leader so that the number of people who have to change their directions is minimized. Find the minimum number of people who have to change their directions. Constraints 2 \leq N \leq 3 \times 10^5 |S| = N S_i is E or W . Input Input is given from Standard Input in the following format: N S Output Print the minimum number of people who have to change their directions. Sample Input 1 5 WEEWW Sample Output 1 1 Assume that we appoint the third person from the west as the leader. Then, the first person from the west needs to face east and has to turn around. The other people do not need to change their directions, so the number of people who have to change their directions is 1 in this case. It is not possible to have 0 people who have to change their directions, so the answer is 1 . Sample Input 2 12 WEWEWEEEWWWE Sample Output 2 4 Sample Input 3 8 WWWWWEEE Sample Output 3 3 | 36,464 |
Score : 200 points Problem Statement You are given string S and T consisting of lowercase English letters. Determine if S equals T after rotation . That is, determine if S equals T after the following operation is performed some number of times: Operation: Let S = S_1 S_2 ... S_{|S|} . Change S to S_{|S|} S_1 S_2 ... S_{|S|-1} . Here, |X| denotes the length of the string X . Constraints 2 \leq |S| \leq 100 |S| = |T| S and T consist of lowercase English letters. Input Input is given from Standard Input in the following format: S T Output If S equals T after rotation , print Yes ; if it does not, print No . Sample Input 1 kyoto tokyo Sample Output 1 Yes In the first operation, kyoto becomes okyot . In the second operation, okyot becomes tokyo . Sample Input 2 abc arc Sample Output 2 No abc does not equal arc after any number of operations. Sample Input 3 aaaaaaaaaaaaaaab aaaaaaaaaaaaaaab Sample Output 3 Yes | 36,465 |
2014 幎æ¥ïŒããåŠçã¯ç¡äºå€§åŠã«åæ ŒãïŒäžäººæ®ãããå§ããäºãšãªã£ãïŒããã§åé¡ãšãªãã®ãå€é£ãã©ããããã§ããïŒåœŒã¯ãããã N æ¥éã®å€é£ã®èšç»ãç«ãŠãäºã«ããïŒ åœŒã¯ N æ¥éã§åŸããã幞çŠåºŠã®åèšãåºæ¥ãéã倧ãããããïŒãã¡ããïŒçŸå³ãããã®ã奜ããªãã®ãé£ã¹ãã»ã©å¹žçŠåºŠã¯é«ãïŒ åœŒã®å€é£ã®éžæè¢ã¯2 ã€ïŒè¿ãã®é£å ã«åãããïŒèªçããããã®ã©ã¡ããã§ããïŒ é£å ã§åŸããã幞çŠåºŠã¯ïŒãã®æ¥ã®ã¡ãã¥ãŒã«ãã£ãŠå€ããïŒã¡ãã¥ãŒã¯æ¥æ¿ããã ãæ¯æ¥äžçš®é¡ã®ã¿ã§ïŒ N æ¥éã®ã¡ãã¥ãŒã¯å
šãŠæ¢ã«å
¬éãããŠããïŒãªã®ã§ïŒåœŒã¯ i æ¥ç® (1 †i †N ) ã«é£å ã«è¡ãã° C i ã®å¹žçŠåºŠãåŸããããšããæ
å ±ãå
šãŠç¥ã£ãŠããïŒ èªçã§åŸããã幞çŠåºŠã¯ïŒãã®èªçã®éå§æç¹ã§ã® èªçãã¯ãŒ ã«å®æ° P ãæãããã®ã§ããïŒ èªçãã¯ãŒ ã¯åæå€ã Q ã§ããïŒæ¯æ¥ïŒé£å ã«è¡ãã°-1ïŒèªçãããã°+1ïŒãã®æ¥ã®é£äºã®çµäºæã«å€åããïŒ åœŒã®ããã«å¹žçŠåºŠã®ç·åã®æå€§å€ãæ±ãããïŒ Input å
¥åã¯ä»¥äžã®åœ¢åŒã§ N + 1 è¡ã§äžããããïŒ N P Q C 1 C 2 : C N 1 è¡ç®ã¯ 3 ã€ã®æŽæ° N, P, Q ãäžãããïŒããããæ¥æ°ïŒèªçã®å¹žçŠåºŠãç®åºããããã®å®æ°ïŒèªçãã¯ãŒã®åæå€ã§ããïŒ 2 è¡ç®ãã N + 1 è¡ç®ã«ã¯ããããæŽæ°ã 1 ã€ãã€äžãããïŒ i + 1 è¡ç®ã§ã¯ i æ¥ç®ã«é£å ã«è¡ã£ãæã«åŸããã幞çŠåºŠãäžããããïŒ Constraints 1 †N †500,000 0 †P †500,000 |Q| †500,000 |C i | †500,000 Output 幞çŠåºŠã®åãããæå€§å€ãäžè¡ã«åºåããïŒ Sample Input 1 1 1 1 2 Output for the Sample Input 1 2 èããã¹ãäºå®ã¯1 æ¥ã ãã§ããïŒé£å ã«è¡ãã°2ïŒèªçãããš1 ã®å¹žçŠåºŠãªã®ã§ïŒçãã¯2 ãšãªãïŒ Sample Input 2 3 2 1 3 3 3 Output for the Sample Input 2 12 ãã®ã±ãŒã¹ã§ã¯æ¯æ¥èªçãããã®ãæé©ã§ïŒå¹žçŠåºŠã¯ 2 à 1 + 2 à 2 + 2 à 3 = 12 ãšãªãïŒ Sample Input 3 3 1 -1 2 -3 2 Output for the Sample Input 3 2 2 æ¥ç®ã®ã¿ã§èªçãããããšãæåãšãªãïŒ Sample Input 4 3 1 -10 -10 -10 -10 Output for the Sample Input 4 -27 çããè² ã«ãªãããšãããïŒããããŸãããŠãå€é£ã¯é£ã¹ãªããã°ãªããªãïŒ | 36,466 |
Score : 1000 points Problem Statement We will call a string x good if it satisfies the following condition: Condition: x can be represented as a concatenation of two copies of another string y of length at least 1 . For example, aa and bubobubo are good; an empty string, a , abcabcabc and abba are not good. Eagle and Owl created a puzzle on good strings. Find one string s that satisfies the following conditions. It can be proved that such a string always exists under the constraints in this problem. 1 †|s| †200 Each character of s is one of the 100 characters represented by the integers 1 through 100 . Among the 2^{|s|} subsequences of s , exactly N are good strings. Constraints 1 †N †10^{12} Input Input is given from Standard Input in the following format: N Output In the first line, print |s| , the length of s . In the second line, print the elements in s in order, with spaces in between. Any string that satisfies the above conditions will be accepted. Sample Input 1 7 Sample Output 1 4 1 1 1 1 There are two good strings that appear as subsequences of s : (1,1) and (1,1,1,1) . There are six occurrences of (1,1) and one occurrence of (1,1,1,1) , for a total of seven. Sample Input 2 299 Sample Output 2 23 32 11 11 73 45 8 11 83 83 8 45 32 32 10 100 73 32 83 45 73 32 11 10 | 36,467 |
Problem B: How I Mathematician Wonder What You Are! After counting so many stars in the sky in his childhood, Isaac, now an astronomer and a mathematician, uses a big astronomical telescope and lets his image processing program count stars. The hardest part of the program is to judge if a shining object in the sky is really a star. As a mathematician, the only way he knows is to apply a mathematical definition of stars . The mathematical defiition of a star shape is as follows: A planar shape F is star-shaped if and only if there is a point C â F such that, for any point P â F , the line segment CP is contained in F . Such a point C is called a center of F . To get accustomed to the definition, let's see some examples below. Figure 2: Star shapes (the first row) and non-star shapes (the second row) The firrst two are what you would normally call stars. According to the above definition, however, all shapes in the first row are star-shaped. The two in the second row are not. For each star shape, a center is indicated with a dot. Note that a star shape in general has infinitely many centers. For example, for the third quadrangular shape, all points in it are centers. Your job is to write a program that tells whether a given polygonal shape is star-shaped or not. Input The input is a sequence of datasets followed by a line containing a single zero. Each dataset specifies a polygon, and is formatted as follows. n x 1 y 1 x 2 y 2 ... x n y n The first line is the number of vertices, n , which satisfies 4 †n †50. Subsequent n lines are the x - and y -coordinates of the n vertices. They are integers and satisfy 0 †x i †10000 and 0 †y i †10000 ( i = 1, ..., n ). Line segments ( x i , y i )-( x i +1 , y i +1 ) ( i = 1, ..., n - 1) and the line segment ( x n , y n )-( x 1 , y 1 ) form the border of the polygon in the counterclockwise order. That is, these line segments see the inside of the polygon in the left of their directions. You may assume that the polygon is simple , that is, its border never crosses or touches itself. You may also assume that no three edges of the polygon meet at a single point even when they are infinitely extended. Output For each dataset, output "1" if the polygon is star-shaped and "0" otherwise. Each number must be in a separate line and the line should not contain any other characters. Sample Input 6 66 13 96 61 76 98 13 94 4 0 45 68 8 27 21 55 14 93 12 56 95 15 48 38 46 51 65 64 31 0 Output for the Sample Input 1 0 | 36,468 |
Problem H: Finding the Top RPS Player A company âACM Foodsâ is preparing for opening its chain shop in a certain area, but another company âICPC Pizzaâ is also planning to set up its branch shop in the same area. In general, two competitive shops gain less incomes if they are located so close to each other. Thus, if both âACM Foodsâ and âICPC Pizzaâ went on opening, they would be damaged financially. So, they had a discussion on this matter and made the following agreement: only one of them can branch its shop in the area. It is determined by Rock-Paper-Scissors (RPS) which to branch the shop. ACM Foods is facing financial difficulties and strongly desires to open their new shop in that area. The executives have decided to make every effort for finding out a very strong RPS player. They believes that players who win consecutive victories must be strong players. In order to find such a player for sure, they have decided their simple strategy. In this strategy, many players play games of RPS repeatedly, but the games are only played between players with the same number of consecutive wins. At the beginning, all the players have no wins, so any pair of players can play a game. The games can be played by an arbitrary number of pairs simultaneously. Let us call a set of simultaneous games as a turn . After the first turn, some players will have one win, and the other players will remain with no wins. In the second turn, some games will be played among players with one win, and some other games among players with no wins. For the former games, the winners will have two consecutive wins, and the losers will lose their first wins and have no consecutive wins. For the latter games, the winners will have one win, and the losers will remain with no wins. Therefore, after the second turn, the players will be divided into three groups: players with two consecutive wins, players with one win, and players with no wins. Again, in the third turn, games will be played among players with two wins, among with one win, and among with no wins. The following turns will be conducted so forth. After a sufficient number of turns, there should be a player with the desired number of consecutive wins. The strategy looks crazy? Oh well, maybe they are confused because of their financial difficulties. Of course, this strategy requires an enormous amount of plays. The executives asked you, as an employee of ACM Foods, to estimate how long the strategy takes. Your task is to write a program to count the minimum number of turns required to find a player with M consecutive wins among N players. Input The input consists of multiple test cases. Each test case consists of two integers N (2 †N †20) and M (1 †M < N ) in one line. The input is terminated by the line containing two zeroes. Output For each test case, your program must output the case number followed by one integer which indicates the minimum number of turns required to find a person with M consecutive wins. Sample Input 2 1 10 5 15 10 0 0 Output for the Sample Input Case 1: 1 Case 2: 11 Case 3: 210 | 36,469 |
Score : 400 points Problem Statement Snuke found N strange creatures. Each creature has a fixed color and size. The color and size of the i -th creature are represented by i and A_i , respectively. Every creature can absorb another creature whose size is at most twice the size of itself. When a creature of size A and color B absorbs another creature of size C and color D ( C \leq 2 \times A ), they will merge into one creature of size A+C and color B . Here, depending on the sizes of two creatures, it is possible that both of them can absorb the other. Snuke has been watching these creatures merge over and over and ultimately become one creature. Find the number of the possible colors of this creature. Constraints 2 \leq N \leq 100000 1 \leq A_i \leq 10^9 A_i is an integer. Input The input is given from Standard Input in the following format: N A_1 A_2 ⊠A_N Output Print the number of the possible colors of the last remaining creature after the N creatures repeatedly merge and ultimately become one creature. Sample Input 1 3 3 1 4 Sample Output 1 2 The possible colors of the last remaining creature are colors 1 and 3 . For example, when the creature of color 3 absorbs the creature of color 2 , then the creature of color 1 absorbs the creature of color 3 , the color of the last remaining creature will be color 1 . Sample Input 2 5 1 1 1 1 1 Sample Output 2 5 There may be multiple creatures of the same size. Sample Input 3 6 40 1 30 2 7 20 Sample Output 3 4 | 36,470 |
Score : 100 points Problem Statement Iroha loves Haiku . Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5 , 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A , B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order. Constraints 1âŠA,B,CâŠ10 Input The input is given from Standard Input in the following format: A B C Output If it is possible to construct a Haiku by using each of the phrases once, print YES (case-sensitive). Otherwise, print NO . Sample Input 1 5 5 7 Sample Output 1 YES Using three phrases of length 5 , 5 and 7 , it is possible to construct a Haiku. Sample Input 2 7 7 5 Sample Output 2 NO | 36,471 |
Score : 1000 points Problem Statement Given are N points on the circumference of a circle centered at (0,0) in an xy -plane. The coordinates of the i -th point are (\cos(\frac{2\pi T_i}{L}),\sin(\frac{2\pi T_i}{L})) . Three distinct points will be chosen uniformly at random from these N points. Find the expected x - and y -coordinates of the center of the circle inscribed in the triangle formed by the chosen points. Constraints 3 \leq N \leq 3000 N \leq L \leq 10^9 0 \leq T_i \leq L-1 T_i<T_{i+1} All values in input are integers. Input Input is given from Standard Input in the following format: N L T_1 : T_N Output Print the expected x - and y -coordinates of the center of the circle inscribed in the triangle formed by the chosen points. Your output will be considered correct when the absolute or relative error is at most 10^{-9} . Sample Input 1 3 4 0 1 3 Sample Output 1 0.414213562373095 -0.000000000000000 The three points have the coordinates (1,0) , (0,1) , and (0,-1) . The center of the circle inscribed in the triangle formed by these points is (\sqrt{2}-1,0) . Sample Input 2 4 8 1 3 5 6 Sample Output 2 -0.229401949926902 -0.153281482438188 Sample Input 3 10 100 2 11 35 42 54 69 89 91 93 99 Sample Output 3 0.352886583546338 -0.109065017701873 | 36,472 |
K-th String Problem Statement é·ã N ã®æåå S ã«å¯Ÿããæ¥å°ŸèŸé
å SA ãïŒä»¥äžã®æé ã§åŸããã N 以äžã®æ£æŽæ°ã®é åãšããŠå®çŸ©ããïŒ S ã® i æåç®ãã j æåç®ãŸã§ã®éšåæååã S[i..j] ãšè¡šãïŒãã ãæ·»åã¯1-indexedã§ããïŒ åæ¥å°ŸèŸ S[i..N] (i=1,2,...,N) ãèŸæžåŒé åºïŒæé ïŒã§æŽåããïŒ æŽåããåæ¥å°ŸèŸã®éå§äœçœ® i ãé ã«äžŠã¹ãïŒ ããšãã°ïŒ S ="mississippi"ã®æ¥å°ŸèŸé
å SA ã¯ïŒä»¥äžã®ããã«ãªãïŒ å
¥åãšããŠïŒé·ã N ã®æååã«å¯Ÿããæ¥å°ŸèŸé
å SA ãäžããããïŒ SA ãåŸããããããªæååã®ãã¡ïŒèŸæžåŒé åºã§ K çªç®(1-indexed)ã®ãã®ãæ±ããïŒ ãã ãïŒå
ã®æååã¯ïŒã¢ã«ãã¡ãããé ã«'a'ããæ°ããŠé«ã
A åã®æåã®ã¿ãããªãïŒ Input å
¥åã¯ä»¥äžã®åœ¢åŒã«åŸãïŒäžããããæ°ã¯å
šãп޿°ã§ããïŒ N A K SA_1 SA_2 ... SA_N Constraints 1âŠNâŠ10^5 1âŠAâŠ26 1âŠKâŠ10^{18} 1âŠSA_iâŠN i \neq j ãªãã° SA_i \neq SA_j Output SA ãåŸããããããªèŸæžåŒé åºã§ K çªç®ã®æååã1è¡ã«åºåããïŒ K çªç®ã®æååãååšããªãå ŽåïŒ"Impossible"ãšåºåããïŒ Sample Input 1 3 4 2 2 1 3 Output for the Sample Input 1 bad A =4ã®å ŽåïŒ SA ={2,1,3}ãšãªãæååã¯"bac","bad","cad","cbd"ã®4éãïŒ ãããã£ãŠïŒèŸæžåŒé åºã§2çªç®ã®"bad"ãçããšãªãïŒ Sample Input 2 18 26 10275802967 10 14 9 13 7 8 2 6 11 18 12 1 4 3 16 5 17 15 Output for the Sample Input 2 ritsumeicampdaytwo | 36,473 |
Problem J: Round Trip Jim is planning to visit one of his best friends in a town in the mountain area. First, he leaves his hometown and goes to the destination town. This is called the go phase. Then, he comes back to his hometown. This is called the return phase. You are expected to write a program to find the minimum total cost of this trip, which is the sum of the costs of the go phase and the return phase. There is a network of towns including these two towns. Every road in this network is one-way, i.e., can only be used towards the specified direction. Each road requires a certain cost to travel. In addition to the cost of roads, it is necessary to pay a specified fee to go through each town on the way. However, since this is the visa fee for the town, it is not necessary to pay the fee on the second or later visit to the same town. The altitude (height) of each town is given. On the go phase, the use of descending roads is inhibited. That is, when going from town a to b , the altitude of a should not be greater than that of b . On the return phase, the use of ascending roads is inhibited in a similar manner. If the altitudes of a and b are equal, the road from a to b can be used on both phases. Input The input consists of multiple datasets, each in the following format. n m d 2 e 2 d 3 e 3 . . . d n-1 e n-1 a 1 b 1 c 1 a 2 b 2 c 2 . . . a m b m c m Every input item in a dataset is a non-negative integer. Input items in a line are separated by a space. n is the number of towns in the network. m is the number of (one-way) roads. You can assume the inequalities 2 †n †50 and 0 †m †n ( n â1) hold. Towns are numbered from 1 to n , inclusive. The town 1 is Jim's hometown, and the town n is the destination town. d i is the visa fee of the town i , and e i is its altitude. You can assume 1 †d i †1000 and 1†e i †999 for 2†i †n â1. The towns 1 and n do not impose visa fee. The altitude of the town 1 is 0, and that of the town n is 1000. Multiple towns may have the same altitude, but you can assume that there are no more than 10 towns with the same altitude. The j -th road is from the town a j to b j with the cost c j (1 †j †m ). You can assume 1 †a j †n , 1 †b j †n , and 1 †c j †1000. You can directly go from a j to b j , but not from b j to a j unless a road from b j to a j is separately given. There are no two roads connecting the same pair of towns towards the same direction, that is, for any i and j such that i â j , a i â a j or b i â b j . There are no roads connecting a town to itself, that is, for any j , a j â b j . The last dataset is followed by a line containing two zeros (separated by a space). Output For each dataset in the input, a line containing the minimum total cost, including the visa fees, of the trip should be output. If such a trip is not possible, output â-1â. Sample Input 3 6 3 1 1 2 1 2 3 1 3 2 1 2 1 1 1 3 4 3 1 4 3 6 5 1 1 2 1 2 3 1 3 2 1 2 1 1 1 3 4 3 1 4 4 5 3 1 3 1 1 2 5 2 3 5 3 4 5 4 2 5 3 1 5 2 1 2 1 1 0 0 Output for the Sample Input 7 8 36 -1 | 36,474 |
ç¢ç³ãªãã¹ åé¡ çœãšé»ã®ç¢ç³ãããŒãã«ã®äžã«ãªãã¹ãŠéã¶.ãŸãããŒãã«ã®å·Šç«¯ã«ç¢ç³ã眮ã.次ã«å·Šãã 2 çªç®ã®å Žæã«ç¢ç³ã眮ã.ããã n åç¹°ãè¿ã㊠n åã®ç¢ç³ã暪äžåã«ãªãã¹ã.ãã ã,æ°ãã i çªç®ã®ç¢ç³ã眮ãéã«ã¯,次ã®ã«ãŒã«ã«åŸã£ãŠããŒãã«äžã®ç¢ç³ã眮ãæãã. i ã奿°ã®å Žå: ããŒãã«ã«çœ®ããŠãã£ãç¢ç³ã¯çœ®ãæãã,æ°ããç¢ç³ãå·Š ãã i çªç®ã«çœ®ã. i ãå¶æ°ã®å Žå: æ°ããå·Šãã i çªç®ã«çœ®ãç¢ç³ã®è²ãšããŒãã«äžã®å³ç«¯ã®ç¢ ç³ã®è²ãåãå Žåã¯,ããŒãã«äžã®ç¢ç³ã¯çœ®ãæãã,æ°ããç¢ç³ãå·Šãã i çªç®ã«çœ®ã.ããã§ãªãå Žå,ããªãã¡,æ°ããå·Šãã i çªç®ã«çœ®ãç¢ç³ã®è² ãšããŒãã«äžã®å³ç«¯ã®ç¢ç³ã®è²ãç°ãªãå Žåã¯,ãŸãããŒãã«äžã®å³ç«¯ã®é£ç¶ ããåè²ã®ç¢ç³ãå
šãŠåãé€ã,i çªç®ã®ç¢ç³ãšåè²ã®ç¢ç³ã«çœ®ãæãã.ã ããŠããŒãã«ã®å³ç«¯ã« i çªç®ã®ç¢ç³ã眮ã. äŸãã°,æåã® 7 åã®ç¢ç³ã眮ããæç¹ã§, âââââââ ãšãªã£ãŠãããšãã. (âã¯çœã®ç¢ç³ã,âã¯é»ã®ç¢ç³ã衚ã. ) 8 çªç®ã®ç¢ç³ãçœ(â)ã®å Žåã¯,å³ç«¯ã®ç¢ç³ãšåè²ãªã®ã§,ãã®ãŸãŸçœ®ã.ã ããã£ãŠ,ããŒãã«äžã®ç¢ç³ã¯ ââââââââ ãšãªã. 8 çªç®ã®ç¢ç³ãé»(â)ã®å Žåã¯,å³ç«¯ã®ç¢ç³(â)ãšè²ãç°ãªãã®ã§,ãŸã ããŒãã«ã®å³ç«¯ã«ãã 3 åã®é£ç¶ããçœãç¢ç³(â)ãåãé€ã,é»ãç¢ç³ (â)ã«çœ®ãæãã.ãããŠå³ç«¯ã« 8 çªç®ã®ç¢ç³ã眮ã.ãããã£ãŠ,ããŒã ã«äžã®ç¢ç³ã¯ ââââââââ ãšãªã. å
¥åãšããŠçœ®ãç¢ç³ã®é çªãäžãããããšã,n åã®ç¢ç³ããªãã¹çµãã£ãåŸ,ã㌠ãã«äžã«çœ®ããŠããçœãç¢ç³ã®åæ°ãæ±ããããã°ã©ã ãäœæãã. å
¥å å
¥åã¯è€æ°ã®ããŒã¿ã»ãããããªãïŒåããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããïŒ 1 è¡ç®ã«ã¯æ£æŽæ° n (1 †n †100000) ãæžãããŠãã.2 è¡ç®ä»¥éã®ç¬¬ i + 1 è¡ç® (1 †i †n) ã«ã¯,i çªç®ã«çœ®ãç¢ç³ã®è²ãè¡šãæŽæ° c i ãæžãããŠãã,c i ã 0 ãªã i çªç®ã«çœ®ãç¢ç³ã®è²ãçœã§ããããšã,1 ãªã i çªç®ã«çœ®ãç¢ç³ã®è²ãé»ã§ããããšã衚ã. æ¡ç¹çšããŒã¿ã®ãã¡, é
ç¹ã® 50% åã«ã€ããŠã¯, n †10000 ãæºãã. n ã 0 ã®ãšãå
¥åã®çµäºã瀺ã. ããŒã¿ã»ããã®æ°ã¯ 10 ãè¶
ããªãïŒ åºå ããŒã¿ã»ããããšã«, n åã®ç¢ç³ããªãã¹çµãã£ãåŸã«ããŒãã«äžã«çœ®ããŠããçœãç¢ç³ã®åæ°ã 1 è¡ã«åºåãã. å
¥åºåäŸ å
¥åäŸ 8 1 0 1 1 0 0 0 0 8 1 0 1 1 0 0 0 1 0 åºåäŸ 6 2 äžèšå顿ãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã | 36,475 |
åå (Twins) square1001åãšE869120åã¯ååã§ãã ãã®ãã¡å
ã«çãŸããæ¹ãåºåããŠäžããã å
¥å å
¥åã¯äžããããªãã åºå æ£è§£ã®æååãäžè¡ã«åºåããã ãã ããæåŸã«ã¯æ¹è¡ãå
¥ããããšã åºåäŸ1 square1001 | 36,476 |
QQ Write a program which prints multiplication tables in the following format: 1x1=1 1x2=2 . . 9x8=72 9x9=81 Input No input. Output 1x1=1 1x2=2 . . 9x8=72 9x9=81 Template for C #include<stdio.h> int main(){ return 0; } Template for C++ #include<iostream> using namespace std; int main(){ return 0; } Template for Java class Main{ public static void main(String[] a){ } } | 36,477 |
Score : 100 points Problem Statement ButCoder Inc. runs a programming competition site called ButCoder . In this site, a user is given an integer value called rating that represents his/her skill, which changes each time he/she participates in a contest. The initial value of a new user's rating is 0 , and a user whose rating reaches K or higher is called Kaiden ("total transmission"). Note that a user's rating may become negative. Hikuhashi is a new user in ButCoder. It is estimated that, his rating increases by A in each of his odd-numbered contests (first, third, fifth, ...), and decreases by B in each of his even-numbered contests (second, fourth, sixth, ...). According to this estimate, after how many contests will he become Kaiden for the first time, or will he never become Kaiden? Constraints 1 †K, A, B †10^{18} All input values are integers. Input Input is given from Standard Input in the following format: K A B Output If it is estimated that Hikuhashi will never become Kaiden, print -1 . Otherwise, print the estimated number of contests before he become Kaiden for the first time. Sample Input 1 4000 2000 500 Sample Output 1 5 Each time Hikuhashi participates in a contest, his rating is estimated to change as 0 â 2000 â 1500 â 3500 â 3000 â 5000 â ⊠After his fifth contest, his rating will reach 4000 or higher for the first time. Sample Input 2 4000 500 2000 Sample Output 2 -1 Each time Hikuhashi participates in a contest, his rating is estimated to change as 0 â 500 â -1500 â -1000 â -3000 â -2500 â ⊠He will never become Kaiden. Sample Input 3 1000000000000000000 2 1 Sample Output 3 1999999999999999997 The input and output values may not fit into 32 -bit integers. | 36,478 |
ãããã 倪éåã¯ãããããç¿ãããŠã®å°åŠçã§ãããªããšãªãã圌ã¯ãããããæ°ã«å
¥ã£ãŠããã®ã§ãæ°åãèŠããããšãããããããããªããŸãããããªåœŒã¯ããã®ãšãããæ¬¡ã®ãããªåŠçã0以äžã®æŽæ°ã«æœãããšã奜ããªããã§ãã (åŠçã®æµã) æé 1. ãã0以äžã®æŽæ°nã10鲿°è¡šç€ºã§äžãããªãã°ããã§åŠçãçµäºãããããã§ãªããã°æé 2ã«é²ã æé 2. 10以äžã®æŽæ°nã10鲿°è¡šç€ºããããšã©ããã®æ¡ã®éã«åãç®ãå
¥ããŠäºã€ã®æ°åã«åè§£ããããšãå¯èœã§ãã(äŸãã°2012-> 20,12)ããã®ãããªåãæ¹ãšããŠãããããã®ã«å¯ŸããŠ,åŸãããäºã€ã®æ°åãæãåãããŠæã倧ãããã®ã次ã®nãšããŠæé 1ã«æ»ãã(詳ããã¯äžèšã®"æé 2ã«é¢ããè£è¶³ãåç
§") 倪éåã¯ãã®åŠçãæ°ã«å
¥ã£ãŠããããã§ãããäœåæé 2ã®æäœãç¹°ãè¿ãã°ããã®ã倧ããæ°åã ãšäºæ³ãã§ãããããããããç¡éåè¡ãããªããã°ãªããªããããããªããšæã£ãŠããŸããããã§ã倪éåã®å
ã§ãã倧åŠçã§ããããªãã«0以äžã®æŽæ°nã«å¯ŸããŠãã®æé 2ãäœåããªããã°ãªããªãããèããŠããŸããã ããªãã®ä»äºã¯ãQåã®0以äžã®æŽæ° N 1 .. N Q ãäžããããã®ã§ãããããã®æŽæ°ã§åŠçã®çµäºãŸã§ã«äœåã®æé 2ãæœãããããæ±ããããšã§ãããã®éã«ããç¡éåã®æé ãå¿
èŠãªãã°ã-1ãåºåããŠãã ããã æé 2ã«é¢ããè£è¶³ åãåããçµæãæ¡ã®åãã«0ãã€ããã®ãèæ
®ã«å
¥ããå¿
èŠããããŸãã äŸãã°n=1024ã®ãšãã1*024 , 10*24 , 102*4ãããããèšç®ãããšãããã24,240,408ãšãªãããã408ãéžã°ãããããæ¬¡ã®nãšãªããŸãã Input Q N 1 N 2 ... N Q Q ã¯äžãããã0以äžã®æŽæ°ã®åæ°ã衚ã N i ã¯å€ªéåãæ°ã«ãªã£ãŠãã0以äžã®æŽæ°ã§,içªç®ã®ãã®ã衚ã Constraints 1â€Qâ€100 0â€N i â€10 6 Output Q åã®æŽæ°ãæ¹è¡åºåãã§åºåãã R 1 R 2 .. R Q R i ã¯ã N i ã«å¯ŸããŠåŠçãçµäºãããŸã§ã«æé 2ãå®è¡ããåæ°ã衚ã N i ã«å¯ŸããŠæé 2ãç¡éåã ãå®è¡ããå¿
èŠãããå Žå㯠R i 㯠-1ãšãªã Sample Input 1 3 9 99 123 Output for the Sample Input 1 0 2 3 9ã¯1æ¡ã®æ°ãªã®ã§ãæé 2ãå®è¡ãããããšã¯ãããŸããã 99ã¯2æ¡ã§ãããæé 2ãæœãã°9,9ãšããåå²ã§ãããã®æ¬¡ã®æ°ã¯81ãšãªãã 81ã2æ¡ã®æ°ã§ãããæé 2ãæœãã°8,1ãšããåå²ã§ãããã®æ¬¡ã®æ°ã¯8ãšãªãã 1æ¡ã®æ°ã«ãªã£ãã®ã§åŠçãçµäºããçãã¯2ã 123ã¯3æ¡ã®æ°ãªã®ã§ãæé 2ãæœããŸãã ãã®å Žåã¯12,3ãš1,23ã®äºã€ã®åãæ¹ããããããããã§ããããããããš36,23ãšãªãã®ã§ã 36ãæ¬¡ã®æ°ãšããŠéžã°ããŸãã Sample Input 2 2 999999 1000000 Output for the Sample Input 2 12 1 | 36,479 |
Score : 100 points Problem Statement It has been decided that a programming contest sponsored by company A will be held, so we will post the notice on a bulletin board. The bulletin board is in the form of a grid with N rows and N columns, and the notice will occupy a rectangular region with H rows and W columns. How many ways are there to choose where to put the notice so that it completely covers exactly HW squares? Constraints 1 \leq H, W \leq N \leq 100 All values in input are integers. Input Input is given from Standard Input in the following format: N H W Output Print the answer. Sample Input 1 3 2 3 Sample Output 1 2 There are two ways to put the notice, as follows: ### ... ### ### ... ### Here, # represents a square covered by the notice, and . represents a square not covered. Sample Input 2 100 1 1 Sample Output 2 10000 Sample Input 3 5 4 2 Sample Output 3 8 | 36,480 |
Problem F: Lying about Your Age You have moved to a new town. As starting a new life, you have made up your mind to do one thing: lying about your age. Since no person in this town knows your history, you donât have to worry about immediate exposure. Also, in order to ease your conscience somewhat, you have decided to claim ages that represent your real ages when interpreted as the base- M numbers (2 †M †16). People will misunderstand your age as they interpret the claimed age as a decimal number (i.e. of the base 10). Needless to say, you donât want to have your real age revealed to the people in the future. So you should claim only one age each year, it should contain digits of decimal numbers (i.e. â0â through â9â), and it should always be equal to or greater than that of the previous year (when interpreted as decimal). How old can you claim you are, after some years? Input The input consists of multiple datasets. Each dataset is a single line that contains three integers A , B , and C , where A is the present real age (in decimal), B is the age you presently claim (which can be a non-decimal number), and C is the real age at which you are to find the age you will claim (in decimal). It is guaranteed that 0 †A < C †200, while B may contain up to eight digits. No digits other than â0â through â9â appear in those numbers. The end of input is indicated by A = B = C = -1, which should not be processed. Output For each dataset, print in a line the minimum age you can claim when you become C years old. In case the age you presently claim cannot be interpreted as your real age with the base from 2 through 16, print -1 instead. Sample Input 23 18 53 46 30 47 -1 -1 -1 Output for the Sample Input 49 -1 | 36,481 |
Problem G: CarrotBreeding ã«ãããã¯ç¹æ®ã®å¥œããªæ€ç©ã§ãã. ããããçã§ã«ãããã飌ãããšã«ãã. ç㯠(0, 0) ãš (1000000000, 1000000000) ã察è§ç·ãšããæ£æ¹åœ¢ (boundary ãå«ã) ã§ãã. ãããã¯, 2 å以äžã®ã«ããããéããã¹ãŠã®çŽç·ã«æ²¿ã£ãŠæ¯æ¥1 åãã€æ°ŽããŸãããšã«ãã. ãã®ã«ããããã¡ã¯, æ¯æ¥ $N$ åãã€æ°ŽããŸãããã®ãç¹æ®ã«æé©ã ãšèããŠããã®ã§, ãã®ãããªæ¡ä»¶ãæºããããã«ãããã®çã«äžŠã¶ããšã«ãã. ã«ãããã¯çå
éšã®æ Œåç¹ã«ãã䞊ã¶ããšãã§ããªã. ãŸã, ãã®ãããªæ¡ä»¶ãæºããäžŠã³æ¹ãè€æ°ããå Žåã¯, æãã«ãããã®åæ°ãå°ãªããã®ãéžã¶ããšã«ãã. æ¡ä»¶ãæºããã«ãããã®é
眮ã1 ã€åºåãã. ãã®ãããªé
眮ãååšããªãå Žåã«ã¯ -1 ãšåºåãã. Constraints $N$ will be between 1 and 1,000,000, inclusive. Input å
¥åã¯ä»¥äžã®åœ¢åŒã§äžãããã: $N$ Output æ¡ä»¶ãæºããé
眮ãååšããªãå Žå, -1 ãšäžè¡ã«åºåãã. ååšããå Žå, ã«ãããã®æ¬æ°ã $K$ ãšãããš, 以äžã®åœ¢åŒã§åºåãã: $K$ $x_1$ $y_1$ ... $x_K$ $y_K$ Sample Input 1 4 Sample Output 1 4 0 0 1 0 2 0 1 1 Sample Input 2 6 Sample Output 2 4 0 0 0 1 1 0 1 1 | 36,482 |
ãã¿ã ãã PCK åã¯ã¿ããªã§ã²ãŒã 倧äŒãããŠããŸãããã®ã²ãŒã 倧äŒã§ã¯ã倧äŒã®æåŸã«ãã¿ã ããã§é äœãå
¥ãæ¿ããŸãã倧äŒã«ã¯ N 人ã®ãã¬ã€ã€ãŒãåå ããŠããããã¿ã ããã«ã¯ N æ¬ã®çžŠæ£ããããŸãã ãã¿ã ããã¯ãå³ã®ããã« N - 1 段ã®éšåããã§ããŠããããããã 1 ãã N -1 ã®çªå·ãå²ãåœãŠãããŠããŸããåéšåã¯ããã¿ã ããã®äžéšã暪æ¹åã«åãåã£ãéšåã§ããåéšåã«ã¯ããã€ãã®æšªæ£ãåŒãããŠããŸãããéšåã®äžã®æšªæ£ã¯ãã¹ãŠåãé«ãã«ãããŸããæšªæ£å士ãã€ãªããããšã¯ãããŸããã 倧äŒã®æåŸã«ãé äœã®é«ã人ããå³ããå·Šã®é ã«çžŠæ£ãå²ãåœãŠãããŸããPCK åã¯çŸæç¹ã§æäžäœãªã®ã§ã巊端ããã¹ã¿ãŒãã§ããäŸãã°ãäžå³ã®çµã¿ç«ãŠæ¹ã§ã¯ãïŒäœã ã£ãPCK åã¯ããã®ãã¿ã ããã«ãã£ãŠïŒäœïŒå³ããïŒçªç®ã®æ£ïŒã«æµ®äžããããšãã§ããŸãã ãã®ã²ãŒã ã§ã¯ãæäžäœã®äººã«ãã¿ã ãããçµã¿ç«ãŠãæš©å©ãäžããããŸããPCK åã¯ããŸããã¿ã ããã®éšåã®é çªã決ããŠãé転åªåãçã£ãŠããŸãããã ããéšåãå転ããããšã¯ã§ããŸããã ïŒâ»è£è¶³ïŒãã¿ã ããã®ãã©ãæ¹ã«ã€ããŠïŒ ãã¿ã ããã®ãã瞊æ£ã®äžç«¯ããåºçºããŠäžããäžãžé²ãããã ããæšªæ£ãããå°ç¹ã§ã¯ãã®æšªæ£ã§ã€ãªãã£ãå¥ã®çžŠæ£ã«ç§»åããããããã瞊æ£ã®äžç«¯ã«ãã©ãçããŸã§ç¹°ãè¿ãã ã²ãŒã ã®åå 人æ°ãšãã¿ã ããã®éšåã®æ
å ±ãå
¥åããPCK åãåªåã§ãããã©ããå€å®ããããã°ã©ã ãäœæãããåªåã§ããå Žåããã®ãã¿ã ããã®éšåã®äžŠã³ãïŒã€åºåããããã ãããã®ãããªäžŠã¹æ¹ãè€æ°ããå Žåã¯ãäžããããéšåã®çªå·ã§èŸæžé æå°ã®ãã®ãåºåããã Input å
¥åã¯ä»¥äžã®åœ¢åŒã§äžããããã N b 1,1 b 1,2 ... b 1,Nâ1 b 2,1 b 2,2 ... b 2,Nâ1 : b Nâ1,1 b Nâ1,2 ... b Nâ1,Nâ1 ïŒè¡ç®ã«å€§äŒã®åå è
æ° N (2 †N †500) ãäžãããããç¶ã N -1 è¡ã« i çªç®ã®éšåã®æšªæ£ã®æ
å ±ãäžããããã b i,j ã 1 ã§ãããšãã i çªç®ã®éšåã®ãå·Šãã j æ¬ç®ã®çžŠæ£ãã j +1 çªç®ã®çžŠæ£ãžæšªæ£ãåŒãããŠããããšã衚ãã b i,j ã 0 ã§ãããšãã i çªç®ã®éšåã®ãå·Šãã j æ¬ç®ã®çžŠæ£ãã j +1 çªç®ã®çžŠæ£ãžæšªæ£ã¯åŒãããŠããªãããšã衚ãã b i,j ã 1 ã§ãããšãã b i,j+1 ã 1 ãšãªããããªéšåã¯äžããããªãããŸããæšªæ£ã®ç·æ°ã¯ 10000 ãè¶ããªãã Output PCK åãåªåã§ããå ŽåïŒïŒè¡ç®ã«ãyesããšåºåãããç¶ã N -1 è¡ã«ããã¿ã ããã®äžããé ã«ãéšåã®çªå·ã®äžŠã³ãåºåããããã®ãããªäžŠã³ãè€æ°ããå ŽåãèŸæžé æå°ã§ãã䞊ã³ãåºåãããPCK åãåªåã§ããªãå ŽåãïŒè¡ã«ãnoããšåºåããã Sample Input 1 6 1 0 0 0 1 1 0 1 0 1 0 1 0 1 0 0 0 0 1 0 0 1 0 0 1 Sample Output 1 yes 1 3 2 4 5 Sample Input 2 5 0 1 0 1 0 1 0 1 1 0 1 0 1 0 0 1 Sample Output 2 yes 4 1 3 2 4 1 3 2 ãš 4 2 3 1 ã®ïŒéãã®çµã¿ç«ãŠæ¹ãå¯èœã ããèŸæžé ã§å°ããæ¹ã® 4 1 3 2 ãåºåããã Sample Input 3 5 1 0 0 1 0 1 0 1 1 0 0 0 0 1 0 1 Sample Output 3 no | 36,483 |
Coin Changing Problem Find the minimum number of coins to make change for n cents using coins of denominations d 1 , d 2 ,.., d m . The coins can be used any number of times. Input n m d 1 d 2 ... d m Two integers n and m are given in the first line. The available denominations are given in the second line. Output Print the minimum number of coins in a line. Constraints 1 †n †50000 1 †m †20 1 †denomination †10000 The denominations are all different and contain 1. Sample Input 1 55 4 1 5 10 50 Sample Output 1 2 Sample Input 2 15 6 1 2 7 8 12 50 Sample Output 2 2 Sample Input 3 65 6 1 2 7 8 12 50 Sample Output 3 3 | 36,484 |
Score : 300 points Problem Statement You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: Append one of the following at the end of T : dream , dreamer , erase and eraser . Constraints 1âŠ|S|âŠ10^5 S consists of lowercase English letters. Input The input is given from Standard Input in the following format: S Output If it is possible to obtain S = T , print YES . Otherwise, print NO . Sample Input 1 erasedream Sample Output 1 YES Append erase and dream at the end of T in this order, to obtain S = T . Sample Input 2 dreameraser Sample Output 2 YES Append dream and eraser at the end of T in this order, to obtain S = T . Sample Input 3 dreamerer Sample Output 3 NO | 36,485 |
Don't Cross the Circles! There are one or more circles on a plane. Any two circles have different center positions and/or different radiuses. A circle may intersect with another circle, but no three or more circles have areas nor points shared by all of them. A circle may completely contain another circle or two circles may intersect at two separate points, but you can assume that the circumferences of two circles never touch at a single point. Your task is to judge whether there exists a path that connects the given two points, P and Q , without crossing the circumferences of the circles. You are given one or more point pairs for each layout of circles. In the case of Figure G-1, we can connect P and Q 1 without crossing the circumferences of the circles, but we cannot connect P with Q 2 , Q 3 , or Q 4 without crossing the circumferences of the circles. Figure G-1: Sample layout of circles and points Input The input consists of multiple datasets, each in the following format. n m Cx 1 Cy 1 r 1 ... Cx n Cy n r n Px 1 Py 1 Qx 1 Qy 1 ... Px m Py m Qx m Qy m The first line of a dataset contains two integers n and m separated by a space. n represents the number of circles, and you can assume 1 †n †100. m represents the number of point pairs, and you can assume 1 †m †10. Each of the following n lines contains three integers separated by a single space. ( Cx i , Cy i ) and r i represent the center position and the radius of the i -th circle, respectively. Each of the following m lines contains four integers separated by a single space. These four integers represent coordinates of two separate points P j = ( Px j , Py j ) and Q j =( Qx j , Qy j ). These two points P j and Q j form the j -th point pair. You can assume 0 †Cx i †10000, 0 †Cy i †10000, 1 †r i †1000, 0 †Px j †10000, 0 †Py j †10000, 0 †Qx j †10000, 0 †Qy j †10000. In addition, you can assume P j or Q j are not located on the circumference of any circle. The end of the input is indicated by a line containing two zeros separated by a space. Figure G-1 shows the layout of the circles and the points in the first dataset of the sample input below. Figure G-2 shows the layouts of the subsequent datasets in the sample input. Figure G-2: Sample layout of circles and points Output For each dataset, output a single line containing the m results separated by a space. The j -th result should be "YES" if there exists a path connecting P j and Q j , and "NO" otherwise. Sample Input 5 3 0 0 1000 1399 1331 931 0 1331 500 1398 0 400 2000 360 340 450 950 1600 380 450 950 1399 1331 450 950 450 2000 1 2 50 50 50 0 10 100 90 0 10 50 50 2 2 50 50 50 100 50 50 40 50 110 50 40 50 0 0 4 1 25 100 26 75 100 26 50 40 40 50 160 40 50 81 50 119 6 1 100 50 40 0 50 40 50 0 48 50 50 3 55 55 4 55 105 48 50 55 55 50 20 6 270 180 50 360 170 50 0 0 50 10 0 10 0 90 50 0 180 50 90 180 50 180 180 50 205 90 50 180 0 50 65 0 20 75 30 16 90 78 36 105 30 16 115 0 20 128 48 15 128 100 15 280 0 30 330 0 30 305 65 42 0 20 10 20 0 20 10 0 50 30 133 0 50 30 133 30 90 40 305 20 90 40 240 30 16 2 0 0 50 0 90 50 0 180 50 90 180 50 180 180 50 205 90 50 180 0 50 65 0 20 115 0 20 90 0 15 280 0 30 330 0 30 305 65 42 75 40 16 90 88 36 105 40 16 128 35 250 30 90 50 305 20 0 0 Output for the Sample Input YES NO NO YES NO NO NO NO YES YES NO NO YES NO NO NO NO | 36,486 |
Score : 400 points Problem Statement In this problem, we only consider strings consisting of lowercase English letters. Strings s and t are said to be isomorphic when the following conditions are satisfied: |s| = |t| holds. For every pair i, j , one of the following holds: s_i = s_j and t_i = t_j . s_i \neq s_j and t_i \neq t_j . For example, abcac and zyxzx are isomorphic, while abcac and ppppp are not. A string s is said to be in normal form when the following condition is satisfied: For every string t that is isomorphic to s , s \leq t holds. Here \leq denotes lexicographic comparison. For example, abcac is in normal form, but zyxzx is not since it is isomorphic to abcac , which is lexicographically smaller than zyxzx . You are given an integer N . Print all strings of length N that are in normal form, in lexicographically ascending order. Constraints 1 \leq N \leq 10 All values in input are integers. Input Input is given from Standard Input in the following format: N Output Assume that there are K strings of length N that are in normal form: w_1, \ldots, w_K in lexicographical order. Output should be in the following format: w_1 : w_K Sample Input 1 1 Sample Output 1 a Sample Input 2 2 Sample Output 2 aa ab | 36,487 |
å·šæš¹ã®å»ã¿æ ããªã㯠N çš®é¡ã®éå
·ã䜿ã£ãŠãç®ã®åã®å·šæš¹ãåãåãããšããŠããŸããã¯ããã¯ãæš¹ã®èä¹
å㯠D ãããªãã®çµéšå€ã¯ 0 ã§ãããéå
· i ã§ïŒåæš¹ãå©ããšæš¹ã®èä¹
å㯠a i æžããããªã㯠e i ã®çµéšå€ãåŸãŸãããã ããéå
· i ã䜿ãããã«ã¯ãããªã㯠r i 以äžã®çµéšå€ãæã£ãŠããªããã°ãªããŸãããæš¹ã®èä¹
åã 0 以äžã«ãªããšæš¹ã¯åããŸãã æš¹ã®èä¹
åãšéå
·ã«ã€ããŠã®æ
å ±ãäžãããããšããæš¹ãåãåãã«ã¯æäœäœåæš¹ãå©ããªããã°ãããªãããæ±ããããã°ã©ã ãäœæããŠãã ããã å
¥å å
¥åã¯è€æ°ã®ããŒã¿ã»ãããããªããå
¥åã®çµããã¯ãŒãïŒã€ã®è¡ã§ç€ºããããåããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããã D N a 1 e 1 r 1 a 2 e 2 r 2 : a N e N r N 1 è¡ç®ã«æš¹ã®èä¹
åãè¡šãæŽæ° D (1 †D †100) ãšéå
·ã®çš®é¡ã®æ° N (1 †N †100) ãäžãããããç¶ã N è¡ã«éå
· 1 ãã N ãŸã§ã®æ
å ±ãäžããããã a i (0 †a i †100) ãš e i (0 †e i †100) ã¯ãéå
·iãïŒå䜿ãããšã§æžãæš¹ã®èä¹
åãšããªããåŸãããšã®ã§ããçµéšå€ããããã衚ãã r i (0 †r i †100) ã¯éå
·ã䜿ãããã«å¿
èŠãªçµéšå€ã衚ãã a i , e i , r i ã¯ãã¹ãп޿°ã§ããã ããŒã¿ã»ããã®æ°ã¯ 50 ãè¶
ããªãã åºå æš¹ãåãåãã®ã«å¿
èŠãªãæš¹ãå©ãæå°ã®åæ°ãïŒè¡ã«åºåããããã ããæš¹ãåãåãããšãäžå¯èœãªå Žå㯠NA ãšåºåããã å
¥åºåäŸ å
¥åäŸ 15 4 1 1 0 1 2 2 5 10 5 8 1 15 60 4 5 2 0 8 8 2 3 5 0 49 0 18 100 1 1 1 1 0 0 åºåäŸ 6 4 NA | 36,488 |
Similarity of Subtrees Define the depth of a node in a rooted tree by applying the following rules recursively: The depth of a root node is 0. The depths of child nodes whose parents are with depth $d$ are $d + 1$. Let $S(T, d)$ be the number of nodes of $T$ with depth $d$. Two rooted trees $T$ and $T'$ are similar if and only if $S(T, d)$ equals $S(T', d)$ for all non-negative integer $d$. You are given a rooted tree $T$ with $N$ nodes. The nodes of $T$ are numbered from 1 to $N$. Node 1 is the root node of $T$. Let $T_i$ be the rooted subtree of $T$ whose root is node $i$. Your task is to write a program which calculates the number of pairs $(i, j)$ such that $T_i$ and $T_j$ are similar and $i < j$. Input The input consists of a single test case. $N$ $a_1$ $b_1$ $a_2$ $b_2$ ... $a_{N-1}$ $b_{N-1}$ The first line contains an integer $N$ ($1 \leq N \leq 100,000$), which is the number of nodes in a tree. The following $N -1$ lines give information of branches: the $i$-th line of them contains $a_i$ and $b_i$, which indicates that a node $a_i$ is a parent of a node $b_i$. ($1 \leq a_i, b_i \leq N, a_i \ne b_i$) The root node is numbered by 1. It is guaranteed that a given graph is a rooted tree, i.e. there is exactly one parent for each node except the node 1, and the graph is connected. Output Print the number of the pairs $(x, y)$ of the nodes such that the subtree with the root $x$ and the subtree with the root $y$ are similar and $x < y$. Sample Input 1 5 1 2 1 3 1 4 1 5 Output for the Sample Input 1 6 Sample Input 2 6 1 2 2 3 3 4 1 5 5 6 Output for the Sample Input 2 2 Sample Input 3 13 1 2 1 3 2 4 2 5 3 6 3 7 4 8 4 9 6 10 7 11 8 12 11 13 Output for the Sample Input 3 14 | 36,489 |
Problem A: Lost in Space William Robinson was completely puzzled in the music room; he could not find his triangle in his bag. He was sure that he had prepared it the night before. He remembered its clank when he had stepped on the school bus early that morning. No, not in his dream. His triangle was quite unique: no two sides had the same length, which made his favorite peculiar jingle. He insisted to the music teacher, Mr. Smith, that his triangle had probably been stolen by those aliens and thrown away into deep space. Your mission is to help Will find his triangle in space. His triangle has been made invisible by the aliens, but candidate positions of its vertices are somehow known. You have to tell which three of them make his triangle. Having gone through worm-holes, the triangle may have changed its size. However, even in that case, all the sides are known to be enlarged or shrunk equally, that is, the transformed triangle is similar to the original. Input The very first line of the input has an integer which is the number of data sets. Each data set gives data for one incident such as that of Willâs. At least one and at most ten data sets are given. The first line of each data set contains three decimals that give lengths of the sides of the original triangle, measured in centimeters. Three vertices of the original triangle are named P, Q, and R. Three decimals given in the first line correspond to the lengths of sides QR, RP, and PQ, in this order. They are separated by one or more space characters. The second line of a data set has an integer which is the number of points in space to be considered as candidates for vertices. At least three and at most thirty points are considered. The rest of the data set are lines containing coordinates of candidate points, in light years. Each line has three decimals, corresponding to x, y, and z coordinates, separated by one or more space characters. Points are numbered in the order of their appearances, starting from one. Among all the triangles formed by three of the given points, only one of them is similar to the original, that is, ratios of the lengths of any two sides are equal to the corresponding ratios of the original allowing an error of less than 0.01 percent. Other triangles have some of the ratios different from the original by at least 0.1 percent. The origin of the coordinate system is not the center of the earth but the center of our galaxy. Note that negative coordinate values may appear here. As they are all within or close to our galaxy, coordinate values are less than one hundred thousand light years. You donât have to take relativistic effects into account, i.e., you may assume that we are in a Euclidean space. You may also assume in your calculation that one light year is equal to 9.461 Ã 10 12 kilometers. A succeeding data set, if any, starts from the line immediately following the last line of the preceding data set. Output For each data set, one line should be output. That line should contain the point numbers of the three vertices of the similar triangle, separated by a space character. They should be reported in the order P, Q, and then R. Sample Input 2 50.36493 81.61338 79.96592 5 -10293.83 -4800.033 -5296.238 14936.30 6964.826 7684.818 -4516.069 25748.41 -27016.06 18301.59 -11946.25 5380.309 27115.20 43415.93 -71607.81 11.51547 13.35555 14.57307 5 -56292.27 2583.892 67754.62 -567.5082 -756.2763 -118.7268 -1235.987 -213.3318 -216.4862 -317.6108 -54.81976 -55.63033 22505.44 -40752.88 27482.94 Output for the Sample Input 1 2 4 3 4 2 | 36,490 |
Change-Making Problem You want to make change for $n$ cents. Assuming that you have infinite supply of coins of 1, 5, 10 and/or 25 cents coins respectively, find the minimum number of coins you need. Input $n$ The integer $n$ is given in a line. åºå Print the minimum number of coins you need in a line. Constraints $1 \le n \le 10^9$ Sample Input 1 100 Sample Output 1 4 Sample Input 2 54321 Sample Output 2 2175 | 36,491 |
Score: 200 points Problem Statement M-kun has the following three cards: A red card with the integer A . A green card with the integer B . A blue card with the integer C . He is a genius magician who can do the following operation at most K times: Choose one of the three cards and multiply the written integer by 2 . His magic is successful if both of the following conditions are satisfied after the operations: The integer on the green card is strictly greater than the integer on the red card. The integer on the blue card is strictly greater than the integer on the green card. Determine whether the magic can be successful. Constraints 1 \leq A, B, C \leq 7 1 \leq K \leq 7 All values in input are integers. Input Input is given from Standard Input in the following format: A B C K Output If the magic can be successful, print Yes ; otherwise, print No . Sample Input 1 7 2 5 3 Sample Output 1 Yes The magic will be successful if, for example, he does the following operations: First, choose the blue card. The integers on the red, green, and blue cards are now 7 , 2 , and 10 , respectively. Second, choose the green card. The integers on the red, green, and blue cards are now 7 , 4 , and 10 , respectively. Third, choose the green card. The integers on the red, green, and blue cards are now 7 , 8 , and 10 , respectively. Sample Input 2 7 4 2 3 Sample Output 2 No He has no way to succeed in the magic with at most three operations. | 36,493 |
Problem G: Make Friendships Isaac H. Ives attended an international student party and made a lot of girl friends (as many other persons expected). To strike up a good friendship with them, he decided to have dates with them. However, it is hard for him to schedule dates because he made so many friends. Thus he decided to find the best schedule using a computer program. The most important criterion in scheduling is how many different girl friends he will date. Of course, the more friends he will date, the better the schedule is. However, though he has the ability to write a program finding the best schedule, he doesnât have enough time to write it. Your task is to write a program to find the best schedule instead of him. Input The input consists of a series of data sets. The first line of each data set contains a single positive integer N ( N †1,000) that represents the number of persons Isaac made friends with in the party. The next line gives Isaacâs schedule, followed by N lines that give his new friendsâ schedules. Each schedule consists of a positive integer M that represents the number of available days followed by M positive integers each of which represents an available day. The input is terminated by a line that contains a single zero. This is not part of data sets and should not be processed. Output For each data set, print a line that contains the maximum number of girl friends Isaac can have dates with. Sample Input 3 3 1 3 5 2 1 4 4 1 2 3 6 1 3 0 Output for the Sample Input 2 | 36,494 |
Score : 600 points Problem Statement You are given a forest with N vertices and M edges. The vertices are numbered 0 through N-1 . The edges are given in the format (x_i,y_i) , which means that Vertex x_i and y_i are connected by an edge. Each vertex i has a value a_i . You want to add edges in the given forest so that the forest becomes connected. To add an edge, you choose two different vertices i and j , then span an edge between i and j . This operation costs a_i + a_j dollars, and afterward neither Vertex i nor j can be selected again. Find the minimum total cost required to make the forest connected, or print Impossible if it is impossible. Constraints 1 †N †100,000 0 †M †N-1 1 †a_i †10^9 0 †x_i,y_i †N-1 The given graph is a forest. All input values are integers. Input Input is given from Standard Input in the following format: N M a_0 a_1 .. a_{N-1} x_1 y_1 x_2 y_2 : x_M y_M Output Print the minimum total cost required to make the forest connected, or print Impossible if it is impossible. Sample Input 1 7 5 1 2 3 4 5 6 7 3 0 4 0 1 2 1 3 5 6 Sample Output 1 7 If we connect vertices 0 and 5 , the graph becomes connected, for the cost of 1 + 6 = 7 dollars. Sample Input 2 5 0 3 1 4 1 5 Sample Output 2 Impossible We can't make the graph connected. Sample Input 3 1 0 5 Sample Output 3 0 The graph is already connected, so we do not need to add any edges. | 36,495 |
Score : 900 points Problem Statement Diverta City is a new city consisting of N towns numbered 1, 2, ..., N . The mayor Ringo is planning to connect every pair of two different towns with a bidirectional road. The length of each road is undecided. A Hamiltonian path is a path that starts at one of the towns and visits each of the other towns exactly once. The reversal of a Hamiltonian path is considered the same as the original Hamiltonian path. There are N! / 2 Hamiltonian paths. Ringo wants all these paths to have distinct total lengths (the sum of the lengths of the roads on a path), to make the city diverse. Find one such set of the lengths of the roads, under the following conditions: The length of each road must be a positive integer. The maximum total length of a Hamiltonian path must be at most 10^{11} . Constraints N is a integer between 2 and 10 (inclusive). Input Input is given from Standard Input in the following format: N Output Print a set of the lengths of the roads that meets the objective, in the following format: w_{1, 1} \ w_{1, 2} \ w_{1, 3} \ ... \ w_{1, N} w_{2, 1} \ w_{2, 2} \ w_{2, 3} \ ... \ w_{2, N} : : : w_{N, 1} \ w_{N, 2} \ w_{N, 3} \ ... \ w_{N, N} where w_{i, j} is the length of the road connecting Town i and Town j , which must satisfy the following conditions: w_{i, i} = 0 w_{i, j} = w_{j, i} \ (i \neq j) 1 \leq w_{i, j} \leq 10^{11} \ (i \neq j) If there are multiple sets of lengths of the roads that meet the objective, any of them will be accepted. Sample Input 1 3 Sample Output 1 0 6 15 6 0 21 15 21 0 There are three Hamiltonian paths. The total lengths of these paths are as follows: 1 â 2 â 3 : The total length is 6 + 21 = 27 . 1 â 3 â 2 : The total length is 15 + 21 = 36 . 2 â 1 â 3 : The total length is 6 + 15 = 21 . They are distinct, so the objective is met. Sample Input 2 4 Sample Output 2 0 111 157 193 111 0 224 239 157 224 0 258 193 239 258 0 There are 12 Hamiltonian paths, with distinct total lengths. | 36,496 |
Problem Statement Infinite Chronicle -Princess Castle- is a simple role-playing game. There are $n + 1$ checkpoints, numbered $0$ through $n$, and for each $i = 1, 2, \ldots, n$, there is a unique one-way road running from checkpoint $i - 1$ to $i$. The game starts at checkpoint $0$ and ends at checkpoint $n$. Evil monsters will appear on the roads and the hero will have battles against them. You can save your game progress at any checkpoint; if you lose a battle, you can restart the game from the checkpoint where you have saved for the last time. At the beginning of the game, the progress is automatically saved at checkpoint $0$ with no time. Rabbit Hanako is fond of this game and now interested in speedrunning. Although Hanako is an expert of the game, she cannot always win the battles because of random factors. For each $i$, she estimated the probability $p_i$ to win all the battles along the road from checkpoint $i - 1$ to $i$. Everytime she starts at checkpoint $i - 1$, after exactly one miniutes, she will be at checkpoint $i$ with probability $p_i$ and where she saved for the last time with probability $1 - p_i$. What puzzles Hanako is that it also takes one minute (!) to save your progress at a checkpoint, so it might be a good idea to pass some checkpoints without saving in order to proceed quickly. The task is to compute the minimum possible expected time needed to complete the game. Input The input consists of multiple datasets. The number of datasets is no more than $50$. Each dataset has two lines: the first line contains an integer $n$ ($1 \le n \le 10^5$), representing the number of roads, and the second line contains $n$ numbers $p_1, p_2, \ldots, p_n$ ($0 \lt p_i \le 1$), representing the winning probabilities. Each $p_i$ has exactly two digits after the decimal point. The end of input is denoted as a line containing only a single zero. Output For each dataset, display the minimum expected time in minutes with a relative error of at most $10^{-8}$ in a line. Sample Input 2 0.50 0.40 2 0.70 0.60 4 0.99 1.00 1.00 0.01 0 Output for the Sample Input 5.5000000000 4.0476190476 104.0101010101 | 36,497 |
Problem A: Calling Extraterrestrial Intelligence Again A message from humans to extraterrestrial intelligence was sent through the Arecibo radio telescope in Puerto Rico on the afternoon of Saturday November l6, l974. The message consisted of l679 bits and was meant to be translated to a rectangular picture with 23 à 73 pixels. Since both 23 and 73 are prime numbers, 23 à 73 is the unique possible size of the translated rectangular picture each edge of which is longer than l pixel. Of course, there was no guarantee that the receivers would try to translate the message to a rectangular picture. Even if they would, they might put the pixels into the rectangle incorrectly. The senders of the Arecibo message were optimistic. We are planning a similar project. Your task in the project is to find the most suitable width and height of the translated rectangular picture. The term ``most suitable'' is defined as follows. An integer m greater than 4 is given. A positive fraction a / b less than or equal to 1 is also given. The area of the picture should not be greater than m . Both of the width and the height of the translated picture should be prime numbers. The ratio of the width to the height should not be less than a / b nor greater than 1. You should maximize the area of the picture under these constraints. In other words, you will receive an integer m and a fraction a / b . It holds that m > 4 and 0 < a / b †1 . You should find the pair of prime numbers p , q such that pq †m and a / b †p / q †1 , and furthermore, the product pq takes the maximum value among such pairs of two prime numbers. You should report p and q as the "most suitable" width and height of the translated picture. Input The input is a sequence of at most 2000 triplets of positive integers, delimited by a space character in between. Each line contains a single triplet. The sequence is followed by a triplet of zeros, 0 0 0, which indicates the end of the input and should not be treated as data to be processed. The integers of each input triplet are the integer m , the numerator a , and the denominator b described above, in this order. You may assume 4 < m < 100000 and 1 †a †b †1000. Output The output is a sequence of pairs of positive integers. The i -th output pair corresponds to the i -th input triplet. The integers of each output pair are the width p and the height q described above, in this order. Each output line contains a single pair. A space character is put between the integers as a delimiter. No other characters should appear in the output. Sample Input 5 1 2 99999 999 999 1680 5 16 1970 1 1 2002 4 11 0 0 0 Output for the Sample Input 2 2 313 313 23 73 43 43 37 53 | 36,498 |
Problem E: Rabbit Plays Games! ãããããšããããŒã«ãã¬ã€ã³ã°ã²ãŒã ã§éãã§ãã. åã«å
¥ãçŽåã§, æµã«åŸ
ã¡äŒããããŠããïŒ ããããæäœãã䞻人å
¬1 人ãš, n äœã®æµãšã®æŠéãšãªã£ã. åãã£ã©ã¯ã¿ãŒã«ã¯4 ã€ã®èœåå€, äœå h i , æ»æå a i , é²åŸ¡å d i , ææ· s i ãå®ããããŠãã. i = 0 ã¯äž»äººå
¬ã®æ
å ±, 1 †i †n ã¯åæµã®æ
å ±ã衚ã. æŠéã¯ã¿ãŒã³å¶ã§ãã. åã¿ãŒã³, çãæ®ã£ãŠãããã£ã©ã¯ã¿ãŒã, ææ·ã®å€ãé«ãé ã«æ»æãè¡ã. æµã¯å¿
ã䞻人å
¬ãæ»æãã. 䞻人å
¬ã¯æµ1 äœãæ»æããã, ã©ã®æµãæ»æãããã¯æ¯ã¿ãŒã³ããšã«äž»äººå
¬ãéžã¹ã.æ»æå a ã®ãã£ã©ã¯ã¿ãŒãé²åŸ¡å d ã®ãã£ã©ã¯ã¿ãŒã«æ»æãããšã, max{ a â d , 0} ã®ãã¡ãŒãžãäžãããã. åãããã¡ãŒãžã®åèšãäœåã®å€ä»¥äžã«ãªã£ããã£ã©ã¯ã¿ãŒã¯çŽã¡ã«æŠéäžèœã«ãªã£ãŠããŸã. 䞻人å
¬ãæŠéäžèœã«ãªã£ããšã, ãããã¯æµããã¹ãŠæŠéäžèœã«ãªã£ããšã, æŠéã¯çµäºãã. Input 1 †n †40 000 1 †h i , a i , d i , s i †1 000 000 000 (æŽæ°) s i ã¯ãã¹ãŠç°ãªã. Output 䞻人å
¬ãå¿
ãæŠéäžèœã«ãªã£ãŠããŸããšã, â1 ãåºåãã. ããã§ãªããšã, 䞻人å
¬ãåãããã¡ãŒãžã®åèšã®æå°å€ãäžè¡ã«åºåãã. Sample Input 1 2 10 3 1 2 2 4 1 3 2 2 1 1 Sample Output 1 4 Sample Input 2 1 1 1 1 1 10000 10000 10000 10000 Sample Output 2 -1 | 36,499 |
Score : 200 points Problem Statement It is only six months until Christmas, and AtCoDeer the reindeer is now planning his travel to deliver gifts. There are N houses along TopCoDeer street . The i -th house is located at coordinate a_i . He has decided to deliver gifts to all these houses. Find the minimum distance to be traveled when AtCoDeer can start and end his travel at any positions. Constraints 1 †N †100 0 †a_i †1000 a_i is an integer. Input Input is given from Standard Input in the following format: N a_1 a_2 ... a_N Output Print the minimum distance to be traveled. Sample Input 1 4 2 3 7 9 Sample Output 1 7 The travel distance of 7 can be achieved by starting at coordinate 9 and traveling straight to coordinate 2 . It is not possible to do with a travel distance of less than 7 , and thus 7 is the minimum distance to be traveled. Sample Input 2 8 3 1 4 1 5 9 2 6 Sample Output 2 8 There may be more than one house at a position. | 36,500 |
Score : 600 points Problem Statement There is a tree with N vertices numbered 1 to N . The i -th edge in this tree connects Vertex a_i and Vertex b_i , and the color and length of that edge are c_i and d_i , respectively. Here the color of each edge is represented by an integer between 1 and N-1 (inclusive). The same integer corresponds to the same color, and different integers correspond to different colors. Answer the following Q queries: Query j ( 1 \leq j \leq Q ): assuming that the length of every edge whose color is x_j is changed to y_j , find the distance between Vertex u_j and Vertex v_j . (The changes of the lengths of edges do not affect the subsequent queries.) Constraints 2 \leq N \leq 10^5 1 \leq Q \leq 10^5 1 \leq a_i, b_i \leq N 1 \leq c_i \leq N-1 1 \leq d_i \leq 10^4 1 \leq x_j \leq N-1 1 \leq y_j \leq 10^4 1 \leq u_j < v_j \leq N The given graph is a tree. All values in input are integers. Input Input is given from Standard Input in the following format: N Q a_1 b_1 c_1 d_1 : a_{N-1} b_{N-1} c_{N-1} d_{N-1} x_1 y_1 u_1 v_1 : x_Q y_Q u_Q v_Q Output Print Q lines. The j -th line ( 1 \leq j \leq Q ) should contain the answer to Query j . Sample Input 1 5 3 1 2 1 10 1 3 2 20 2 4 4 30 5 2 1 40 1 100 1 4 1 100 1 5 3 1000 3 4 Sample Output 1 130 200 60 The graph in this input is as follows: Here the edges of Color 1 are shown as solid red lines, the edge of Color 2 is shown as a bold green line, and the edge of Color 4 is shown as a blue dashed line. Query 1 : Assuming that the length of every edge whose color is 1 is changed to 100 , the distance between Vertex 1 and Vertex 4 is 100 + 30 = 130 . Query 2 : Assuming that the length of every edge whose color is 1 is changed to 100 , the distance between Vertex 1 and Vertex 5 is 100 + 100 = 200 . Query 3 : Assuming that the length of every edge whose color is 3 is changed to 1000 (there is no such edge), the distance between Vertex 3 and Vertex 4 is 20 + 10 + 30 = 60 . Note that the edges of Color 1 now have their original lengths. | 36,501 |
ãã«ã¯ã·ã§ãã éŽæšããã¯äŒæŽ¥å°åã«æ°ããæŸãããŠãã«ã¯ã®ç§»å販売ã®ãåºãéããŸããããã®æ¥è²·ãæ±ãã«æ¥ãã客ããã¯å
šå¡æã¡åž°ãããã®ããã«ãæã£ãŠæ¢ã«ãåºã«äžŠãã§ããŠããã以äžå¢ããªããã®ãšããŸããã客ããã¯ãããã1åã ãããæ³šæããŸãããã¿ã³ã¯ã®èå£ãäžã€ãããªãã®ã§ãäžäººãã€é çªã«è²©å£²ããªããã°ãªããŸãããããã§ãéŽæšããã¯ãªãã¹ã䞊ãã§ããã客ããã®åŸ
ã¡æéãå°ãªãããããšèããŠããŸãã ã客ããã®äººæ°ãšã客ãããçä¹³ãæ³šãããã®ã«èŠããæéãå
¥åãšããŠäžããããŸããããªãã¯ã客ããã®ãäžäººäžäººã®åŸ
ã¡æéã®åèšã(以äžãåŸ
ã¡æéã®åèšããšãã)ãæå°ã«ããããã®æ³šæã®é åºãéŽæšããã«ä»£ãã£ãŠèª¿ã¹ããã®ãšãã®ãåŸ
ã¡æéã®åèšããåºåããŠçµäºããããã°ã©ã ãäœæããŠãã ããããã ããã客ãã㯠10,000 人以äžã§ 1 人ãããã«èŠããæé㯠60 å以äžãšããŸãã äŸãã°ãã客ããã®äººæ°ã 5 人ã§ãåã客ãããèŠããæéãé ã« 2,6,4,3,9 åã®å Žåããã®ãŸãŸã®é åºã ãšãåŸ
ã¡æéã®åèšã㯠37 åã«ãªããŸããæ¬¡ã®äŸã§ã¯ãæåã®åã®é ã® 2 人ç®ãš 3 人ç®ãå
¥ãæ¿ããŠããŸãããã®å ŽåããåŸ
ã¡æéã®åèšã㯠35 åã«ãªããŸããæé©ãªé åºã ãš 31 åã§æžã¿ãŸãã åŸ
ã¡æé 1 äººç® 2 å 0 å 2 äººç® 6 å 2 å 3 äººç® 4 å 8 å 4 äººç® 3 å 12 å 5 äººç® 9 å 15 å 37 å â ãåŸ
ã¡æéã®åèšã 2 人ç®ãš 3 人ç®ãå
¥ãæ¿ããäŸ åŸ
ã¡æé 1 äººç® 2 å 0 å 2 äººç® 4 å 2 å 3 äººç® 6 å 6 å 4 äººç® 3 å 12 å 5 äººç® 9 å 15 å 35 å â ãåŸ
ã¡æéã®åèšã Input è€æ°ã®ããŒã¿ã»ãããäžããããŸããåããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããŸãã n t 1 t 2 : t n 1 è¡ç®ã«ã客ããã®äººæ° n ( n †10,000) ãäžããããŸããç¶ã n è¡ã« i 人ç®ã®ã客ãããèŠããæéãè¡šãæŽæ° t i (0 †t i †60) ãããããïŒè¡ã«äžããããŸãã å
¥åã¯ïŒã€ã® 0 ãå«ãè¡ã§çµãããŸããããŒã¿ã»ããã®æ°ã¯ 50 ãè¶
ããŸããã Output åããŒã¿ã»ããããšã«ãåŸ
ã¡æéã®åèš(æŽæ°)ãïŒè¡ã«åºåããŠãã ããã Sample Input 5 2 6 4 3 9 0 Output for the Sample Input 31 | 36,502 |
ç§ç®éžæ (Selecting Subjects) åé¡ JOI åã¯ç©çïŒååŠïŒçç©ïŒå°åŠïŒæŽå²ïŒå°çã® 6 ç§ç®ã®ãã¹ããåããïŒ ããããã®ãã¹ã㯠100 ç¹æºç¹ã§æ¡ç¹ãããïŒ JOI åã¯ç©çïŒååŠïŒçç©ïŒå°åŠã® 4 ç§ç®ãã 3 ç§ç®ãéžæãïŒæŽå²ïŒå°çã® 2 ç§ç®ãã 1 ç§ç®ãéžæããïŒ ãã¹ãã®åèšç¹ãæãé«ããªãããã«ç§ç®ãéžã¶ãšãïŒ JOI åã®éžãã ç§ç®ã®ãã¹ãã®åèšç¹ãæ±ããïŒ å
¥å å
¥å㯠6 è¡ãããªãïŒ1 è¡ã« 1 ã€ãã€æŽæ°ãæžãããŠããïŒ 1 è¡ç®ã«ã¯ JOI åã®ç©çã®ãã¹ãã®ç¹æ° A ãæžãããŠããïŒ 2 è¡ç®ã«ã¯ JOI åã®ååŠã®ãã¹ãã®ç¹æ° B ãæžãããŠããïŒ 3 è¡ç®ã«ã¯ JOI åã®çç©ã®ãã¹ãã®ç¹æ° C ãæžãããŠããïŒ 4 è¡ç®ã«ã¯ JOI åã®å°åŠã®ãã¹ãã®ç¹æ° D ãæžãããŠããïŒ 5 è¡ç®ã«ã¯ JOI åã®æŽå²ã®ãã¹ãã®ç¹æ° E ãæžãããŠããïŒ 6 è¡ç®ã«ã¯ JOI åã®å°çã®ãã¹ãã®ç¹æ° F ãæžãããŠããïŒ æžãããŠããæŽæ° A, B, C, D, E, F ã¯ãã¹ãŠ 0 ä»¥äž 100 以äžã§ããïŒ åºå JOI åãéžãã ç§ç®ã®ãã¹ãã®åèšç¹ã 1 è¡ã§åºåããïŒ å
¥åºåäŸ å
¥åäŸ 1 100 34 76 42 10 0 åºåäŸ 1 228 å
¥åäŸ 2 15 21 15 42 15 62 åºåäŸ 2 140 å
¥åºåäŸ 1 ã§ã¯ïŒJOI åãç©çïŒçç©ïŒå°åŠïŒæŽå²ã® 4 ç§ç®ãéžã¶ãšãïŒãã¹ãã®åèšç¹ãæé«ã«ãªãïŒ ç©çïŒçç©ïŒå°åŠïŒæŽå²ã®ç¹æ°ã¯ãããã 100, 76, 42, 10 ãªã®ã§ïŒéžãã ç§ç®ã®ãã¹ãã®åèšç¹ã¯ 228 ã§ããïŒ å
¥åºåäŸ 2 ã§ã¯ïŒJOI åãååŠïŒçç©ïŒå°åŠïŒå°çã® 4 ç§ç®ãéžã¶ãšãïŒãã¹ãã®åèšç¹ãæé«ã«ãªãïŒ ååŠïŒçç©ïŒå°åŠïŒå°çã®ç¹æ°ã¯ãããã 21, 15, 42, 62 ãªã®ã§ïŒéžãã ç§ç®ã®ãã¹ãã®åèšç¹ã¯ 140 ã§ããïŒ å
¥åºåäŸ 2 ã§ã¯ïŒJOI åãç©çïŒååŠïŒå°åŠïŒå°çã® 4 ç§ç®ãéžã¶å Žåã§ãïŒéžãã ãã¹ãã®åèšç¹ã¯ 140 ã§ããïŒ æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒäœ ã第 15 åæ¥æ¬æ
å ±ãªãªã³ãã㯠JOI 2015/2016 äºéžç«¶æèª²é¡ã | 36,503 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.