Kill three steps

Solution

Step 1

Test when SB think XOR ......

First, the complexity is definitely linear, or can not meet.

Step 2

Range operation, considered for differential into a single point of operation.

Then if  S = E  , is an ordinary differential

If not, that is, the difference plus the same number of each array, consider the difference array to maintain a differential array.

Every time plus tolerance, the final statistics.

Modify  O (. 1 ), the statistical  O (N)  , can withstand

Step 3

#include<bits/stdc++.h>
using namespace std;
long long sum[10000005],d[10000005];
template <typename T>void read(T &x){
    int f=1;x=0;char c=getchar();
    for(;!isdigit(c);c=getchar())if(c=='-')f=!f;
    for(; isdigit(c);c=getchar()) x=x*10+c-'0';
    x*=f;
}
int n-, m, L, R & lt;
 Long  Long S, E, A [ 10,000,005 ];
 int main () {
 //   The freopen ( "sequence.in", "R & lt", stdin);
 //   The freopen ( "sequence.out "," W ", stdout); 
    Read (n-); Read (m);
     the while (M-- ) { 
        Read (L); Read (R & lt); Read (S); Read (E); 
        Long  Long GC = (ES) / (R- L); 
        D [L + . 1 ] + = GC; D [R & lt + . 1 ] - = GC; // difference array difference array from the second to the last item plus tolerance 
        sum [l ] + = S; SUM [R & lt + . 1 ] - = E; // difference at both ends of the array itself modified 
    }
     for ( int= I . 1 ; I <= n-; I ++ ) 
     SUM [I] + = (D [I] D = + [I- . 1 ]); // statistical difference array 
    Long  Long ANS = 0 , tmp = 0 , MX = 0 ;
     for ( int I = . 1 ; I <= n-; I ++) ANS ^ = (tmp + = SUM [I]), MX = max (MX, tmp); // count the original array 
    the printf ( " % LLD% LLD " , ANS, MX);
     return  0 ; 
}

 

Guess you like

Origin www.cnblogs.com/coder-cjh/p/11621759.html