#include<bits/stdc++.h>
using namespace std;
#define NAME "VOLUNTEER"
#define nl '\n'
#define allofa(x,sz) x,x+sz+1
#define allof(x) x.begin(),x.end()
#define allof1(x) x.begin()+1,x.end()
#define mset(x,val) memset(x,val,sizeof(x))
#define couf(x) cout << fixed << setprecision(x)
template<class T> T Abs(T &x) {return (x>=0 ? x : -x);};
template<class X,class Y> bool minimize(X &a, Y b){if(a>b) {a=b;return true;}return false;};
template<class X,class Y> bool maximize(X &a, Y b){if(a<b) {a=b;return true;}return false;};
typedef long long ll;
const ll mod = (long long)1e9+7;
const ll LINF = (long long)1e15;
const int INF = (int)1e9;
const int MAXN = (int)1e6+5;
int org[MAXN],a[MAXN];
ll dp[MAXN];
int n;
void ccps() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);cout.tie(nullptr);
    if(fopen(NAME".inp","r")) {
        freopen(NAME".inp","r",stdin);
        freopen(NAME".out","w",stdout);
    }
}
struct FenwickTree {
    int n;
    vector<ll> fen;
    FenwickTree(int N = 0) {
        n=N;
        if(n>0) {
            fen.assign(n+1,0);
        }
    }
    void update(int node, ll val) {
        while(node<=n) {
            maximize(fen[node],val);
            node+=(node & -node);
        }
    }
    ll getVal(int node) {
        ll res = 0;
        while(node>0) {
            maximize(res,fen[node]);
            node-=(node & -node);
        }
        return res;
    }
} bit;
signed main() {
    ccps();
    cin >> n;
    vector<int> comp;
    fill(allofa(dp,n+1),1);
    for (int i = 1; i<=n; i++) {
        cin >> org[i];
        comp.push_back(org[i]);
    }
    sort(allof(comp));
    comp.resize(unique(allof(comp))-comp.begin());
    bit = FenwickTree((int)comp.size());
    for (int i = 1; i<=n; i++) {
        a[i] = lower_bound(allof(comp),org[i])-comp.begin()+1;
    }
    ll lisLen = 0;
    for (int i = 1; i<=n; i++) {
        dp[i] = bit.getVal(a[i]-1)+1;
        bit.update(a[i],dp[i]);
        maximize(lisLen,dp[i]);
    }
    vector<int> id;
    vector<vector<int>> res;
    vector<bool> visited(n+1,0);
    for (int i = 1; i<=n; i++) {
        if(dp[i]==lisLen) {
            id.push_back(i);
        }
    }
    while(!id.empty()) {
        int cur = lisLen;
        int last = id.back();id.pop_back();
        int curVal  =a[last]+1;
        vector<int> trace;
        for (int i = last; i>=1 and cur>=1; i--) {
            if(a[i]<curVal and dp[i]==cur and !visited[i]) {
                visited[i]=true;
                curVal=a[i];
                cur--;
                trace.push_back(i);
            }
        }
        if((int)trace.size()!=lisLen) continue;
        sort(allof(trace));
        res.push_back(trace);
    }
    sort(allof(res));
    cout << (int)res.size() << " " << lisLen << nl;
    for (vector<int> v : res) {
        for (int x : v) cout << x << " ";
        cout << nl;
    }
}
Compilation message (stderr)
Main.cpp: In function 'void ccps()':
Main.cpp:26:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |         freopen(NAME".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
Main.cpp:27:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |         freopen(NAME".out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |