阅读背景:

CF 767A_alusang的博客

来源:互联网 

第一遍笨方法模拟过的


#include <iostream>
#include <cstring>
#include <cstdio>

using namespace std;

const int maxn=1e6+5;

struct P
{
    int x;
    int s;
}p[maxn];

int main()
{
    memset(p,0,sizeof(p));
    int n;
    scanf("%d",&n);
    int k;
    int l=n,m=n;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&k);
        p[k].x=1;
        int j;
        for(j=m;j>=0;j--)
        {
            if(!(p[j].x==1 && p[j].s==0))
            {
                l=j+1;
                break;
            }
        }
        for(int j=m;j>=l;j--)
        {
            if(j==m)
                printf("%d",j);
            else
                printf(" %d",j);
            p[j].s=1;
        }
        m=l-1;
        printf("\n");
    }
    return 0;
}#include <iostream>
#includ



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: