I am trying to solve a problem on Spoj, but all i get is SIGSEGV on test 10. I just want a second on review on my code to try to figure out what is happening here.
I see each island of the problem (cartesian point with integers coordinates) as an edge between x and y. Then if a build several path alternating colors it guarantees that each island will have a couple on the same row (column) with another color. Of course, each path start on a node with odd degree unless there aren't, so then, i am looking for cycles. If this approach is wrong i need some suggestion, but if it isn't, i just want to know why this answer is getting SIGSEGV.
I guess you have used g++ 4.3.2 to send it, am I right? I've got the same problem so I prefer not to use it :) Use g++ 4.9.2 and you will receive "Wrong answer".
Usually i used g++ 4.9.2 but in this case i tried both, and the outcome was the same, any other idea?... I was thinking that maybe the dfs with 100000 elements will break the program, but, is that the usual error when stack overflow happens??
I'm not sure about that. But I am wondering why after submitting your code the outcome is Wrong answer instead of SIGSEGV.
Check this out
I got a lot of SIGSEGV first, then I increase the size of my array to be sure that it wasn't the problem. Then spoj alternate between SIGSEGV and wrong answer, the wrong answer i think are because im not trying to access a forbidden part of the memory but a bad one, just i don't know where. I see you get wrong answer too, i imagine on test 10 like me. I tried with a lot of dataset generated by me with huge input, but everything was ok, maybe the stack memory of the judge is not big in off for this solution.
I received those wrong answer with your solution to see what outcome will give with g++ 4.3.2 and g++ 4.9.2 :) BTW the WA may not be on test 10. Even if your solution fails a test it will be tested through all of the cases and the response will be Accepted(if your solution pass all the tests) or the outcome of the first failed test.
I don't understand, why my code will be tested through all cases if I fail one test?? If i fail one case the outcome will be WA??
P_Nyagolov thanks for all your attention on my problem, I already figured out what was wrong with the help of a friend. When i was generating the data, i was multiplying numbers in the range(1, 100000), so there was overflow using int32, already fixed , and ... AC.