THRSUM  ZERO TRIPLET
The general elections are coming and so rahul and modi have started the preparations.An astrologer predicted that whoever solves the given problem first will win the elections.
The problem is as follows: Given an array nums
of n integers, are there elements a, b, c in nums
such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.
As I want modi to win,so you have to solve this problem for modi before rahul does...Good Luck
Input
In the first line ,you will be given t the number of test cases ,for each test case you will be given n, the size of the array.In the next line you will be given n space separated elements of the array.
Input constraints :t<=10000, n<=10000 (sum of n over all test cases won't exceed 10^8)
Output
Output the number of such triplets and subsequently print each of the triplets in a separate line in lexicographic order.
Example
Input:
2
5
1 0 1 2 1
3
0 0 0
Output:
2
1 1 2
1 0 1
1
0 0 0
hide comments
DOT:
20180730 18:28:41
@Sushovan, ah, right! Thank you. :) 

Sushovan Sen:
20180730 14:33:35
1s is the time limit to solve a single file. There may be multiple input files, your 2.75s is run time of all the files which need not be less than a second. 

DOT:
20180729 20:04:53
Can anyone clarify what the 1s in time limit mean? I thought the solution should produce output for all testcases within the set 1s limit. But my solution ran for 2.75s, yet got accepted. How come? 

trijeet:
20180614 04:40:38
Slight correction  the triplets should be printed in sorted order, not lexicographically (as character sorting). Good problem 

mehul_sri:
20180609 18:39:53
Nice problem!! Well done bro @be1035016 ;) 

Ishwar:
20180531 10:30:08
@learnerinblack


learnerinblack:
20180524 13:26:33
Finally AC, Oh gosh, pheww!


nadstratosfer:
20180524 07:15:53
Input is badly formatted, linebased reading crashes a Python solution. Psetter, please check if there are no linebreaks between numbers of the same array. Other than that, well designed problem in that rejecting suboptimal solutions still allows PyPy to get AC. Last edit: 20180524 07:34:32 

sikh_coder:
20180523 21:16:10
Can't think of a better sol than O(n^2*logn)...


be1035016:
20180523 19:42:05
@vipul just to avoid suboptimal solutions 
Added by:  ac_baz 
Date:  20180523 
Time limit:  1s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All 
Resource:  https://www.hackerrank.com/contests/cnc02/challenges/thesimplestcountingproblem/editorial 