当前位置:网站首页>Did you brush the real title of the blue bridge cup over the years? Come here and teach you to counter attack!
Did you brush the real title of the blue bridge cup over the years? Come here and teach you to counter attack!
2022-07-05 21:50:00 【Blue bridge cloud class】
The Blue Bridge Cup registration has begun , Are you ready ?
Before the entry , We must be well prepared , In addition to learning basic knowledge such as algorithms , Also learn to fight .
today , I bring 2017 The real problem of the 2011 Blue Bridge Cup provincial competition , Welcome to do the questions together ~ Poke me alone or move the work Zong number : Blue bridge cloud class , You can get the Blue Bridge Cup real question bank for free !(PS: Don't just look without thinking without tapping the code !)
01 The real problem of the Blue Bridge Cup provincial competition
This question is to fill in the blanks , Just calculate the result , Use the output statement in the code to output the filled results .
X A labyrinth playground on the planet is built on a hillside . It is from 10x10 Made up of interconnected small rooms . There is a big letter on the floor of the room . Let's assume that the player is standing facing uphill , be :
L Go to the room on the left ;
R Go to the room on the right ;
U It means walking up the slope ;
D It means going downhill .
X The inhabitants of the planet are a little lazy , Not willing to think . They prefer to play games of luck . The same is true of this game !
At the beginning , Helicopter handle 100 Players into a small room . Players must move according to the letters on the ground .
The map of the maze is as follows :
UDDLUULRUL
UURLLLRRRU
RRUURLDLRD
RUDDDDUUUU
URUDLLRRUU
DURLRLDLRL
ULLURLLRDU
RDLULLRDDD
UUDDUDUDLL
ULRDLUURRR
Please calculate , Last , How many players will walk out of the maze ? Instead of going around in circles .
If you don't understand the rules of the game , See the following simplified 4x4 Explanation of the maze :
02 Their thinking
(1) Opportunistic
according to “ Note to examinees ”, This question is to fill in the blanks , Just hand in the answer . If you don't want to code , Directly count them one by one with your hands 100 A little bit , It's finished in a few minutes , The answer is 31, Faster than coding .
(2) DFS code
A search question , You can choose dfs, The code is short .
#include <iostream>
using namespace std;
#include<vector>
#include<string>
using namespace std;
int ans;
vector<vector<char>>s={
{'U','D','D','L','U','U','L','R','U','L'},
{'U','U','R','L','L','L','R','R','R','U'},
{'R','R','U','U','R','L','D','L','R','D'},
{'R','U','D','D','D','D','U','U','U','U'},
{'U','R','U','D','L','L','R','R','U','U'},
{'D','U','R','L','R','L','D','L','R','L'},
{'U','L','L','U','R','L','L','R','D','U'},
{'R','D','L','U','L','L','R','D','D','D'},
{'U','U','D','D','U','D','U','D','L','L'},
{'U','L','R','D','L','U','U','R','R','R'}};
bool vis[100][100];
void dfs(int x,int y)
{
if(vis[x][y] == true)
return;
if(x<0||y<0||x>=s.size() || y>=s[x].size())
{
ans++;
return;
}
switch (s[x][y])
{
case 'U':
vis[x][y]= true;dfs(x-1,y);vis[x][y]= false;break;
case 'L':
vis[x][y]= true;dfs(x,y-1);vis[x][y]= false;break;
case 'R':
vis[x][y]= true;dfs(x,y+1);vis[x][y]= false;break;
case 'D':
vis[x][y]= true;dfs(x+1,y);vis[x][y]= false;break;
default:return;
}
}
void has_Path()
{
for(int i=0;i<s.size();++i)
for(int j=0;j<s[i].size();++j)
dfs(i,j);
}
int main()
{
has_Path();
cout<<ans;
}
That's all for today's Blue Bridge Cup real question , In the future, I will update the explanation of the real blue bridge cup from time to time .
If there is any Blue Bridge Cup 、 Code problem , You can also poke me alone , Or step-by-step gongzong number : Blue bridge cloud class
边栏推荐
- 123456
- HDU 4391 paint the wall segment tree (water
- Simple interest mode - lazy type
- 冯唐“春风十里不如你”数字藏品,7月8日登录希壤!
- NET中小型企业项目开发框架系列(一个)
- 资深电感厂家告诉你电感什么情况会有噪音电感噪音是比较常见的一种电感故障情况,如果使用的电感出现了噪音大家也不用着急,只需要准确查找分析出什么何原因,其实还是有具体的方法来解决的。作为一家拥有18年品牌
- 华为游戏多媒体服务调用屏蔽指定玩家语音方法,返回错误码3010
- Why can't Chinese software companies produce products? Abandon the Internet after 00; Open source high-performance API gateway component of station B | weekly email exclusive to VIP members of Menon w
- Poj3414 extensive search
- An exception occurred in Huawei game multimedia calling the room switching method internal system error Reason:90000017
猜你喜欢
What should I do to prepare for the interview algorithm position during school recruitment?
Xlrd common operations
怎么利用Tensorflow2进行猫狗分类识别
Matlab | app designer · I used Matlab to make a real-time editor of latex formula
EBS Oracle 11g cloning steps (single node)
An exception occurred in Huawei game multimedia calling the room switching method internal system error Reason:90000017
Teach yourself to train pytorch model to Caffe (2)
Haas506 2.0 development tutorial - Alibaba cloud OTA - PAC firmware upgrade (only supports versions above 2.2)
Comprehensive optimization of event R & D workflow | Erda version 2.2 comes as "7"
Parker driver maintenance COMPAX controller maintenance cpx0200h
随机推荐
怎么利用Tensorflow2进行猫狗分类识别
Incentive mechanism of Ethereum eth
Poj 3237 Tree (Tree Chain Split)
Yolov5 training custom data set (pycharm ultra detailed version)
int GetMonth( ) const throw( ); What does throw () mean?
深信服X计划-网络协议基础 DNS
Some things make feelings nowhere to put
Alibaba cloud award winning experience: build a highly available system with polardb-x
[daily training -- Tencent select 50] 89 Gray code (only after seeing the solution of the problem)
Dbeaver executes multiple insert into error processing at the same time
Implementing Lmax disruptor queue from scratch (IV) principle analysis of multithreaded producer multiproducersequencer
ICMP 介绍
How to use tensorflow2 for cat and dog classification and recognition
Access Zadig self-test environment outside the cluster based on ingress controller (best practice)
854. String BFS with similarity K
張麗俊:穿透不確定性要靠四個“不變”
matlab绘制hsv色轮图
Selenium finds the contents of B or P Tags
Problems encountered in office--
crm创建基于fetch自己的自定义报告