Is my output correct for this case:
Code: Select all
8
1 1 1 1 1 2 1 3 1 3 1 4 4 5 5 4 6 7 7 6 8 1 0 0
8 1 2 3 4 5 6 7 8
0
Code: Select all
Case #1:
1.500
0.250
0.500
infinity
infinity
0.000
0.000
0.000
Moderator: Board moderators
Code: Select all
8
1 1 1 1 1 2 1 3 1 3 1 4 4 5 5 4 6 7 7 6 8 1 0 0
8 1 2 3 4 5 6 7 8
0
Code: Select all
Case #1:
1.500
0.250
0.500
infinity
infinity
0.000
0.000
0.000
Yes.shamim wrote:Does the solution involve solving a system of linear equations.
Code: Select all
3
1 2 2 3 3 2 0 0
3 1 2 3
5
1 2 2 3 3 2 3 4 4 5 5 4 0 0
5 1 2 3 4 5
3
1 2 1 3 2 3 3 3 0 0
3 1 2 3
0
Code: Select all
Case #1:
1.000
infinity
infinity
Case #2:
1.000
2.000
2.000
infinity
infinity
Case #3:
1.000
0.500
infinity
I assume that it is due to the fact that 1e-15 is already quite on the boundary of the precision of double. The precision error in your computations can easily be larger than that.shamim wrote:I was getting tons of WAs when I made zero comparison as
fabs(x) < 1e-15, but when I changed it to fabs(x) < 1e-8, I got AC.
Code: Select all
#include <stdio.h>
#define EPSILON (1.0e-8)
--- CODE DELETED ---
Finally got the red letters by setting EPSILON to 1.0e-11
Code: Select all
5
1 4 1 4 5 1 1 2 5 5 2 5 5 3 1 4 5 2 3 1 3 4 3 2 0 0
5 1 2 3 4 5
5
2 4 3 4 1 2 2 3 3 2 2 1 3 3 1 3 1 5 1 3 0 0
5 1 2 3 4 5
0
Code: Select all
Case #1:
1.250
0.563
0.187
1.000
0.750
Case #2:
1.250
0.750
1.312
0.687
0.313
Code: Select all
Case #1:
1.250
0.563
0.188
1.000
0.750
Case #2:
1.250
0.750
1.313
0.688
0.313
Code: Select all
Case #1:
1.2500000000
0.5625000000
0.1875000000
1.0000000000
0.7500000000
Case #2:
1.2500000000
0.7500000000
1.3125000000
0.6875000000
0.3125000000