当前位置:网站首页>[Blue Bridge Cup 2017 preliminary] grid division
[Blue Bridge Cup 2017 preliminary] grid division
2022-07-06 11:25:00 【%xiao Q】
subject

analysis
Because every plan goes through the middle point (3,3), So we can (3,3) Start the minute 2 A direction Search for ( And this 2 The direction is symmetrical , So when one direction reaches the boundary , The other will also reach the border , That is an answer )
Reference code
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>
#include <algorithm>
#include <unordered_map>
#define LL long long
#define rep(i, a, b) for(int i = a; i <= b; i++)
#define reps(i, a, b) for(int i = a; i < b; i++)
#define pre(i, a, b) for(int i = b; i >= a; i--)
using namespace std;
typedef pair<int, int> PII;
bool st[10][10] = {
0};
int dx[] = {
1, -1, 0, 0};
int dy[] = {
0, 0, 1, -1};
int ans = 0;
void dfs(int x, int y)
{
// Meeting the boundary is a solution
if(x == 0 || x == 6 || y == 0 || y == 6)
{
ans++;
return ;
}
rep(i, 0, 3)
{
int x1 = x + dx[i], y1 = y + dy[i];
int x2 = 6 - x1, y2 = 6 - y1; //(X1,y1) About (3,3) Symmetrical points
if(x1 < 0 || x1 > 6 || y1 < 0 || y1 > 6 || st[x1][y1]) continue;
st[x1][y1] = st[x2][y2] = true; //2 Two symmetrical points are marks
dfs(x1, y1);
st[x1][y1] = st[x2][y2] = false; // to flash back
}
}
int main()
{
st[3][3] = true;
dfs(3, 3);
cout << ans / 4 << endl; // Because up and down , Both sides are symmetrical , So divide and 4
return 0;
}
边栏推荐
- In the era of DFI dividends, can TGP become a new benchmark for future DFI?
- Swagger, Yapi interface management service_ SE
- Case analysis of data inconsistency caused by Pt OSC table change
- Vs2019 first MFC Application
- ES6 let 和 const 命令
- Software testing and quality learning notes 3 -- white box testing
- 引入了junit为什么还是用不了@Test注解
- double转int精度丢失问题
- Windows下安装MongDB教程、Redis教程
- QT creator create button
猜你喜欢

How to configure flymcu (STM32 serial port download software) is shown in super detail

Request object and response object analysis

vs2019 第一个MFC应用程序

Did you forget to register or load this tag 报错解决方法

02-项目实战之后台员工信息管理

人脸识别 face_recognition

QT creator test

Mtcnn face detection

Case analysis of data inconsistency caused by Pt OSC table change

Software I2C based on Hal Library
随机推荐
QT creator uses Valgrind code analysis tool
[蓝桥杯2021初赛] 砝码称重
解决安装Failed building wheel for pillow
Punctual atom stm32f103zet6 download serial port pin
Software testing - interview question sharing
MySQL的一些随笔记录
牛客Novice月赛40
[蓝桥杯2017初赛]方格分割
Learning question 1:127.0.0.1 refused our visit
Armv8-a programming guide MMU (2)
The virtual machine Ping is connected to the host, and the host Ping is not connected to the virtual machine
Antlr4 uses keywords as identifiers
AcWing 179.阶乘分解 题解
How to configure flymcu (STM32 serial port download software) is shown in super detail
Windows下安装MongDB教程、Redis教程
引入了junit为什么还是用不了@Test注解
Install mongdb tutorial and redis tutorial under Windows
Ubuntu 20.04 安装 MySQL
Software I2C based on Hal Library
保姆级出题教程