0w1

Entries from 2017-02-28 to 1 day

IOICJ 89 Tool Man ( DP )

Problem Description: You are given an array A consisting of N elements. You know that they are K different people's orders, where some consecutive elements are what they have ordered. You also know that every order was ordered by some one,…

IOICJ 31 Repeated String ( KMP )

Problem Description: Given string S, find A with minimum length, such that S is equivalent to A being concatenated several times.Constraints: 1≤T≤100 1≤|S|≤1e5 TL: 1000 msSample Input: 3 ababab aaabaaab aaabaaaSample Output: 2 4 7Solution:…

CFR 442 B. Andrey and Problem ( Math, Probability, Greedy )

Problem - B - Codeforces題意: 你有一件事情要完成,但你太懶所以想請你朋友做。你可以同時請很多朋友做,但是如果兩個以上個朋友同時做出來,他們會覺得你把他們當工具人,不特別看待他們。求最佳策略下,可以不讓朋友傷心而完成這項作業的機率是多少。資…

CFR 484 B. Maximum Value ( Math, Binary Search, Harmonic Series )

Problem - 484B - Codeforces題意: 給 N 個數字的數列 A。求最大的 A[ j ] % A[ i ],滿足 A[ j ] ≥ A[ i ]。資料規模: N ≤ 2e5 max{ A } ≤ 1e6解法: 首先發現相同的值是沒有用的,所以 unique() 一下。此時就能因為 Harmonic Series 想到每個數的倍數數…

CFR 567 D. One-Dimensional Battle Ships ( Sqrt Decomposition )

Problem - 567D - Codeforces題意: 有 1 * N 的棋盤,K 艘長度為 A 的船,不接觸且不重疊地擺放在其中。你接著對 M 個相異位子依序開槍,但你的朋友每一次都說你撲空。求第幾次開槍後是可以確定你的朋友說謊。若無解輸出 -1。資料規模: N ≤ 2e5 M ≤ 2e5解…

CFR 303 A. Lucky Permutation Triple ( Math, Modulo )

Problem - 303A - Codeforces題意: 求長度為 N 的三個排列 A, B, C,使得所有 ( A[ i ] + B[ i ] ) % N = C[ i ]。若無解輸出 - 1。資料規模: N ≤ 1e5解法: 先算一下總和:Sigma( i % N, for all 0 ≤ i 時間 / 空間複雜度: O( N ) #include <bits/stdc++.h> using names</bits/stdc++.h>…