11069 - A Graph Problem

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

Moderator: Board moderators

Nemo
New poster
Posts: 16
Joined: Thu Apr 14, 2005 10:40 am

11069 - A Graph Problem

Post by Nemo »

i am ashamed to see so many people have solved this problem but i coudn't understand how to.

is there any constant time formula? or is it a brute force enumeration? (doesn't seem so).
mf
Guru
Posts: 1244
Joined: Mon Feb 28, 2005 4:51 am
Location: Zürich, Switzerland
Contact:

Post by mf »

There's a simple recurrence, which can let you compute answer in O(n) time.
Moheeb
New poster
Posts: 21
Joined: Fri May 05, 2006 9:08 am
Location: Dhaka ,Bangladesh

Post by Moheeb »

edit
Last edited by Moheeb on Wed Aug 30, 2006 5:14 am, edited 1 time in total.
little joey
Guru
Posts: 1080
Joined: Thu Dec 19, 2002 7:37 pm

Post by little joey »

Come on, no spoilers!
Nemo
New poster
Posts: 16
Joined: Thu Apr 14, 2005 10:40 am

Post by Nemo »

thanks. i sweat it out to find the pattern. surprised to see so simple recurrence. i got AC with precalculation as you said. i don't know how to solve the recurrence. then i could solve it in constant time.
shanto86
Experienced poster
Posts: 160
Joined: Wed Jul 30, 2003 8:10 pm

Post by shanto86 »

well... it is not fair to post the recurrence directly. plz who ever did it, delete that. u may give him enough hint but not direct recurrence!

if u have a close look, then u will realize it is fibonacci. but if u want to formulate it there is a big chance to get precission error (i think u know the direct formula for fib series.)
Self judging is the best judging!
FAQ
Learning poster
Posts: 84
Joined: Wed Jan 28, 2004 6:23 pm

Post by FAQ »

I wonder how you could find the recurrence (some math proof behind?) or it's just an experience in "looking at an integer sequence"?
mf
Guru
Posts: 1244
Joined: Mon Feb 28, 2005 4:51 am
Location: Zürich, Switzerland
Contact:

Post by mf »

(Spoiler removed.)
Last edited by mf on Sun Aug 13, 2006 11:49 am, edited 1 time in total.
lonelyone
Learning poster
Posts: 65
Joined: Sat Feb 19, 2005 6:53 pm

Post by lonelyone »

how about 6 nodes

what's the subsets of it..

could somebody explain problem for me, thanks a lot
lonelyone
Learning poster
Posts: 65
Joined: Sat Feb 19, 2005 6:53 pm

Post by lonelyone »

n=6

{1,3,5}
{2,5}
{1,4,6}
{2,4,6}
{3,6}

am I right?
but why {1,6} can't be included
Darko
Guru
Posts: 580
Joined: Fri Nov 11, 2005 9:34 am
Location: Calgary, Canada

Post by Darko »

for 6:

1 3 5
1 3 6
1 4 6
2 4 6
2 5

{1,6}is not one of them, because you can insert 3 or 4 which are not connected to 1 or 6 - same thing with {3,6}(you can add 1)
lonelyone
Learning poster
Posts: 65
Joined: Sat Feb 19, 2005 6:53 pm

Post by lonelyone »

thanks, I think I realized it
little joey
Guru
Posts: 1080
Joined: Thu Dec 19, 2002 7:37 pm

Post by little joey »

Please guys, remove those posts that give the solution to this problem. The boards are meant to discuss problems, not to give spoilers.
mf: I know you responded to a request for proof, but you should give that in a PM, not publicly on the board.
okz
New poster
Posts: 3
Joined: Fri May 25, 2007 3:54 am

Post by okz »

easy problem...
but i want to know what is the provision for terminating the program..??
"The input will be terminated by EOF",i didnt understand what it meant

just write down
while(!EOF){
cin>>xxx;
cout<<xxx;
}


let me got a WA...
shanto86
Experienced poster
Posts: 160
Joined: Wed Jul 30, 2003 8:10 pm

Post by shanto86 »

I do like this:

while(scanf("%d",&x)!=EOF)
{
}

i dont know what it is for cin... may be:

while(cin>>x)
{
}

you may check it in your pc. just end your input by ctrl+z. See if your code terminates!
Self judging is the best judging!
Post Reply

Return to “Volume 110 (11000-11099)”