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 <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define fi first
#define se second
#define pb emplace_back
template <class T>
inline bool maximize(T &a, const T &b) {return (a < b ? (a = b, 1) : 0);}
template <class T>
inline bool minimize(T &a, const T &b) {return (a > b ? (a = b, 1) : 0);}
const int N = 1e6 + 5;
int n, m;
pii arr[N];
vector<int> comp[N];
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n;
for (int i = 1; i <= n; ++i){
cin >> arr[i].fi;
arr[i].se = i;
}
sort(arr+1, arr+n+1);
reverse(arr+1, arr+n+1);
int i = 1;
while (i <= n){
++m;
for (int j = i; j <= i + arr[i].fi - 1; ++j)
comp[m].push_back(arr[j].se);
i += arr[i].fi;
}
cout << m << '\n';
for (int i = 1; i <= m; ++i){
cout << comp[i].size() << ' ';
for (int id : comp[i]) cout << id << ' ';
cout << '\n';
}
}
# | 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... |