10823 - Of Circles and Squares

All about problems in Volume 108. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

User avatar
A1
Experienced poster
Posts: 173
Joined: Wed Jan 28, 2004 3:34 pm
Location: Bangladesh

10823 WA

Post by A1 » Sun Mar 13, 2005 4:37 pm

I am getting WA in this easy problem, please help

Code: Select all

#include <stdio.h>
Thanks to every one
I cut the code after AC
Last edited by A1 on Tue Mar 15, 2005 9:41 am, edited 1 time in total.

User avatar
Dreamer#1
Learning poster
Posts: 77
Joined: Tue Oct 07, 2003 10:07 pm

Post by Dreamer#1 » Sun Mar 13, 2005 7:46 pm

Code: Select all



               dr=((double)tr/(double)co)+0.5000001; 
               dg=((double)tg/(double)co)+0.5000001; 
               db=((double)tb/(double)co)+0.5000001; 
               r=dr; 
               g=dg; 
               b=db; 

your rounding part seems incorrect to me. if u need help on rounding check out the other post on this problem.

Emilio
Experienced poster
Posts: 163
Joined: Sun Oct 17, 2004 8:31 pm
Location: Murcia, Spain

Post by Emilio » Mon Mar 14, 2005 2:39 am

To sumankar:

Maybe you got AC. But if not is the case, you must read your onCircle function, the line

Code: Select all

long d = (p.x-c.x)*(p.x-c.x) + (p.y-c.y)*(p.x-c.y); 
must be

Code: Select all

long d = (p.x-c.x)*(p.x-c.x) + (p.y-c.y)*(p.y-c.y); 

sumankar
A great helper
Posts: 286
Joined: Tue Mar 25, 2003 8:36 am
Location: calcutta
Contact:

Post by sumankar » Mon Mar 14, 2005 6:28 am

I am moved!So many responses :) Thanks a lot guys!

Anyway special thanks to Emilio - I spotted that glaring mistake, however
the problem was with precision, once again. So....

Regards,
Suman.

User avatar
_.B._
Experienced poster
Posts: 160
Joined: Sat Feb 07, 2004 7:50 pm
Location: Venezuela
Contact:

Need I/O.

Post by _.B._ » Mon Mar 14, 2005 6:46 am

Greetings!
Time to post some I/O 8)
Can anyone please post some critical Input/Output for this problem?
Is this I/O good?:

Input:

Code: Select all

3
1 1
SQUARE 0 0 5 0 0 0
0 5
3 3
CIRCLE 0 0 5 10 10 10
SQUARE 1 1 5 255 10 10
CIRCLE 5 5 3 0 0 0
5 6
6 5
8 5
3 9
CIRCLE 0 0 7 255 0 0
SQUARE 2 -1 6 0 0 255
CIRCLE 4 7 4 0 255 0
2 8
1 5
6 4
3 4
4 0
7 2
0 0
3 -1
20 20
Output:

Code: Select all

Case 1:
(0, 0, 0)

Case 2:
(0, 0, 0)
(0, 0, 0)
(0, 0, 0)

Case 3:
(0, 255, 0)
(128, 128, 0)
(0, 128, 128)
(85, 85, 85)
(128, 0, 128)
(0, 0, 255)
(255, 0, 0)
(0, 0, 0)
(255, 255, 255)
Thanks in advance!
_.

sumankar
A great helper
Posts: 286
Joined: Tue Mar 25, 2003 8:36 am
Location: calcutta
Contact:

Post by sumankar » Mon Mar 14, 2005 7:16 am

Looks good to me.My code (AC/PE) gives the same answers.

Regards,
Suman.

User avatar
_.B._
Experienced poster
Posts: 160
Joined: Sat Feb 07, 2004 7:50 pm
Location: Venezuela
Contact:

Good.

Post by _.B._ » Mon Mar 14, 2005 7:28 am

Thanks Suman!
Now I need some critical input to test the precission of my code :o
sumankar wrote:My code (AC/PE)
Remember blank lines are only between test cases, maybe you are printing one extra line at the end of the output.

Keep posting!
_.

sumankar
A great helper
Posts: 286
Joined: Tue Mar 25, 2003 8:36 am
Location: calcutta
Contact:

Post by sumankar » Mon Mar 14, 2005 7:47 am

Code: Select all

r = (int)(((double)r+0.5)/(double)k );
                g = (int)(((double)g+0.5)/(double)k);
                b = (int)(((double)b+0.5)/(double)k);
changed my code from WA to AC/PE.

Code: Select all

r = (int)(((double)r)/(double)k + 0.5);
                g = (int)(((double)g)/(double)k + 0.5);
                b = (int)(((double)b)/(double)k + 0.5);
I know about that PE thing, but I am tooo lazy to print newlines correctly :P

Regards,
Suman.

User avatar
_.B._
Experienced poster
Posts: 160
Joined: Sat Feb 07, 2004 7:50 pm
Location: Venezuela
Contact:

Nada.

Post by _.B._ » Mon Mar 14, 2005 8:01 am

I'll have to post my code to see if anyone can help me, because I am using:

unsigned int r, g, b, divisor;

Code: Select all

r = (double(r) / divisor) + .5;
g = (double(g) / divisor) + .5;
b = (double(b) / divisor) + .5;
and got WA, after your example, changed it to:

Code: Select all

r = (double(r) / double(divisor)) + .5;
g = (double(g) / double(divisor)) + .5;
b = (double(b) / double(divisor)) + .5;
and still WA :o

Maybe the reading of the data?

Code: Select all

Code posted below.
Last edited by _.B._ on Tue Mar 15, 2005 5:21 am, edited 1 time in total.
_.

sumankar
A great helper
Posts: 286
Joined: Tue Mar 25, 2003 8:36 am
Location: calcutta
Contact:

Post by sumankar » Mon Mar 14, 2005 8:26 am

So, how do you check if your point lies on a circle, or not?And squares?
Also, how do you calculate r?what is the starting value for color of a particular point?

Suman.

User avatar
A1
Experienced poster
Posts: 173
Joined: Wed Jan 28, 2004 3:34 pm
Location: Bangladesh

Post by A1 » Mon Mar 14, 2005 9:32 am

if u need help on rounding check out the other post on this problem
I think there is no other post on this porblem :( . better you give me some hints.

sumankar
A great helper
Posts: 286
Joined: Tue Mar 25, 2003 8:36 am
Location: calcutta
Contact:

Post by sumankar » Mon Mar 14, 2005 10:28 am


mf
Guru
Posts: 1244
Joined: Mon Feb 28, 2005 4:51 am
Location: Zürich, Switzerland
Contact:

Post by mf » Mon Mar 14, 2005 11:57 am

I used this macro to round fractions p/q:
#define ROUND(p,q) ((int)((((double)(p)) / ((double)(q))) + 0.5 + 10e-9))

I got accepted without any problems.

User avatar
_.B._
Experienced poster
Posts: 160
Joined: Sat Feb 07, 2004 7:50 pm
Location: Venezuela
Contact:

Please, take a look.

Post by _.B._ » Mon Mar 14, 2005 12:56 pm

NOTE: Thanks sumankar. Changed code: added borde = false, but still WA :o

Greetings!
Here's part of my code for this problem. Any ideas?

Code: Select all

Code posted below.
Last edited by _.B._ on Tue Mar 15, 2005 5:22 am, edited 3 times in total.
_.

sumankar
A great helper
Posts: 286
Joined: Tue Mar 25, 2003 8:36 am
Location: calcutta
Contact:

Post by sumankar » Mon Mar 14, 2005 1:07 pm

Where are you differentiating between the fact that an object lies on
or within a circle/square.Your in_square method returns true for both the cases.

Suman.

Post Reply

Return to “Volume 108 (10800-10899)”