poj 3254 状压DP

常用本体建模工具 常用本体建模工具: Apollo、OntoStudio、TopBraid Composer、Semantic Turkey、Knoodl、Chimaera、OliEd、WebODE、Kmgen和DOME Protégé Protégé[1]是一款由斯坦福大学编写并维护的开源本体建模和编辑工具,其支持Web版本和PC版本,使用OWL语言(关于OWL的详细介绍可参看前文2.1节内容)对知识进行表示,读者可以通过Protégé的官方网站访问Web版本或下载桌面版本。Protégé最早开发于1987年,最初目的是 阅读详情

传送门:http://poj.org/problem?id=3254


题意:就是你给一个n行m列的矩阵,矩阵里的元素由0和1组成,1代表肥沃的土地可以种植作物,0则不可以种植作物,并且相邻的土地不能同时种植作物,问你有多少种种植方案。

这题和1185不同的是,不需要记录每一行的种植数,只需要知道每一种状态是否可行,可行的话就dp[r][i](第r行,第i种状态)==1;最后统计最后一行的可行数加起来就是答案。两题就是,1185需要求种植作物的最多数量,这题只需要知道多少种方案。

#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int ma[1<<13],st[1<<13];
int dp[13][1<<13];
int x;
int main()
{
    int N,M;
    while(scanf("%d%d",&N,&M)!=EOF)
    {
        memset(ma,0,sizeof(ma));
        memset(st,0,sizeof(st));
        memset(dp,0,sizeof(dp));
        for(int i=0;i<N;i++)
        {
            for(int j=0;j<M;j++)
            {
                scanf("%d",&x);
                if(x==0)
                    ma[i]+=(1<<j);
            }
        }
        int num=0;
        for(int i=0;i<(1<<M);i++)
        {
            if(i&(i<<1)) continue;
            st[num++]=i;
        }
        for(int i=0;i<num;i++)
        {
            if(st[i]&ma[0]) continue;
            dp[0][i]=1;
        }
        for(int r=1;r<N;r++)
        {
            for(int i=0;i<num;i++)
            {
                if(ma[r]&st[i]) continue;
                for(int j=0;j<num;j++)
                {
                    if(st[i]&st[j]) continue;
                    dp[r][i]+=dp[r-1][j];
                }
            }
        }
        int ans=0;
        for(int j=0;j<num;j++)
        {
            ans=(ans+dp[N-1][j])%100000000;
        }
        printf("%d\n",ans);
    }
    return 0;
}

【深度学习】肺结节分割项目实战二:分割肺实质 在后续训练模型的时候如果直接使用原始的肺部CT图像,其中的非肺区域会对训练造成干扰,因此我们需要提取分割肺实质。这一部分参考了kaggle上的教程。 从这张CT图像中可以看出扫描器以外的部分为黑色,背景和肺内部颜色较深,非肺组织和骨头颜色较浅。我们的目的是将肺部分割出来。由于肺部区域和其他部分对比明显,我们可以设置一个合适的阈值对图像中的区域进行隔离。 import argparse import os import numpy as np from medpy.filter.smoothing imp 阅读详情

相关推荐

Loupe Browser实战指南:解锁10xGenomics单细胞数据的可视化奥秘

本文提供了Loupe Browser的实战指南,帮助用户无需编程即可探索和可视化10xGenomics单细胞数据。文章详细介绍了从数据导入、界面导航到细胞亚群鉴定、差异基因分析的核心操作流程,并分享了高级技巧与避坑指南,是快速上手这一强大可视化工具的必备参考。

weixin_29313423的博客 208

poj 3254(状压dp入门)

题目链接:http://poj.org/problem?id=3254 状压dp一般范围都较小,这类dp一般数据范围有一项很小(好像是不超过16吧),看到这种数据范围就可以往状压上想 先提一下位运算, '&' 表示对两个数的二进制进行操作, 相同位如果都为1, 则此位最终结果为1。 y >>...

Error Man 的博客 376

09、Flutter FFI Dart Native API

本文介绍了 Dart Native API 的基本用法,解决了 Dart 与 C 异步通讯的问题

eieihihi的专栏 4400

poj 3254 Corn Fields 状压dp

Corn Fields Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 19399   Accepted: 10189 Description Farmer John has purchased a lush new rectangular pasture composed of M by...

liluoyu_1016的博客 226

Python爬虫实战:5分钟搞定Web of Science文献批量导出与解析(附完整代码)

本文提供了一套利用Python爬虫技术,快速实现Web of Science文献批量提取与解析的完整方案。通过解析官方导出的HTML文件,结合BeautifulSoup和pandas库,可将文献数据自动转换为结构化的Excel/CSV表格,帮助科研人员高效管理文献信息,节省大量手动整理时间。

weixin_29050513的博客 1166

Canoe主要功能的详细介绍

CANoe是德国Vetor公司推出的一款用于总线开发的设备,全程为CAN open environment。后来随着总线技术的发展,CANoe不仅限于CAN类型的总线开发,还包含LIN、FlexRay、MOST和以太网等开发。在车载网络和ECU开发、测试和分析方面,CANoe几乎长期占据着垄断地位,当然是因为其强大的功能性了。目前用这个工具的主要是整车厂和供应商的网络设计工程是、开发工程师和测试工程师。小编当时安装CANoe的时候也是花了一定的时间和精力,好在没有崩溃。

车载测试 3723

状压DP入门 POJ - 3254

POJ - 3254 状压DP Farmer John has purchased a lush new rectangular pasture composed of M by N (1 ≤ M ≤ 12; 1 ≤ N ≤ 12) square parcels. He wants to grow some yummy corn for the cows on a numbe...

qq_41398235的博客 259

基于YOLOv5与海康工业相机的高分辨率实时检测实践

本文详细介绍了基于YOLOv5与海康工业相机的高分辨率实时检测实践,通过优化相机配置、网络传输和YOLOv5模型适配,实现了每秒15帧以上的实时检测性能,缺陷识别准确率高达99.2%。特别适用于电子元件焊接点检测、精密齿轮齿痕检查等对微小缺陷敏感的场景。

weixin_30872499的博客 474

poj 3254 Corn Fields 状压dp入门

// poj3254 状压dp入门 // dp[i][S]表示前i行第i行状态为S时放牧的情况 // S为十进制的二进制数形式如5为101表示第一列和第三列放牧的方法数 // 首先dp[0][S]合法的话就是1 // 状态转移方程为dp[i][S] = sigma(dp[i-1][V])(S与V是合法状态) // 最后的结果就是dp[n][S](S为所有的合法状态) // // 刚开始十分傻x的

TIMELIMITE的专栏 662

【计算机组成原理】课程设计四:控制器设计(二)

本文主要是介绍了计算机组成原理课程设计四其二,即控制器设计(二),属于计算机课程设计专栏

superiony的博客 1430

modelsim软件安装教程及踩坑(极简版)

1.安装的网盘链接:链接:https://pan.baidu.com/s/1ltUfssyXlCnqDmLhWyhlwA提取码:jery 2.步骤(参考博文):https://blog.youkuaiyun.com/weixin_42693097/article/details/90523692?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522163521788716780357213801%2522%252C%2522scm%2522%253A%2522

subtitle_的博客 3780

状压DP详解(1)-从状压到状压DP+简单例题玉米田Corn Fields-POJ3254

emmm,首先要搞懂状压DP这个东西的时候我们要搞懂状压这个概念,其实就是二进制运算的概念,比较经典的就是我写的一个状压非DP–的题目Even Parity—Uva11464—偶数矩阵: 这是我对与状压非DP的一个做法https://blog.youkuaiyun.com/qq_43906000/article/details/90798220 当然,在里面应该就可以搞懂状压这个概念了,简单来讲就是暴力枚举,...

孤风的博客 1201

Python爬虫:无账号无限制获取企查查信息

无限制企查查爬虫 ​通过网上爬虫获取了全国所有企业,然后就需要补充企业信息,首先想到的就是企查查,启信宝等专业网站,最终选择了企查查,尝试了多种方法: 1、selenium爬虫,绕过企查查的登录验证,但账号和IP限制太大,最终放弃 2、通过requests直接请求+cookies,遇到了cookie有效期和限制问题 不断的尝试和修改参数,最终发现一种有效方式selenium+ wep 只需要IP代理,不需要账号,没有限制,因为是没有登录,拿到的信息有限,能展示的都能获取。 一、初始化..

攻城狮的家园 1万+

POJ 3254 简单状压DP

没什么可说的,入门级状压DP,直接撸掉 #include #include #include #include #include #include #include #include #include #include #include #define LL long long #define FOR(i, x, y) for(int i=x;i<=y;i++) using

蘑菇--走在通往梦想的道路上。 780

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

POJ 3254 Corn Fields (状压DP+滚动数组)

题目地址:POJ 3254 状压水题。 先预处理出每行所有可能出现的情况。然后可以用vector存起来。 然后先处理出第一行所有的情况。然后再从第二行开始不断与上一行进行状态转移,状态转移很简单就不说了。 最后统计出最后一行的个数和就可以了。 代码如下; #include #include #include #include #include #include #inclu

scf0920 853

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

[poj 3254]Corn Fields[状压DP]

题意: 一块玉米地,有的位置不能种草,种草的小方格不能有临边. 问有多少种方案. 思路: 状压DP. dp[ i ][ j ] 表示从上到下处理到第 i 行时, 该行状态为 j 的方案数. 下一行某状态的方案数就是上一行所有合理状态的方案数之和. 注意初始化和最后一行的处理. #include #include using namespace std; const int MAX

以中有足乐者... 993

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

【POJ 3254】 Corn Fields(状压DP)

【POJ 3254】 Corn Fields(状压DP) Corn Fields Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 10891   Accepted: 5705 Description Farmer John has purchase

ACMer' 1557

POJ3254(状压dp)

Corn Fields Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 16310   Accepted: 8613 Description Farmer John has purchased a lush new rectangular pasture compo

creatorx的博客 256

POJ 3254 Corn Fields 状压DP

POJ 3254 Corn Fields 状压DP 链接:http://poj.org/problem?id=3254 题意:一块M*N的田地。每小块地大小是1*1,能够种植物的标记为1。不能够种植物的标记为0。而且相邻的两块地不能够同一时候种植物。问题是有多少种不同的种植方案(全部地都不种也是一种种植方案) 思路:这是第一道状压D...

weixin_30390075的博客 104

poj 3254 Corn Fields 状压DP

传送门:poj 3254 Corn Fields题目大意给出一个M*N的矩阵,元素为0表示这个地方不能种玉米,为1表示这个地方能种玉米,现在规定所种的玉米不能相邻,即每行或者没列不能有相邻的玉米,问一共有多少种种植方法。举个例子:2 3 1 1 1 0 1 0 表示2*3的玉米地,现在一共有多少种种植方法呢? 答案:种0个玉米(算一个合法方案)+种1个玉米(4)+种2个玉米(3)+种3个玉米(

woshinannan的专栏 495

状压dp Poj - 3254 Corn Fields

状压dp 题意 有一块 m 行 n 列的农场地形,要在 ‘1’ 上养牛,并且相邻上下左右不能同时养牛。 问:有多少种方案来养牛? 思路 先看第一行样例 1 1 1,肯定不能相邻养牛,所以有以下几种情况 0 0 0 0 0 0 1 1 0 1 0 2 1 0 0 4 1 0 1 5 当加上第二行的时候,又分为两种情况,每种情况与上一行结合判断是否可行 得出状态转移方程:dp [ i ] [ state[ j ] ] = dp [ i - 1 ] [ state [ k1 ] ]

HappyCode 331

POJ3254 状压DP入门

题目:http://poj.org/problem?id=3254 因为&运算写成&&--导致调试了快一个小时代的代码没有搞定 关于建图: 1、题目中是1表示可以放牧,0表示不可以放牧,但是建图的时候,可以放牧的位用0表示,不可以放牧的位用1表示。原因如下: 假设可以放牧的位用1表示,不可以放牧的位用0表示,那么假设当前行状态时1010   想要放置1001 ,&运算的结果

Pilgrim 1063

POJ 3254 - Corn Fields [状压DP]

这是一个比较简单的状压DP问题。 状压DP即是利用位运算来进行状态压缩的动态规划。 一些动态规划的状态信息过多,需要高维的数组进行存贮和转移。这个时候,一些满足可以用低进制来存贮(主要为2进制,但不限定于),再通过位运算的帮助进行状态转移,这就是状态压缩动态规划。 这题的基本题意是,有一个n行m列的矩阵,矩阵里的元素由0和1组成,1代表肥沃的土地可以放牛,0则不可以,并且相邻的土地不

JeffCsoul 492

[poj3254]Corn Fields_状压dp

Corn Fields poj3254     题目大意:给你一个n*m的地,每一块地可以种或不种,两块种过的地不能挨着,可以一块都不种,问所有的种地方案数。     注释:读入用0和1,1<=n,m<=12.       想法:这题和炮兵阵地特别像,比炮兵更简单。我们再度入的时候直接处理出当前行的地的不可种的情况。预处理出一行如果都能种的话所可能的方案数。此处需要满足...

dianan0938的博客 139

poj3254(状压dp)

Corn Fields Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 19518 Accepted: 10243 Description Farmer John has purchased a lush new rectangular pasture...

allia990718的博客 136

【状压dp】南京icpc- AC chanllege 、POJ- 3254 Corn Fields (有关状压dp) 详解。。没写代码

首先我们来学习一下有关状压dp的内容。参考链接 状压DP全称状态压缩DP,指的是根据题目情况和数据范围压缩数组的维度。 对于本题(POJ 3254),常见的方法是将每一行的方格肥沃状态以及作物可能的种植状态用二进制表达,再压缩为十进制。 题目的意思是种树,每行给你一堆0和1,要求不能种在相邻、十字花里面(上下左右) 【常用状态!!】 (1)(具体分析,此题中)i&amp;(i&lt;&l...

lx233 479
上一篇: poj 1185 状压DP
下一篇: Codeforces Round #306 (Div. 2) B. Preparing Olympiad
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值