Monday, 11 November 2013

Regionals 2012 :: Asia - Dhaka. Wedding of Sultan (UVA 12582 + UVALive 6201)

Problem: Wedding of Sultan
You are given a path for an connected undirected graph with no cycle. The path is written by a man in the way: if he enter or leave the node he will write it down. When he comes to a node he looks for another connected to it which he has not traversed yet. If he finds such node, he follows that one. Otherwise, he go back. You have to find degree of each node.

Category: basic data structure [stack]

Idea: use stack to push the nodes in path one by one. if two consecutive node are equal, that means, this is the end of that node. now increase the degree of that node by one, and also increase its parent degree by one.
You are done.

Code


3 comments:

  1. কোড গুলো দেখানোর জন্য gist অথবা পেস্টবিনের মত টুল ব্যবহার করলে ব্লগটা আরো সুন্দর লাগত। আপনার সাবনেটিং লেখাটা পড়েছি। সুন্দর লেখা। ধন্যবাদ।

    ReplyDelete
    Replies
    1. Thanks a lot for your great Suggestion.
      From now, i will post code link rather than code directly.

      Delete
  2. This comment has been removed by the author.

    ReplyDelete