当前位置:网站首页>[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;
}
边栏推荐
- 项目实战-后台员工信息管理(增删改查登录与退出)
- QT creator test
- 软件测试-面试题分享
- QT creator specify editor settings
- Test objects involved in safety test
- Antlr4 uses keywords as identifiers
- What does BSP mean
- When you open the browser, you will also open mango TV, Tiktok and other websites outside the home page
- 基于apache-jena的知识问答
- 牛客Novice月赛40
猜你喜欢
Kept VRRP script, preemptive delay, VIP unicast details
Windows下安装MongDB教程、Redis教程
About string immutability
Machine learning notes week02 convolutional neural network
How to configure flymcu (STM32 serial port download software) is shown in super detail
Deoldify项目问题——OMP:Error#15:Initializing libiomp5md.dll,but found libiomp5md.dll already initialized.
Face recognition_ recognition
Vs2019 desktop app quick start
QT creator specify editor settings
QT creator test
随机推荐
neo4j安装教程
QT creator custom build process
Dotnet replaces asp Net core's underlying communication is the IPC Library of named pipes
vs2019 第一个MFC应用程序
Ansible practical Series III_ Task common commands
Machine learning -- census data analysis
02 staff information management after the actual project
Why can't STM32 download the program
报错解决 —— io.UnsupportedOperation: can‘t do nonzero end-relative seeks
Kept VRRP script, preemptive delay, VIP unicast details
Remember a company interview question: merge ordered arrays
记某公司面试算法题:查找一个有序数组某个数字出现的次数
Leetcode 461 Hamming distance
数据库高级学习笔记--SQL语句
误删Path变量解决
[AGC009D]Uninity
图像识别问题 — pytesseract.TesseractNotFoundError: tesseract is not installed or it‘s not in your path
Django运行报错:Error loading MySQLdb module解决方法
QT creator create button
QT creator support platform