This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <stdio.h>
#include <string.h>
#define N	1000000
int max(int a, int b) { return a > b ? a : b; }
unsigned int X = 12345;
int rand_() {
	return (X *= 3) >> 1;
}
int *xx;
void sort(int *ii, int l, int r) {
	while (l < r) {
		int i = l, j = l, k = r, i_ = ii[l + rand_() % (r - l)], tmp;
		
		while (j < k)
			if (xx[ii[j]] == xx[i_])
				j++;
			else if (xx[ii[j]] < xx[i_]) {
				tmp = ii[i], ii[i] = ii[j], ii[j] = tmp;
				i++, j++;
			} else {
				k--;
				tmp = ii[j], ii[j] = ii[k], ii[k] = tmp;
			}
		sort(ii, l, i);
		l = k;
	}
}
int ii_[N + 1], dp[N + 1], pp[N + 1], ll[N + 1], n;
int solve(int s) {
	static int prev[N + 1];
	static char ok[N + 1];
	int i, l;
	memset(prev, -1, (n + 1) * sizeof *prev);
	memset(ok, 0, (n + 1) * sizeof *ok);
	memset(pp, -1, (n + 1) * sizeof *pp);
	ok[0] = 1;
	i = 0;
	while (i < n && ll[ii_[i]] < 0)
		i++;
	for (l = 0; l <= n; l++) {
		if (ok[l])
			prev[dp[l]] = l;
		while (i < n && ll[ii_[i]] == l) {
			int p = prev[dp[ii_[i]] - 1];
			if (p != -1 && ii_[i] - p <= s)
				ok[ii_[i]] = 1, pp[ii_[i]] = p;
			i++;
		}
	}
	return ok[n];
}
int main() {
	static int aa[N], ii[N], dq[N + 1];
	int h, i, j, lower, upper;
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &aa[i]);
		ii[i] = i;
	}
	xx = aa, sort(ii, 0, n);
	dp[0] = dq[0] = 0;
	for (i = 1; i <= n; i++) {
		ll[i] = i - aa[ii[i - 1]];
		dp[i] = ll[i] < 0 ? -1 : dq[ll[i]] + 1;
		dq[i] = max(dq[i - 1], dp[i]);
		ii_[i - 1] = i;
	}
	xx = ll, sort(ii_, 0, n);
	lower = 0, upper = n;
	while (upper - lower > 1) {
		int s = (lower + upper) / 2;
		if (solve(s))
			upper = s;
		else
			lower = s;
	}
	solve(upper);
	printf("%d\n", dp[n]);
	for (j = n; j > 0; j = i) {
		i = pp[j];
		printf("%d", j - i);
		for (h = i; h < j; h++)
			printf(" %d", ii[h] + 1);
		printf("\n");
	}
	return 0;
}
Compilation message (stderr)
tea.c: In function 'main':
tea.c:67:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   67 |  scanf("%d", &n);
      |  ^~~~~~~~~~~~~~~
tea.c:69:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   69 |   scanf("%d", &aa[i]);
      |   ^~~~~~~~~~~~~~~~~~~| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |