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# (judge verdict: Wrong Answer)

using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
class Program
{
static string[] input = Console.ReadLine().Split(' ');
static long n = long.Parse(input[0]);
static long q = long.Parse(input[1]);
static long[] nums = new long[600*600];
static long[] numSets = new long[600];//600*600に分割
static long[] numSetsSub = new long[600];

	static void Main()
	{
    AreaChangeMinGetReady();
      //区間以上以下の値を全てchangeNumに変更し、区間以上以下の最小値を求める初期値前処理。
    for(long question = 0; question < q; question++)
    {
      string[] inputq = Console.ReadLine().Split(' ');
      long howNum = long.Parse(inputq[0]);
      int leftNum = int.Parse(inputq[1]);
      int rightNum = int.Parse(inputq[2]);
      if(howNum == 0)//書き換え
      {
        long changeNum = long.Parse(inputq[3]);
        AreaChangeMinGet(leftNum,rightNum,changeNum);
      }
      if(howNum == 1)//最小値を求める
      {
        Console.WriteLine(AreaChangeMinGet(leftNum,rightNum));
      }
    }
	}

  static void AreaChangeMinGetReady()
  {//区間以上以下の値を全てchangeNumに変更し、区間以上以下の最小値を求める初期値前処理。
    for(int i = 0; i < 600*600; i++)
    {
      nums[i] = 2147483647;
    }
    for(int i = 0; i < 600; i++)
    {
      numSets[i] = 2147483647;
      numSetsSub[i] = long.MinValue;
    } 
  }

  static void AreaChangeMinGet(int leftNum, int rightNum, long changeNum)
  {//区間以上以下の値を全てchangeNumに変更し、区間以上以下の最小値を求める。入力側
    long leftPosition = WherePosition(leftNum);
    long rightPosition = WherePosition(rightNum);

    if(numSetsSub[leftPosition] != long.MinValue)
    {
      for(long i = 0; i < 600; i++)//区間内全てを見る
      {
        nums[leftPosition*600+i] = numSetsSub[leftPosition];
      }
      numSetsSub[leftPosition] = long.MinValue;
    }
    if(numSetsSub[rightPosition] != long.MinValue)
    {
      for(long i = 0; i < 600; i++)//区間内全てを見る
      {
        nums[rightPosition*600+i] = numSetsSub[rightPosition];
      }
      numSetsSub[rightPosition] = long.MinValue;
    }

    if(leftPosition == rightPosition)//左右が同じ分類のとき
    {
      for(long i = leftNum; i <= rightNum; i++)
      {
        nums[i] = changeNum;
      }
      long minMemo = long.MaxValue;
      for(long i = 0; i < 600; i++)//区間内全てを見る
      {
        minMemo = Math.Min(minMemo, nums[leftPosition*600+i]);
      }
      numSets[leftPosition] = minMemo;
    }else
    {
      for(long i = leftNum; i < 600*(leftPosition+1); i++)//左区間内（左端より右だけ見る）
      {
        nums[i] = changeNum;
      }
      for(long i = 600*rightPosition; i <= rightNum; i++)//右区間内
      {
        nums[i] = changeNum;
      }
      long minMemoL = long.MaxValue;
      long minMemoR = long.MaxValue;
      for(long i = 0; i < 600; i++)//区間内全てを見る
      {
        minMemoL = Math.Min(minMemoL, nums[leftPosition*600+i]);
        minMemoR = Math.Min(minMemoR, nums[rightPosition*600+i]);
      }
      numSets[leftPosition] = minMemoL;
      numSets[rightPosition] = minMemoR;

      for(long i = leftPosition+1; i < rightPosition; i++)//見ていない区間内
      {
        numSetsSub[i] = changeNum;
        numSets[i] = changeNum;
      }
    }
  }

  static long AreaChangeMinGet(int leftNum, int rightNum)
  {//区間以上以下の値を全てchangeNumに変更し、区間以上以下の最小値を求める。出力側
    long minMemo = long.MaxValue;
    long leftPosition = WherePosition(leftNum);
    long rightPosition = WherePosition(rightNum);

    if(leftPosition == rightPosition)
    {
      for(long i = leftNum; i <= rightNum; i++)//左右が同じ分類のとき
      {
        minMemo = Math.Min(minMemo, nums[i]);
      }
    }else
    {
      for(long i = leftNum; i < 600*(leftPosition+1); i++)//左区間内（左端より右だけ見る）
      {
        minMemo = Math.Min(minMemo, nums[i]);
      }
      for(long i = 600*rightPosition; i <= rightNum; i++)//右区間内
      {
        minMemo = Math.Min(minMemo, nums[i]);
      }
      for(long i = leftPosition+1; i < rightPosition; i++)//見ていない区間内
      {
        minMemo = Math.Min(minMemo, numSets[i]);
      }
    }
    return minMemo;
  }

  static int WherePosition(int num)//左から何番目の分類に属するか
  {
    return num / 600;
  }
  
}