The reason why IMPOSSIBLE is not provided is because you can always provide an A[] such that no matter what B[] you get back, it is always possible to divide A+B into two subset with equal sum. So you will never run into IMPOSSIBLE case.
The judge however, will never guarantee that A + B can be divided into two subset with equal sum. If it is impossible to do that, the judge just mark your solution is Wrong Answer :) 在2022年4月21日星期四 UTC-7 17:11:16<[email protected]> 写道: > Thanks, all. It is strange that Google doesn't provide IMPOSSIBLE > solution. Can someone share correct solution in python? > > пн, 18 апр. 2022 г., 22:02 Alexander Karpov <[email protected]>: > >> Hi expert. >> I am a beginner in Python. >> I try to solve Equal Sum problem, but my submission is failed and I >> can't see test cases. >> Sample test cases are successful. >> Maybe someone can help with fix code below. >> >> *def getX(nums,x):* >> >> * for i in nums:* >> * if sum(x) == sum(nums):* >> * return x* >> >> * x.insert(0,i)* >> * nums.remove(i)* >> * if sum(x) == sum(nums):* >> * return x* >> * elif sum(x) > sum(nums):* >> * x.remove(i)* >> * nums.insert(0,i)* >> * else:* >> * getX(nums,x)* >> >> *def main():* >> * T = int(input())* >> * for t in range(1, T+1):* >> * N = int(input())* >> >> * A = [i for i in range(N)]* >> * print(*A, flush=True)* >> >> * *B, = map(int, input().split())* >> >> * N = A+B* >> >> * N.sort(reverse=True)* >> >> * X = getX(nums=N,x=[])* >> >> * print(*X, flush=True)* >> >> *main()* >> >> Best Regard, Alex. >> >> -- >> > -- You received this message because you are subscribed to the Google >> Groups Code Jam group. To post to this group, send email to >> [email protected]. To unsubscribe from this group, send email to >> [email protected]. For more options, visit this group at >> https://groups.google.com/d/forum/google-code?hl=en >> --- >> You received this message because you are subscribed to the Google Groups >> "Google Code Jam" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/google-code/6fd43747-c077-4c52-96c6-d24da2af3475n%40googlegroups.com >> >> <https://groups.google.com/d/msgid/google-code/6fd43747-c077-4c52-96c6-d24da2af3475n%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > -- -- You received this message because you are subscribed to the Google Groups Code Jam group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at https://groups.google.com/d/forum/google-code?hl=en --- You received this message because you are subscribed to the Google Groups "Google Code Jam" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/google-code/c2519efd-eae7-4a4a-82c7-42ab8bb9e765n%40googlegroups.com.
