mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-09 17:18:49 +00:00
#1543. 【2022 正睿 NOIP 十连测 Day4】零二(Zero Two)
https://sjzezoj.com/submission/70995
This commit is contained in:
parent
2d19eb0ab2
commit
0cfa7fdef7
64
S2OJ/1543/1543.cpp
Normal file
64
S2OJ/1543/1543.cpp
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <cstring>
|
||||||
|
#include <iterator>
|
||||||
|
#include <utility>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
using std::cin;
|
||||||
|
using std::cout;
|
||||||
|
const char endl = '\n';
|
||||||
|
|
||||||
|
const int N = 105;
|
||||||
|
const int mod = 998244353;
|
||||||
|
|
||||||
|
int n, a[N], p[N], f[N][N][N];
|
||||||
|
std::vector<std::pair<int, int>> nums;
|
||||||
|
|
||||||
|
int solve(int l, int r, int x) {
|
||||||
|
if (x == 0) return 1;
|
||||||
|
if (l == r) return 1;
|
||||||
|
if (f[l][r][x] != -1) return f[l][r][x];
|
||||||
|
|
||||||
|
int pos = std::find(p + l, p + r + 1, x) - p;
|
||||||
|
|
||||||
|
if (pos > r) {
|
||||||
|
return f[l][r][x] = solve(l, r, x - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int res = 0;
|
||||||
|
|
||||||
|
for (int i = pos; i <= r; i++) {
|
||||||
|
if (p[i] <= x) {
|
||||||
|
res = (res + static_cast<long long>(solve(l, i, x - 1)) * solve(i + 1, r, x) % mod) % mod;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return f[l][r][x] = res;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
std::ios::sync_with_stdio(false);
|
||||||
|
cin.tie(nullptr);
|
||||||
|
|
||||||
|
cin >> n;
|
||||||
|
|
||||||
|
for (int i = 1; i <= n; i++) {
|
||||||
|
cin >> a[i];
|
||||||
|
|
||||||
|
nums.emplace_back(a[i], i);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::sort(nums.begin(), nums.end());
|
||||||
|
nums.erase(std::unique(nums.begin(), nums.end()), nums.end());
|
||||||
|
|
||||||
|
for (int i = 1; i <= n; i++) {
|
||||||
|
p[i] = std::distance(nums.begin(), std::lower_bound(nums.begin(), nums.end(), std::pair<int, int>{a[i], i}));
|
||||||
|
}
|
||||||
|
|
||||||
|
memset(f, 0xff, sizeof(f));
|
||||||
|
|
||||||
|
cout << solve(1, n, n) << endl;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
BIN
S2OJ/1543/data/data1.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1543/data/data1.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1543/data/data1.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1543/data/data1.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1543/data/data10.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1543/data/data10.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1543/data/data10.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1543/data/data10.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1543/data/data11.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1543/data/data11.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1543/data/data11.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1543/data/data11.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1543/data/data12.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1543/data/data12.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1543/data/data12.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1543/data/data12.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1543/data/data13.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1543/data/data13.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1543/data/data13.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1543/data/data13.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1543/data/data14.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1543/data/data14.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1543/data/data14.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1543/data/data14.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1543/data/data15.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1543/data/data15.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1543/data/data15.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1543/data/data15.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1543/data/data16.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1543/data/data16.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1543/data/data16.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1543/data/data16.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1543/data/data17.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1543/data/data17.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1543/data/data17.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1543/data/data17.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1543/data/data18.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1543/data/data18.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1543/data/data18.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1543/data/data18.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1543/data/data19.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1543/data/data19.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1543/data/data19.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1543/data/data19.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1543/data/data2.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1543/data/data2.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1543/data/data2.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1543/data/data2.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1543/data/data20.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1543/data/data20.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1543/data/data20.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1543/data/data20.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1543/data/data21.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1543/data/data21.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1543/data/data21.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1543/data/data21.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1543/data/data22.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1543/data/data22.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1543/data/data22.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1543/data/data22.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1543/data/data23.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1543/data/data23.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1543/data/data23.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1543/data/data23.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1543/data/data24.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1543/data/data24.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1543/data/data24.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1543/data/data24.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1543/data/data3.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1543/data/data3.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1543/data/data3.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1543/data/data3.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1543/data/data4.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1543/data/data4.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1543/data/data4.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1543/data/data4.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1543/data/data5.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1543/data/data5.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1543/data/data5.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1543/data/data5.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1543/data/data6.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1543/data/data6.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1543/data/data6.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1543/data/data6.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1543/data/data7.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1543/data/data7.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1543/data/data7.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1543/data/data7.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1543/data/data8.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1543/data/data8.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1543/data/data8.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1543/data/data8.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1543/data/data9.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1543/data/data9.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1543/data/data9.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1543/data/data9.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1543/data/ex_data1.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1543/data/ex_data1.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1543/data/ex_data1.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1543/data/ex_data1.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1543/data/ex_data2.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1543/data/ex_data2.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1543/data/ex_data2.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1543/data/ex_data2.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1543/data/ex_data3.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1543/data/ex_data3.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1543/data/ex_data3.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1543/data/ex_data3.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1543/data/ex_data4.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1543/data/ex_data4.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1543/data/ex_data4.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1543/data/ex_data4.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1543/data/ex_data5.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1543/data/ex_data5.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1543/data/ex_data5.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1543/data/ex_data5.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1543/data/problem.conf
(Stored with Git LFS)
Normal file
BIN
S2OJ/1543/data/problem.conf
(Stored with Git LFS)
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user