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(

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

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

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

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

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

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

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

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

2

h23w1.dvi


AGC 034 yosupo, sigma For International Readers: English editorial starts on page 8. 1

elemmay09.pub


149 (Newell [5]) Newell [5], [1], [1], [11] Li,Ryu, and Song [2], [11] Li,Ryu, and Song [2], [1] 1) 2) ( ) ( ) 3) T : 2 a : 3 a 1 :

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

4.1 % 7.5 %

A5 PDF.pwd

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

L3 Japanese (90570) 2008

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

早稲田大学現代政治経済研究所 ダブルトラック オークションの実験研究 宇都伸之早稲田大学上條良夫高知工科大学船木由喜彦早稲田大学 No.J1401 Working Paper Series Institute for Research in Contemporary Political and Ec


Vol. 42 No MUC-6 6) 90% 2) MUC-6 MET-1 7),8) 7 90% 1 MUC IREX-NE 9) 10),11) 1) MUCMET 12) IREX-NE 13) ARPA 1987 MUC 1992 TREC IREX-N

Table 1. Assumed performance of a water electrol ysis plant. Fig. 1. Structure of a proposed power generation system utilizing waste heat from factori


The 15th Game Programming Workshop 2010 Magic Bitboard Magic Bitboard Bitboard Magic Bitboard Bitboard Magic Bitboard Magic Bitboard Magic Bitbo

x p v p (x) x p p-adic valuation of x v 2 (8) = 3, v 3 (12) = 1, v 5 (10000) = 4, x 8 = 2 3, 12 = 2 2 3, = 10 4 = n a, b a

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

Analysis of Algorithms

2 ( ) i

Microsoft Word - Win-Outlook.docx

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



_Y05…X…`…‘…“†[…h…•




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

2017 (413812)

1 1 tf-idf tf-idf i



1 [1, 2, 3, 4, 5, 8, 9, 10, 12, 15] The Boston Public Schools system, BPS (Deferred Acceptance system, DA) (Top Trading Cycles system, TTC) cf. [13] [

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

untitled

[ ]藤原武男

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

C. S2 X D. E.. (1) X S1 10 S2 X+S1 3 X+S S1S2 X+S1+S2 X S1 X+S S X+S2 X A. S1 2 a. b. c. d. e. 2

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

™…


,


卒業論文はMS-Word により作成して下さい


WE WESB WENB WESNB 428

206“ƒŁ\”ƒ-fl_“H„¤‰ZŁñ

IPSJ SIG Technical Report Vol.2016-CE-137 No /12/ e β /α α β β / α A judgment method of difficulty of task for a learner using simple



はじめに

(43) Vol.33, No.6(1977) T-239 MUTUAL DIFFUSION AND CHANGE OF THE FINE STRUCTURE OF WET SPUN ANTI-PILLING ACRYLIC FIBER DURING COAGULATION, DRAWING AND

Anl_MonzaJAP.indd

総研大文化科学研究第 11 号 (2015)

きずなプロジェクト-表紙.indd


<96DA8E9F82D982A95F944E95F1906C8AD489C88A775F33332E696E6464>

06_学術.indd

untitled

FAX-760CLT


Level 3 Japanese (90570) 2011

3_23.dvi

Bull. of Nippon Sport Sci. Univ. 47 (1) Devising musical expression in teaching methods for elementary music An attempt at shared teaching

f(x) x S (optimal solution) f(x ) (optimal value) f(x) (1) 3 GLPK glpsol -m -d -m glpsol -h -m -d -o -y --simplex ( ) --interior --min --max --check -

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

2007-Kanai-paper.dvi

浜松医科大学紀要

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

A5 PDF.pwd

<303288C991BD946797C797592E696E6464>

CONTENTS Public relations brochure of Higashikawa November No.745 Higashikawa 215 November 2

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,

Fig. 3 Flow diagram of image processing. Black rectangle in the photo indicates the processing area (128 x 32 pixels).

27 1 NP NP-completeness of Picross 3D without segment-information and that with height of one

A Feasibility Study of Direct-Mapping-Type Parallel Processing Method to Solve Linear Equations in Load Flow Calculations Hiroaki Inayoshi, Non-member

41 1. 初めに ) The National Theatre of the Deaf 1980

FA FA FA FA FA 5 FA FA 9


soturon.dvi

kut-paper-template.dvi

St. Andrew's University NII-Electronic Library Service


Literacy 2 Mathematica Mathematica 3 Hiroshi Toyoizumi Univ. of Aizu REFERENCES [1] C.P Williams [2] [3] 1 Literacy 2 Mathematica Ma

II

国際恋愛で避けるべき7つの失敗と解決策

MRI | 所報 | 分権経営の進展下におけるグループ・マネジメント

PowerPoint Presentation

Transcription:

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

B: Choice Integers A A 1 ( ) A%B, 2A%B, 3A%B,... A%B A B (k + B)A%B = (ka + BA)%B = ka%b B A BA B 2

C: Sentou i i + 1 T T T min(t, ) 3

D: Simple Knapsack N W v i ABC032 D i = 2, 3,, N w 1 w i w 1 + 3 4 (N/4) 4 = 25 4 = 390625 O( ) C++ Java D Python Ruby O(1) 4

E: Ball Coloring 400, 000 R max, R min, B max, B min 4 MIN = min(x 1, x 2,..., x n, y 1, y 2,..., y n ) MAX = max(x 1, x 2,..., x n, y 1, y 2,..., y n ) R min = MIN, B min = MIN R max = MAX, B max = MAX R min = MIN&B max = MAX R min = MIN&B max = MAX R min = MIN&B max = MAX R min B max R min = MIN&R max = MAX 1-5

F: Many Move DP O(N 3 ) DP dp[i][a][b] := i a b O(N 2 ) dp[i][a] := i a x i x 0 = B dp[0][a] = 0, dp[0][x] = (x A) min(dp[q][1], dp[q][2],..., dp[q][n]) DP dp[i][a] = dp[i 1][a] + x i 1 + x i (a x i ) dp[i][x i 1 ] = min(dp[i 1][x i 1 ] + x i 1 + x i, min j=1,2,...,n (dp[i 1][j] + j x i )) DP dp[i 1][1], dp[i 1][2],..., dp[i 1][n] dp[i][1], dp[i][2],..., dp[i][n] 1. x i 1 + xi 2. min j=1,2,...,n (dp[i 1][j] + j x i ) dp[i][x i 1 ] min j=1,2,...,n (dp[i 1][j] + j x i ) j x i min j=1,2,...,xi (dp[i 1][j] j + x i ) min j=xi+1,2,...,n(dp[i 1][j] + j x i ) dp[i 1][j] j dp[i 1][j] + j min dp[i 1][j] dp[i 1][j] j dp[i 1][j] + j 6

dp[i 1][j] j dp[i 1][j] + j add min Segment Tree 7

AtCoder Regular Contest 073 Editorial Kohei Morita(yosupo) 29 4 29 A: Shiritori python3 example: a, b, c = input ( ). s p l i t ( ) i f a [ l e n ( a ) 1] == b [ 0 ] and b [ l e n ( b) 1] == c [ 0 ] : p r i n t ( YES ) e l s e : p r i n t ( NO ) 1

B: Choice Integers The sum of multiples of A is always a multiple of A. Thus, we can assume that we choose only one integer. Consider the sequence A%B, 2A%B, 3A%B,... Since (k + B)A%B = (ka + BA)%B = ka%b, this sequence has a period of B. Therefore, we can check the first B elements of this sequence by brute force. 2

C: Sentou After the i-th person pushes the switch, the i + 1-th person If the i+1-th person comes within T seconds, the water keeps emitting. If the i + 1-th person comes after at least T seconds, the water emits for T seconds and stops. Therefore, the answer is the sum of min(t, t i+1 t i ). 3

D: Simple Knapsack This problem is known as the knapsack problem, and it s hard to solve in general case. This time we use the constraint w 1 w i w 1 + 3. Because of this, there are at most 4 possible weights for a single item. For each weight w, let s fix k w, the number of items of weight w we choose. Obviously, we should choose k w items greedily (in the descending order of values). Let A, B, C, D be the number of items of weights w 1, w 1 +1, w 1 +2, w 1 +3, respectively. This algorithm works in O(ABCD). In the worst case, this is (N/4) 4 = 25 4 = 390625. 4

E: Ball Coloring Let MIN = min(x 1, x 2,..., x n, y 1, y 2,..., y n ) MAX = max(x 1, x 2,..., x n, y 1, y 2,..., y n ). One of R min = MIN, B min = MIN will be satisfied, and one of R max = MAX, B max = MAX will be satisfied. Without loss of generality, we can consider the following two cases: R min = MIN&B max = MAX In this case we want to minimize R max and maximize B min. For each bag, we should color the ball with the larger integer blue, and color the other ball blue. R min = MIN&R max = MAX In this case we are only interested in blue balls (the value of B max B min. First, for each bag, we color the ball with the smaller integer blue, and sort the blue balls in ascending order. Call them z 1,..., z n (in ascending order). Then, for each i = 1,..., n, color z i red and color the opponent of z i blue. 5

F: Many Move Let dp[i][a][b] be the minimum cost required to process the first i queries such that the tokens are at a and b after the queries. This DP works in O(N 3 ). We ll improve this. Let dp[i][a] be the minimum cost required to process the first i queries such that the tokens are at a and x i after the queries. This DP works in O(N 2 ). Suppose that we have an array dp[i 1][1], dp[i 1][2],..., dp[i 1][n], and we want to convert it to the array dp[i][1], dp[i][2],..., dp[i][n]. The following operations are required: 1. Add x i 1 + xi to the whole array. 2. Compute min j=1,2,...,n (dp[i 1][j] + j x i ). This can be done by two RMQs: one of them holds the values of dp[i 1][j] j and the other one holds the values of dp[i 1][j] + j. 6