update
This commit is contained in:
parent
0de7fbaabb
commit
3039ac5e93
@ -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<max_n;i++)dp[i]=ll_min;
|
||||
dp[0]=0; // 注意第0个点是能到达的reachable
|
||||
```
|
@ -4,7 +4,6 @@
|
||||
#include <algorithm>
|
||||
|
||||
using ll = long long;
|
||||
using std::endl;
|
||||
static auto &is = std::cin;
|
||||
static auto &os = std::cout;
|
||||
|
||||
|
@ -1,17 +1,53 @@
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <bitset>
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
#include <type_traits>
|
||||
|
||||
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<decltype(ll_min)>::min()};
|
||||
ll n, d, k;
|
||||
struct Point{
|
||||
ll posit,score;
|
||||
}points[max_n];
|
||||
ll dp[max_n];
|
||||
|
||||
ll n,d,k;
|
||||
std::bitset<max_n> dp[max_d][max_n][max_n];
|
||||
void flush_exit(){
|
||||
os<<std::flush;
|
||||
_Exit(0);
|
||||
}
|
||||
|
||||
int main(){
|
||||
is>>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<max_n;i++)dp[i]=ll_min;
|
||||
dp[0]=0; // 注意第0个点是能到达的reachable
|
||||
const ll max_step {coin+d}, min_step {std::max((ll)1,d-coin)};
|
||||
for(ll i{1};i<=n;++i){
|
||||
for(ll from{i-1};from>=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<<coin<<'\n';
|
||||
flush_exit();
|
||||
}
|
||||
}else{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
os<<-1<<'\n';
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user