//#include <bits/stdc++.h>
#include<vector>
#include<iostream>
#include<string.h>
using namespace std;
//#include <bits/stdc++.h>
using namespace std;
int n, t[5000010 * 4];
namespace io {
const int SIZE = (1 << 21) + 1;
char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55]; int f, qr;
// getchar
#define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
// print the remaining part
inline void flush () {
fwrite (obuf, 1, oS - obuf, stdout);
oS = obuf;
}
// putchar
inline void putc (char x) {
*oS ++ = x;
if (oS == oT) flush ();
}
template<typename A>
inline bool read (A &x) {
for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;else if(c==EOF)return 0;
for (x = 0; c <= '9' && c >= '0'; c = gc()) x = x * 10 + (c & 15); x *= f;
return 1;
}
template<typename A>
inline bool write (A x) {
if (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;
while (x) qu[++ qr] = x % 10 + '0', x /= 10;
while (qr) putc (qu[qr --]);
return 0;
}
inline bool write (char x) {
putc(x);
return 0;
}
//no need to call flush at the end manually!
struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
}
void up(int x) {
t[x] = t[x << 1] + t[x << 1 | 1];
}
void modify(int x, int l, int r, int pos, int val) {
if (l == r) {
t[x] = val;
return;
}
int mid = l + r >> 1;
if (pos <= mid) modify(x << 1, l, mid, pos, val);
else modify(x << 1 | 1, mid + 1, r, pos, val);
up(x);
}
int query(int x, int l, int r) {
if (l == r) return t[x];
int mid = l + r >> 1;
if (t[x << 1] == (mid - l + 1)) return t[x << 1] + query(x << 1 | 1, mid + 1, r);
return query(x << 1, l, mid);
}
using io :: read;
using io :: putc;
using io :: write;
char buf[16 * 1024 * 1024 + 5]; // 10 MiB Buffer
int curpos = 0, iseof;
int nextInt()
{
int ret = 0;
if (iseof) return 0;
while (!('0' <= buf[curpos] && buf[curpos] <= '9'))
{
if (buf[curpos] == 0)
{
if (fgets(buf, 16 * 1024 * 1024, stdin) == NULL) iseof = true;
curpos = 0;
continue;
}
curpos++;
}
int flg = 0;
if (curpos && buf[curpos - 1] == '-') flg = -1;
else flg = 1;
while ('0' <= buf[curpos] && buf[curpos] <= '9')
{
ret = ret * 10 + (buf[curpos] - '0');
curpos++;
}
return ret * flg;
}
int main() {
// scanf("%d", &n);
// read(n);
n=nextInt();
for (int i = 1; i <= n; i++) {
int opt, x;
opt=nextInt();
x=nextInt();
// read(opt), read(x);
if (opt == 1) modify(1, 1, n, x, 1);
else {
modify(1, 1, n, x, 1);
write(query(1, 1, n) + 1);
putc('\n');
modify(1, 1, n, x, 0);
}
}
}
快速读入板子
最新推荐文章于 2022-05-04 11:43:42 发布