Codeforces Round #659 (Div. 2) B1. Koa and the Beach (Easy Version)
Posted acmllf
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Codeforces Round #659 (Div. 2) B1. Koa and the Beach (Easy Version)相关的知识,希望对你有一定的参考价值。
题意 小明从一岸游泳到另一岸,每片区域有水深,一旦水深超过L,小明就会淹死
同时每段时刻有海浪和退潮
搜索一下 然后记忆化一下
老了,搜索写半天
#include<bits/stdc++.h> using namespace std; /*int main() { // freopen("data2.in", "r", stdin); // freopen("data2.out", "w", stdout); int n,m; cin>>n; for(int i=1;i<=n;i++) { int x; cin>>x; a[i]=a[i-1]+x; } cin>>m; while(m--) { int l,r; cin>>l>>r; if(l==r) cout<<a[l]-a[l-1]<<endl; else cout<<a[r]-a[l-1]<<endl; } }*/ int d[105]; int n,k,l; int vis[105][205]; int dfs(int x,int t) { if(vis[x][t]) return 0; vis[x][t]=1; int flag=0; if(x==n+1) return 1; t=t%(2*k); int ad; if(t<=k) ad=t; else ad=k-(t-k); if(x!=0&&(d[x]+ad)>l) return 0; flag=max(flag,dfs(x+1,t+1)); t++; t=t%(2*k); if(t<=k) ad=t; else ad=k-(t-k); if(x>0) { if(d[x]+ad>l) return max(flag,0); } flag=max(dfs(x,t),flag); return flag; } int main() { int t; cin>>t; while(t--) { memset(vis,0,sizeof(vis)); int flag=0; cin>>n>>k>>l; for(int i=1;i<=n;i++) { cin>>d[i]; if(d[i]>l) flag=1; } if(flag){cout<<"NO"<<endl;continue;} if(dfs(0,0))cout<<"YES"<<endl; else cout<<"NO"<<endl; } } /*int main() { // freopen("data.in", "r", stdin); //freopen("test.in", "w", stdout); int t; cin>>t; mt19937 u32Rnd(time(0)); cout<<t<<endl; while(t--) { int n; while((n=u32Rnd())<1); cout<<n<<endl; } }*/
以上是关于Codeforces Round #659 (Div. 2) B1. Koa and the Beach (Easy Version)的主要内容,如果未能解决你的问题,请参考以下文章
Codeforces Round #659 (Div. 2)
Codeforces Round #659 (Div. 1) 题解 (AB)
Codeforces Round #659 (Div. 2) A.Common Prefixes
Codeforces Round #659 (Div. 2) D GameGame
Codeforces Round #659 (Div. 2) B1. Koa and the Beach (Easy Version)