当前位置:网站首页>[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;
}
边栏推荐
- Neo4j installation tutorial
- ES6 let 和 const 命令
- AI benchmark V5 ranking
- QT creator uses Valgrind code analysis tool
- Did you forget to register or load this tag 报错解决方法
- MySQL master-slave replication, read-write separation
- 一键提取pdf中的表格
- 数据库高级学习笔记--SQL语句
- Ansible practical Series II_ Getting started with Playbook
- Vs2019 first MFC Application
猜你喜欢
One click extraction of tables in PDF
Face recognition_ recognition
图片上色项目 —— Deoldify
Integration test practice (1) theoretical basis
Vs2019 desktop app quick start
Learn winpwn (3) -- sEH from scratch
[download app for free]ineukernel OCR image data recognition and acquisition principle and product application
About string immutability
MySQL主从复制、读写分离
[number theory] divisor
随机推荐
About string immutability
Ansible practical series I_ introduction
[蓝桥杯2020初赛] 平面切分
Did you forget to register or load this tag
Database advanced learning notes -- SQL statement
Vs2019 first MFC Application
DICOM: Overview
PyCharm中无法调用numpy,报错ModuleNotFoundError: No module named ‘numpy‘
Error reporting solution - io UnsupportedOperation: can‘t do nonzero end-relative seeks
Ansible practical Series II_ Getting started with Playbook
解决安装Failed building wheel for pillow
Django running error: error loading mysqldb module solution
Data dictionary in C #
AcWing 179.阶乘分解 题解
What does BSP mean
机器学习--人口普查数据分析
Vs2019 desktop app quick start
Kept VRRP script, preemptive delay, VIP unicast details
Remember a company interview question: merge ordered arrays
QT creator custom build process