Problem:
RMQ and RUQ

Write a program which manipulates a sequence A = {a0, a1, . . . , an−1} with the following operations:

update(s, t, x): change as, as+1, ..., at to x.

find(s, t): report the minimum element in as, as+1, ..., at.

Note that the initial values of ai (i = 0, 1, . . . , n−1) are 231-1.

Input

n q
query1
query2
:
queryq

In the first line, n (the number of elements in A) and q (the number of queries) are given. Then, ith query queryi is given in the following format:

0 s t x

or

1 s t

The first digit represents the type of the query. '0' denotes update(s, t, x) and '1' denotes find(s, t).

Output

For each find operation, print the minimum value.

Constraints

1 ≤ n ≤ 100000

1 ≤ q ≤ 100000

0 ≤ s ≤ t < n

0 ≤ x < 231−1

Sample Input 1

3 5
0 0 1 1
0 1 2 3
0 2 2 2
1 0 2
1 1 2

Sample Output 1

1
2

Sample Input 2

1 3
1 0 0
0 0 0 5
1 0 0

Sample Output 2

2147483647
5

Solution in C++14 (judge verdict: Accepted)

#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;

using namespace std;
#define N (1<<17)
#define G 2147483647
class RUQ{
private:
    #define D 20
    ll dat[2*N],laz[2*N];
    ll eval(int k){
	if(laz[k]!=G){
	    dat[k]=laz[k];
	    if(k<N){
		laz[k*2]=laz[k];
		laz[k*2+1]=laz[k];
	    }
	}
	laz[k]=G;
	return dat[k];
    }
public:
    void Init(){
	lol(i,2*N)dat[i]=laz[i]=G;
    }
    void Upd(int l,int r,ll x){
	l+=N,r+=N+1;
	for(int i=D;i>=0;i--){
	    eval(l>>i);eval(r>>i);
	}
	for(int a=l,b=r;a<b;a>>=1,b>>=1){
	    if(a&1)laz[a++]=x;
	    if(b&1)laz[--b]=x;
	}
	for(int a=l,b=r;a;a>>=1,b>>=1){
	    dat[a/2]=min(eval(a),eval(a^1));
	    dat[b/2]=min(eval(b),eval(b^1));
	}
    }
    ll Min(int l,int r){
	l+=N,r+=N+1;
	for(int i=D;i>=0;i--){
	    eval(l>>i);eval(r>>i);
	}
	ll res=(ll)mod*(ll)mod;
	for(int a=l,b=r;a<b;a>>=1,b>>=1){
	    if(a&1)res=min(res,eval(a++));
	    if(b&1)res=min(res,eval(--b));
	}
	return res;
    }
};
int main(){
    int n,q;cin>>n>>q;
    RUQ seg;seg.Init();
    while(q--){
	ll a,b,c;cin>>a;
	if(a==0){
	    cin>>a>>b>>c;
	    seg.Upd(a,b,c);
	}
	else{
	    cin>>a>>b;
	    cout<<seg.Min(a,b)<<endl;
	}
    }
    return 0;
}