| 
 | 
вернуться в форумThere is my code:   Program t1134;   Const MaxN=1000;   Var Card      : array[1..MaxN]of boolean;     Numb      : array[1..MaxN]of integer;     Use       : array[1..MaxN]of boolean;     M,N,i,j   : integer;     ex        : boolean;   begin Read(N,M); if (M>N)or(m=0) then begin  writeln('NO');  halt(0); end; for i:=1 to N do Card[i]:=false; for i:=1 to M do Use[i]:=false; for i:=1 to M do begin  read(Numb[i]);  if (Numb[i]<0)or(Numb[i]>n) then begin    writeln('NO');    halt(0);  end; end; for i:=1 to M do  if Numb[i]=0 then begin   Use[i]:=true;   if Card[1] then begin     writeln('NO');     halt(0);   end;   Card[1]:=true;  end else  if Numb[i]=n then begin   Use[i]:=true;   if Card[n] then begin     writeln('NO');     halt(0);   end;   Card[n]:=true;  end; for i:=1 to m-1 do if not(use[i]) then  for j:=i+1 to m do if not(use[j]) then   if numb[i]=numb[j] then begin    if (card[numb[i]])or(card[numb[j]-1]) then begin     writeln('NO');     halt(0);    end;    card[numb[i]-1]:=true;    card[numb[i]]:=true;    use[i]:=true;    use[j]:=true;   end; repeat ex:=true; for i:=1 to m do if not(use[i]) then  if (card[numb[i]])or(card[numb[i]-1]) then begin   if (card[numb[i]])and(card[numb[i]-1]) then begin     writeln('NO');     halt(0);   end;   if card[numb[i]] then begin    card[numb[i]-1]:=true;    use[i]:=true;   end else begin    card[numb[i]-1]:=true;    use[i]:=true;   end;  end; until ex; Writeln('YES'); end. 3 3 2 2 3 Maybe you forgot something, because the output of your program for this test case is 'YES'; hope this will help Good luck! > 3 3 > 2 2 3 > Maybe you forgot something, because the output of your program for > this test case is 'YES'; > hope this will help > Good luck! > i suppose the answer should be NO for that 2 2 means the 2nd and the 3rd had been taken, so the third number 3 is uncorrect 3 3 2 2 3 Maybe you forgot something, because the output of your program for this test case is 'YES'; hope this will help Good luck!  |  
  | 
|