10351 - Cutting Diamonds
Moderator: Board moderators
-
- New poster
- Posts: 19
- Joined: Tue Jul 16, 2002 5:56 pm
- Location: Seoul
- Contact:
10351 - Cutting Diamonds
Sample outputs are Perfect.
But, I recieve WA, again.
My Solution is wrong?
[cpp]#include<stdio.h>
#define PI 3.14159265358979323846
double sqr(double a);
typedef struct _Coordinate
{
int x;
int y;
int z;
} Coordinate;
int main()
{
Coordinate Box[3], Diamond[3];
int i, j, count = 1;
bool first;
float min, result;
while(scanf("%d%d%d%d%d%d", &Box[0].x, &Box[0].y, &Box[0].z, &Diamond[0].x, &Diamond[0].y, &Diamond[0].z) > 0)
{
Box[2].z = Box[1].x = Box[0].y;
Box[2].x = Box[1].y = Box[0].z;
Box[2].y = Box[1].z = Box[0].x;
Diamond[2].z = Diamond[1].x = Diamond[0].y;
Diamond[2].x = Diamond[1].y = Diamond[0].z;
Diamond[2].y = Diamond[1].z = Diamond[0].x;
first = false;
for(i=0;i<3;i++)
for(j=0;j<3;j++)
if(Box.x < Diamond[j].x && ((Box.y >= Diamond[j].y && Box.z >= Diamond[j].z) ||
(Box.y >= Diamond[j].z && Box.z >= Diamond[j].y)))
{
result = PI * (Diamond[j].y / 2.0) * (Diamond[j].z / 2.0) * (1 - sqr(Box.x - Diamond[j].x / 2.0) / sqr(Diamond.x / 2.0));
if(first == false)
{
min = result;
first = true;
}
else if(min > result)
min = result;
}
printf("Set #%d\n", count++);
printf("%.6f\n", min);
}
return 0;
}
double sqr(double a)
{
return a*a;
}[/cpp]
But, I recieve WA, again.
My Solution is wrong?
[cpp]#include<stdio.h>
#define PI 3.14159265358979323846
double sqr(double a);
typedef struct _Coordinate
{
int x;
int y;
int z;
} Coordinate;
int main()
{
Coordinate Box[3], Diamond[3];
int i, j, count = 1;
bool first;
float min, result;
while(scanf("%d%d%d%d%d%d", &Box[0].x, &Box[0].y, &Box[0].z, &Diamond[0].x, &Diamond[0].y, &Diamond[0].z) > 0)
{
Box[2].z = Box[1].x = Box[0].y;
Box[2].x = Box[1].y = Box[0].z;
Box[2].y = Box[1].z = Box[0].x;
Diamond[2].z = Diamond[1].x = Diamond[0].y;
Diamond[2].x = Diamond[1].y = Diamond[0].z;
Diamond[2].y = Diamond[1].z = Diamond[0].x;
first = false;
for(i=0;i<3;i++)
for(j=0;j<3;j++)
if(Box.x < Diamond[j].x && ((Box.y >= Diamond[j].y && Box.z >= Diamond[j].z) ||
(Box.y >= Diamond[j].z && Box.z >= Diamond[j].y)))
{
result = PI * (Diamond[j].y / 2.0) * (Diamond[j].z / 2.0) * (1 - sqr(Box.x - Diamond[j].x / 2.0) / sqr(Diamond.x / 2.0));
if(first == false)
{
min = result;
first = true;
}
else if(min > result)
min = result;
}
printf("Set #%d\n", count++);
printf("%.6f\n", min);
}
return 0;
}
double sqr(double a)
{
return a*a;
}[/cpp]
-
- New poster
- Posts: 19
- Joined: Tue Jul 16, 2002 5:56 pm
- Location: Seoul
- Contact:
Judge Server is very Stupid...
This source is Accept...
Very similar Code, But compare parameter(i, j) is different.
Judge Server is very very stupid..!!!
[cpp]
#include<stdio.h>
#define PI 3.14159265358979323846
double sqr(double a);
typedef struct _Coordinate
{
int x;
int y;
int z;
} Coordinate;
int main()
{
Coordinate Box[3], Diamond[3];
int i, j, count = 1;
bool first;
double min, result;
while(scanf("%d%d%d%d%d%d", &Box[0].x, &Box[0].y, &Box[0].z, &Diamond[0].x, &Diamond[0].y, &Diamond[0].z) > 0)
{
Box[2].z = Box[1].x = Box[0].y;
Box[2].x = Box[1].y = Box[0].z;
Box[2].y = Box[1].z = Box[0].x;
Diamond[2].z = Diamond[1].x = Diamond[0].y;
Diamond[2].x = Diamond[1].y = Diamond[0].z;
Diamond[2].y = Diamond[1].z = Diamond[0].x;
first = false, min = 0, result = 0;
for(i=0;i<3;i++)
for(j=0;j<3;j++)
if(Box[j].x < Diamond.x &&
((Box[j].y == Diamond.y && Box[j].z == Diamond.z) ||
(Box[j].y == Diamond.z && Box[j].z == Diamond.y)))
{
result = PI *
(Diamond[j].y / 2.0) *
(Diamond[j].z / 2.0) *
(1 - sqr(Box[j].x - Diamond.x / 2.0) / sqr(Diamond.x / 2.0));
if(first == false)
{
min = result;
first = true;
}
else if(min > result)
min = result;
}
printf("Set #%d\n", count++);
printf("%.6lf\n", min);
}
return 0;
}
double sqr(double a)
{
return a*a;
}
[/cpp]
Very similar Code, But compare parameter(i, j) is different.
Judge Server is very very stupid..!!!
[cpp]
#include<stdio.h>
#define PI 3.14159265358979323846
double sqr(double a);
typedef struct _Coordinate
{
int x;
int y;
int z;
} Coordinate;
int main()
{
Coordinate Box[3], Diamond[3];
int i, j, count = 1;
bool first;
double min, result;
while(scanf("%d%d%d%d%d%d", &Box[0].x, &Box[0].y, &Box[0].z, &Diamond[0].x, &Diamond[0].y, &Diamond[0].z) > 0)
{
Box[2].z = Box[1].x = Box[0].y;
Box[2].x = Box[1].y = Box[0].z;
Box[2].y = Box[1].z = Box[0].x;
Diamond[2].z = Diamond[1].x = Diamond[0].y;
Diamond[2].x = Diamond[1].y = Diamond[0].z;
Diamond[2].y = Diamond[1].z = Diamond[0].x;
first = false, min = 0, result = 0;
for(i=0;i<3;i++)
for(j=0;j<3;j++)
if(Box[j].x < Diamond.x &&
((Box[j].y == Diamond.y && Box[j].z == Diamond.z) ||
(Box[j].y == Diamond.z && Box[j].z == Diamond.y)))
{
result = PI *
(Diamond[j].y / 2.0) *
(Diamond[j].z / 2.0) *
(1 - sqr(Box[j].x - Diamond.x / 2.0) / sqr(Diamond.x / 2.0));
if(first == false)
{
min = result;
first = true;
}
else if(min > result)
min = result;
}
printf("Set #%d\n", count++);
printf("%.6lf\n", min);
}
return 0;
}
double sqr(double a)
{
return a*a;
}
[/cpp]
-
- Guru
- Posts: 724
- Joined: Wed Dec 19, 2001 2:00 am
- Location: Germany
Can anybody see what's wrong with this code? I'm getting WA....
For the input My program gives:Can anybody who got AC verify it for me?
Code: Select all
#include <iostream>
#include <math.h>
using namespace std;
typedef long double ld;
int a, b, c, aa, bb, cc;
ld getcut(ld mx, ld a, ld b, ld c){
ld d = abs(mx - a/2);
b *= 0.5*sqrt(1 - 4*d*d/(a*a));
c *= 0.5*sqrt(1 - 4*d*d/(a*a));
return 2*acos((ld)0.0)*c*b;
}
int main(){
cout.setf(ios::fixed);
cout.precision(6);
int test = 1;
while(cin >> a >> b >> c >> aa >> bb >> cc){
cout << "Set #" << test++ << endl;
if(aa > a) cout << getcut(a, aa, bb, cc) << endl;
else if(bb > b) cout << getcut(b, bb, aa, cc) << endl;
else if(cc > c) cout << getcut(c, cc, aa, bb) << endl;
else cout << 0.0 << endl;
}
return 0;
}
Code: Select all
7 6 4 8 6 4
4 8 8 8 8 8
17 18 19 17 18 19
16 18 19 17 18 19
17 17 19 17 18 19
17 18 18 17 18 19
15 18 19 17 18 19
17 16 19 17 18 19
17 18 17 17 18 19
14 18 19 17 18 19
17 15 19 17 18 19
17 18 16 17 18 19
1 18 19 17 18 19
17 1 19 17 18 19
17 18 1 17 18 19
7 18 19 17 18 19
17 8 19 17 18 19
17 18 9 17 18 19
8 18 19 17 18 19
17 9 19 17 18 19
17 18 6 17 18 19
Code: Select all
Set #1
8.246681
Set #2
50.265482
Set #3
0.000000
Set #4
59.483720
Set #5
53.242238
Set #6
47.933220
Set #7
111.531974
Set #8
100.220684
Set #9
90.540526
Set #10
156.144764
Set #11
140.935337
Set #12
127.821919
Set #13
59.483720
Set #14
53.242238
Set #15
47.933220
Set #16
260.241274
Set #17
250.551710
Set #18
239.666099
Set #19
267.676739
Set #20
253.683607
Set #21
207.710619
This code gets wrong answer!!
- There is no correction program written for this problem, so I am guessing precision problem!!
- I also get correct output for the input posted above.
- I tried using long double too, but no luck!
Edit:: no problem with precision.
- There is no correction program written for this problem, so I am guessing precision problem!!
- I also get correct output for the input posted above.
- I tried using long double too, but no luck!
Code: Select all
--x Code removed x--
Though unnecessary!!! AC code is posted above. :P
Last edited by sohel on Fri Aug 10, 2007 1:49 pm, edited 1 time in total.
-
- Guru
- Posts: 1080
- Joined: Thu Dec 19, 2002 7:37 pm
Quite strange indeed. I created an exhaustive test file containing all possible legal cases this way:
and then ran both our codes with it. Guess what: no differences.
So maybe the judge input contains illegal cases like "0 3 6 2 3 6" and "1 2 3 2 3 4" or even "1 2 3 1 2 2"? Should be easy to check with assert.
If the judge input is indeed rotten, and you feel like it, you could write a new one. I could PM you my accepted code. The approach is somewhat different, but the results should be the same.
Code: Select all
#include <stdio.h>
int main(){
int i1,i2,i3,j1,j2,j3;
for(j1=1;j1<20;j1++){
for(j2=1;j2<20;j2++){
for(j3=1;j3<20;j3++){
for(i1=1;i1<=j1;i1++) printf("%d %d %d %d %d %d\n",i1,j2,j3,j1,j2,j3);
for(i2=1;i2<=j2;i2++) printf("%d %d %d %d %d %d\n",j1,i2,j3,j1,j2,j3);
for(i3=1;i3<=j3;i3++) printf("%d %d %d %d %d %d\n",j1,j2,i3,j1,j2,j3);
}
}
}
return 0;
}
So maybe the judge input contains illegal cases like "0 3 6 2 3 6" and "1 2 3 2 3 4" or even "1 2 3 1 2 2"? Should be easy to check with assert.
If the judge input is indeed rotten, and you feel like it, you could write a new one. I could PM you my accepted code. The approach is somewhat different, but the results should be the same.
The biggest problem with most problems is not how to solve the problem, but how to not solve what is not the problem.
:-?
Just got Accepted!!!
It seems that there are some inputs in which [:: x_box > x_diamond | y_box > y_diamond | z_box > z_diamond ::]
Output for those cases should be '0.000000'.
After rereading the problemstatement, it doesn't say that the box can't be bigger than the diamond. So, I guess, the data is correct.
It seems that there are some inputs in which [:: x_box > x_diamond | y_box > y_diamond | z_box > z_diamond ::]
Output for those cases should be '0.000000'.
After rereading the problemstatement, it doesn't say that the box can't be bigger than the diamond. So, I guess, the data is correct.
