题意:给定各有n个整数的四个数列A,B,C,D。要从每个数列中各一个数,是的四个数的和为0.求出这样的组合的个数。
解法:折半,枚举A,B数列的两两组合,然后排序,再枚举C,D的两两组个,在A,B的组合中二分查找匹配数的个数。复杂度n^2logn.
代码:
/****************************************************
* author:xiefubao
*******************************************************/
#pragma comment(linker, "/STACK:102400000,102400000")
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <string.h>
using namespace std;
#define eps 1e-8
typedef long long LL;
int n