I'm having a WA on my solution. I'm attempting this with square root decomposition. I did look up the hint and turn out my idea is kinda similar to the hint. The only difference is the data structure used. If anyone is kind enough to give me some test cases or find bugs in my code I'll be very appreciated. I tried multiple test cases with n less than 20 and they all seem fine.
#include <bits/stdc++.h>using namespace std;#define pb push_backtypedef vector <int> vi;typedef pair <int, int> ii;#define v first#define id secondint nBlock, n, q;int arr, key, mn, lazy;vector <ii> f;