fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4. const int Mod=998244353;
  5.  
  6. void solve() {
  7. int n;
  8. cin >> n;
  9. int ans=0;
  10. unordered_map<int,int> seen;
  11.  
  12. for(int i=0;i<n;i++){
  13. int a;
  14. cin >> a;
  15. if(seen.find(a)==seen.end()) ans++;
  16. seen[a]=1;
  17. }
  18.  
  19. cout << ans << "\n";
  20. }
  21.  
  22. int main(){
  23. ios::sync_with_stdio(false);
  24. cin.tie(nullptr);
  25.  
  26. int t;
  27. cin >> t;
  28. while (t--) solve();
  29.  
  30.  
  31. return 0;
  32. }
  33.  
Success #stdin #stdout 0s 5288KB
stdin
3
3
1 2 3
5
3 1 4 1 5
1
1
stdout
3
4
1