1616A Integer Diversity codeforces solution in cpp
by ujjal roy
#include<bits/stdc++.h>
using namespace std;
main()
{
int t,n,i,c;
cin>>t;
while(t--)
{
cin>>n;
c=0;
int ans=0,co=1;
map<int,int> m;
for(i=0;i<n;i++)
{
cin>>co;
if(m[co]==0)
{
c++;
m[co]++;
}
else if(m[-co]==0)
{
c++;
m[-co]++;
}
}
cout<<c<<endl;
}
return 0;
}
0 Comments