ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1273. Tie

Show all messages Hide all messages

(wa5) give me wrong test. PLEASE. Виктор Крупко 17 Aug 2005 00:05
    var
 x,y:array[1..100] of integer;
 b:array[1..100] of boolean;
 i,n,otv:integer; ex:boolean;
procedure reflesh;
    var
    i,max,col,j,yd:integer;
begin
   ex:=false;
   for i:=1 to n do
   if b[i] then
   begin
   col:=0;
   for j:=1 to n do
   if (i<>j) and b[j] then
   begin
   if (x[i]=y[i]) then break;
   if (x[i]<y[i]) then
   if ((x[j]>x[i]) and (y[i]>y[j])) then begin inc(col); yd:=j; end;
   if (x[i]>y[i]) then
   if ((x[i]>x[j]) and (y[i]<y[j])) then begin inc(col); yd:=j; end;
   end;
   if col=1 then begin  inc(otv); b[yd]:=false; ex:=true; break; end;
   end;
end;
begin
{   assign(input,'c:\test.txt');
   reset(input);}
   ex:=true;
   readln(n);
   fillchar(b,sizeof(b),true);
   for i:=1 to n do readln(x[i],y[i]);
   while ex do reflesh;
   writeln(otv);
end.
Try this
3
1 5
2 3
3 4
The right answer - 1.
You should use DP.
I have lost your address of mail/ Виктор Крупко 18 Aug 2005 06:13
I am very weak in the theory.
My algorithm not true.
Whether you can give me idea. (my mail xxvictorxx@mail.ru (if has overlooked))
Re: I have lost your address of mail/ Tolstobrov_Anatoliy[Ivanovo SPU] 20 Aug 2005 13:01

you algo wrong.

You need use DP.
i got AC O(N^2/2)
MALADEZ +FAMAS+ 20 Aug 2005 15:00
Re: MALADEZ Tolstobrov_Anatoliy[Ivanovo SPU] 21 Aug 2005 21:39

SURE?