其他分享
首页 > 其他分享> > NOI2005瑰丽华尔兹

NOI2005瑰丽华尔兹

作者:互联网

include<bits/stdc++.h>

using namespace std;
namespace yspm{
inline int read()
{
int res=0,f=1; char k;
while(!isdigit(k=getchar())) if(k'-') f=-1;
while(isdigit(k)) res=res10+k-'0',k=getchar();
return res
f;
}
const int N=210;
int f[N][N],n,m,k,ans;
char mp[N][N];
int fx[5]={0,-1,1,0,0};
int fy[5]={0,0,0,-1,1};
struct node{
int val,pos;
};deque q;
inline bool in(int x,int y){return x<=n&&x>=1&&y>=1&&y<=m;}
inline void dp(int x,int y,int d,int tim)
{
q.clear();
for(int i=1;in(x,y);++i,x+=fx[d],y+=fy[d])
{
if(mp[x][y]
'x') {q.clear(); continue;}
while(q.size()&&q.back().val+i-q.back().pos<f[x][y]) q.pop_back();
q.push_back((node){f[x][y],i});
while(q.size()&&q.back().pos-q.front().pos>tim) q.pop_front();
f[x][y]=q.front().val+i-q.front().pos;
ans=max(ans,f[x][y]);
}return ;
}
signed main()
{
n=read(); m=read();
int p=read(),q=read(); k=read();
memset(f,-0x3f,sizeof(f)); f[p][q]=0;
for(int i=1;i<=n;++i) scanf("%s",mp[i]+1);
while(k--)
{
int s=read(),t=read(),d=read();
if(d1) for(int i=1;i<=m;++i) dp(n,i,d,t-s+1);
if(d
2) for(int i=1;i<=m;++i) dp(1,i,d,t-s+1);
if(d3) for(int i=1;i<=n;++i) dp(i,m,d,t-s+1);
if(d
4) for(int i=1;i<=n;++i) dp(i,1,d,t-s+1);
}printf("%d\n",ans);
return 0;
}
}
signed main(){return yspm::main();}

标签:华尔兹,while,return,int,pos,瑰丽,read,NOI2005,ans
来源: https://www.cnblogs.com/yspm/p/12769361.html