(large{题目链接})
(\)
(Large extbf{Solution: } large{首先我的思路是对原序列进行排序离散,然后预处理出每个数字的最右对应数字的下标。然后再扫一遍求出有用的数字个数cnt,答案即为2^{cnt},复杂度 ext{O(nlogn)。}\其实可以 ext{O(n),因为值域太大,所以数组开不下,不过可以开vector啊,我当时没想到,STL大法好。}})
(\)
(Large extbf{Code: })
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 5;
const int p = 998244353;
int a[N], b[N], c[N], pos[N], nxt[N];
int pow(int x, int y) {
ll a = x, ret = 1;
for (; y ; y >>= 1, a = (a * a) % p) if (y & 1) ret = (ret * a) % p;
return ret;
}
int main() {
ios::sync_with_stdio(false);
int n, cnt = 0;
cin >> n;
for (int i = 1; i <= n; ++i) cin >> a[i], b[i] = a[i];
sort(b + 1, b + 1 + n);
int q = unique(b + 1, b + 1 + n) - b - 1;
for (int i = n; i >= 1; --i) {
c[i] = lower_bound(b + 1, b + 1 + q, a[i]) - b;
if (!pos[c[i]]) pos[c[i]] = i;
nxt[c[i]] = pos[c[i]];
}
int l = 1;
for (int i = 1; i <= n; ++i) {
if (i > l) ++cnt;
l = max(l, nxt[c[i]]);
}
cout << pow(2, cnt);
return 0;
}