10041 - Vito's Family

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

Moderator: Board moderators

_.B._
Experienced poster
Posts: 160
Joined: Sat Feb 07, 2004 7:50 pm
Location: Venezuela
Contact:

Thanks.

Post by _.B._ »

Thanks again little joey!.
Changed the code.
Still WA, so I believe the error is in my algo.
Going to take a look at it... over and over again, hehe.
Already read the other posts, but can't find what's wrong with mine.
Keep posting!.

Hey!, please evaluate the input posted above and tell me the output :)
_.
WR
Experienced poster
Posts: 145
Joined: Thu Nov 27, 2003 9:46 am

Post by WR »

My program (C this time) returns:

Code: Select all

0
119529
14245460
Oh, and read Little Joey's post carefully!

Seems we solved more or less the same problems. I'm still waiting
for a reply on problem 484. May be you could have another look at the post?

Thanks
_.B._
Experienced poster
Posts: 160
Joined: Sat Feb 07, 2004 7:50 pm
Location: Venezuela
Contact:

Clueless.

Post by _.B._ »

Greetings!.
WR, thanks for answering... but how come the output for
2 8 8
is
119529 ?. Shouldn't it be 0?.

< Starting to dislike Vito and his family >
_.
WR
Experienced poster
Posts: 145
Joined: Thu Nov 27, 2003 9:46 am

Post by WR »

Sorry, of course it should be zero. In fact my program returns zero.
I've probably mixed up your sample input when copying it.
Trying it again!

Code: Select all

0
0
62250
Hope it's ok this time.

Sorry again

Added 1 hour later:
The fault was not mixing up the data. My program still had a bug! The OJ didn't find it, though. I simply forgot to read the value when the number of relatives was one, so in your example 23 was the new number of relatives!

Thank you! Wouldn't have detected it without your sample data.
_.B._
Experienced poster
Posts: 160
Joined: Sat Feb 07, 2004 7:50 pm
Location: Venezuela
Contact:

Good/bad.

Post by _.B._ »

Heya WR!.
Glad the input helped you.
Don't worry about the previous output.
Now, that's the same output I get.
I've got EVERY SINGLE OUTPUT I'VE COMPARED.
Freaking Vito should stay where he is and not move.
Keep posting!.
_.
WR
Experienced poster
Posts: 145
Joined: Thu Nov 27, 2003 9:46 am

Post by WR »

Hi,

I just copied your program and tried some test cases.

They all worked well, but the last one failed!!

Just delete the 1 in the second line of your sample input:

Code: Select all

3
23
2 8 8
499 29999 ...
My program returns

Code: Select all

119529
14245460
14245460
Your program returns

Code: Select all

119529
Runtime error 106 at 0x0000F8F0
  0x0000F8F0
  0x000020A1
I used the Free Pascal compiler.

Hope it helps you to get rid of Vito and his family.
little joey
Guru
Posts: 1080
Joined: Thu Dec 19, 2002 7:37 pm

Post by little joey »

Deleting the 1 on the second line leaves the dataset invalid, so no conclusions can be drawn.

Try this test:

Code: Select all

1
16 5 49 12 23 29 100 44 47 69 41 23 12 11 6 2 62
Your program gives 371, but the correct answer is 347 (which can be achieved if Vito lives at no. 23).
I haven't studied your code, so I don't now why it fails.
_.B._
Experienced poster
Posts: 160
Joined: Sat Feb 07, 2004 7:50 pm
Location: Venezuela
Contact:

Thanks!.

Post by _.B._ »

Thanks WR and little joey!.
Indeed, if you take the 1 out, the problem rules won't apply, since the limit for the sum of distances would go beyond the expected according problem description.
Now, little joey, first time I've seen a wrong output from my program!!.
THANKS!!, I'll study it right now!!.
_.
_.B._
Experienced poster
Posts: 160
Joined: Sat Feb 07, 2004 7:50 pm
Location: Venezuela
Contact:

FINALLY AC!!!!!!!!!!!!!!!!!!!!.

Post by _.B._ »

FINALLY I GOT ME AC!!!!!!!!!!!!!!!!!!!! (one ``!'' for every WA I got with this one, hehe).
My error was ni the last part of the code.
I didn't consider the case my MMN and MMM sums were the same :roll:
It was a "IF <" error.
I got WA after fixing that, but since WR posted a result over 65000, I realized another mistake. The result could be over 65000, and I thought it couldn't :o
Changed word for longWord and got AC!!.
Thank you all SO much for your time and interest in helping others.
Keep posting!.
Best regards.
_.
tan_Yui
Experienced poster
Posts: 155
Joined: Sat Jul 10, 2004 12:41 am

10041 Vito's Family (Input/Output)

Post by tan_Yui »


My code written by C was receieved WA several times.
I tried to execute with some input data.
Following is I/O set.


Input :

Code: Select all

20
10 2 2 4 2 2 2 2 2 2 2
3 6 4 2
9 2 4 6 4 4 4 4 4 4
3 100 10 1
7 5 1 7 1 9 1 10
3 1 1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1 1 1 1 1 1
100 29999 29999 29999 29999 1 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999
5 100 1 1 1 1
5 4 6 6 6 3
5 4 6 1 1 13
2 1 4
1 888
16 5 49 12 23 29 100 44 47 69 41 23 12 11 6 2 62
2 8 8
499 29999 29998 29997 29996 29995 29994 29993 29992 29991 29990 29989 29988 29987 29986 29985 29984 29983 29982 29981 29980 29979 29978 29977 29976 29975 29974 29973 29972 29971 29970 29969 29968 29967 29966 29965 29964 29963 29962 29961 29960 29959 29958 29957 29956 29955 29954 29953 29952 29951 29950 29949 29948 29947 29946 29945 29944 29943 29942 29941 29940 29939 29938 29937 29936 29935 29934 29933 29932 29931 29930 29929 29928 29927 29926 29925 29924 29923 29922 29921 29920 29919 29918 29917 29916 29915 29914 29913 29912 29911 29910 29909 29908 29907 29906 29905 29904 29903 29902 29901 29900 29899 29898 29897 29896 29895 29894 29893 29892 29891 29890 29889 29888 29887 29886 29885 29884 29883 29882 29881 29880 29879 29878 29877 29876 29875 29874 29873 29872 29871 29870 29869 29868 29867 29866 29865 29864 29863 29862 29861 29860 29859 29858 29857 29856 29855 29854 29853 29852 29851 29850 29849 29848 29847 29846 29845 29844 29843 29842 29841 29840 29839 29838 29837 29836 29835 29834 29833 29832 29831 29830 29829 29828 29827 29826 29825 29824 29823 29822 29821 29820 29819 29818 29817 29816 29815 29814 29813 29812 29811 29810 29809 29808 29807 29806 29805 29804 29803 29802 29801 29800 29799 29798 29797 29796 29795 29794 29793 29792 29791 29790 29789 29788 29787 29786 29785 29784 29783 29782 29781 29780 29779 29778 29777 29776 29775 29774 29773 29772 29771 29770 29769 29768 29767 29766 29765 29764 29763 29762 29761 29760 29759 29758 29757 29756 29755 29754 29753 29752 29751 29750 29749 29748 29747 29746 29745 29744 29743 29742 29741 29740 29739 29738 29737 29736 29735 29734 29733 29732 29731 29730 29729 29728 29727 29726 29725 29724 29723 29722 29721 29720 29719 29718 29717 29716 29715 29714 29713 29712 29711 29710 29709 29708 29707 29706 29705 29704 29703 29702 29701 29700 29699 29698 29697 29696 29695 29694 29693 29692 29691 29690 29689 29688 29687 29686 29685 29684 29683 29682 29681 29680 29679 29678 29677 29676 29675 29674 29673 29672 29671 29670 29669 29668 29667 29666 29665 29664 29663 29662 29661 29660 29659 29658 29657 29656 29655 29654 29653 29652 29651 29650 29649 29648 29647 29646 29645 29644 29643 29642 29641 29640 29639 29638 29637 29636 29635 29634 29633 29632 29631 29630 29629 29628 29627 29626 29625 29624 29623 29622 29621 29620 29619 29618 29617 29616 29615 29614 29613 29612 29611 29610 29609 29608 29607 29606 29605 29604 29603 29602 29601 29600 29599 29598 29597 29596 29595 29594 29593 29592 29591 29590 29589 29588 29587 29586 29585 29584 29583 29582 29581 29580 29579 29578 29577 29576 29575 29574 29573 29572 29571 29570 29569 29568 29567 29566 29565 29564 29563 29562 29561 29560 29559 29558 29557 29556 29555 29554 29553 29552 29551 29550 29549 29548 29547 29546 29545 29544 29543 29542 29541 29540 29539 29538 29537 29536 29535 29534 29533 29532 29531 29530 29529 29528 29527 29526 29525 29524 29523 29522 29521 29520 29519 29518 29517 29516 29515 29514 29513 29512 29511 29510 29509 29508 29507 29506 29505 29504 29503 29502 29501
10 1 1 1 1 1 9 9 9 9 9
400 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999
Output :

Code: Select all

2
4
4
99
23
7
8
163
29998
29998
99
5
17
3
0
347
0
62250
40
5999600

Are these Output my code provided correct?
And, if you have good input data or advice, teach me please.
Thank you for your kind!
cytmike
Learning poster
Posts: 95
Joined: Mon Apr 26, 2004 1:23 pm
Location: Hong Kong and United States
Contact:

Post by cytmike »

Your output is the same as my AC program.
So maybe u should try other outputs then.

Good Luck!
tan_Yui
Experienced poster
Posts: 155
Joined: Sat Jul 10, 2004 12:41 am

Post by tan_Yui »

Thanks for your reply!
I tried again, but same result...

Algorithm of my code is following step:

1. Read the number ' r ' and get the space of memory by malloc.
2. Store the ' s ' (street numbers) .
3. Calculate a central value of street numbers.
4. Find the street number which is the nearest to the central value.
5. In step4, if data set have other same absoluted value, also check.
(ex. central value is 2.5 and data set have 2 & 3,
I check 2 in step4, and check 3 in step5.)
6. Calculate the sum of distances from nearest street number (step4).
7. Calculate the sum of distances from nearest street number (step5).
8. Make a comparison between the step6' sum and the step7' sum.
9. Determine an answer.
10. free the memory.

and next is my code... Please forgive, although many useless things may be included.

[c]
delete
[/c]

I'm glad if someone inspect my code and algorithm.
Thanks.
Last edited by tan_Yui on Thu Jul 15, 2004 11:18 am, edited 1 time in total.
Andrew Neitsch
New poster
Posts: 43
Joined: Fri Jun 25, 2004 9:37 pm

Post by Andrew Neitsch »

Your algorithm is wrong.
tan_Yui
Experienced poster
Posts: 155
Joined: Sat Jul 10, 2004 12:41 am

Post by tan_Yui »

Thank you for your reply!
I try to consider again.
Sedefcho
A great helper
Posts: 374
Joined: Sun Jan 16, 2005 10:18 pm
Location: Bulgaria

Post by Sedefcho »

My program which just got ACC gives me the following


Output

Code: Select all

373
1897
for this

Input

Code: Select all

2
16 13 17 17 19 22 22 55 100 101 22 22 23 23 24 100 101
8 101 102 505 606 506 605 900 1000 
This looks quite suspicious to me! Can someone who has an
ACC program just confirm or reject the correctness of this I/O ?
Post Reply

Return to “Volume 100 (10000-10099)”