rt,AC了,但是样例2对拍的时候死活显示我答案错误,求纠错
//------------------------
//Online Judge : Luogu
//By : KS_tips_CN
//Subject :
//------------------------
//#include<bits/stdc++.h>
//#include<map>
//#include<stack>
//#include<list>
//#include<set>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<queue>
#include<algorithm>
#include<vector>
#define ll long long
#define reg register int
#define gc getchar()
#define MAXN 100010
#define MOD
using namespace std;
inline ll read( void ) ;
int T,N,Q;
ll A[MAXN],B[MAXN];
struct node{
int l,r,opt;
ll p ;
}ND[MAXN];
ll tree[MAXN<<2],tag[MAXN<<2];
inline void build( int x , int l , int r ){
if( l == r ){
tree[x] = B[l];
return ;
}
int mid = ( l + r ) >> 1 ;
build( x*2 , l , mid );
build( x*2+1 , mid+1 , r );
tree[x] = min( tree[x*2] , tree[x*2+1] );
}
inline bool INRANGE( int l , int r , int L , int R ){
if( l >= L && r <= R ) return 1;
return 0;
}
inline bool OUTRANGE( int l , int r , int L , int R ){
if( l > R || r < L ) return 1;
return 0;
}
inline void make_tag( int x , ll tag_ ){
tree[x] += tag_;
tag[x] += tag_;
}
inline void pushdown( int x ){
if( tag[x] == 0 ) return ;
make_tag( x*2 , tag[x] );
make_tag( x*2+1 , tag[x] );
tree[x] = min( tree[x*2] , tree[x*2+1] );
tag[x] = 0 ;
}
inline void add( int x , int l , int r , int L , int R , ll d ){
if( INRANGE(l,r,L,R) ) make_tag(x,d);
else if( !OUTRANGE(l,r,L,R) ){
pushdown(x);
int mid = ( l + r ) >> 1 ;
add( x*2 , l , mid , L , R , d );
add( x*2+1 , mid+1 , r , L , R , d );
tree[x] = min( tree[x*2] , tree[x*2+1] );
}
}
inline ll search( int x , int l , int r , int L , int R ){
// printf("search(%d,%d,%d,%d,%d)\n",x,l,r,L,R);
if( INRANGE(l,r,L,R) ) return tree[x];
else if( OUTRANGE(l,r,L,R) ) return 9223372036854775807;
else {
pushdown(x);
int mid = ( l + r ) >> 1 ;
ll a1 = search(x*2,l,mid,L,R);
ll a2 = search(x*2+1,mid+1,r,L,R);
return min(a1,a2);
}
}
int main( void ) {
freopen("restore2.in","r",stdin);
freopen("my.ans","w",stdout);
T = read();
while( T-- ){
// /*reset();
// memset(B,0,sizeof(B));
// memset(tree,0,sizeof(tree));
memset(tag,0,sizeof(tag));
memset(ND,0,sizeof(ND));
// */
N = read();
Q = read();
for( reg i = 1 ; i <= N ; i++ )
A[i] = read();
for( reg i = 1 ; i <= Q ; i++ ){
ND[i].opt = read();
ND[i].l = read();
ND[i].r = read();
if( ND[i].opt == 1 )
ND[i].p = read();
}
for( reg i = 1 ; i <= N ; i++ )
B[i] = read();
build(1,1,N);
for( reg i = Q ; i >= 1 ; i-- ){
// printf("%lld %lld %lld\n",ND[i].opt,ND[i].l,ND[i].r);
if( ND[i].opt == 1 )
add(1,1,N,ND[i].l,ND[i].r,0-ND[i].p);
if( ND[i].opt == 2 )
ND[i].p = search(1,1,N,ND[i].l,ND[i].r);
}
for( reg i = 1 ; i <= Q ; i++ ){
if( ND[i].opt == 2 )
printf("%lld ",ND[i].p);
}
printf("\n");
}
fclose(stdin);
fclose(stdout);
return 0;
}
inline ll read( void ) {
ll x = 0 , f = 0 ;
char ch = gc ;
while( !isdigit( ch ) )
f |= ( ch == '-' ) , ch = gc ;
while( isdigit( ch ) )
x = ( x << 1 ) + ( x << 3 ) + ( ch ^ 48 ) , ch = gc ;
return f ? -x : x ;
}