From 3039ac5e93e25421ada52a01028df3d5846a7362 Mon Sep 17 00:00:00 2001 From: Zengtudor Date: Sun, 13 Oct 2024 13:36:20 +0800 Subject: [PATCH] update --- README.md | 8 ++++++++ src/P1330/P1330.cpp | 1 - src/P3957/P3957.cpp | 48 +++++++++++++++++++++++++++++++++++++++------ 3 files changed, 50 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 8ed2382..0c89af6 100755 --- a/README.md +++ b/README.md @@ -36,4 +36,12 @@ void bfs(){ set_color(i, 1); vis[i]=true; // 注意初始化错误 while(!q.empty()){ +``` + +### [P3957](https://www.luogu.com.cn/problem/P3957) +#### 初始状态依赖已走过的部分时注意起始点状态 +```cpp + for(ll coin{0};coin<=(points[n].posit-d);++coin){ + for(ll i{0};i using ll = long long; -using std::endl; static auto &is = std::cin; static auto &os = std::cout; diff --git a/src/P3957/P3957.cpp b/src/P3957/P3957.cpp index a069d25..af92663 100644 --- a/src/P3957/P3957.cpp +++ b/src/P3957/P3957.cpp @@ -1,17 +1,53 @@ +#include #include -#include +#include +#include +#include -using ll = unsigned long long; +using ll = long long; auto &is = std::cin; auto &os = std::cout; -const ll /*max_n = 5e5+5*/max_n = 500+5, max_d = 2e3+5, max_x = 1e9+5, max_k = 1e9+5; +const ll max_n = 5e5+5, ll_min{std::numeric_limits::min()}; +ll n, d, k; +struct Point{ + ll posit,score; +}points[max_n]; +ll dp[max_n]; -ll n,d,k; -std::bitset dp[max_d][max_n][max_n]; +void flush_exit(){ + os<>n>>d>>k; - + for(ll i{1};i<=n;++i){ + is>>points[i].posit>>points[i].score; + } + + for(ll coin{0};coin<=(points[n].posit-d);++coin){ + for(ll i{0};i=0;from--){ + ll dis{points[i].posit-points[from].posit}; + if(min_step<=dis){ + if(dis<=max_step){ + if(dp[from]==ll_min)continue; + dp[i] = std::max(dp[i],dp[from]+points[i].score); + if(dp[i]>=k){ + os<