815 - Flooded!
Moderator: Board moderators
815 - Flooded!
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
Any help will be thankful received!!
Thanks,
Jo
-
- New poster
- Posts: 1
- Joined: Tue Aug 13, 2002 9:11 pm
same here!
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.
![:(](./images/smilies/icon_frown.gif)
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.
![:(](./images/smilies/icon_frown.gif)
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
- 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
-
- System administrator
- Posts: 1286
- Joined: Sat Oct 13, 2001 2:00 am
- Location: Valladolid, Spain
- Contact:
Judge's answer
> 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.
> - 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.
-
- Experienced poster
- Posts: 167
- Joined: Fri Oct 19, 2001 2:00 am
- Location: Saint Petersburg, Russia
And if exact answer is -1.235 what we're need to output, -1.24 or -1.23?marceh wrote:One hint, in some test cases, the exact answer may be:
1.235
you should print 1.24 instead of 1.23.
...May be this problem needs correction program?
Also there is something wrong with limits -- problem's description states
but this code gets assertion failed:Each begins with a pair of integers, m and n, each less than 30...
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);
...
Code: Select all
assert(r >= 1 && r < 60);
assert(c >= 1 && c < 60);
-
- New poster
- Posts: 10
- Joined: Tue Oct 01, 2002 11:37 pm
Posts can't be deleted but edited? uh
Last edited by Santiago Zanella on Thu Oct 10, 2002 2:10 am, edited 1 time in total.
-
- New poster
- Posts: 10
- Joined: Tue Oct 01, 2002 11:37 pm
Help checking solution
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?
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]
![:roll:](./images/smilies/icon_rolleyes.gif)
-
- New poster
- Posts: 10
- Joined: Tue Oct 01, 2002 11:37 pm
-
- New poster
- Posts: 6
- Joined: Mon May 05, 2003 1:48 pm
any special case?
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]
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]
-
- New poster
- Posts: 7
- Joined: Fri Sep 03, 2004 6:47 pm
815 compile error
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]
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]