记录编号 62269 评测结果 AAAAAAAAAA
题目名称 [CEOI1994]数列问题 最终得分 100
用户昵称 GravatarEzoi_XY 是否通过 通过
代码语言 Pascal 运行时间 0.002 s
提交时间 2013-06-23 15:55:58 内存使用 0.21 MiB
显示代码纯文本
Program cog1300;
    Var
        N,P,A,I,H,T:Longint;
        G:Array[0..100,0..100]Of Longint;
        Q,D,M:Array[0..110]Of Longint;
        U:Array[0..100]Of Boolean;
    Procedure Qu;
        Begin
            Close(Input);
            Close(Output);
            Halt;
        End;
    Begin
        Assign(Input,'topoa.in');
        Assign(Output,'topoa.out');
        Reset(Input);
        Rewrite(Output);
        Readln(N,P,A);
        Fillchar(Q,Sizeof(Q),0);
        For I:=0 To N Do
            For T:=0 to N do G[I,T]:=N;
        Fillchar(U,Sizeof(U),0);
        Fillchar(M,Sizeof(T),0);
        For I:=0 to N do D[I]:=N;
        For I:=1 To N-A+1 Do G[I-1,I+A-1]:=-1;
        For I:=1 To N-P+1 Do G[I+P-1,I-1]:=-1;
        H:=1;
        T:=0;
        Q[1]:=0;
        D[0]:=0;
        U[0]:=True;
        Inc(M[0]);
        While H<>T Do
            Begin
                If T>N Then Dec(T,N+1);
                Inc(T);
                U[Q[T]]:=False;
                For I:=0 To N Do
                    If (G[Q[T],I]<>$3F3F3F3F) And (D[I]>D[Q[T]]+G[Q[T],I]) Then
                        Begin
                            D[I]:=D[Q[T]]+G[Q[T],I];
                            If U[I] Then Continue;
                            If M[I]=N+1 Then
                                Begin
                                    Writeln('no');
                                    Qu;
                                End;
                            If H>N Then Dec(H,N+1);
                            Inc(H);
                            Q[H]:=I;
                            U[I]:=True;
                            Inc(M[I]);
                        End;
            End;
        For I:=1 To N-1 Do Write(D[I]-D[I-1],' ');
        Writeln(D[N]-D[N-1]);
        Qu;
    End.