10546 - The Eagle's Nest

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

Moderator: Board moderators

Farid Ahmadov
Experienced poster
Posts: 131
Joined: Thu Apr 17, 2003 8:39 am
Location: Baku, Azerbaijan

Post by Farid Ahmadov »

Hello.

kmhasan you said that answer is not always equal to the number of missions. Why?

For example (second sample test case) :

3
Meet_The_Boss 3
Rob_The_Cop 6
A_Petty_Thief 5

1-st I play (3, 5);
I restart and play (6);

As you can see there are three missions that are completed.

Maybe I am wrong. Explain it please.

Thank you.
_____________
NO sigNature
kmhasan
Problemsetter
Posts: 107
Joined: Fri Oct 26, 2001 2:00 am
Location: Canada
Contact:

Post by kmhasan »

quite simple. you always have to play K (2 in this case) missions.
..
A great helper
Posts: 454
Joined: Thu Oct 18, 2001 2:00 am
Location: Hong Kong

Post by .. »

kmhasan wrote:Construct the network as follows:
For each mission make two vertices. From the 1st vertex connect using a unit edge to the 2nd vertex of the missions that appear before this mission and are easier than the one at hand. Then connect the 2nd vertex of the current mission to the 1st vertex of the current mission. From the source connect to the 2nd vertex of the missions that can be chosen as the K th mission in some LIS. And from the 1st missions of the LISs connect to the sink. Now run a max flow from source to sink.

The answer would be K*max-flow.
Hi Kmhasan,
I don't understand the setence "can be chosen as the K th mission in some LIS", could you please give me an example of the constructed network? Thanks!
My signature:
  • Please make discussion about the algorithm BRFORE posting source code.
    We can learn much more in discussion than reading source code.
  • I HATE testing account.
  • Don't send me source code for debug.
kmhasan
Problemsetter
Posts: 107
Joined: Fri Oct 26, 2001 2:00 am
Location: Canada
Contact:

Post by kmhasan »

I think my post lacked an illustration. If the following network fails to explain the idea, please let me know. I'd try to elaborate some more.
Image
We can construct this network for the sequence:

Code: Select all

A = <7,5,1,15,13,8,16,10,9>
As you'd see, the length of the LIS is 3, and there is at most two such LIS that are disjoint. The flow shown in red highlights them.
..
A great helper
Posts: 454
Joined: Thu Oct 18, 2001 2:00 am
Location: Hong Kong

Post by .. »

Thanks for your quick response and great picture :D
But I still have one question, is it that if the length of LIS = 4,
your network will have 2 layers of missions between the start layer and end layer? If no, how can you guarantee that every augmenting path will have length of LIS?
My signature:
  • Please make discussion about the algorithm BRFORE posting source code.
    We can learn much more in discussion than reading source code.
  • I HATE testing account.
  • Don't send me source code for debug.
kmhasan
Problemsetter
Posts: 107
Joined: Fri Oct 26, 2001 2:00 am
Location: Canada
Contact:

Post by kmhasan »

That actually follows from our construction of the network. Our network is basically a multistage graph that you form for finding all possible LISs of a sequence. Before I start to make it more confusing, let me clarify through a picture:
Image
We construct this multistage graph for the sequece:

Code: Select all

A = <6, 5, 2, 15, 7, 4, 10, 9, 8, 16, 14, 12, 11>
Now, we would only connect the source, s to the nodes of the final stage. And the sink, t will only be connected to the nodes of the first stage. For any augmenting path we know that it has to go from the source to the sink. Therefore, it is bound to go through the all the stages -- which actually ensures that we have a path length of LIS for each and every augmenting path. Agreed?
Last edited by kmhasan on Mon Sep 06, 2004 7:19 pm, edited 1 time in total.
..
A great helper
Posts: 454
Joined: Thu Oct 18, 2001 2:00 am
Location: Hong Kong

Post by .. »

Agree :D
So, before constructing the network, you have to use the LIS algorithm
to decide putting each mission at which stage, right?
My signature:
  • Please make discussion about the algorithm BRFORE posting source code.
    We can learn much more in discussion than reading source code.
  • I HATE testing account.
  • Don't send me source code for debug.
kmhasan
Problemsetter
Posts: 107
Joined: Fri Oct 26, 2001 2:00 am
Location: Canada
Contact:

Post by kmhasan »

Right.
Khaled_912
New poster
Posts: 33
Joined: Fri Jan 06, 2006 5:51 pm

Post by Khaled_912 »

kmhasan wrote: From the 1st vertex connect using a unit edge to the 2nd vertex of the missions that appear before this mission and are easier than the one at hand.
Well, this seems not to be correct. Let h be the length of the maximum sequence of missions ending with 'i'. In this case, 2nd vertex of mission 'j' is connected to the first vertex of mission 'i' iff h = h[j] + 1 (which also implies that difficulty > difficulty[j]).
Post Reply

Return to “Volume 105 (10500-10599)”