Pages

Tuesday, October 19, 2010

352 Seasonal War Uva Online Judge

Problem: http://uva.onlinejudge.org/external/3/352.html
My Approach:


  • Traverse all elements starting from 0,0
  • Check whether the element is one
    • If it is the applydfs
      • applydfs
        • if it is one, mark it as 0
        • apply the same to all its unvisited neighbours
        • if zero, return
    • count the no. of times dfs is applied
    • this will count the number of connected components
    • And thus we have our answer



No comments:

Post a Comment