Page 1 of 2
10203 - Snow Clearing
Posted: Thu Jan 10, 2002 9:58 pm
by Even
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...

Posted: Thu Jan 10, 2002 10:17 pm
by Adrian Kuegel
You should print the seconds with leading zeros (in C %02d).
Posted: Fri Jan 11, 2002 2:45 pm
by Even
here I make two mistake ...
1. when min round to 60, it should be 00, and hour should add 1.
2. just like Adrian Kuegel says... min should has leading zero...
that is, ex) 3:5 ...you should show 3:05, not 3:5 or 03:05 ...
thank you ...Adrian Kuegel...
10203
Posted: Fri Jan 31, 2003 8:27 pm
by razibcse
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]
Posted: Sun Feb 02, 2003 6:32 pm
by gvcormac
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
10203 is the judge wrong?
Posted: Thu Oct 09, 2003 4:42 pm
by Cosmin.ro
Even the official solution from Waterloo gets wa on this problem.
Posted: Thu Oct 09, 2003 10:35 pm
by Adrian Kuegel
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.
10203 Snow Clearing
Posted: Tue Apr 20, 2004 9:43 am
by zacharyleung
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]
Posted: Tue Apr 20, 2004 9:09 pm
by Dominik Michniewski
Think again - it's not good to use flating numbers ... exists simple solution which operates only on integers
Best regards
DM
Posted: Tue May 04, 2004 7:55 am
by zacharyleung
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?
Posted: Tue May 04, 2004 8:53 am
by Dominik Michniewski
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
Posted: Sat Jul 31, 2004 8:41 am
by sidky
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)?
10203
Posted: Thu Nov 18, 2004 2:34 pm
by WR
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:
And - if nothings's wrong, why do I get WA?
I've tried int, long and double as co-ordinate types (in C).
10203
Posted: Fri Feb 25, 2005 5:48 am
by Rony
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 ."
Posted: Sat Feb 26, 2005 6:07 am
by Guest
Sorry my post was wrong !