aboutsummaryrefslogtreecommitdiff
path: root/TokitsukazeAndAllZeroSequence/TokitsukazeAndAllZeroSequence.cpp
blob: f83e44daed4463f43be545dbf3c365bac0317358 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include<bits/stdc++.h>
using namespace std;
int main() {
  int tt;
  cin >> tt;
  while(tt--) {
    int ansZ = 0;
    bool duple = false;
    bool zero = false;
    int n; cin >> n;
    vector<int> v(n);
    map<int, int> mp;
    for(auto &x : v) {
      cin >> x;
      if(x == 0) {
        zero = true;
      }
      mp[x]++;
    }
    for(auto &p : mp) {
      if(p.first == 0) {
        ansZ+=p.second;
      }
      if(p.second > 1 && p.first != 0) {
        duple = true;
      }
    }
    if(zero) {
      cout << n - ansZ << endl;
    }
    else if(duple){
      cout << n << endl;
    }
    else {
      cout << n + 1 << endl;
    }
  }
}