#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using std::sort;
const int MAXN(500010);
struct NODE
{
int num, ab;
friend bool operator < (const NODE &op1, const NODE &op2)
{
return op1.ab < op2.ab;
}
};
NODE node[MAXN];
inline int getsign(int num)
{
if(num < 0)
return -1;
else
return 1;
}
inline int ABS(int num)
{
if(num < 0)
return -num;
else
return num;
}
int main()
{
int T;
scanf("%d", &T);
while(T--)
{
int N;
scanf("%d", &N);
if(N == 0)
{
printf("0\n");
continue;
}
for(int i = 1; i <= N; ++i)
{
scanf("%d", &node[i].num);
node[i].ab = ABS(node[i].num);
}
sort(node+1, node+1+N);
int ans = 1, flag = getsign(node[1].num);
for(int i = 2; i <= N; ++i)
{
int temp = getsign(node[i].num);
if(temp != flag)
{
++ans;
flag = temp;
}
}
printf("%d\n", ans);
}
return 0;
}
Building Designing
最新推荐文章于 2018-11-14 11:31:05 发布