穷举水题
var v:array[..] of boolean;
q:array[..] of longint;
ans,count,jud:array[..] of longint;
x,i,j,n,m,tot,t,k:longint; function check: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
readln(n,m);
for i:= to *m+ do
begin
read(x);
if count[x]= then
begin
inc(t);
q[t]:=x;
end;
inc(count[x]);
v[x]:=true;
v[x-]:=true;
v[x+]:=true;
end; for i:= to n do
if v[i] then //穷举添加的牌
begin
for j:= to n do
jud[j]:=count[j];
inc(jud[i]);
for j:= to t do //穷举对子
begin
dec(jud[q[j]],);
if check then
begin
inc(tot);
ans[tot]:=i;
break;
end;
for k:= to n+ do
jud[k]:=count[k];
inc(jud[i]);
end;
end; if tot= then writeln('NO')
else begin
for i:= to tot do
begin
write(ans[i]);
if i<>tot then write(' ');
end;
writeln;
end;
end.