//
// main.cpp
// Richard
//
// Created by 邵金杰 on 16/10/3.
// Mail:1016427040@qq.com or jasonshaosjj@gmail.com
// Copyright © 2016年 邵金杰. All rights reserved.
//
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn=1000000+10;
int vis[maxn];
int abs(int x) {return x>0?x:-x;}
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
memset(vis,0,sizeof(vis));
int n,x,up=0;
scanf("%d",&n);
for(int i=0;i<n;i++) {scanf("%d",&x);if(x>0) vis[x]=1;else vis[-x]=-1;up=max(up,abs(x));}
int last=0,len=0;
for(int i=1;i<=up;i++){
if(vis[i]!=0){
if(last==0) {last=vis[i];len++;}
else{
if(last!=vis[i]) {last=vis[i];len++;}
}
}
}
cout<<len<<endl;
}
return 0;
}
UVA 11039 Building desigining(水题)
最新推荐文章于 2019-09-13 23:32:29 发布