当前位置:网站首页>状态压缩复习
状态压缩复习
2022-08-08 05:42:00 【一条小小yu】
简单记录一下,后期慢慢补
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
int main()
{
//状态压缩复习//
//程序编写1
for(int S=0;S<(1<<n);++S)
for(int i=0;i<n;++i)if(S&(1<<i))//S中含i
for(int j=0;j<n;++j)
if(!(S&(1<<j))&&G[i][j])
dp[j][S|(1<<i)]=min(dp[j][S|(1<<i)],dp[i][S]+G[i][j])
//程序编写2
for(int S=0;S<(1<<n);++S)
for(int i=0;i<n;++i)if(S&(1<<i))
for(int j=0;j<n;++j)
if((S&(1<<j))&&G[j][i])
dp[i][S]=min(dp[i][S],dp[j][S^(1<<i)]+G[j][i]);
return 0;
}
边栏推荐
猜你喜欢

轮播文字! QPainter

The only OpenCyphal/UAVCAN tutorial in the whole network (11) Write a Cyphal protocol parsing tool with candump and gawk tools

automation tool

Sqlmap + dnslog injection of repetition

Eighteen, OIDC OAuth2 】 【 the understanding of the application

leetcode-isomorphic string judgment

Servlet---ServletConfig类使用介绍

说说Redis分布式锁的原理和实现蚂【蚁金服三面】

神经网络参数量和计算量,神经网络是参数模型吗

Rust开发——Struct使用示例
随机推荐
【Win10】Several sleep problems and countermeasures
Database sub-database sub-table, when?How to divide?
VSCode已经设置过为中文但变成英文的解决办法
神经网络解决哪些问题,神经网络结果不稳定
Single host docker builds redis-cluster
14.Unity2D 横版 粒子系统特效 飙血粒子+高处落地粒子+对象池管理所有粒子
[u-boot] Analysis of the driver model of u-boot
Typescript 命名空间
28.异常检测
断言失败——[UITableView _configureCellForDisplay: forIndexPath:]
Talk about the principle and implementation of Redis distributed lock [Ant Financial Services Three Sides]
sqlmap+dnslog注入复现
Go-Excelize API源码阅读(十)—— SetActiveSheet(index int)
Rust开发——Struct使用示例
0 dictionary tree/string medium LeetCode676. Implement a magic dictionary
Week 8 Transformer Language Models and Implications
《动机与人格》笔记(二)——认识和理解的欲望
leetcode-isomorphic string judgment
人体神经元细胞分布图片,神经元人体分布大图
Web attack log analysis: a guide for beginners