Page 1 of 2
815 - Flooded!
Posted: Fri Jun 28, 2002 3:43 pm
by jpfarias
Hi, anyone knows any trick input? i think my solution is ok but I'm getting WA!!!
Any help will be thankful received!!
Thanks,
Jo
Posted: Fri Jun 28, 2002 4:16 pm
by Ivor
You do know that this problem has 0% acceptance rate.
Couldn't resist reminding.
Ivor
same here!
Posted: Tue Aug 13, 2002 9:19 pm
by afernandez
I have the same problem: it keeps replying WA. The problem is very simple and my program works fine with all special cases I tested.
I have the feeling that either there is a bad testcase or there is some particularity that has not been properly described in the problem statement.

Posted: Thu Aug 15, 2002 2:33 pm
by mmikla10
A few special cases I'm not sure about:
- What's the water level if there is no rain at all? (The same as the lowest point?)
- Is the landscape completly enclosed: may water level exceed the highest point in the region?
- Are the regions under the sea level already "flooded" by the sea even before any rain falls? (Although I don't believe so.)
Bye, Mojca
Judge's answer
Posted: Thu Aug 22, 2002 11:55 pm
by Carlos
> A few special cases I'm not sure about:
> - What's the water level if there is no rain at all? (The same as the lowest point?)
There is not such case on th input.
> - Is the landscape completly enclosed: may water level exceed the highest point in the region?
Of course it can, if there's a lot of water every point will be underwater.
> - Are the regions under the sea level already "flooded" by the sea even before any rain falls? (Although I don't believe so.)
No, they are not. There isn't sea on this land.
One hint, in some test cases, the exact answer may be:
1.235
you should print 1.24 instead of 1.23.
If you keep getting WA, mail us:
problemset@acm.uva.es and send us your source code.
Ciao!!
Carlos.
Posted: Fri Aug 23, 2002 6:11 am
by Ivan Golubev
marceh wrote:One hint, in some test cases, the exact answer may be:
1.235
you should print 1.24 instead of 1.23.
And if exact answer is -1.235 what we're need to output, -1.24 or -1.23?
...May be this problem needs correction program?
Also there is something wrong with limits -- problem's description states
Each begins with a pair of integers, m and n, each less than 30...
but this code gets assertion failed:
Code: Select all
while (scanf("%d %d\n", &r, &c) == 2) {
if (r == 0 && c == 0) break;
assert(r >= 1 && r < 30);
assert(c >= 1 && c < 30);
...
Changing this into
Code: Select all
assert(r >= 1 && r < 60);
assert(c >= 1 && c < 60);
gives me WA instead of RTE.
Posted: Thu Oct 10, 2002 2:06 am
by Santiago Zanella
Posts can't be deleted but edited? uh
Help checking solution
Posted: Thu Oct 10, 2002 2:07 am
by Santiago Zanella
I wonder if someone that have already solved this problem could help me.
There must be some tricky input or something wrong with my solution.
Any help is welcome.
[c]
#include <stdio.h>
#include <search.h>
#include <math.h>
/* Although the statement says that m and n will be less than 30, they can actually reach 30 */
int i, j, m, n, w, r, A[901]; /* A[30*30+1] */
int compare(const void *, const void *);
void solve();
void main()
{
for(r=1;;r++) {
/* Get region dimensions */
scanf("%d %d", &m, &n);
/* Check for end of input */
if(m==0 && n==0) break;
/* Follow the output of each input with a blank line */
if(r>1) printf("\n");
/* Get elevations */
for(i=0; i<m*n; i++)
scanf("%d", &A
);
/* Get water that collects in the region */
scanf("%d", &w);
/* Output answer */
solve();
}
}
int compare( const void *arg1, const void *arg2 )
{
return (*(int *)arg1 - *(int *)arg2);
}
void solve()
{
double h, t;
/* First sort the elevations in ascendant order */
qsort(A, m*n, sizeof(A[0]), compare);
/* Sentinel */
A[m*n] = 2147483647;
/* Then incrementally flood the squares until all water is distributed */
/* h = temporary water level */
/* t = water already distributed */
t = 0;
for(i=0; i<m*n; i++) {
for(j=i+1; A[j]<=A && j<=m*n; j++);
t += fabs(A[j]-A)*j*100.0;
if(t>=w) {
t -= fabs(A[j]-A)*j*100.0;
h = A+(w-t)/(j*100.0);
goto flooded;
}
}
flooded:
printf("Region %d\n", r);
printf("Water level is %.2f meters.\n", h);
printf("%.2f percent of the region is under water.\n", (j*100.0)/(m*n));
}
[/c]
What's wrong?
Posted: Thu Oct 10, 2002 7:24 pm
by cytse
I have tested your program with my testdata. Your program fails at this case:
2 2
1 1
1 2
301
0 0
Posted: Fri Oct 11, 2002 5:44 am
by Santiago Zanella
Thank you cytse!
There was a little big error that wasn't shown in my test cases.
Posted: Mon May 19, 2003 12:26 pm
by ashutoshkorde
there has to be a special input case cos my program is working for all the inputs i can possiblly think of. just need that one special case ....
what if the water level equals the elevation of a region for e.g.
2 2
1 0
0 1
200
0 0
should this print area covered as 50% or 100% ???
Posted: Fri Jul 25, 2003 9:23 am
by bobi1978
Here is the output for this case:
INPUT:
2 2
1 0
0 1
200
OUTPUT:
Region 1
Water level is 1.00 meters.
50.00 percent of the region is under water.
any special case?
Posted: Sat Sep 27, 2003 7:10 am
by snick
I got this output for this test case.
could anyone give some test cases for negative inputs??
is there any special cases?
thank you!~!
2 2
1 1
1 2
301
Region 1
Water level is 2.00 meters.
100.00 percent of the region is under water.
[/cpp]
Posted: Fri Oct 03, 2003 2:14 pm
by snick
I got WA still
anyone have special test cases for this question?
especially negative values
thank you!
815 compile error
Posted: Mon Sep 06, 2004 5:38 pm
by Gazi Shaheen Hossain
Can anyone help me?
the code given below (for 815 in c++) gives me compile error
[cpp]
#include <stdio.h>
void main()
{
int m,n,squr;
unsigned long i,j,region=1;
char flag=0;
double sqr[900],water,dif,under,count,lebel;
while(1)
{
scanf("%d %d",&m,&n);
if(m==0&&n==0)break;
if(flag)printf("\n");
flag=1;
squr=m*n;
for(i=0;i<squr;i++)
scanf("%lf",&sqr);
scanf("%lf",&water);
water/=100;
for(i=0;i<squr-1;i++)
for(j=i+1;j<squr;j++)
{
if(sqr>sqr[j])
{
dif=sqr;
sqr=sqr[j];
sqr[j]=dif;
}
}
printf("Region %lu\n",region++);
count=1;under=0;
for(i=1;i<squr;i++)
{
dif=sqr - sqr[i-1];
if((under + dif*count)<water )
under=under+dif*count;
else break;
count++;
}
lebel=sqr[count-1]+(water-under)/count;
printf("Water level is %.2lf meters.\n",lebel);
printf("%.2lf percent of the region is under water.\n",(count/squr*100));
}
}[/cpp]