当前位置:网站首页>Codeforces Round #416 (Div. 2) D. Vladik and Favorite Game
Codeforces Round #416 (Div. 2) D. Vladik and Favorite Game
2022-07-07 05:33:00 【Don't eat toast】
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <math.h>
#include <bitset>
#include <algorithm>
using namespace std;
#define X first
#define Y second
#define eps 1e-2
#define gcd __gcd
#define pb push_back
#define PI acos(-1.0)
#define lowbit(x) (x)&(-x)
#define bug printf("!!!!!\n");
#define mem(x,y) memset(x,y,sizeof(x))
typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef unsigned long long uLL;
const int N = 1e5+2;
const int INF = 1<<30;
const int mod = 1e9+7;
int n,m;
char ch[105][105],dr2[4]={
'D','U','R','L'};
int pre[105][105];
int dr[4][2]={
{
1,0},{
-1,0},{
0,1},{
0,-1}},vis[105][105];
pair<int,int> pre2[105][105];
int getd(int x,int y,int xx,int yy){
if(x-1==xx) return 1;
if(x+1==xx) return 0;
if(y-1==yy) return 3;
return 2;
}
bool check(int x,int y){
if(x>0&&x<=n&&y>0&&y<=m) return 1;
else return 0;
}
int edx,edy;
void sol1(){
for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) if(ch[i][j]=='F') edx=i,edy=j;
int sx=1,sy=1;
queue< pair<int,int> > q;
q.push({
sx,sy});
while(q.size()){
auto tp=q.front();q.pop();
vis[tp.first][tp.second]=1;
// cout<<tp.first<<" "<<tp.second<<endl;
for(int i=0;i<4;i++){
int x=tp.first+dr[i][0],y=tp.second+dr[i][1];
if(vis[x][y]==1||ch[x][y]=='*'||check(x,y)==0) continue;
q.push({
x,y});
vis[x][y]=1;
pre2[x][y]=tp;
}
}
// return ;
sx=edx,sy=edy;
// cout<<sx<<" "<<sy<<endl;
// cout<<pre2[sx][sy].first<<" "<<pre2[sx][sy].second<<endl;
while(sx!=1||sy!=1){
int px=sx,py=sy;
sx=pre2[px][py].first;
sy=pre2[px][py].second;
pre[sx][sy]=getd(sx,sy,px,py);
// cout<<sx<<" "<<sy<<endl;
// cout<<pre[sx][sy]<<" "<<dr2[pre[sx][sy]]<<endl;
}
}
map<int,int> mp;
void solve(){
for(int i=0;i<=3;i++) mp[i]=i;
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++) scanf("%s",ch[i]+1);
sol1();
int sx=1,sy=1;
while(sx!=edx||sy!=edy){
int mpop=mp[pre[sx][sy]];
// cout<<mpop<<endl;
cout<<dr2[mpop]<<endl;
int tsx=sx+dr[mpop][0],tsy=sy+dr[mpop][1];
// cout<<tsx<<" "<<tsy<<endl;
int tx,ty;cin>>tx>>ty;
if(tsx!=tx||tsy!=ty){
if(pre[sx][sy]==1||pre[sx][sy]==0) mp[0]=1,mp[1]=0;
else mp[2]=3,mp[3]=2;
mpop=mp[pre[sx][sy]];
cout<<dr2[mpop]<<endl;
cin>>tx>>ty;
}
sx=tx;sy=ty;
}
return;
}
int main()
{
// freopen("in.txt","r",stdin);
// freopen("out.txt","w",stdout);
// ios::sync_with_stdio(false);
int t = 1;
//scanf("%d",&t);
while(t--){
// printf("Case %d: ",cas++);
solve();
}
return 0;
}
边栏推荐
- The founder has a debt of 1billion. Let's start the class. Is it about to "end the class"?
- Photo selector collectionview
- JD commodity details page API interface, JD commodity sales API interface, JD commodity list API interface, JD app details API interface, JD details API interface, JD SKU information interface
- 基于 hugging face 预训练模型的实体识别智能标注方案:生成doccano要求json格式
- Life experience of an update statement
- Addressable pre Download
- 数字化创新驱动指南
- 设f(x)=∑x^n/n^2,证明f(x)+f(1-x)+lnxln(1-x)=∑1/n^2
- Writing process of the first paper
- Timer create timer
猜你喜欢

基于 hugging face 预训练模型的实体识别智能标注方案:生成doccano要求json格式

K6EL-100漏电继电器
![[论文阅读] Semi-supervised Left Atrium Segmentation with Mutual Consistency Training](/img/d6/e6db0d76e81e49a83a30f8c1832f09.png)
[论文阅读] Semi-supervised Left Atrium Segmentation with Mutual Consistency Training

Jhok-zbl1 leakage relay

论文阅读【Sensor-Augmented Egocentric-Video Captioning with Dynamic Modal Attention】

【js组件】自定义select

Pinduoduo product details interface, pinduoduo product basic information, pinduoduo product attribute interface

Use Zhiyun reader to translate statistical genetics books

4. Object mapping Mapster

Design, configuration and points for attention of network unicast (one server, multiple clients) simulation using OPNET
随机推荐
《5》 Table
Life experience of an update statement
4. 对象映射 - Mapping.Mapster
As we media, what websites are there to download video clips for free?
Let f (x) = Σ x^n/n^2, prove that f (x) + F (1-x) + lnxln (1-x) = Σ 1/n^2
1. AVL tree: left-right rotation -bite
说一说MVCC多版本并发控制器?
Pytest testing framework -- data driven
高级程序员必知必会,一文详解MySQL主从同步原理,推荐收藏
Jhok-zbl1 leakage relay
Tablayout modification of customized tab title does not take effect
Taobao commodity details page API interface, Taobao commodity list API interface, Taobao commodity sales API interface, Taobao app details API interface, Taobao details API interface
《4》 Form
基于NCF的多模块协同实例
JVM (19) -- bytecode and class loading (4) -- talk about class loader again
实现网页内容可编辑
Senior programmers must know and master. This article explains in detail the principle of MySQL master-slave synchronization, and recommends collecting
【js组件】自定义select
Zero sequence aperture of leakage relay jolx-gs62 Φ one hundred
论文阅读【Open-book Video Captioning with Retrieve-Copy-Generate Network】