## 10203 - Snow Clearing

Moderator: Board moderators

Even
Learning poster
Posts: 75
Joined: Thu Nov 22, 2001 2:00 am
Location: Taiwan

### 10203 - Snow Clearing

it says that...all roads are perfectly straight, with one lane in each direction ...

it means that every road has two lane ???
(from begin to end & from end to begin )

if it is, each graph's vertex should always have even degree, and Euler circuit always exist ...

if not, why sample output is 3:55?

I am confuse...can anybody help me? thx... Guru
Posts: 724
Joined: Wed Dec 19, 2001 2:00 am
Location: Germany
You should print the seconds with leading zeros (in C %02d).

Even
Learning poster
Posts: 75
Joined: Thu Nov 22, 2001 2:00 am
Location: Taiwan
here I make two mistake ...

1. when min round to 60, it should be 00, and hour should add 1.

that is, ex) 3:5 ...you should show 3:05, not 3:5 or 03:05 ...

razibcse
New poster
Posts: 50
Joined: Mon Jul 22, 2002 3:17 am
Contact:

### 10203

I thot this is very easy...

just sum all the distances,double the distance and divide by 20...

but this is getting WA....

can anybody help me with this...

Code: Select all

``````#include <stdio.h>
#include <math.h>

void main()
{

float sum,x_start,x_end,y_start,y_end;
float x1,y1,x2,y2,dis,x_dif,y_dif,min_time,gap,dif;
long hour,minute,hanger_x,hanger_y,n,x,gap_dif;
scanf("%ld",&n);
for(x=0;x<n;x++)
{

scanf("%ld %ld",&hanger_x,&hanger_y);
sum=0;
while(scanf("%f %f %f %f",&x1,&y1,&x2,&y2)==4)
{
x_start=x1/1000;
y_start=y1/1000;
x_end=x2/1000;
y_end=y2/1000;

x_dif=x_end-x_start;
if(x_dif<0)
x_dif=(-1.0)*x_dif;

y_dif=y_end-y_start;
if(y_dif<0)
y_dif=(-1.0)*y_dif;

dis=sqrt((x_dif*x_dif)+(y_dif*y_dif));
sum+=dis;
}
min_time=sum/10.0;

hour=(long)min_time;

dif=min_time-hour;

gap=(min_time-hour)*60;
gap_dif=(long)gap;

if((gap-gap_dif)>0.00)
minute=(long)(gap+1);
else if((gap-gap_dif)==0.00)
minute=(long)gap;
printf("%ld:%ld\n",hour,minute);
}
}
``````
[/code]

gvcormac
Problemsetter & Reviewer
Posts: 194
Joined: Fri Mar 15, 2002 2:00 am
Contact:
I see at least two errors in your code.

In order to find them, consider all the inputs
that might yield an anwer of

3:00

Cosmin.ro
Learning poster
Posts: 95
Joined: Thu Aug 21, 2003 12:02 am

### 10203 is the judge wrong?

Even the official solution from Waterloo gets wa on this problem.

Guru
Posts: 724
Joined: Wed Dec 19, 2001 2:00 am
Location: Germany
This problem is in multiple input format, so of course the waterloo solution gets WA because it expects other input format.
If you don't know multiple input format, read here: http://online-judge.uva.es/problemset/minput.html
Each problem with a blue checkmark or with a green checkmark is in multiple input format.

zacharyleung
New poster
Posts: 14
Joined: Tue Feb 03, 2004 3:43 am

### 10203 Snow Clearing

I'm quite sure my code is correct, could anyone tell me what's wrong, cos I keep on getting WA....

[cpp]
#include <cstdio>
#include <cmath>
#include <cstring>

#define DEBUG(var) cout << #var << " = " << var << endl;
#define LINE cout << __LINE__ << endl;

const int MAX_LINE_LEN = 100;

void test();

int main() {
/*
test();
return 0;
*/

int n_cases;
double distance;
int x1, y1, x2, y2;
double time;
int hour, minute;
char buf[ MAX_LINE_LEN ];

scanf( "%d", &n_cases );
for( int case_num = 0; case_num < n_cases; case_num++ ) {
distance = 0;
scanf( "%d %d\n", &x1, &y1 );
while( fgets( buf, MAX_LINE_LEN, stdin ) != NULL ) {
if( buf[ 0 ] == '\n' )
break;
sscanf( buf, "%d %d %d %d", &x1, &y1, &x2, &y2 );
distance += sqrt( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) );
}

time = distance / 10000.0;
hour = (int) time;
minute = (int) ((time - hour) * 60 + 0.5);
if( minute == 60 ) {
minute = 0;
hour++;
}

if( case_num != 0 )
printf( "\n" );
printf( "%d:", hour );
if( minute < 10 )
printf( "0%d\n", minute );
else
printf( "%d\n", minute );
}

return 0;
}

/*
* Test values:
* 2.99 2:59
* 2.9999 3:00
* 3.001 3:00
* 3.01 3:01
*/
void test() {
float time;
int hour, minute;

time = 3.01;
hour = (int) time;
minute = (int) ((time - hour) * 60 + 0.5);

if( minute == 60 ) {
minute = 0;
hour++;
}
printf( "%d:", hour );
if( minute < 10 )
printf( "0%d\n", minute );
else
printf( "%d\n", minute );
}
[/cpp]
For God so loved the world, that he gave his only Son, that whoever believes in him should not perish but have eternal life.
(John 3:16)

Dominik Michniewski
Guru
Posts: 834
Joined: Wed May 29, 2002 4:11 pm
Location: Wroclaw, Poland
Contact:
Think again - it's not good to use flating numbers ... exists simple solution which operates only on integers Best regards
DM
If you really want to get Accepted, try to think about possible, and after that - about impossible ... and you'll get, what you want ....
Born from ashes - restarting counter of problems (800+ solved problems)

zacharyleung
New poster
Posts: 14
Joined: Tue Feb 03, 2004 3:43 am
I tried to think about it, but I really have no idea how to do that. Since we use the square root of x^2 and y^2, won't that always be a float?
For God so loved the world, that he gave his only Son, that whoever believes in him should not perish but have eternal life.
(John 3:16)

Dominik Michniewski
Guru
Posts: 834
Joined: Wed May 29, 2002 4:11 pm
Location: Wroclaw, Poland
Contact:
Sorry, I make wrong comment I see ...

My solution is mainly the same (counting distance) ... but I in different way compute time ...

Best regards
DM
If you really want to get Accepted, try to think about possible, and after that - about impossible ... and you'll get, what you want ....
Born from ashes - restarting counter of problems (800+ solved problems)

sidky
New poster
Posts: 50
Joined: Wed Nov 06, 2002 1:37 pm
Location: Planet Earth, Universe
Contact:
I am a little confused about the problem. I thought this is like the 'Chinese postman problem'. But from the previous posts, i think i misunderstood. Can anyone please tell me, should we traverse each road twice, or at least once (like the postmans problem)?

WR
Experienced poster
Posts: 145
Joined: Thu Nov 27, 2003 9:46 am

### 10203

What's wrong with the following results?

input:

Code: Select all

``````3

0 0
0 0 10000 10000
5000 -10000 5000 10000
5000 10000 10000 10000

0 0
0 0 19999 0

10 10
-10000 -10000 10000 10000
10000 10000 -10000 10000
-10000 10000 -10000 -10000
-10000 -10000 10000 -10000
-298 -837 276 876
-10000 0 10000 0
``````
output:

Code: Select all

``````3:55

2:00

11:01
``````
And - if nothings's wrong, why do I get WA?

I've tried int, long and double as co-ordinate types (in C).

Rony
New poster
Posts: 16
Joined: Wed Jun 30, 2004 6:46 am
Location: Dhaka
Contact:

### 10203

Hi,
Can any one help me,what's wrong with the code that's why i am getting
wrong answer ? Or, can any one give me some test cases?
Here is my code.

#include<stdio.h>
#include<stdlib.h>
#include<math.h>
double x,y,a,b,c,d,r,sum,v,sec,min,hour,integer;

int main(){

int tcase,n;
v=50.0/9.0;
//freopen("input.txt","r",stdin);

scanf("%d",&tcase);
while(tcase--){
scanf("%lf %lf\n",&x,&y);
sum=0.0;
while(scanf("%lf %lf %lf %lf\n",&a,&b,&c,&d)==4){
r=sqrt((a-c)*(a-c)+(b-d)*(b-d));
sum+=r*2;
}
min=(sum/v)/60.0;
hour=min/60.0;
min=modf(hour,&integer);
if((min*60.0)>0&&(min*60.0)<10) printf("%.0lf:0%.0lf\n",integer,(min*60.0)+.05);

else if((min*60.0)>59.0){

integer+=1;
min=0;
printf("%.0lf:0%.0lf\n",integer,min);
}

else printf("%.0lf:%.0lf\n",integer,(min*60.0)+.05);

putchar(10);

}
return 0;
}

Thanks.
"Still, I like her ."

Guest
New poster
Posts: 39
Joined: Wed May 19, 2004 5:52 pm