2020.11.19 刷题记录

1 tran

题意:给出一个图,求从任一位置射入光束后光束存在的最长时间与射入方向。若存在多种时间相同的,输出字典序最小的方案。
题解:比较water的大模拟,题意看对很快能想出来

CODE
 
#include
using namespace std;
#define re register
#define LL long long
#define DB double
#define il inline
#define For(x,a,b) for(re int x=a;x<=b;x++)
#define For2(x,a,b) for(re int x=a;x>=b;x--)
#define LFor(x,a,b) for(re LL x=a;x<=b;x++)
#define LFor2(x,a,b) for(re LL x=a;x>=b;x--)
#define Abs(x) ((x>0)? x:-x)
#define INF 100000000
#define pii pair<int,int>
#define fi first
#define se second
#define mabs(x) ((abs(x))==(0)? (INF):(abs(x)))
int gi()
{
    int res=0,fh=1;char ch=getchar();
    while((ch>'9'||ch<'0')&&ch!='-') ch=getchar();
    if(ch=='-') fh=-1,ch=getchar();
    while(ch>='0'&&ch<='9')res=res*10+ch-'0',ch=getchar();
    return fh*res;
}
LL gl()
{
    LL res=0,fh=1;char ch=getchar();
    while((ch>'9'||ch<'0')&&ch!='-') ch=getchar();
    if(ch=='-') fh=-1,ch=getchar();
    while(ch>='0'&&ch<='9')res=res*10+ch-'0',ch=getchar();
    return fh*res;
}
char mp[4]={'U','D','L','R'};
int n,m,a[505][505];
bool mrk[505][505][4][4];
int Time,ans[10];
int solve(pii POS,pii D)
{
	int x=POS.fi,y=POS.se,dx=D.fi,dy=D.se;
	if(x<1 || x>n || y<1 || y>m || a[x][y]==2)
		return Time;
	if(mrk[x][y][dx+1][dy+1])
			return INF;
	mrk[x][y][dx+1][dy+1]=true;
	Time++;
	if(a[x][y]==0) return solve(pii(x+dx,y+dy),D);
	int ndx=dy*a[x][y],ndy=dx*a[x][y];
	return solve(pii(x+ndx,y+ndy),pii(ndx,ndy));
}
void init()
{
	Time=0;
	memset(mrk,0,sizeof(mrk));
}
上一篇:android自定义控件的惯性滑动


下一篇:idea导入工程