ABC 151 writers: beet, DEGwer, kort0n, kyopro friends, satashun, tozangezan For International Readers: English editorial starts on page 7. A

Similar documents
1 # include < stdio.h> 2 # include < string.h> 3 4 int main (){ 5 char str [222]; 6 scanf ("%s", str ); 7 int n= strlen ( str ); 8 for ( int i=n -2; i

25 II :30 16:00 (1),. Do not open this problem booklet until the start of the examination is announced. (2) 3.. Answer the following 3 proble

AtCoder Regular Contest 073 Editorial Kohei Morita(yosupo) A: Shiritori if python3 a, b, c = input().split() if a[len(a)-1] == b[0] and b[len(

M-SOLUTIONS writer: yokozuna A: Sum of Interior Angles For International Readers: English editorial starts on page 7. N 180(N 2) C++ #i n

h23w1.dvi

n 2 n (Dynamic Programming : DP) (Genetic Algorithm : GA) 2 i

Page 1 of 6 B (The World of Mathematics) November 20, 2006 Final Exam 2006 Division: ID#: Name: 1. p, q, r (Let p, q, r are propositions. ) (10pts) (a

L1 What Can You Blood Type Tell Us? Part 1 Can you guess/ my blood type? Well,/ you re very serious person/ so/ I think/ your blood type is A. Wow!/ G

,,,,., C Java,,.,,.,., ,,.,, i

Quiz 1 ID#: Name: 1. p, q, r (Let p, q and r be propositions. Determine whether the following equation holds or not by completing the truth table belo

九州大学学術情報リポジトリ Kyushu University Institutional Repository 看護師の勤務体制による睡眠実態についての調査 岩下, 智香九州大学医学部保健学科看護学専攻 出版情報 : 九州大学医学部保健学

JOURNAL OF THE JAPANESE ASSOCIATION FOR PETROLEUM TECHNOLOGY VOL. 66, NO. 6 (Nov., 2001) (Received August 10, 2001; accepted November 9, 2001) Alterna


「プログラミング言語」 SICP 第4章 ~超言語的抽象~ その6

浜松医科大学紀要

B : Find Symmetries (A, B) (A + 1, B + 1) A + 1 B + 1 N + k k (A, B) (0, 0), (0, 1),..., (0.N 1) N O(N 2 ) N O(N 3 ) 2

elemmay09.pub

Continuous Cooling Transformation Diagrams for Welding of Mn-Si Type 2H Steels. Harujiro Sekiguchi and Michio Inagaki Synopsis: The authors performed


™…

平成29年度英語力調査結果(中学3年生)の概要

B: flip / 2 k l k(m l) + (N k)l k, l k(m l) + (N k)l = K O(NM) O(N) 2

soturon.dvi

Visual Evaluation of Polka-dot Patterns Yoojin LEE and Nobuko NARUSE * Granduate School of Bunka Women's University, and * Faculty of Fashion Science,


2

西川町広報誌NETWORKにしかわ2011年1月号


24_ChenGuang_final.indd

16_.....E...._.I.v2006



joho09.ppt

T rank A max{rank Q[R Q, J] t-rank T [R T, C \ J] J C} 2 ([1, p.138, Theorem 4.2.5]) A = ( ) Q rank A = min{ρ(j) γ(j) J J C} C, (5) ρ(j) = rank Q[R Q,


L3 Japanese (90570) 2008


On the Wireless Beam of Short Electric Waves. (VII) (A New Electric Wave Projector.) By S. UDA, Member (Tohoku Imperial University.) Abstract. A new e



A5 PDF.pwd

WE WESB WENB WESNB 428

千葉県における温泉地の地域的展開

<836F F312E706466>

fx-9860G Manager PLUS_J

Microsoft Word - Win-Outlook.docx

kut-paper-template.dvi

) ,

高等学校 英語科

Cain & Abel

1 Fig. 1 Extraction of motion,.,,, 4,,, 3., 1, 2. 2.,. CHLAC,. 2.1,. (256 ).,., CHLAC. CHLAC, HLAC. 2.3 (HLAC ) r,.,. HLAC. N. 2 HLAC Fig. 2

ron.dvi

駒田朋子.indd




25 Removal of the fricative sounds that occur in the electronic stethoscope


untitled




Corrections of the Results of Airborne Monitoring Surveys by MEXT and Ibaraki Prefecture


.N..

p _08森.qxd

はじめに

Motivation and Purpose There is no definition about whether seatbelt anchorage should be fixed or not. We tested the same test conditions except for t

WASEDA RILAS JOURNAL

220 28;29) 30 35) 26;27) % 8.0% 9 36) 8) 14) 37) O O 13 2 E S % % 2 6 1fl 2fl 3fl 3 4

Bead Instructions First, locate the acupressure point you wish to stimulate. Next, remove a plastic bead from the bag. Remove the backing from the adh



日本語教育紀要 7/pdf用 表紙

21 Effects of background stimuli by changing speed color matching color stimulus


_’¼Œì


The Effect of the Circumferential Temperature Change on the Change in the Strain Energy of Carbon Steel during the Rotatory Bending Fatigue Test by Ch

untitled

在日外国人高齢者福祉給付金制度の創設とその課題


生研ニュースNo.132


...



49148


diverta 2019 Programming Contest camypaper For International Readers: English editorial starts on page 8. A: Consecutive Integers K 1 N K +

Vol. 48 No. 4 Apr LAN TCP/IP LAN TCP/IP 1 PC TCP/IP 1 PC User-mode Linux 12 Development of a System to Visualize Computer Network Behavior for L


alternating current component and two transient components. Both transient components are direct currents at starting of the motor and are sinusoidal

3_23.dvi


P


kut-paper-template.dvi

126 学習院大学人文科学論集 ⅩⅩⅡ(2013) 1 2

Anl_MonzaJAP.indd

Transcription:

ABC 151 writers: beet, DEGwer, kort0n, kyopro friends, satashun, tozangezan 2020 1 12 For International Readers: English editorial starts on page 7. A: Next Alphabet 25 if 1 ( AtCoder ) Listing 1 C++ 1 #include <stdio.h> 2 3 char in[2]; 4 int main(){ 5 scanf("%s",in); 6 in[0]++; 7 printf("%s\n",in); 8 } 1

B:Achieve the goal O(NK) 0 K M O(N) N M N N M N M (A 1 +... + A N 1 ) 2

C: Welcome to AtCoder, AC WA,. WA, WA 1 AC, AC,., 1, WA. O (N + M),. C++ : https://atcoder.jp/contests/abc151/submissions/9430678 3

D:Maze Master BFS O(HW ) O((HW ) 2 ) O((HW ) 3 ) 4

E:Max-Min Sums A N max min f(s) ( max S) ( min S) A i max S A i max S = A i S max S max S = A i S A i A i K 1 min S A i A i ( (A i, i) max S = (A i, i) ) 5

F: Enclose All : N (x i, y i ) r r R N R 2 N R R N R 2 N R 1 R R O(N 3 ) 50 ( 2 R ) 2 2 h ( ) 2 2 h (2 ) 2 2 6

A: Next Alphabet One possible way is to write if statements for 25 kinds of input and determine the character to output. However, the lowercase English letters are aligned consecutively on the character codes, so you can obtain the answer by adding 1 to the input. (Actually, it is not guaranteed that those are aligned consecutively on the character codes in every environment. However, in the modern computers including AtCoder, in most case they are aligned consecutively like this.) Listing 2 Sample Code in C++ 1 #include <stdio.h> 2 3 char in[2]; 4 int main(){ 5 scanf("%s",in); 6 in[0]++; 7 printf("%s\n",in); 8 } 7

B:Achieve the goal O(N K) Solution Brute force through all the possible scores from 0 points to K points, and when the average score is more than or equal to K points for the first time, the score then is the answer. O(N)Solution The average score of K subjects are more than or equal to M is equivalent to the sum of scores of K subjects is more than or equal to N M. Therefore, he can achieve the goal if he gets more than or equal to N M (A 1 +... + A N 1 ) points for the last test. 8

C: Welcome to AtCoder For each problem, record whether AC has already appeared for the problem or not and the number of WAs appeared so far for the problem, while processing the submissions in order. If the verdict was WA, then increase the number of WAs for the problem by one. If the verdict was AC, then if it is not the first AC for the problem, then do nothing. If it was the first one, the number of Takahashi s correct answers increases by one, and the penalties increases by the number of WAs appeared so far for the problem. The process above is O (N + M) and fast enough. Sample Code in C++: https://atcoder.jp/contests/abc151/submissions/9430678 9

D:Maze Master When a starting square is fixed, it is optimal to set the goal square to be the furthest square from the starting square. Such square can be found by BFS or any other algorithms in a total of O(HW ) time. Therefore, by calculating for each square as a starting square, this problem could be solved in a total of O((HW ) 2 time. Note that you can also calculate in a total of O((HW ) 3 ) time by applying Warshall Floyd Algorithm. 10

E:Max-Min Sums Assume that A is sorted beforehand. Also, you can assume that you can calculate binomial coefficients fast by precalculating the factorials till N and their inverses. Consider calculating the sum separately for min and max. In other words, consider ( max S) ( min S) instead of f(s). For simplicity, assume that A i is distinct from each other. Possible value of max S is any element of A. Therefore, by counting the number of S such that max S = A i for each i, you can find max S. The necessary and sufficient condition of max S = A i is S contains A i, and also contains K 1 elements less than A i, so such number can be directly calculated by using binomial coefficients. You can calculate min S similarly. If A i contains duplicates, you can prove that the explanation above also holds if you assume arbitrary order between A i s with same value (for example, consider a lexicographical order of (A i, i and count the number of elements satisfying max S = (A i, i). Therefore, you can also process in the same way in this case. 11

F: Enclose All This problem is equivalent to the following problem. Problem : You are given N points, (x i, y i ). Find minimum r such that there exists a point contained in all the circles of radius r whose centers are the given points. For a radius r, if there exists an intersection area of N circles of radius R, then it contains an intersection point of some two circles somewhere. Of course, the distance between this intersection point and any center of circle is less than or equal to R. Therefore, the answer can be found by a binary search for the desired answer. Fix a radius R. Enumerate the N circles of radius R, and then enumerate all the intersection points of all pair of circles. For each intersection, check if the distance from the N points are less than or equal to R or not. If any intersection satisfies the condition above, then the answer is less than or equal to R. Otherwise it is more than R. The binary search above costs O(N 3 ) time for each step, and it is enough to loop about 50 times. (Be careful of the precision error. The candidate point is an intersection of two circles, so the distance from the centers of those two circles are exactly R, so you have to skip such points or judge by adding very small value.) The intersection of two circles of same radius can be found by the following steps: Find the distance h between the two intersection (by the Pythagorean theorem, this can be found from the distance between the two circles and the radius of the circles. Note that you have to take care of the cases where the circles are far from each other and intersections do not exist) Find a vector of length h starting from the midpoint of the centers of two circles and take its endpoint (there are two of them) Those two points are the intersections of the two circles. 12