zoukankan      html  css  js  c++  java
  • bzoj2882

    2882: 工艺

    Time Limit: 10 Sec  Memory Limit: 128 MB
    Submit: 1348  Solved: 575
    [Submit][Status][Discuss]

    Description

    小敏和小燕是一对好朋友。
    他们正在玩一种神奇的游戏,叫Minecraft。
    他们现在要做一个由方块构成的长条工艺品。但是方块现在是乱的,而且由于机器的要求,他们只能做到把这个工艺品最左边的方块放到最右边。
    他们想,在仅这一个操作下,最漂亮的工艺品能多漂亮。
    两个工艺品美观的比较方法是,从头开始比较,如果第i个位置上方块不一样那么谁的瑕疵度小,那么谁就更漂亮,如果一样那么继续比较第i+1个方块。如果全都一样,那么这两个工艺品就一样漂亮。

    Input

    第一行两个整数n,代表方块的数目。
    第二行n个整数,每个整数按从左到右的顺序输出方块瑕疵度的值。

    Output

    一行n个整数,代表最美观工艺品从左到右瑕疵度的值。

    Sample Input


    10
    10 9 8 7 6 5 4 3 2 1

    Sample Output


    1 10 9 8 7 6 5 4 3 2

    HINT



    【数据规模与约定】

    对于20%的数据,n<=1000

    对于40%的数据,n<=10000

    对于100%的数据,n<=300000

    • 跟GlassBeads一样
    • 原来难点在map hhh 记着这个用法啊
     1 #include<cstdio>
     2 #include<cstring>
     3 #include<algorithm>
     4 #include<map>
     5 const int N=1200006;
     6 const int inf=2000000000;
     7 using namespace std;
     8 map<int,int>c[N];
     9 int T,pre=1,cnt=1,n,l[N],f[N];
    10 
    11 inline int gi(){int d=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    12 while(c<='9'&&c>='0'){d=(d<<3)+(d<<1)+c-'0';c=getchar();}return d*f;}
    13 inline void ins(int x){
    14     int p=pre,np=++cnt;pre=np;l[np]=l[p]+1;
    15     for(;p&&!c[p].count(x);p=f[p])c[p][x]=np;
    16     if(!p)f[np]=1;
    17     else{
    18         int q=c[p][x];
    19         if(l[q]==l[p]+1)f[np]=q;
    20         else{
    21             int nq=++cnt;
    22             l[nq]=l[p]+1;
    23             c[nq]=c[q];f[nq]=f[q];f[q]=f[np]=nq;
    24             for(;c[p][x]==q;p=f[p])c[p][x]=nq;
    25         }
    26     }
    27 }
    28 int s[N];
    29 int main(){
    30     n=gi();int xx,tt,now;
    31     for(int i=1;i<=n;++i){
    32         s[i]=gi();ins(s[i]);
    33         s[i+n]=s[i];
    34     }
    35     for(int i=1;i<=n;++i)ins(s[i+n]);
    36     xx=n;now=1;
    37     map<int,int>::iterator ite;
    38     for(int nn=0;nn<n;){
    39         ite=c[now].lower_bound(-inf);
    40         printf("%d ",ite->first);
    41         now=ite->second;++nn;
    42     }
    43     return 0;
    44 }
  • 相关阅读:
    用电脑Python控制Arduino
    Arduino-LiquidCrystal_I2C 液晶库
    Arduino通讯串口
    nginx statistics in multi-workers
    Nginx RTMP 模块 nginx-rtmp-module 指令详解
    windows下搭建nginx-rtmp服务器
    超实用压力测试工具-ab工具
    (总结)Nginx配置文件nginx.conf中文详解
    NGINX conf 配置文件中的变量大全 可用变量列表及说明
    「自己开发直播」实现nginx-rtmp-module多频道输入输出与权限控制
  • 原文地址:https://www.cnblogs.com/xln1111/p/8615168.html
Copyright © 2011-2022 走看看