Amongst other things (e.g. passing v by value in dfs), you’re also making exactly the same mistake as this guy (and countless others in that thread).
Stamping out this CP anti-pattern is probably top of my if I ruled the world list ![]()
Amongst other things (e.g. passing v by value in dfs), you’re also making exactly the same mistake as this guy (and countless others in that thread).
Stamping out this CP anti-pattern is probably top of my if I ruled the world list ![]()
I didn’t get the point
Would you explain me little more?
Try this test input; it won’t TLE, but it should give you a hint about what is going on (and what is causing your TLE):
5
6 3
10 2 5 6 5 6
1 2
2 3
2 4
1 5
5 6
5 6
3 5
1 4
6 3
10 2 5 6 5 6
1 2
2 3
2 4
1 5
5 6
5 6
3 5
1 4
6 3
10 2 5 6 5 6
1 2
2 3
2 4
1 5
5 6
5 6
3 5
1 4
6 3
10 2 5 6 5 6
1 2
2 3
2 4
1 5
5 6
5 6
3 5
1 4
6 3
10 2 5 6 5 6
1 2
2 3
2 4
1 5
5 6
5 6
3 5
1 4
6 3
Oh my mistake was not clearing edge vector ? Did I have made any other mistake?
N,Q<=1000 is for each TC or overall?
Yes. Or more fundamentally: this.
Passing v by value is another one.
The wording suggests “each TC”.
How passing v by value is giving TLE?
You’re still passing v by value.
Yeah, why passing by value giving TLE?
Now it turned into WA CodeChef: Practical coding for everyone
Passing by value copies the vector every time you pass it; passing by reference does not.
Oh but having globally vector v is giving WA 
I meant “pass v by reference”, not “make v global” XD
Why are you only sometimes calling v.pop_back()?
Finally got it. Thanks a lot!!
I dislike your hate for global variables, they make function headers much less ugly
I saw the editorial and designed my code in that way but i am getting runtime error when i submit my code.
It would be great help if you could tell e why its giving SIGSEV.
https://www.codechef.com/viewsolution/33577600
Thanks again.
It’s quite a bad idea to return in the middle of a test case, especially before reading in all the input
Ya, my bad i shared the wrong solution. This is giving SIGSEV despite the fact of not returning and doing everything else the same way.
https://www.codechef.com/viewsolution/33585543
It would be nice if you could point out what us going wrong for a beginner like me.
Thanks.
Wait, why would you comment out line 11