FIRESC - Editorial

Any border test cases? I am still getting WA
http://www.codechef.com/viewsolution/1954203

@anton_lunyov >> Please clarify this:

for (VI::iterator v = a[u].begin(); v != a[u].end(); ++v) {
	// *v is the adjacent vertex itself
	if (!mark[*v]) {
		// if it was not visited before we move to it
		dfs(*v);
	}
}

In the loop part, the begin() and end() functions are called each time an iteration occurs, so isnā€™t it time consuming? Instead if we just store

x = a[u].begin() 

and

y = a[u].end() 

before entering the loop and then use x and y, do we save some time?

Can anybody explain what is the runtime of Union/Find approach. I used union by size approach.

Plz help me out in thisā€¦i thought a lot on this problem and finally did itā€¦though i got a WA i canā€™t figure out what was wrong with my codeā€¦i wrote a c program which can be seen at
http://www.codechef.com/viewsolution/1900728

please suggest me in whatcase my code giving wrong answerā€¦CodeChef: Practical coding for everyone

url:- CodeChef: Practical coding for everyone

I m getting WA cna someone help in finding a test case where my code fails??

thank u in advanceā€¦:slight_smile:

can any one tell me whats wrong with this codeā€¦

its running on my pc but giving compilation error
http://ww2.codechef.com/viewsolution/2076377

Please help . Getting Wrong answers for even test case!!!
link to my code ā†’ lU40Sl - Online C++0x Compiler & Debugging Tool - Ideone.com

2 Likes

well sorry for reviving such an old topic but there seems to be an error with my implementation,i dont know why i am getting a TLE here is my submission CodeChef: Practical coding for everyone i have used a dfs and a linked list approach could anyone illuminate my mistake.

What is wrong with thi??
https://www.codechef.com/viewsolution/14792552

Whats wrong with this CodeChef: Practical coding for everyone

Please star my projects and contribute if you are interested.

  1. GitHub - armgabrielyan/DiceRoller: Dice Rolling Simulator
  2. https://github.com/ArmenGabrielyan16/SuperLibrary

Can someone please point out the mistake in this code?

Code-(CodeChef: Practical coding for everyone)

Thanks :slight_smile:

such a nice problem, thank you codechef.

1 Like

Used union find but kept getting TLE. Code:gDZvZc - Online C++0x Compiler & Debugging Tool - Ideone.com
Would be really helpful if someone could point out the mistake in this.

very good question ā€¦

You have loop for(int j=i; j<n; j++) after each call to dfs. In the case of no edges in the graph you will have O(N^2) solution. Obviously it should get TLE :slight_smile:

@anton_lunyov >> So, if I consider the case of graph consisting of no edges separately, will it run within TL?

Replace c[p[i]]++ by c[find(i)]++
p[i] is not always the actual root of the disjoint set containing i.
Namely, after link operation.

1 Like

http://www.codechef.com/viewplaintext/1916644