#include<bits/stdc++.h> #define N 1000010 usingnamespace std; int tot; int n; char s[N]; int len, ans; intmain(){ freopen("queue.in", "r", stdin); freopen("queue.out", "w", stdout); scanf("%s", s); len = strlen(s); { int i = 0; while (len && s[len - 1] == 'M') --len; while (i < len && s[i] == 'F') ++i; if (i == len || !len) { puts("0"); return0; } } for (int i = 0; i < len; ++i) { if (s[i] == 'M') ++tot; else { ans = max(ans + 1, tot); } } printf("%d", ans); return0; }
#include<bits/stdc++.h> #define N 100010 usingnamespace std; int n, m; int ans[N], a[N]; vector <pair <int, int> > q[N]; structque { int opt, a, b; }op[N]; intmain(){ freopen("array.in", "r", stdin); freopen("array.out", "w", stdout); scanf("%d%d", &n, &m); for (int i = 1; i <= n; ++i) scanf("%d", a + i); for (int i = 1; i <= m; ++i) { scanf("%d%d%d", &op[i].opt, &op[i].a, &op[i].b); if (op[i].opt) { q[op[i].b].emplace_back(make_pair(i, op[i].a)); } } for (auto &i : q[0]) { ans[i.first] = a[i.second]; } for (int i = 1; i <= m; ++i) { if (!op[i].opt) { a[op[i].a] = op[i].b; } for (auto &j : q[i]) { ans[j.first] = a[j.second]; } } for (int i = 1; i <= m; ++i) { if (op[i].opt) { printf("%d\n", ans[i]); } } return0; }