#include #ifndef ONLINE_JUDGE #define DEBUG #include #else #define zqy1018zqy1018zqy1018zqy1018zqy1018 123 #endif #define INF 2000000000 #define MOD 1000000007 #define MAXN 200005 #define REP(temp, init_val, end_val) for (int temp = init_val; temp <= end_val; ++temp) #define REPR(temp, init_val, end_val) for (int temp = init_val; temp >= end_val; --temp) using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair intpair; int read(){ int f = 1, x = 0; char c = getchar(); while (c < '0' || c > '9'){if(c == '-') f = -f; c = getchar();} while (c >= '0' && c <= '9')x = x * 10 + c - '0', c = getchar(); return f * x; } inline int lowbit(int x){ return x & (-x); } inline int modadd(int x, int y){ return (x + y >= MOD ? x + y - MOD: x + y); } inline int sgn(int x){ return (x < 0 ? -1: (x > 0 ? 1: 0)); } template T gcd(T a, T b){ return (!b) ? a: gcd(b, a % b); } int poww(int a, int b){ int res = 1; while (b > 0){ if (b & 1) res = 1ll * res * a % MOD; a = 1ll * a * a % MOD, b >>= 1; } return res; } const int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1}; const int ddx[] = {-1, -1, -1, 0, 0, 1, 1, 1}, ddy[] = {-1, 0, 1, -1, 1, -1, 0, 1}; /*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/ int n; int fa[5000005] = {0}, siz[5000005], lf[5000005]; bool vis[5000005] = {0}; int Find(int x){ return (x == fa[x] ? x: (fa[x] = Find(fa[x]))); } int Union(int x, int y){ x = Find(x), y = Find(y); if (x == y) return 0; if (siz[x] > siz[y]) siz[x] += siz[y], fa[y] = x, lf[x] = min(lf[x], lf[y]); else siz[y] += siz[x], fa[x] = y, lf[y] = min(lf[y], lf[x]); return 1; } void init(){ n = read(); // REP(i, 1, n) // fa[i] = i, siz[i] = 1; } void solve(){ REP(q, 1, n){ int opr = read(), pos = read(); if (opr == 1){ if (vis[pos]) continue; vis[pos] = true; fa[pos] = pos, siz[pos] = 1, lf[pos] = pos; if (fa[pos + 1] > 0){ Union(pos + 1, pos); } if (fa[pos - 1] > 0){ Union(pos - 1, pos); } } else { int len; if (!vis[1]){ if (pos == 1){ if (!vis[2]) len = 1; else { int tt = Find(2); len = siz[tt] + 1; } } else { len = 0; } } else { int tt = Find(1); int s1 = siz[tt]; if (vis[pos]) len = s1; else { if (pos == s1 + 1){ if (!vis[pos + 1]){ len = s1 + 1; } else { int s2 = siz[Find(pos + 1)]; len = s1 + 1 + s2; } } else { len = s1; } } } printf("%d\n", len + 1); } } } int main(){ int T = 1; while (T--){ init(); solve(); } return 0; }