L_H's blog

By L_H, 10 years ago, In English

I am solving this problem in O(m*n) but still TLE link to problem http://www.codechef.com/problems/PD12 Link to solution http://www.codechef.com/viewsolution/6514367

  • Vote: I like it
  • -3
  • Vote: I do not like it

| Write comment?
»
10 years ago, # |
Rev. 4   Vote: I like it 0 Vote: I do not like it

Add this on the top of the main function:

ios_base::sync_with_stdio(false);
cin.tie(NULL);

and then use '\n' instead of endl.

Edit: This cin>>t; confused me. I just saw it and assumed that you have used cin/cout...

»
10 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Why don't you do a normal DFS or BFS?