so easy(unordered_map+并查集)
There are n n points in an array with index from 1 1 to n n, and there are two operations to those points. 1: 1 \ x 1 x marking the point x x is not available 2: 2 \ x 2 x query for the index of the first available point after that point (including x x itself) . 样例输入 5 3 1 2 2 2 2 1 样例输出 3 1 1 #include <bits/stdc++.h> 2 3 using namespace std; 4 5 unordered_map<int, int> fa; 6 7 int findfa(int x) 8 { 9 if (!fa.count(x)) return x; 10 return fa[x] = findfa(fa[x]); 11 } 12 13 int main() 14 { 15 int n, q; 16 int op, x; 17 scanf("%d %d", &n, &q); 18 while (q--) 19 { 20 scanf("%d %d", &op, &x); 21 if