当前位置:网站首页>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
边栏推荐
- uni-app 蓝牙通信
- HDU 4391 paint the wall segment tree (water
- 事项研发工作流全面优化|Erda 2.2 版本如“七”而至
- Dbeaver executes multiple insert into error processing at the same time
- Deployment of Jenkins under win7
- Defect detection - Halcon surface scratch detection
- Cross end solution to improve development efficiency rapidly
- [daily training -- Tencent select 50] 89 Gray code (only after seeing the solution of the problem)
- 如何组织一场实战攻防演练
- Recursive query of multi-level menu data
猜你喜欢
Reading and writing operations of easyexcel
Evolution of zhenai microservice underlying framework from open source component encapsulation to self-development
An exception occurred in Huawei game multimedia calling the room switching method internal system error Reason:90000017
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
Interviewer: will concurrent programming practice meet? (detailed explanation of thread control operation)
Some common processing problems of structural equation model Amos software
EBS Oracle 11g 克隆步骤(单节点)
Matlab | app designer · I used Matlab to make a real-time editor of latex formula
2.2.5 basic sentences of R language drawing
Oracle checkpoint queue - Analysis of the principle of instance crash recovery
随机推荐
从零开始实现lmax-Disruptor队列(四)多线程生产者MultiProducerSequencer原理解析
Objects in the list, sorted by a field
Huawei cloud modelarts text classification - takeout comments
The solution to the problem that Oracle hugepages are not used, causing the server to be too laggy
使用Aspect制作全局异常处理类
Teach yourself to train pytorch model to Caffe (I)
SecureCRT使用提示
Codeforces 12D ball tree array simulation 3 sorting elements
SQL knowledge leak detection
MMAP学习
Some things make feelings nowhere to put
Some common processing problems of structural equation model Amos software
Deeply convinced plan X - network protocol basic DNS
kingbaseES V8R3数据安全案例之---审计记录清除案例
regular expression
Four components of logger
Selenium finds the contents of B or P Tags
Simple interest mode - lazy type
初级软件测试必问面试题
总结出现2xx、3xx、4xx、5xx状态码的原因