kikit
6/27/2016 - 6:19 AM

Absolute distinct count in a sorted array

Absolute distinct count in a sorted array

/*
http://ideone.com/0IHJOg
http://www.geeksforgeeks.org/absolute-distinct-count-array-sorted-absolute-values/
http://www.practice.geeksforgeeks.org/problem-page.php?pid=903
*/

#include <iostream>
#include <set>
#include <cmath>
using namespace std;

int main() {
	int t, n, x;
	cin >> t;
	while(t--){
		cin >> n;
		set<int> s;
		for(int i=0; i<n; i++){
			cin >> x;
			s.insert(abs(x));
		}
		cout << s.size() << endl;
	}
	return 0;
}