Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define endl '\n'
- #include <bits/stdc++.h>
- #include <ext/pb_ds/tree_policy.hpp>
- #include <ext/pb_ds/assoc_container.hpp>
- using namespace __gnu_pbds;
- using namespace std;
- typedef tree<int, null_type, less<int>, rb_tree_tag,
- tree_order_statistics_node_update> OrderedSet;
- OrderedSet st[100010];
- int v[100010];
- int main() {
- ios_base::sync_with_stdio(false); cin.tie(NULL);
- int n, q;
- cin >> n >> q;
- for(int i=1; i<=n; i++){
- cin >> v[i];
- st[v[i]].insert(i);
- }
- while(q--){
- int op;
- cin >> op;
- if(op == 1){
- int x, w;
- cin >> x >> w;
- st[v[x]].erase(x);
- v[x] = w;
- st[v[x]].insert(x);
- }else{
- int x, y, w;
- cin >> x >> y >> w;
- int a = st[w].order_of_key(x);
- int b = st[w].order_of_key(y+1);
- cout << (y-x+1)-(b-a) << endl;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement