Prvt's blog

By Prvt, history, 6 years ago, In English

I am getting runtime error on this problem https://mirror.codeforces.com/contest/3/problem/B on some ending test cases. My soultion is https://mirror.codeforces.com/contest/3/submission/55215191

  • Vote: I like it
  • 0
  • Vote: I do not like it

| Write comment?
»
6 years ago, # |
  Vote: I like it 0 Vote: I do not like it
bool fuct(p a, p b){
	if(a.s >= b.s) return true;
	return false;
}

In short, your "true" condition is ambiguous: with two objects $$$a$$$ and $$$b$$$ having the same parameters $$$s$$$, both statements $$$a < b$$$ and $$$b < a$$$ is true (the comparator in sort function will return true if the first argument is considered "lower" than the second one), therefore either cause a TLE or reach maximum recursion depth by continuously swapping such elements.