0w1

Entries from 2017-04-02 to 1 day

AGC 12 D - Colorful Balls ( Math, Combination )

D: Colorful Balls - AtCoder Grand Contest 012 | AtCoder題意: 有若干個球排成一排,第 i 個球用顏色 C[ i ],重量 W[ i ] 描述。可以進行的操作有兩種: 1. 選擇兩個相異位置的相同顏色的球,若它們的重量和不超過 X,將它們交換位置 2. 選擇兩個相異位…

AGC 12 C - Tautonym Puzzle ( Binary Enumeration )

C: Tautonym Puzzle - AtCoder Grand Contest 012 | AtCoder題意: 要求構造一個字串 S,使得 S 有洽 N 個偶數長度 ( ≥ 2 ) 的子序列,使得子序列前半等於子序列後半。資料規模: 1≦|s|≦200 s は 1 から 100 までの整数で表される 100 種類の文字のみからな…

AGC 12 B - Splatter Painting ( BFS )

B: Splatter Painting - AtCoder Grand Contest 012 | AtCoder題意: 給一張圖,以及 Q 次操作,每次操作將離 u 距離 d 內的所有節點塗色為 c。初始時每個節點顏色為 0。問所有操作結束後,每個節點分別顏色是什麼。資料規模: 1≦N,M,Q≦1e5 1≦ai,bi,vi≦N ai≠…

CFR 44 E. Anfisa the Monkey ( Greedy )

Problem - 44E - Codeforces題意: 給 K, A, B,以及一個字串 S。要求輸出方案,使得將 S 分為 K 個子字串,滿足所有子字串長度在 [ A, B ] 之間。資料規模: The first line contains three integers k, a and b (1 ≤ k ≤ 200, 1 ≤ a ≤ b ≤ 200). The secon…

CFR 768 D. Jon and Orbs ( DP, Probability )

Problem - D - Codeforces題意: 有 K 種卡片,每天都可以抽一張,抽到的種類機率分佈是隨機均勻。Q 筆詢問,問第幾天開始可以確定,對於任意一種卡片,有 P / 2000 的機率有至少一張。資料規模: First line consists of two space separated integers k, q…

CFR 552 E. Vanya and Brackets ( Greedy, Expression Parsing, Python )

Problem - E - Codeforces題意: 給一個由 '+', '*', '0' ~ '9' 組成的合法數式,要求在任意合法的位置插入一對括弧,求最大可能結果。資料規模: The first line contains expression s (1 ≤ |s| ≤ 5001, |s| is odd), its odd positions only contain digi…

CFR 768 C. Jon Snow and his Favourite Number ( DP )

Problem - C - Codeforces題意: 給一個長度為 N 的數列,要做 K 次操作。每次將數列排序後,奇數項 ( 1 based ) 和 X 做 xor,偶數項不變。問所有操作結束後,數列的長相。資料規模: First line consists of three integers n, k, x (1 ≤ n ≤ 1e5, 0 ≤ k ≤…