题解:CF1102E Monotonic Renumeration
RpInfinity · · 题解
Upd on 2026-5-29:发现了一个错别字,拜托管理员再审一下。
水题???
思路
考虑从若
考虑两组位置
考虑用一个 map 存下对于每一个
那么合并的时候,显然就可以从左到右,维护当前块的右端点
显然对于
代码如下:
::::success[Code]
#include <bits/stdc++.h>
using namespace std;
#define inl inline
#define ls (p << 1)
#define rs (p << 1 | 1)
#define Cst constexpr
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define pb(x) push_back(x)
#define SZ(x) (int)(x).size()
#define ppc(x) __builtin_popcount(x)
#define All(x) (x).begin(), (x).end()
#define mems(x, v) memset((x), (v), sizeof(x))
#define memc(x, y) memcpy((x), (y), sizeof(x))
using LL = long long;
using ULL = unsigned long long;
Cst int N = 2e5 + 5, Mod = 998244353;
auto fIO = []() {
return cin.tie(0)->sync_with_stdio(0), 0;
}();
int n, a[N];
map<int, int> lst;
signed main() {
cin >> n;
for (int i = 1; i <= n; ++i) {
cin >> a[i];
lst[a[i]] = i;
}
int cnt = 0, r = 0;
for (int i = 1; i <= n; ++i) {
r = max(r, lst[a[i]]);
if (i == r) ++cnt;
}
LL Ans = 1;
for (int i = 1; i < cnt; ++i) Ans = Ans * 2 % Mod;
cout << Ans << '\n';
}
::::