0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-24 03:31:59 +00:00

4380. [POI2015]Myjnie

https://hydro.ac/d/bzoj/record/6322a2ebbdf9bc31d1605b23
This commit is contained in:
Baoshuo Ren 2022-09-15 12:01:41 +08:00
parent 226513485c
commit 0c3e00a97b
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
111 changed files with 441 additions and 0 deletions

111
BZOJ/4380/4380.cpp Normal file
View File

@ -0,0 +1,111 @@
#include <iostream>
#include <algorithm>
#include <numeric>
#include <tuple>
#include <vector>
using std::cin;
using std::cout;
const char endl = '\n';
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, m;
cin >> n >> m;
std::vector<std::tuple<int, int, int>> data(m);
std::vector<int> nums;
for (auto& e : data) {
int a, b, c;
cin >> a >> b >> c;
e = std::make_tuple(a - 1, b - 1, c);
nums.push_back(c);
}
std::sort(nums.begin(), nums.end());
nums.erase(std::unique(nums.begin(), nums.end()), nums.end());
for (auto& e : data) {
std::get<2>(e) = std::lower_bound(nums.begin(), nums.end(), std::get<2>(e)) - nums.begin();
}
std::vector<std::vector<int>> g(n, std::vector<int>(nums.size(), 0));
std::vector<std::vector<std::vector<int>>>
f(n, std::vector<std::vector<int>>(n, std::vector<int>(nums.size(), 0))),
pos(n, std::vector<std::vector<int>>(n, std::vector<int>(nums.size(), 0))),
pre(n, std::vector<std::vector<int>>(n, std::vector<int>(nums.size(), 0)));
for (int len = 1; len <= n; len++) {
for (int l = 0, r = l + len - 1; r < n; l++, r++) {
std::for_each(g.begin() + l, g.begin() + r + 1, [&](auto& v) {
std::fill(v.begin(), v.end(), 0);
});
for (const auto& e : data) {
int a, b, c;
std::tie(a, b, c) = e;
if (l <= a && b <= r) {
std::for_each(g.begin() + a, g.begin() + b + 1, [&](auto& v) { v[c]++; });
}
}
std::for_each(g.begin() + l, g.begin() + r + 1, [&](auto& v) {
std::partial_sum(v.rbegin(), v.rend(), v.rbegin());
});
for (int i = nums.size() - 1; i >= 0; i--) {
int max = 0;
for (int j = l; j <= r; j++) {
int t = (j > 0 ? f[l][j - 1][i] : 0)
+ (j + 1 < n ? f[j + 1][r][i] : 0)
+ g[j][i] * nums[i];
if (max <= t) {
max = t;
pos[l][r][i] = j;
}
}
if (i + 1 == nums.size() || f[l][r][i + 1] <= max) {
f[l][r][i] = max;
pre[l][r][i] = i;
} else {
f[l][r][i] = f[l][r][i + 1];
pre[l][r][i] = pre[l][r][i + 1];
}
}
}
}
cout << f[0][n - 1][0] << endl;
std::vector<int> ans(n);
auto dfs = [&](int l, int r, int k, auto&& dfs) -> void {
if (l > r) return;
int p = pos[l][r][k = pre[l][r][k]];
ans[p] = nums[k];
dfs(l, p - 1, k, dfs);
dfs(p + 1, r, k, dfs);
};
dfs(0, n - 1, 0, dfs);
for (const int& x : ans) {
cout << x << ' ';
}
cout << endl;
return 0;
}

BIN
BZOJ/4380/data/1.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/1.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/10.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/10.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/11.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/11.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/12.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/12.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/13.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/13.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/14.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/14.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/15.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/15.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/16.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/16.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/17.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/17.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/18.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/18.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/19.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/19.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/2.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/2.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/20.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/20.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/21.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/21.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/22.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/22.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/23.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/23.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/24.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/24.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/25.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/25.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/26.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/26.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/27.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/27.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/28.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/28.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/29.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/29.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/3.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/3.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/30.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/30.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/31.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/31.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/32.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/32.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/33.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/33.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/34.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/34.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/35.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/35.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/36.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/36.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/37.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/37.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/38.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/38.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/39.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/39.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/4.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/4.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/40.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/40.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/41.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/41.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/42.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/42.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/43.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/43.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/44.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/44.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/45.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/45.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/46.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/46.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/47.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/47.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/48.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/48.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/49.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/49.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/5.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/5.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/50.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/50.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/51.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/51.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/52.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/52.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/53.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/53.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4380/data/54.in (Stored with Git LFS) Normal file

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More