当前位置:网站首页>【集训DAY16】KC ‘ s Stars【dfs】
【集训DAY16】KC ‘ s Stars【dfs】
2022-07-29 23:52:00 【VL——MOESR】

思路:
直接爆搜然后判断
c o d e code code
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
struct node {
int x, y;
}a[10];
int b[10];
int dis[10][10];
bool v[10];
bool check() {
if(dis[b[1]][b[2]] != dis[b[2]][b[3]]) return 0;
if(dis[b[1]][b[2]] != dis[b[3]][b[4]]) return 0;
if(dis[b[1]][b[2]] != dis[b[4]][b[1]]) return 0;
if(dis[b[1]][b[3]] != dis[b[2]][b[4]]) return 0;
if(dis[b[5]][b[6]] != dis[b[7]][b[8]]) return 0;
if(dis[b[5]][b[8]] != dis[b[6]][b[7]]) return 0;
if(dis[b[5]][b[7]] != dis[b[6]][b[8]]) return 0;
return 1;
}
void dfs(int x) {
if(x == 8) {
if(check()) {
sort(b + 1, b + 5);
sort(b + 6, b + 9);
printf("YES\n");
for(int i = 1; i <= 8; i ++) {
printf("%d ", b[i]);
if(i == 4) printf("\n");
}
exit(0);
}
return ;
}
for(int i = 1; i <= 8; i ++) {
if(v[i] == 0) {
b[x + 1] = i;
v[i] = 1;
dfs(x + 1);
v[i] = 0;
}
}
}
int main() {
for(int i = 1; i <= 8; i ++) scanf("%d%d", &a[i].x, &a[i].y);
for(int i = 1; i <= 8; i ++)
for(int j = 1; j <= 8; j ++)
dis[i][j] = (a[i].x - a[j].x) * (a[i].x - a[j].x) + (a[i].y - a[j].y) * (a[i].y - a[j].y);
dfs(0);
printf("NO");
return 0;
}
边栏推荐
猜你喜欢

经典论文-SqueezeNet论文及实践

BEVDetNet:Bird‘s Eye View LiDAR Point Cloud based Real-time 3D Object Detection for Autonomous Drivi

第一范式、第二范式、第三范式

Getting Started with Sentinel

Design for failure 12 common design ideas

消息中间件解析 | 如何正确理解软件应用系统中关于系统通信的那些事?

月薪15k的阿里测试岗,面试原来这么简单

【openlayers】Map【1】

Gao Shu Xia|Triple Integral Exercises|Uncle Gao Shu|Handwritten Notes

标签分发协议(LDP)
随机推荐
devops学习(九) Helm工具--持续部署
经典论文-SqueezeNet论文及实践
HRNet-Facial-Landmark-Detection 训练自己数据集
一文解答web性能优化
logback过期日志文件自动删除
The basic parallel I/O port of single chip microcomputer development
How to design and implement report collaboration system for instruction set data products——Development practice of industrial collaborative manufacturing project based on instruction set IoT operating
EA&UML日拱一卒-多任务编程超入门-(2)进程和线程
vim相关介绍(二)
shell编写规范和变量
学会使用MySQL的Explain执行计划,SQL性能调优从此不再困难
重庆OI 2005 新年好
Brute force recursion to dynamic programming 04 (digital string conversion)
C陷阱与缺陷 第5章 库函数 5.1 返回整数的getchar函数
外包干了五年,废了...
vim相关介绍(三)
Windows 安装 MySQL 5.7详细步骤
Apache Doris 1.1 特性揭秘:Flink 实时写入如何兼顾高吞吐和低延时
Vulkan与OpenGL对比——Vulkan的全新渲染架构
【小程序项目开发-- 京东商城】uni-app之自定义搜索组件(下) -- 搜索历史