ENG  RUS Timus Online Judge
Online Judge
Problems
Authors
Online contests
Site news
Webboard
Problem set
Submit solution
Judge status
Guide
Register
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1134. Cards

Why I get WA? Pelase, help me!!!!!!!
Posted by Revenger and NSC 27 Dec 2001 19:15
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
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
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.
Try this test case(+)
Posted by shitty.Mishka 27 Dec 2001 21:37
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!
Re: Thank you! I get AC.
Posted by Revenger and NSC 27 Dec 2001 23:14
> 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!
>
Re: Try this test case(+)
Posted by LLL 7 Nov 2016 17:55
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
shitty.Mishka wrote 27 December 2001 21:37
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!