QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#581297 | #962. Thanks to MikeMirzayanov | Eznibuil | WA | 0ms | 3768kb | C++14 | 1.2kb | 2024-09-22 11:42:51 | 2024-09-22 11:42:52 |
Judging History
answer
#include<algorithm>
#include<iostream>
#include<vector>
int a[20001];
std::vector<int>ans[121];
void solve(int d,int l,int r)
{
bool f=1;
for(int i=l+1;i<r;i++)
f&=a[i-1]<a[i];
if(f)
{
for(int i=d;i<120;i++)
for(int j=l;j<r;j++)
ans[i].push_back(1);
return;
}
const int m=l+r>>1;
for(;;d++)
{
std::vector<int>c;
for(int i=0,j=l;;i^=1)
{
int x=0;
for(;j<r&&(a[j]>m)==i;j++)
x++;
c.push_back(x);
if(j==r)
break;
}
if(c.size()<3)
break;
for(int i=0,j=l;i<c.size();j+=c[i],i++)
if((i&3)==1&&i<c.size()-1)
continue;
else if((i&3)==2)
ans[d].push_back(c[i-1]+c[i]),std::reverse(a+j-c[i-1],a+j+c[i]);
else if(c[i])
ans[d].push_back(c[i]),std::reverse(a+j,a+j+c[i]);
}
return solve(d,l,l+r>>1),solve(d,l+r>>1,r);
}
int main()
{
std::cin.tie(0)->sync_with_stdio(0);
int n;
std::cin>>n;
for(int i=0;i<n;i++)
std::cin>>a[i];
solve(0,0,n),std::cout<<120-(ans[0].size()==1);
for(int i=ans[0].size()==1;i<120;i++)
{
if(i&1)
std::reverse(ans[i].begin(),ans[i].end());
std::cout<<'\n'<<ans[i].size();
for(int j:ans[i])
std::cout<<' '<<j;
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3768kb
input:
4 3 1 2 4
output:
120 2 3 1 3 1 1 2 4 1 1 1 1 4 1 1 1 1 4 1 1 1 1 4 1 1 1 1 4 1 1 1 1 4 1 1 1 1 4 1 1 1 1 4 1 1 1 1 4 1 1 1 1 4 1 1 1 1 4 1 1 1 1 4 1 1 1 1 4 1 1 1 1 4 1 1 1 1 4 1 1 1 1 4 1 1 1 1 4 1 1 1 1 4 1 1 1 1 4 1 1 1 1 4 1 1 1 1 4 1 1 1 1 4 1 1 1 1 4 1 1 1 1 4 1 1 1 1 4 1 1 1 1 4 1 1 1 1 4 1 1 1 1 4 1 1 1 1 4 ...
result:
ok OK
Test #2:
score: 0
Accepted
time: 0ms
memory: 3496kb
input:
6 6 5 4 3 2 1
output:
119 6 1 1 1 1 1 1 6 1 1 1 1 1 1 6 1 1 1 1 1 1 6 1 1 1 1 1 1 6 1 1 1 1 1 1 6 1 1 1 1 1 1 6 1 1 1 1 1 1 6 1 1 1 1 1 1 6 1 1 1 1 1 1 6 1 1 1 1 1 1 6 1 1 1 1 1 1 6 1 1 1 1 1 1 6 1 1 1 1 1 1 6 1 1 1 1 1 1 6 1 1 1 1 1 1 6 1 1 1 1 1 1 6 1 1 1 1 1 1 6 1 1 1 1 1 1 6 1 1 1 1 1 1 6 1 1 1 1 1 1 6 1 1 1 1 1 1 6 ...
result:
ok OK
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3764kb
input:
1 1
output:
119 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
result:
wrong answer Integer 1 violates the range [2, 1]