A little thought about discretization

  In fact, when Ben Konjac was self-taught, he didn't learn much about discretization. qaq, the question was probably because the data was too watery, right?

  Okay, so close to the subject, what is discretization?

  In my opinion, discretization is a processing of data, processing numbers with a large range of data (of course, the premise is that there is not so much data), storing a large number in each array element, and then processing the array directly .

  

  Recommended viewing (please understand the infringement) (https://www.cnblogs.com/hkttg/p/8445019.html)

 

  First introduce the conventional method (no unique)

  

for (int i = 0 ; i < n ; i ++) {
    scanf("%d%d",&li[i] , &ri[i]);
    X[nn++] = li[i];
    X[nn ++] = ri[i];                 // When reading, it will be stored in the X array for discretization operations 
}
sort(X , X + nn);                       // sort, essential 
int m = 1 ;
 for ( int i = 1 ; i < nn; i ++ ) {
     if (X[i] != X[i- 1 ]) X[m ++] = X[i];        // remove duplicate elements 
}
 for ( int i = m - 1 ; i > 0 ; i -- ) {
     if (X[i] != X[i- 1 ] + 1 ) X[m ++] = X[i- 1 ] + 1 ;          // Insert the number between the two larger elements, which can improve the ability to deal with some bad data 
}
sort(X , X + m);                 // sort one last time for the following work() operation

 

 

 

  And use the unique method, just look at the blog of the big guy! @#¥@%¥&%*

 

 

 

  If you have any more thoughts, please add... . . .

Q  A  Q

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325016096&siteId=291194637