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 1173. Lazy Snail

why i got WA ? who can help me?
Posted by ruwelcome 29 Apr 2003 12:21
var
i,j,k,n,m,s:longint;
xx:real;
x,y:array[0..1000] of real;
a:Array[0..1000] of integer;
an:array[0..1000] of real;
d:array[0..1000] of integer;
begin
for i:=1 to n do
for i:=1 to n do
begin
x[i]:=x[i]-x[0];
y[i]:=y[i]-y[0];
end;
for i:=1 to n do
for j:=i+1 to n do
if ((x[i]=x[j]) and (y[i]=y[j])) or ((x[i]=0) and (y[i]=0))then
begin
writeln(-1);
halt;
end;
writeln(0);
fillchar(a,sizeof(a),0);
fillchar(an,sizeof(an),0);
s:=0;
for i:=1 to n do
if (x[i]=0) and (y[i]>0) then writeln(i);

for i:=1 to n do
if (x[i]>0) and (y[i]>=0) then
begin
inc(s);
a[s]:=i;
an[s]:=arctan(y[i]/x[i]);
end;
for i:=1 to s-1 do
for j:=1 to s-i do
if an[j]<an[j+1] then
begin
k:=a[j];
a[j]:=a[j+1];
a[j+1]:=k;
xx:=an[j];
an[j]:=an[j+1];
an[j+1]:=xx;
end;
for i:=1 to s do
writeln(d[a[i]]);

fillchar(a,sizeof(a),0);
fillchar(an,sizeof(an),0);
s:=0;
for i:=1 to n do
if (x[i]>0) and (y[i]<0) then
begin
inc(s);
a[s]:=i;
an[s]:=arctan(-1*y[i]/x[i]);
end;
for i:=1 to s-1 do
for j:=1 to s-i do
if an[j]>an[j+1] then
begin
k:=a[j];
a[j]:=a[j+1];
a[j+1]:=k;
xx:=an[j];
an[j]:=an[j+1];
an[j+1]:=xx;
end;
for i:=1 to s do
writeln(d[a[i]]);

for i:=1 to n do
if (x[i]=0) and (y[i]<0) then writeln(i);

fillchar(a,sizeof(a),0);
fillchar(an,sizeof(an),0);
s:=0;
for i:=1 to n do
if (x[i]<0) and (y[i]<=0) then
begin
inc(s);
a[s]:=i;
an[s]:=arctan(y[i]/x[i]);
end;
for i:=1 to s-1 do
for j:=1 to s-i do
if an[j]<an[j+1] then
begin
k:=a[j];
a[j]:=a[j+1];
a[j+1]:=k;
xx:=an[j];
an[j]:=an[j+1];
an[j+1]:=xx;
end;
for i:=1 to s do
writeln(d[a[i]]);

fillchar(a,sizeof(a),0);
fillchar(an,sizeof(an),0);
s:=0;
for i:=1 to n do
if (x[i]<0) and (y[i]>0) then
begin
inc(s);
a[s]:=i;
an[s]:=arctan(-1*y[i]/x[i]);
end;
for i:=1 to s-1 do
for j:=1 to s-i do
if an[j]>an[j+1] then
begin
k:=a[j];
a[j]:=a[j+1];
a[j+1]:=k;
xx:=an[j];
an[j]:=an[j+1];
an[j+1]:=xx;
end;
for i:=1 to s do
writeln(d[a[i]]);
writeln(0);
end.