当前位置:网站首页>Blue Bridge Cup seven segment code (dfs/ shape pressing + parallel search)
Blue Bridge Cup seven segment code (dfs/ shape pressing + parallel search)
2022-06-24 07:33:00 【Lin Shiliu should work hard】

#include<iostream>
#include<queue>
#include<cmath>
#include<cstring>
using namespace std;
int g[10][10];
//abcdefg
//0123456
int p[10];
bool vis[10];
int res;
void init()
{
for(int i=0;i<10;i++) p[i]=i;
memset(vis,false,sizeof vis);
}
int find(int x)
{
if(p[x]!=x) p[x]=find(p[x]);
return p[x];
}
void solve()
{
for(int i=1;i<1<<7;i++)
{
init();
int st=i;
for(int j=0;j<7;j++)
if(st>>j&1)
vis[j]=true;
for(int j=0;j<7;j++)
for(int k=0;k<7;k++)
if(vis[j]&&vis[k]&&g[j][k]==1)
{
int a=find(j),b=find(k);
if(a!=b) p[a]=b;
}
int t=0;
for(int j=0;j<7;j++)
if(p[j]==j&&vis[j]) t++;
if(t==1) res++;
}
}
int main()
{
g[0][1]=g[0][5]=1;
g[1][0]=g[1][6]=g[1][2]=1;
g[2][1]=g[2][6]=g[2][3]=1;
g[3][2]=g[3][4]=1;
g[4][5]=g[4][6]=g[4][3]=1;
g[5][0]=g[5][4]=g[5][6]=1;
g[6][1]=g[6][2]=g[6][4]=g[6][5]=1;
solve();
cout<<res;
}
边栏推荐
- Fine! Storage knowledge is a must for network engineers!
- MFC使用控制台时 项目路径中不能有空格和中文,否则会报错误 LNK1342 未能保存要编辑的二进制文件的备份副本等
- RDD basic knowledge points
- Cisco router configuration notes: static routing, rip, OSPF, principles combined with experiments, worth a visit!
- What is a CC attack? How to judge whether a website is attacked by CC? How to defend against CC attacks?
- 使用SystemParametersInfo访问用户界面设置
- [learn FPGA programming from scratch -42]: Vision - technological evolution of chip design in the "post Moorish era" - 1 - current situation
- Face pincher: a hot meta universe stylist
- Win11分磁盘怎么分?Win11系统怎么分磁盘?
- JVM debugging tool -jmap
猜你喜欢

Leetcode probability interview shock series 11~15

bjdctf_2020_babystack
![(cve-2020-11978) command injection vulnerability recurrence in airflow DAG [vulhub range]](/img/33/d601a6f92b1b73798dceb027263223.png)
(cve-2020-11978) command injection vulnerability recurrence in airflow DAG [vulhub range]
![buuctf misc [UTCTF2020]docx](/img/e4/e160f704d6aa754e85056840e14bd2.png)
buuctf misc [UTCTF2020]docx

MySQL enable binlog

Summary of 2022 blue team HW elementary interview questions

在终端pip install xxx但在pycharm却no module named xxx

Canal installation configuration
![[GUET-CTF2019]zips](/img/79/22ff5d4a3cdc3fa9e0957ccc9bad4b.png)
[GUET-CTF2019]zips

How to open the soft keyboard in the computer, and how to open the soft keyboard in win10
随机推荐
(cve-2020-11978) command injection vulnerability recurrence in airflow DAG [vulhub range]
[wustctf2020] climb
Several misunderstandings of VPN
Tutorial on simple use of Modbus to BACnet gateway
【图像融合】基于NSST结合PCNN实现图像融合附matlab代码
How to distinguish PAAS, IAAs and SaaS?
取模软件 模拟显示验证取模数据正确性 逆向 把点阵数组bin文件转显示
10 common malware detection and analysis platforms
[WordPress website] 6 Article content copy prevention
MFC使用控制台时 项目路径中不能有空格和中文,否则会报错误 LNK1342 未能保存要编辑的二进制文件的备份副本等
Big factories are not the only way to measure ability. The three years' experience of Shangcai's graduation
[DDCTF2018](╯°□°)╯︵ ┻━┻
【图像特征提取】基于脉冲耦合神经网络(PCNN)实现图像特征提取含Matlab源码
More than 60 million shovel excrement officials, can they hold a spring of domestic staple food?
get_ started_ 3dsctf_ two thousand and sixteen
蓝牙耳机怎么连接电脑使用,win10电脑如何连接蓝牙耳机
The fund management of London gold is more important than others
Selector (>, ~, +, [])
【图像融合】基于方向离散余弦变换和主成分分析的图像融合附matlab代码
Win11笔记本省电模式怎么开启?Win11电脑节电模式打开方法