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;
int main()
{
int n;
cin >> n;
vector<pair<int, int> > v(n);
vector<vector<int> > g(0, vector<int>(0));
for(int i = 0; i < n; i++)
{
cin >> v[i].first;
v[i].second = i + 1;
}
sort(v.begin(), v.end());
int r = (int) v.size() - 1;
for(int i = (int) v.size() - 1; i >= 0; i--)
{
int val = v[r].first;
if(r - i + 1 >= val)
{
vector<int> cur;
for(int j = i; j <= r; j++)
cur.push_back(v[j].second);
g.push_back(cur);
r = i - 1;
}
}
int mx = 0;
for(int i = 0; i < (int) g.size(); i++)
mx = max(mx, (int) g[i].size());
while(0 <= r)
{
for(int i = 0; i < (int) g.size(); i++)
while(0 <= r && (int) g[i].size() < mx)
g[i].push_back(v[r--].second);
mx++;
}
printf("%d\n", (int) g.size());
for(int i = 0; i < (int) g.size(); i++)
{
printf("%d ", (int) g[i].size());
for(int j = 0; j < (int) g[i].size(); j++)
printf("%d ", g[i][j]);
printf("\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... |