水题 排序 判符号
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
struct pp
{
int a;
bool b;
void f(int n)
{
if(n >= 0)
{
b = true;
a = n;
}
else
{
b = false;
a = -n;
}
}
bool operator<(const pp& p) const
{
return a < p.a;
}
};
pp cc[500010];
int main()
{
int T;
scanf("%d",&T);
while(T--)
{
int n;
scanf("%d",&n);
for(int i = 0; i < n; i++)
{
int x;
scanf("%d",&x);
cc[i].f(x);
}
sort(cc, cc+n);
bool now = cc[0].b;
int con = 1;
for(int i = 1; i < n; i++)
{
if(now != cc[i].b)
{
now = cc[i].b;
con++;
}
}
printf("%d\n",con);
}
return 0;
}