# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
57863 | okaybody10 | Teams (CEOI11_tea) | C++98 | 2557 ms | 73480 KiB |
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;
typedef pair<int,int> pii;
vector<int> ans[1000006];
pii v[1000006];
int idx=0,pos,copyidx;
void q2()
{
copyidx=idx;
while(v[pos].first>pos+1 && pos>0) { ans[copyidx][0]++,ans[copyidx].push_back(v[pos--].second); if(--copyidx<0) copyidx=idx; }
}
void q1()
{
ans[idx].push_back(v[pos].first);
for(int i=0;i<ans[idx][0];i++) ans[idx].push_back(v[pos--].second);
idx++;
}
int main()
{
int n; scanf("%d",&n);
for(int i=0;i<n;i++) scanf("%d",&v[i].first),v[i].second=i+1;
sort(v,v+n);
pos=n-1;
while(pos>=0)
{
if(v[pos].first>pos+1) q2();
else q1();
}
printf("%d\n",idx);
for(int i=0;i<idx;i++)
{
printf("%d ",ans[i][0]);
for(int j=0;j<ans[i][0];j++) printf("%d ",ans[i][j+1]);
printf("\n");
}
}
Compilation message (stderr)
# | 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... |