bzoj 1028 暴力枚举判断

时间:2023-12-25 22:39:43

昨天梦到这道题了,所以一定要A掉(其实梦到了3道,有两道记不清了)

暴力枚举等的是哪张牌,将是哪张牌,然后贪心的判断就行了。

对于一个状态判断是否为胡牌,1-n扫一遍,然后对于每个牌,先mod 3,

如果还有剩余,就需要和i+1,i+2凑成顺子,减掉i+1,i+2的值就行了,然后

只要枚举到的i为负就是不可行,还有要枚举到n+2位,因为第n,n-1为可能

减了n+1,n+2但是没扫到。

/**************************************************************
    Problem:
    User: BLADEVIL
    Language: Pascal
    Result: Accepted
    Time: ms
    Memory: kb
****************************************************************/
 
//By BLADEVIL
var
    n, m                        :longint;
    count, jud                  :array[..] of longint;
    i, j, k                     :longint;
    x                           :longint;
    ans                         :array[..] of longint;
     
function judge:boolean;
var
    i                           :longint;
begin
    for i:= to n+ do
    begin
        if jud[i]< then exit(false);
        jud[i]:=jud[i] mod ;
        if jud[i]> then
        begin
            dec(jud[i+],jud[i]);
            dec(jud[i+],jud[i]);
            jud[i]:=;
        end;
    end;
    exit(true);
end;
     
begin
    read(n,m);
    for i:= to *m+ do
    begin
        read(x);
        inc(count[x]);
    end;
    for i:= to n do
    begin
        for j:= to n do jud[j]:=count[j];
        inc(jud[i]);
        for j:= to n do if jud[j]>= then
        begin
            dec(jud[j],);
            if judge then
            begin
                inc(ans[]);
                ans[ans[]]:=i;
            end;
            if ans[ans[]]=i then break;
            for k:= to n+ do jud[k]:=count[k];
            inc(jud[i]);
        end;
    end;
    if ans[]= then
    begin
        writeln('NO');
        halt;
    end;
    write(ans[]);
    for i:= to ans[] do write(' ',ans[i]); writeln;
end.