Carding ideas

Start from scratch


 

One:

T1: Censoring (string hash)

hash + flexible use + immortal ideas:

JG [] represents the answer string, c [] is read into the string, lhash [] denotes the hash value of the new string, shash [] represents the original string of hash values

Denotes the length of the output string with the last two pointers js, zz represents the original string where added,

Each of the original string in answer to add a new character, to see it again from the enumerated list of n word which can delete the word, the word length put js- =

Delete finish on a break away, to prevent the re-count (do not know will not)

 

Core code

 

 

 

 

T2: profile memory (Almost god of + DP)

(1) First, read the questions first, read carefully
     such as: to ensure that data is j k's father, built a one-way side;
         go wrong node will read files! Error leaves;
         went wrong leaf reading files but also another step to go back;
   *** NOTE: There is a problem of t remember cleared; ***
(2) Second,
     One: Since there is this amazing archive things, a two-dimensional DP is constant;
     therefore provided f [i] [j] ( i correct for the current node, the j-th remaining opportunities to archive the desired step number n)
     is f [i] [j] = min ( f [i] [j], a desired number of steps from i to k F + [k] [-J. 1]) i +. 1 <= k <= n-;
     *** NOTE: only initialization [n] f [ 0] = 0; ***
       as f [n-1] [0] That went no chance archived n-1, the title says and 1, n two points must be filed,
       so the other values are f maximum;
     TWO: maintaining a desired number of steps from i to j DP [i] [j] (i, j are the correct node and i, j are not archived intermediate)
      the dp [i] [j] = dp [i] [j-1] + a desired number of steps from the j-1 to j;
          = j directly to the desired error from the leaves come + j-1 from a desired number of steps j-1 to j-1 j from another step further Back then i j desired;
      with G [i] from the wrong node i maintains an error came another step leaves a desired number of steps;
      the g [i] = sigma (( 1 / du [i]) * g [ j] +1) = 1 + ( 1 / du [i]) + sigma (g [j]); (j is the son i)
      With s [i] records the correct node i g values of all errors and sons;
      set d = d [j-1] ;
      to give dp [i] [j] = dp [i] [j-1] + (1 / d) / * j-1 directly to j * / + sigma ((1 / d) * (1 / * from the step j-1 to his son of k * / + g [k] + dp [i] [j ])) (Sigma be removed right node)
                = DP [I] [J-. 1] + (. 1 / D) + ((D-. 1) / D) * (. 1 + DP [I] [J]) + Sigma ((. 1 / D) * G [K]);                     
                      | -------> value <------- | | ----> i.e., s [i] <---- |
      by both sides of the equation with d, the dp [i] [j] to the left to obtain dp [i] [j] = dp [i] [j-1] * d + d + s [j-1];
    final output f [1] [p-1 ] can be because 1 must be filed;
      Three: achievements
        because only even the wrong side of the node, so from 1 to n-1 must again dfs, dfs du ago Do not forget to add its own correct son;
        the DFS to handle G, S;
      at Four: fantasy time optimization
       because dp array growing quickly, so if i and j differ by more than 40 dp [i] [j] has a great value for the answer does not contribute, therefore j enumerate only need to min (n, i + 40) to;

 

Guess you like

Origin www.cnblogs.com/qwertyuiopasdfghjklzxcvbnm/p/11670733.html