602 - What Day Is It?

All about problems in Volume 6. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

beeplove
New poster
Posts: 17
Joined: Tue Sep 30, 2003 9:28 pm
Location: Boston, MA, USA
Contact:

Post by beeplove »

From what year we should consider leap year?
is it from the Julian modified the calander ( year is not given in the calander)?
or from 1 1 1?

There is is no date between 2 sep 1752 14 sep 1752, is it right?
deddy one
Experienced poster
Posts: 120
Joined: Tue Nov 12, 2002 7:36 pm

Post by deddy one »

leap year after 1752 is considered like this
[c]if ((!(year%4) && year%100) || !(year%400))[/c]

leap year <= 1752 is considered like
[c]if (!(year%4))[/c]

yes there is is no date between 2 sep 1752 14 sep 1752,
2 sep and 14 sep 1752 is valid.
the invalid one is from 3 sep to 13 sep 1752.

happy hunting..
beeplove
New poster
Posts: 17
Joined: Tue Sep 30, 2003 9:28 pm
Location: Boston, MA, USA
Contact:

602

Post by beeplove »

I would request to fix the problem 602.

This problem need a reference weekday. like September 14, 1752 was saturday. Otherwise, programmers will have to create their own reference from current date or some other date. As a programmer, I dont want to make a reference from my own.

If you notice in 'Sample Input' and 'Sample Output' section of the problem, you guys will notice September 2, 1752 is a Wednesday and September 14, 1752 is a Thursday. If September 2 to be declared as September 14 then either september 2 and september 14 is same day or september 2 is an invalid day.

Also from the board I have noticed, year 0 is a valid year that should not be.

Do you guys think "Problem 602 need to be fixed"?
Adrian Kuegel
Guru
Posts: 724
Joined: Wed Dec 19, 2001 2:00 am
Location: Germany

Post by Adrian Kuegel »

If you notice in 'Sample Input' and 'Sample Output' section of the problem, you guys will notice September 2, 1752 is a Wednesday and September 14, 1752 is a Thursday. If September 2 to be declared as September 14 then either september 2 and september 14 is same day or september 2 is an invalid day.
Did you read the problem description careful?
You should have noticed this:
...when the day following September 2 was declared to be September 14...
So it is not that September 2 is same day as September 14, only that there is no date between 3 and 13 (inclusive).
beeplove
New poster
Posts: 17
Joined: Tue Sep 30, 2003 9:28 pm
Location: Boston, MA, USA
Contact:

Post by beeplove »

Sorry, not to notice the word 'following'.
What about day reference?
Adrian Kuegel
Guru
Posts: 724
Joined: Wed Dec 19, 2001 2:00 am
Location: Germany

Post by Adrian Kuegel »

In my opinion there is no need for a day reference, because it is given implicitly in the sample output. You have to try only 7 assignments of weekdays to your reference date, the one with which your program matches the sample output is the right one.
Larry
Guru
Posts: 647
Joined: Wed Jun 26, 2002 10:12 pm
Location: Hong Kong and New York City
Contact:

Post by Larry »

Can someone post some cases? I've passed everyone's except for the year 0's, and it's not on the judge, but I get WA..
Maddas
New poster
Posts: 11
Joined: Sat Apr 03, 2004 1:45 am

602 WA -- why?

Post by Maddas »

hi
I'm about to give up now :-(
I tested my program with lots of input and it always works
but when I send it I get WA
only thing that I didn't do is for year 0, but I read year 0 doesn't come anyway so that shouldn't matter

I also tried with this input:
2 28 0
2 29 0
1 1 1
9 10 2500
5 5 999
7 3 8888
2 27 1000
2 28 1000
2 29 1000
2 30 1000
3 1 1000
2 27 1400
2 28 1400
2 29 1400
2 30 1400
3 1 1400
2 27 1800
2 28 1800
2 29 1800
2 30 1800
3 1 1800
2 27 2000
2 28 2000
2 29 2000
2 30 2000
3 1 2000
2 27 2100
2 28 2100
2 29 2100
2 30 2100
3 1 2100
2 27 10000
2 28 10000
2 29 10000
2 30 10000
3 1 10000
10 1 1752
10 2 1752
11 1 1752

0 0 0
that I got from another post. My program always displays things correctly.
Why could I get WA?? A missing newline or something? But that would be PE not WA
Any ideas appreciated, thanks :(
alu_mathics
Learning poster
Posts: 55
Joined: Sat Jan 24, 2004 9:30 pm
Location: Chittagong
Contact:

Post by alu_mathics »

My ac program gives the following outputs for your inputs.
input:

2 28 0
2 29 0
1 1 1
9 10 2500
5 5 999
7 3 8888
2 27 1000
2 28 1000
2 29 1000
2 30 1000
3 1 1000
2 27 1400
2 28 1400
2 29 1400
2 30 1400
3 1 1400
2 27 1800
2 28 1800
2 29 1800
2 30 1800
3 1 1800
2 27 2000
2 28 2000
2 29 2000
2 30 2000
3 1 2000
2 27 2100
2 28 2100
2 29 2100
2 30 2100
3 1 2100
2 27 10000
2 28 10000
2 29 10000
2 30 10000
3 1 10000
10 1 1752
10 2 1752
11 1 1752

0 0 0

output:

February 28, 0 is a Sunday
February 29, 0 is a Monday
January 1, 1 is a Saturday
September 10, 2500 is a Friday
May 5, 999 is a Friday
July 3, 8888 is a Saturday
February 27, 1000 is a Tuesday
February 28, 1000 is a Wednesday
February 29, 1000 is a Thursday
2/30/1000 is an invalid date.
March 1, 1000 is a Friday
February 27, 1400 is a Friday
February 28, 1400 is a Saturday
February 29, 1400 is a Sunday
2/30/1400 is an invalid date.
March 1, 1400 is a Monday
February 27, 1800 is a Thursday
February 28, 1800 is a Friday
2/29/1800 is an invalid date.
2/30/1800 is an invalid date.
March 1, 1800 is a Saturday
February 27, 2000 is a Sunday
February 28, 2000 is a Monday
February 29, 2000 is a Tuesday
2/30/2000 is an invalid date.
March 1, 2000 is a Wednesday
February 27, 2100 is a Saturday
February 28, 2100 is a Sunday
2/29/2100 is an invalid date.
2/30/2100 is an invalid date.
March 1, 2100 is a Monday
February 27, 10000 is a Sunday
February 28, 10000 is a Monday
February 29, 10000 is a Tuesday
2/30/10000 is an invalid date.
March 1, 10000 is a Wednesday
October 1, 1752 is a Sunday
October 2, 1752 is a Monday
November 1, 1752 is a Wednesday
cuii e
Maddas
New poster
Posts: 11
Joined: Sat Apr 03, 2004 1:45 am

Post by Maddas »

My program gives the same output:
February 28, 0 is a Sunday
February 29, 0 is a Monday
January 1, 1 is a Saturday
September 10, 2500 is a Friday
May 5, 999 is a Friday
July 3, 8888 is a Saturday
February 27, 1000 is a Tuesday
February 28, 1000 is a Wednesday
February 29, 1000 is a Thursday
2/30/1000 is an invalid date.
March 1, 1000 is a Friday
February 27, 1400 is a Friday
February 28, 1400 is a Saturday
February 29, 1400 is a Sunday
2/30/1400 is an invalid date.
March 1, 1400 is a Monday
February 27, 1800 is a Thursday
February 28, 1800 is a Friday
2/29/1800 is an invalid date.
2/30/1800 is an invalid date.
March 1, 1800 is a Saturday
February 27, 2000 is a Sunday
February 28, 2000 is a Monday
February 29, 2000 is a Tuesday
2/30/2000 is an invalid date.
March 1, 2000 is a Wednesday
February 27, 2100 is a Saturday
February 28, 2100 is a Sunday
2/29/2100 is an invalid date.
2/30/2100 is an invalid date.
March 1, 2100 is a Monday
February 27, 10000 is a Sunday
February 28, 10000 is a Monday
February 29, 10000 is a Tuesday
2/30/10000 is an invalid date.
March 1, 10000 is a Wednesday
October 1, 1752 is a Sunday
October 2, 1752 is a Monday
November 1, 1752 is a Wednesday
Where could the problem be? I think I tested all special cases
Maddas
New poster
Posts: 11
Joined: Sat Apr 03, 2004 1:45 am

Post by Maddas »

I found the problem. The problem is the input!
In the problem description it says:
The format for a date is ``month day year" where month is a number between 1 (which indicates January) and 12 (which indicates December), day is a number between 1 and 31, and year is positive number
But that is not correct!
There is a month that is passed that is larger than 12.
My problem was that I didn't check for that because it said that wouldn't happen in the problem description.
Examiner
New poster
Posts: 28
Joined: Thu Feb 19, 2004 1:19 pm

Post by Examiner »

Try this:

Code: Select all

 Input:

 9  2 1752
 9 14 1752
 9 15 1752
 9 30 1752
10  1 1752
12 31 1752
 1  1 1753
pasear
New poster
Posts: 2
Joined: Wed Sep 01, 2004 9:14 am
Location: Taiwan

602 (costs many memory)

Post by pasear »

hello there.
I've solved 602, and received a mail saying...
--
Your C program has solved Ok the problem 602 (What Day Is It?)
in 0.148 seconds using as much as 396 kbytes of virtual memory.
Congratulations!
--

However, I think it very strange in the size of memory used
because I do not use any big arrays (not larger than 15 elements)
or malloc anything, and I have tried to use as few variables as needed.
even the source code is only 2k in size with many lines of comments.

my program simply get one line from the input, compute the date,
print it, and then enter next loop, so i do not need to store each input.

I find in the problem stat page (http://acm.uva.es/cgi-bin/OnlineJudge?ProblemStat:602),
almost every one uses 3xx kb of memory,
so maybe it's not my problem.

In my previous solved problem, 158, the biggest array I opened stored at least 10000 element of some struct, but it turned out to be consuming less than 64k memory.

so can any one tell me how memory usage is calculated ?
I'm totally confused now.

thank u very much.
Dominik Michniewski
Guru
Posts: 834
Joined: Wed May 29, 2002 4:11 pm
Location: Wroclaw, Poland
Contact:

Post by Dominik Michniewski »

You try to solve any problem at acm.zju.edu.cn and you see that always program in C/C++ gives 3xx kB of memory - it's size of executable file I think. On this page judge has a little problem with memory measurement, so if your program finish work fast, it could be scored with 64kB of memory ;-) (fast means not more than 0.07 or 0.08s I think) Your program take more time, so judge got memory usage as he write in message :-)
Sometimes it's very strange. I solved once problem using static array of 1MB for input, but I exist in scoreborad with 64kB of used memory - so I think, that you should think that time of execution is more important that memory usage :-)

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)
pasear
New poster
Posts: 2
Joined: Wed Sep 01, 2004 9:14 am
Location: Taiwan

Post by pasear »

well, from the ranklist of 602

12 0:00.096 64 Andrey Mokhov C++
13 0:00.102 388 Kevin Cheung C

So maybe the longest time for being misjudged 64k was about 0:00.099.

I've rewrited my code, but still can't reach it :(

this time i simply added a input buffer(so the memory used was high) ,
and then found it cost 0:00.115.

=.= the ranked first person is toooooo terrible.
Post Reply

Return to “Volume 6 (600-699)”