| 比赛 |
2026.9.5 |
评测结果 |
AAAAAAAAEAEAAAA |
| 题目名称 |
To-Do List |
最终得分 |
86 |
| 用户昵称 |
终焉折枝 |
运行时间 |
10.436 s |
| 代码语言 |
C++ |
内存使用 |
42.35 MiB |
| 提交时间 |
2026-09-05 10:52:03 |
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using f64 = double;
using f128 = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
#define pb emplace_back
#define mk make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)((x).size())
#define ciallo(x) cerr << (x) << '\n';
template <typename T, typename U>
inline bool chmin(T& a, const U& b){return (b < a ? a = b, true : false);}
template <typename T, typename U>
inline bool chmax(T& a, const U& b){return (a < b ? a = b, true : false);}
const int N = 2e6 + 5;
const int P = 1e6 + 3;
#define lc u << 1
#define rc u << 1 | 1
ll mx[N << 2], tag[N << 2];
inline void up(int u){
mx[u] = max(mx[lc], mx[rc]);
}
inline void down(int u){
if(tag[u]){
mx[lc] += tag[u];
mx[rc] += tag[u];
tag[lc] += tag[u];
tag[rc] += tag[u];
tag[u] = 0;
}
}
inline void modify(int u, int l, int r, int pos, ll k){
if(l == r){
mx[u] += k;
return;
}
down(u);
int mid = (l + r) >> 1;
if(pos <= mid) modify(lc, l, mid, pos, k);
else modify(rc, mid + 1, r, pos, k);
up(u);
}
inline void upd(int u, int l, int r, int ql, int qr, ll k){
if(ql <= l && r <= qr){
tag[u] += k;
mx[u] += k;
return;
}
down(u);
int mid = (l + r) >> 1;
if(ql <= mid) upd(lc, l, mid, ql, qr, k);
if(qr > mid) upd(rc, mid + 1, r, ql, qr, k);
up(u);
}
ll s[N], t[N], tot = 0;
bool vis[N];
inline void solve(){
int n; cin >> n;
ll ans = 0;
for(int i = 1;i <= n;i ++){
char op; cin >> op;
if(op == 'A'){
cin >> s[++ tot] >> t[tot];
s[tot] = (s[tot] + ans) % P;
t[tot] = (t[tot] + ans) % P;
// cout << "s : " << s[tot] << " t : " << t[tot] << '\n';
if(!vis[s[tot]]){
modify(1, 1, N, s[tot], s[tot]);
vis[s[tot]] = 1;
}
upd(1, 1, N, 1, s[tot], t[tot]);
}
else{
ll x; cin >> x;
x = (x + ans) % P;
modify(1, 1, N, s[x], -s[x]);
vis[s[x]] = 0;
upd(1, 1, N, 1, s[x], -t[x]);
}
ans = mx[1];
ans --;
cout << ans << '\n';
}
}
signed main(){
freopen("List.in", "r", stdin);
freopen("List.out", "w", stdout);
cin.tie(0) -> ios::sync_with_stdio(0);
int T = 1;
while(T --) solve();
// #ifdef LOCAL
// cout << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s\n ";
// #endif
return 0;
}