Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #include <ext/pb_ds/assoc_container.hpp> // Common file
- #include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
- using namespace std;
- using namespace __gnu_pbds;
- typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
- int main()
- {
- int t;
- cin >> t;
- while(t--)
- {
- int n, q;
- unordered_map<long long , int> freq;
- cin >> n >> q;
- vector<long long> vec;
- vec.resize(n + 1);
- for(int i = 1; i <= n; i++)
- {
- cin >> vec[i];
- if(vec[i] != 0)
- freq[vec[i]]++;
- }
- while (q--)
- {
- int which;
- cin >> which;
- if(which == 1)
- {
- int a;
- long long b;
- cin >> a >> b;
- if(vec[a] != 0)
- freq[vec[a]]--;
- if(vec[a] != 0 && freq[vec[a]] == 0)
- freq.erase(vec[a]);
- vec[a] = b;
- if(b != 0)
- freq[vec[a]]++;
- }
- else
- cout << freq.size() << endl;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement