happy_zero @ 2023-04-16 15:26:13
开了 O2 也没用
#include <bits/stdc++.h>
#define int long long
#define lowbit(x) x&(-x)
using namespace std;
const int N = 1e6 + 5;
int n, m, len;
char op[N];
int nx[N], ny[N], b[N];
int c[N], c1[N], a[N];
inline void add(int x, int y, int t[])
{
for (int i = x; i <= N; i += lowbit(i))
t[i] += y;
}
inline int query(int x, int t[])
{
int res = 0;
for (int i = x; i >= 1; i -= lowbit(i))
res += t[i];
return res;
}
signed main()
{
cin >> n >> m;
for (int i = 1; i <= m; i++)
{
scanf("%s%lld%lld", &op[i], &nx[i], &ny[i]);
b[++len] = ny[i];
}
sort(b + 1, b + 1 + len);
len = unique(b, b + len + 1) - b - 1;
for (int i = 1; i <= m; i++)
{
if (ny[i]) ny[i] = lower_bound(b + 1, b + 1 + len, ny[i]) - b;//对于这行,如果不判断则是WA80
int x = nx[i], y = ny[i];
if (op[i] == 'U')
{
if (a[x] != 0)
{
add(a[x], -1, c);
add(a[x], -b[a[x]], c1);
}
a[x] = y;
add(a[x], 1, c);
add(a[x], b[a[x]], c1);
}
else
{
int t = query(N, c) - query(y - 1, c);
int t1 = (y != 0) ? query(y - 1, c1) : 0;
if (t1 >= (x - t) * b[y]) cout << "TAK\n";
else cout << "NIE\n";
}
}
return 0;
}
by happy_zero @ 2023-04-16 15:52:15
@happy_zero 艹,是 unique
写错了