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 <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

struct SegTree {
    int n;
    vll data;
    vll lazy;
    const ll amax = (1ll << 31) - 1;

    SegTree(int m) {
        n = 1;
        while(n < m) n *= 2;
        data = vll(2 * this->n - 1, amax); // need to change
        lazy = vll(2 * this->n - 1, INFL);  // need to change
    }

    void eval(int k) {
        if(lazy[k] == INFL) return;
        if(k < n - 1) {
            lazy[k * 2 + 1] = lazy[k];  // need to change
            lazy[k * 2 + 2] = lazy[k];  // need to change
        }
        data[k] = lazy[k];  // need to change
        lazy[k] = INFL; // need to change
    }

    void update(int a, int b, ll x, int k, int l, int r) {
        eval(k);
        if(a <= l && r <= b) {
            lazy[k] = x;    // need to change
            eval(k);
        }
        else if(a < r && l < b) {
            update(a, b, x, k * 2 + 1, l, (l + r) / 2);
            update(a, b, x, k * 2 + 2, (l + r) / 2, r);
            data[k] = min(data[k * 2 + 1], data[k * 2 + 2]);
        }
    }

    void update(int a, int b, ll x) {   // update for [a, b)
        update(a, b, x, 0, 0, n);
    }

    ll query(int a, int b, int k, int l, int r) {
        eval(k);
        if(r <= a || b <= l) {
            return INFL;    // need to change
        }
        if(a <= l && r <= b) {
            return data[k];
        }
        else {
            ll vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
            ll vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
            return min(vl, vr); // need to change
        }
    }

    ll query(int a, int b) {
        return query(a, b, 0, 0, n);   // query for [a, b)
    }
};

void solve() {
    ll n, q;
    cin >> n >> q;
    SegTree st(n);
    vll ans;
    for(ll i = 0; i < q; i++) {
        ll c;
        cin >> c;
        if(c == 0) {
            ll s, t, x;
            cin >> s >> t >> x;
            st.update(s, t + 1, x);
        }
        else {
            ll s, t;
            cin >> s >> t;
            ans.push_back(st.query(s, t + 1));
        }
    }
    for(auto i : ans) cout << i << endl;
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}