Page 2 of 6
Re: About 476
Posted: Tue Jun 17, 2003 7:54 pm
by kallal
I just can't find why my code is not getting accepted !
Is there any exception in this problem?

Posted: Fri Jun 20, 2003 10:59 pm
by the LA-Z-BOy
i don't think there is any `exception' in this problem... i just got it accepted at first try... so you better check your code again.. tell us if you still got problem...
Greetings
WA!476
Posted: Sun Aug 03, 2003 2:15 am
by decken kang
/* @JUDGE_ID: 476 C++ */
#include<iostream.h>
void main()
{
char s[2];
int j,k,n_figure=0,n_dot=0;
bool test;
double x,y,figure[10000][3][3]={0};
while(cin>>s)
{
if(s[0]=='r')
{
n_figure++;
for(j=1;j<3;j++)
for(k=1;k<3;k++) cin>>figure[n_figure][k][j];
}
else if(s[0]=='*')
{
while(cin>>x>>y)
{
if(x==9999.9 && y==9999.9)
goto over;
test=false;
n_dot++;
for(j=1;j<=n_figure;j++)
if(x>figure[j][1][1] && x<figure[j][1][2] && y<figure[j][2][1] && y>figure[j][2][2])
{
cout<<"Point "<<n_dot<<" is contained in figure "<<j<<endl;
test=true;
}
if(test==false)
cout<<"Point "<<n_dot<<" is not contained in any figure"<<endl;
}
}
}
over:;
}
/* @END_OF_SOURCE_CODE */
I've test many times.
I think my answer is correct.
But it ayways gets "WA".
I really don't know why.
Anyone could help me.
Thank you very much.
Easy way
Posted: Tue Sep 23, 2003 2:49 pm
by joydip
Cheak out the question again, Take four data in 4 double variable,
and put them in 4 arrays then cheak...........
I think you get the max array size

476 why compile error?[java]
Posted: Sat Oct 11, 2003 8:09 pm
by Morning
[java]
import java.io.*;
import java.util.*;
class Main
{
static String ReadLn (int maxLg) // utility function to read from stdin
{
byte lin[] = new byte [maxLg];
int lg = 0, car = -1;
String line = "";
try
{
while (lg < maxLg)
{
car = System.in.read();
if ((car < 0) || (car == '\n')) break;
lin [lg++] += car;
}
}
catch (IOException e)
{
return (null);
}
if ((car < 0) && (lg == 0)) return (null); // eof
return (new String (lin, 0, lg));
}
public static void main (String args[]) // entry point from OS
{
Main myWork = new Main(); // create a dinamic instance
myWork.Begin(); // the true entry point
}
void Begin()
{
String input;
StringTokenizer idata;
float x,y;
float [][] matrix=new float [10][4];
int numOfRec=0;
int numOfPoint=0;
int loop;
String temp;
boolean ifBeCon;
while ((input = Main.ReadLn (255)) != null)
{
if(input.charAt(0)=='*') break;
if(input.charAt(0)=='r')
{
numOfRec++;
idata = new StringTokenizer (input);
idata.nextToken();
{
matrix[numOfRec-1][0] = Float.parseFloat (idata.nextToken());
matrix[numOfRec-1][1] = Float.parseFloat (idata.nextToken());
matrix[numOfRec-1][2] = Float.parseFloat (idata.nextToken());
matrix[numOfRec-1][3] = Float.parseFloat (idata.nextToken());
}
}
}
while ((input = Main.ReadLn (255)) != null)
{
numOfPoint++;
idata = new StringTokenizer (input);
ifBeCon=false;
x=Float.parseFloat (idata.nextToken());
y=Float.parseFloat (idata.nextToken());
if((x==9999.9)&&(y==9999.9)) break;
for(loop=0;loop<numOfRec;loop++)
{
if((x>matrix[loop][0])&&(x<matrix[loop][2])&&(y<matrix[loop][1])&&(y>matrix[loop][3]))
{
ifBeCon=true;
System.out.println("Point "+numOfPoint+" is contained in figure "+(loop+1));
}
}
if(ifBeCon==false)
System.out.println("Point "+numOfPoint+" is not contained in any figure");
}
}
}[/java][/java]
476 WA help
Posted: Fri Dec 05, 2003 5:41 pm
by Eduard
it Give's WA i don't no what is wrong.help please.
[pascal]program acm476;
label 1,2;
var a,a1,a2,a3:array[1..10000] of real;
number,i,j,k,n:integer;
c:char;
b,bb:real;
t:boolean;
begin
while not eof do
begin
i:=0;
repeat
read(c);
i:=i+1;
if c='*' then goto 1;
readln(a,a1,a2,a3)
until 1=2;
1: n:=i;
number:=0;
repeat
number:=number+1;
read(b);
readln(bb);
if (b=9999.9) and (bb=9999.9) then goto 2;
t:=false;
for i:=1 to n do
if (b>=a) and (b<=a2) and (bb<=a1) and (bb>=a3) then begin t:=true;
writeln('Point ',number,' is contained in figure ',i) end;
if t=false then writeln('Point ',number,' is not contained in any figure');
until 1=2;
2:
end;
end.[/pascal]
about 476
Posted: Sun Dec 21, 2003 12:27 pm
by Eduard
it gives WA help please i really don't know what is wrong
[pascal]program acm476;
label 1,2;
var a:array[1..4,1..100] of real;
x,y:real;
i,j,k,n,number:longint;
c:char;
procedure solve(x,y:real;number:longint);
var i,j,k:longint;
t:boolean;
begin
t:=false;
for i:=1 to n do
begin
if
(x>a[1,i]) and
(x<a[3,i]) and
(y<a[2,i]) and
(y>a[4,i]) then
begin
t:=true;
writeln('Point ',number,' is contained in figure ',i);
end;
end;
if t=false then writeln('Point ',number,' is not contained in any figure');
end;
begin
i:=0;
repeat
read(c);
if c='*' then goto 1;
if c='r' then
begin
i:=i+1;
for j:=1 to 4 do
read(a[j,i]);
end;
until 1=2;
1: n:=i;
number:=0;
repeat
number:=number+1;
readln(x,y);
if (x=9999.9) and (y=9999.9) then goto 2;
solve(x,y,number);
until 1=2;
2:
end.[/pascal]
about help 476
Posted: Tue Dec 23, 2003 4:43 pm
by mohiul alam prince
int rectangle(double x,double y)
{
if(x>=a1 && x<=a3 && y>=a4 && y<=a2)
{
i++;
return 1;
}
else {i++; return 0; }
}
this is my function i have use this function in 477 & got AC
but in problem 476 i got WA what is my funtions problem any body can
help me??
prince
23-12-2003
Posted: Wed Dec 24, 2003 3:24 pm
by shamim
Please specify what does a1 contain.
Why are u using the variable i when you have never initialized it.
Posted: Sun Dec 28, 2003 1:00 pm
by Eduard
Help please.
Posted: Tue Jan 27, 2004 8:57 pm
by aakash_mandhar
Hi mohiul,
You do not have to create an array and fill it up to create a rectangle.. This problem is easy. keep an array like you are keeping and when a pt is given just compare if the point lies in bound..
Eg. l=left r=right t=top b=bottom x,y is the point
if(x>l && x<r && y>b && y<t) cout<<"In figure";
if it fails for all figures then it obviously does not lie in any figure....
I hope it answers any doubts you have about the problem...
Aakash

Posted: Tue Jan 27, 2004 9:02 pm
by aakash_mandhar
Your idea seems right but am no good with pascal..
if t=top l=left r=right b=botom and x,y is the point
if(x>l && x<r && y<t && y>b) then pt in figure
if it fails for all figures then point not in any figure.
Aakash

Posted: Sat Feb 07, 2004 4:45 pm
by mohiul alam prince
thanks akash i got AC.
help about 476
Posted: Sun Mar 07, 2004 12:26 pm
by Salmin Sultana
why this is wa?my code is here
#include<stdio.h>
class rect
{
public:
long double left,right,top,bottom;
}a[1500];
int main()
{
char ch;
long double p1x,p1y,p2x,p2y,temp;
long int num=0,i,p=1,flag;
while(1){
scanf("%c",&ch);
if(ch=='*')
break;
scanf("%Lf %Lf %Lf %Lf",&p1x,&p1y,&p2x,&p2y);
fflush(stdin);
if(p1x>p2x){
temp=p1x;
p1x=p2x;
p2x=temp;
}
if(p1y<p2y){
temp=p1y;
p1y=p2y;
p2y=temp;
}
a[num].left=p1x;
a[num].right=p2x;
a[num].top=p1y;
a[num].bottom=p2y;
num++;
}
for(p=1;;p++){
scanf("%Lf %Lf",&p1x,&p1y);
p2x=p1x-0.9;
p2y=p1y-0.9;
if(p2x==9999&&p2y==9999)
break;
flag=0;
for(i=0;i<num;i++){
if((p1x>(a.left))&&(p1x<(a.right))&&
(p1y>(a.bottom))&&(p1y<(a.top)))
{
flag=1;
printf("Point %ld is contained in figure %ld\n",p,i+1);
}
}
if(flag==0)
printf("Point %ld is not contained in any figure\n",p);
}
return 0;
}[/cpp][/code]
minor mistake!
Posted: Sun Mar 07, 2004 1:58 pm
by sohel
your program is perfectly alright but your input taking format is not quite correct.
try avoid scanf("%c",&ch) ,
use scanf("%s",str) and then str[0] ==.
I have changed this part of your code and removed fflush(stdin) and got Ac.
Hope it helps.