The 10th Blue Bridge Cup (Clear Code + Maze)

The 10th Blue Bridge Cup Provincial Competition C++ Group B

The glyphs of Chinese characters exist in the font library, and even today, the 16-dot font library is still widely used.
The 16-dot font library regards each Chinese character as 16x16 pixel information. And record this information in bytes.

One byte can store 8 bits of information, and 32 bytes can store the glyph of a Chinese character.
Convert each byte to binary representation, 1 for ink, 0 for background color. 2 bytes per line, a
total of 16 lines, the layout is:

第1字节,第2字节
第3字节,第4字节
....
第31字节, 第32字节

This title is to give you a piece of information composed of multiple Chinese characters, each Chinese character is represented by 32 bytes, and the value of the bytes as a signed integer is given here.

The title's requirements are hidden in this information. Your task is to restore the glyphs of these Chinese characters, find out the requirements of the questions, and fill in the answers according to the requirements.

This piece of information is (10 Chinese characters in total):

4 0 4 0 4 0 4 32 -1 -16 4 32 4 32 4 32 4 32 4 32 8 32 8 32 16 34 16 34 32 30 -64 0
16 64 16 64 34 68 127 126 66 -124 67 4 66 4 66 -124 126 100 66 36 66 4 66 4 66 4 126 4 66 40 0 16
4 0 4 0 4 0 4 32 -1 -16 4 32 4 32 4 32 4 32 4 32 8 32 8 32 16 34 16 34 32 30 -64 0
0 -128 64 -128 48 -128 17 8 1 -4 2 8 8 80 16 64 32 64 -32 64 32 -96 32 -96 33 16 34 8 36 14 40 4
4 0 3 0 1 0 0 4 -1 -2 4 0 4 16 7 -8 4 16 4 16 4 16 8 16 8 16 16 16 32 -96 64 64
16 64 20 72 62 -4 73 32 5 16 1 0 63 -8 1 0 -1 -2 0 64 0 80 63 -8 8 64 4 64 1 64 0 -128
0 16 63 -8 1 0 1 0 1 0 1 4 -1 -2 1 0 1 0 1 0 1 0 1 0 1 0 1 0 5 0 2 0
2 0 2 0 7 -16 8 32 24 64 37 -128 2 -128 12 -128 113 -4 2 8 12 16 18 32 33 -64 1 0 14 0 112 0
1 0 1 0 1 0 9 32 9 16 17 12 17 4 33 16 65 16 1 32 1 64 0 -128 1 0 2 0 12 0 112 0
0 0 0 0 7 -16 24 24 48 12 56 12 0 56 0 -32 0 -64 0 -128 0 0 0 0 1 -128 3 -64 1 -128 0 0

【Answer submission】

This is a fill-in-the-blank question, you need to submit an integer, don't fill in any extra content.

Answer: 387420489

#include<iostream>
#include<cstdio>

#include<cstring>
#include<bitset>
#include<sstream>
#include<string.h>
#include<iomanip>

#include<cmath>
#include<algorithm>
#include<cstdlib>

#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
#define ll long long
#define lowbit(x) x&(-x) 
const ll inf=0x3f3f3f3f;
typedef pair<int ,int > PII;
int main(){
    
    
	//#define io
	#ifdef io
		freopen("in.txt","r",stdin);
	#endif 
	int n,m;
	bitset<8> t;
	string st;
	while(cin>>n>>m)
	{
    
    
		t = n;
		st = t.to_string();
		for(int i = 0; i < st.length(); i++)
		{
    
    
			if(st[i] == '0') printf(" ");
			else printf("*");
		}
		t = m;
		st = t.to_string();
		for(int i = 0; i < st.length(); i++)
		{
    
    
			if(st[i] == '0') printf(" ");
			else printf("*");
		}
		printf("\n");
	}
	int a,b,ans = 1;
	b = 9;
	a = 9;
	while(b)
	{
    
    
		if(b%2==1) ans = a*ans;
		a = a*a;
		b/=2;
	}
	printf("%d\n",ans);
	return 0;
}

The 10th Blue Bridge Cup Provincial Tournament C++ Group B Labyrinth

The figure below shows a plan view of a maze, in which the obstacles marked 1 are obstacles, and
the places marked 0 are accessible.

010000
000100
001001
110000

The entrance to the maze is the upper left corner and the exit is the lower right corner. In the maze, you can only go from one position to one of the four directions of up, down, left and right.

For the above maze, starting from the entrance, you can pass through the maze in the order of DRRURRDDDR, a total of 10 steps. Among them, D, U, L, and R represent going down, up, left, and right, respectively.

For the more complex maze below (30 rows and 50 columns), find a way to go through the maze that uses the fewest steps, and with the fewest steps, find the answer with the smallest lexicographical order. Note that D<L<R<U in the lexicographical order. (If you copy the following text into a text file, please be sure to check whether the copied content is consistent with the document. There is a file maze.txt in the test question directory with the same content as the text below)

Sample/Maze Map

01010101001011001001010110010110100100001000101010
00001000100000101010010000100000001001100110100101
01111011010010001000001101001011100011000000010000
01000000001010100011010000101000001010101011001011
00011111000000101000010010100010100000101100000000
11001000110101000010101100011010011010101011110111
00011011010101001001001010000001000101001110000000
10100000101000100110101010111110011000010000111010
00111000001010100001100010000001000101001100001001
11000110100001110010001001010101010101010001101000
00010000100100000101001010101110100010101010000101
11100100101001001000010000010101010100100100010100
00000010000000101011001111010001100000101010100011
10101010011100001000011000010110011110110100001000
10101010100001101010100101000010100000111011101001
10000000101100010000101100101101001011100000000100
10101001000000010100100001000100000100011110101001
00101001010101101001010100011010101101110000110101
11001010000100001100000010100101000001000111000010
00001000110000110101101000000100101001001000011101
10100101000101000000001110110010110101101010100001
00101000010000110101010000100010001001000100010101
10100001000110010001000010101001010101011111010010
00000100101000000110010100101001000001000000000010
11010000001001110111001001000011101001011011101000
00000110100010001000100000001000011101000000110011
10101000101000100010001111100010101001010000001000
10000010100101001010110000000100101010001011101000
00111100001000010000000110111000000001000000001011
10000001100111010111010001000110111010101101111000

【Answer submission】

   这是一道结果填空的题,你只需要算出结果后提交即可。本题的结果为一 个字符串,包含四种字母 D、U、L、R,在提交答案时只填写这个字符串,填写多余的内容将无法得分。

Answer:

DDDDRRURRRRRRDRRRRDDDLDDRDDDDDDDDDDDDRDDRRRURRUURRDDDDRDRRRRRRDRRURRDDDRRRRUURUUUUUUULULLUUUURRRRUULLLUUUULLUUULUURRURRURURRRDDRRRRRDDRRDDLLLDDRRDDRDDLDDDLLDDLLLDLDDDLDDRRRRRRRRRDDDDDDRR

Idea: Seeing that it is related to the minimum number of steps, it is natural to think of bfs. If you do not search once, you need to record the path. The title also says that the lexicographical order is the smallest, so we might as well arrange the search direction according to the lexicographical order when searching for the path. Sequentially. In order to verify the correctness of the answer, I also walked the maze manually _(:з"∠)_

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<set>
using namespace std;
#define N 30
#define M 50
char map[N][M];
int dir[4][2]={
    
    {
    
    1,0},{
    
    0,-1},{
    
    0,1},{
    
    -1,0}};//D<L<R<U
char ch[4]={
    
    'D','L','R','U'};
int vis[N][M]={
    
    0};
struct point
{
    
    
	int x,y;
	string road;
	point(int a,int b)
	{
    
    
		x=a;
		y=b;
	}
};
 
void bfs()
{
    
    
	queue<point> q;
	point p(0,0);
	p.road="";
	q.push(p);
	vis[0][0]=1;
	while(!q.empty())
	{
    
    
		point t=q.front();
		q.pop();
		if(t.x==N-1&&t.y==M-1)
		{
    
    
			cout<<t.road<<endl;
			break;
		}
		for(int i=0;i<4;i++)
		{
    
    
			int dx=t.x+dir[i][0];
			int dy=t.y+dir[i][1];
			if(dx>=0&&dx<N&&dy>=0&&dy<M)
			{
    
    
				if(map[dx][dy]=='0'&&!vis[dx][dy])
				{
    
    
					point tt(dx,dy);
					tt.road=t.road+ch[i];//记录路径
					q.push(tt);
					vis[dx][dy]=1;
				}
			}
		}
	}
}
 
int main()
{
    
    
    //freopen("in.txt","r",stdin);
	for(int i=0;i<N;i++)
	{
    
    
		scanf("%s",map[i]);
	}
	bfs();
	return 0;
}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325837426&siteId=291194637