UVA 10651 Pebble Solitaire 状态压缩dp

OpenClaw 3.13 + Mac mini M4 集成 qmd 记忆存储:qmd embed 卡死 / 报错 sqlite-vec 不可用 终极解决教程 模型加速让 qmd 从国内镜像下载模型,避免网络超时;SQLite 扩展支持:修改 qmd 源码后,Bun 不再使用内置 SQLite,而是调用 Homebrew 安装的,该版本支持接口,可正常加载vec0.dylib向量扩展;OpenClaw 3.13 适配:核心逻辑与 OpenClaw 3.13 的 qmd 记忆调用逻辑完全兼容,无需额外调整;sqlite-vec 加载:qmd 自动通过sqlite-vec包获取vec0.dylib路径,调用完成向量扩展加载,实现高效向量搜索。 阅读详情

一开始还在纠结怎么表示一个状态,毕竟是一个串。后来搜了一下题解发现了这里用一个整数的前12位表示转态就好了 ,1~o,0~'-',每个状态用一个数来表示,然后dp写起来就比较方便了。

代码:

 1 #include <iostream>
 2 #include <sstream>
 3 #include <cstdio>
 4 #include <climits>
 5 #include <cstring>
 6 #include <cstdlib>
 7 #include <string>
 8 #include <cmath>
 9 #include <vector>
10 #include <queue>
11 #include <algorithm>
12 #define esp 1e-6
13 #define pb push_back
14 #define in  freopen("in.txt", "r", stdin);
15 #define out freopen("out.txt", "w", stdout);
16 #define print(a) printf("%d\n",(a));
17 #define bug puts("********))))))");
18 #define Rep(i, c) for(__typeof(c.end()) i = c.begin(); i != c.end(); i++)
19 #define inf 0x0f0f0f0f
20 using namespace std;
21 typedef long long  LL;
22 typedef vector<int> VI;
23 typedef pair<int, int> pii;
24 typedef vector<pii,int> VII;
25 typedef vector<int>:: iterator IT;
26 #define N 50000
27 int dp[N];
28 int ans;
29 void f(int x)
30 {
31     if(dp[x])
32         return ;
33     int num = 0;
34     for(int i = 0; i < 12; i++)
35         if(x&(1<<i))
36         num++;
37     ans = min(ans, num);
38     dp[x] = 1;
39     for(int i = 0; i <= 9; i++)
40         if(((x&(1<<i)) && (x&(1<<(i+1))) && !(x&(1<<(i+2))))
41                 ||(!(x&(1<<i)) && (x&(1<<(i+1))) && (x&(1<<(i+2)))))
42             f(x^(1<<(i+1))^(1<<i)^(1<<(i+2)));
43 }
44 int main(void)
45 {
46 
47     char s[100];
48     int T, t;
49     for(t = scanf("%d", &T), gets(s); t <= T; t++)
50     {
51         memset(dp, 0, sizeof(dp));
52         gets(s);
53         int n = 0;
54         ans = 20;
55         for(int i = 0; i < 12; i++)
56             if(s[i] - '-')
57                 n ^= (1<<i);
58                 f(n);
59         printf("%d\n", ans);
60     }
61     return 0;
62 }
View Code

 

或者可以用map+string的方法,一直都没怎么学过STL,看了http://www.myexception.cn/ai/1243266.html 这里的方法表示又涨了不少知识,拿来重新写了一遍(其实还是“剽窃”,没办法先当一个"搬运工”吧)。

 1 #include <iostream>
 2 #include <sstream>
 3 #include <cstdio>
 4 #include <climits>
 5 #include <cstring>
 6 #include <cstdlib>
 7 #include <string>
 8 #include <cmath>
 9 #include <stack>
10 #include <map>
11 #include <vector>
12 #include <queue>
13 #include <algorithm>
14 #define esp 1e-6
15 #define pb push_back
16 #define in  freopen("in.txt", "r", stdin);
17 #define out freopen("out.txt", "w", stdout);
18 #define print(a) printf("%d\n",(a));
19 #define bug puts("********))))))");
20 #define Rep(i, c) for(__typeof(c.end()) i = c.begin(); i != c.end(); i++)
21 #define inf 0x0f0f0f0f
22 using namespace std;
23 typedef long long  LL;
24 typedef vector<int> VI;
25 typedef pair<int, int> pii;
26 typedef vector<pii,int> VII;
27 typedef vector<int>:: iterator IT;
28 map<string, bool> my;
29 int ans;
30 void dfs(string cur)
31 {
32     if(my.find(cur) != my.end())
33         return;
34     int len = cur.size(), num = 0;
35     for(int i = 0; i < len; i++)
36         if(cur[i] == 'o')
37         num++;
38     ans = min(ans, num);
39     my[cur] = true;
40     for(int i = 0; i <= 9; i++)
41     {
42         if(cur.substr(i, 3) == "-oo")
43         {
44             string temp = cur;
45             temp.replace(i, 3, "o--");
46             dfs(temp);
47         }
48         if(cur.substr(i, 3) == "oo-")
49         {
50             string temp = cur;
51             temp.replace(i, 3, "--o");
52             dfs(temp);
53         }
54     }
55 }
56 int main(void)
57 {
58     int T;
59     string s;
60     for(int t = scanf("%d", &T); t <= T; t++)
61     {
62         cin>>s;
63         my.clear();
64         ans = 20;
65         dfs(s);
66         printf("%d\n", ans);
67     }
68     return 0;
69 }
View Code

 

Qualcomm AI Engine Direct SDK(QNN)的使用介绍 Qualcomm AI Engine Direct SDK,高通新的AI模型推理框架,又名QNN,为AI开发提供统一API的底层框架。通过这个SDK,可以在高通的 CPU/GPU和HTP上对AI模型进行性能加速。2.Qualcomm AI Engine Direct SDK的公开英文文档。1.Qualcomm AI Engine Direct SDK的下载和安装。 阅读详情

相关推荐

常用的集成TTL门电路

本篇主要分析了常用的逻辑门电路与非门,详细分析了电源原理。值得收藏。

ManagerUser的博客 5086

UVa 10651 Pebble Solitaire(状态压缩DP)

题意:转化为01序列,可以做如下转换011-->100, 110-->001 使得序列的1最少 二进制的集合表示: 空集:0 全集:( 1 集合里添加元素:S|(1 集合删去元素:S&~(1 #include #include #include #include #include #include #include #include #include #include #incl

qwesde 567

SAP S/4HANA 物料分类账(ML)/实际成本核算(Actual Costing)——底表全景 & CKMLCP 执行后数据变化

插入 ML 重估凭证行项目:Dr/Cr 库存科目(期末库存调整)、Dr/Cr COGS/消耗科目(消耗重估)、Cr/Dr ML 重估抵消科目(PRY/PRV 类逻辑)also STPRS/VERPR/PEINH/LBKUM 等(但 S/4 很多“真理”在 ACDOCA)MLPP / MLPPF / MLCR / MLCRF / MLCD / CKMLMV003/004 等。Material Ledger Document(行项目明细:收货/发票价差/结算写入/重估相关)间接(PUP在CKMLCR;

weixin_52203666的博客 578

UVa 10651 - Pebble Solitaire 状态压缩 dp

Problem A Pebble Solitaire Input: standard input Output: standard output Time Limit: 1 second   Pebble solitaire is an interesting game. This is a game where you are given a board with an arrang

Azarath Metrion Zinthos 1095

进程间通信的七种方法实战演示!值得收藏!

线程和进程间的通讯(Inter-Process Communication, IPC)是操作系统中的一个重要概念,用于实现不同进程或同一进程中的不同线程之间的数据交换和协调。以下是几个常见的进程间通信的方式:管道、消息队列、共享内存、信号、套接字、信号量、文件映射

十年饮冰,难凉热血,保持热爱,奔赴星海! 2816

abaqus2matlab的安装与使用:如何用matlab提取abaqus的odb结果

官网abaqus2matlab官网地址matlab社区地址matlab社区地址在这里可以看到.m文件的源码论文:Abaqus2Matlab: A suitable tool for finite element post-processingabaqus2matlab可以处理.inp、.fil、.odb三种类型的文件。.inp文件:处理功能就在于只是单纯的输出inp文件,由于我自己写了自己的函数,不需要用到这个功能。

qianxin1234的博客 2017

uva 10651- Pebble Solitaire(状态压缩DP)待看。。。

1、http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1592 2、题目: Problem A Pebble Solitaire Input: standard input Output: standard output Time Limit:

sdjzping的专栏 1078

2025年MathorCup数学应用挑战赛【B题完整论文】附参考代码(免费分享)

摘。

RS_handy的博客 2694

uva_10651_Pebble Solitaire(状态压缩DP)

题目意思很明确,12这个数字很有状态压缩的意味 这一题的阶段就是按照left -> right 的顺序DP 这里一共有2^12个状态,从1 到 2^12 的数字,每个数字的二进制表示这一行的状态 状态:dp[i]表示该状态的游戏最终结果 状态转移:dp[i] = min(dp[j]), j就是从i的状态经过游戏规则所能转换的状态 ans = dp[n] #include #include #

unixcsir的专栏 351

基于FPGA的数据采集系统(一)

整体系统设计 本设计主要是对ADC和DAC的使用,主要实现功能流程为:首先通过串口向FPGA发送控制信号,控制DAC芯片tlv5618进行DA装换,转换的数据存在ROM中,转换开始时读取ROM中数据进行读取转换。其次用按键控制adc128s052进行模数转换100次,模数转换数据存储到FIFO中,再从FIFO中读取数据通过串口输出显示在pc上。其整体系统框图如下: 图1:FPGA数据采集系统框图 从图中可以看出,该系统主要包括9个模块:串口接收模块、按键消抖模块、按键控制模块、ROM模块、D..

phflovelt的博客 2万+

(五)深入理解蓝牙BLE之“Beacon包格式详解”

蓝牙Beacon格式详解 本文重点在结合Bluetooth官网spec和几个例子来使beacon帧格式更加容易被理解。 广播帧格式: 首先beacon是蓝牙BLE广播包的一种,蓝牙广播帧格式如下: PS:其实BLE数据帧除了报头字段和数据字段定义与广播帧不同之外,前导/接入地址/长度/校验格式均相同。 广播帧数据字段格式: 数据字段最长为37个字节:6个字节的广播设备地址 + 31个字节广播数据。 广播数据的格式如下:AD Structure1 +AD Structure2 + .....

1万+

uva 10651 Pebble Solitaire(dp,状态压缩,记忆化搜索)

把每个空格子看做0,有石头的格子看做1 若zgeg

yjCola 645

【VTKExamples::PolyData】第十六期 GradientFilter

本文分享VTK样例GradientFilter,并解析接口vtkGradientFilter & vtkAssignAttribute,希望对各位小伙伴有所帮助!

qq_40041064的博客 319

UVa10651 Pebble Solitaire

UVa10651 Pebble Solitaire 题意:n组测试数据,每个测试数据有12个字符构成。'o'表示当前位置有珠子,‘-’表示是空位,如果有两个珠子连在一起,且两个珠子的左右有空位,那么,就可以把一个珠子越过另一个珠子,占据空了的位置(左边或右边的空位都可以。很像跳棋) 状态压缩DP load……

天亮说晚安 1588

深度学习工具包 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")

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

UVA 10651 --Pebble Solitaire +dfs

这道题有两种做法:搜索和状态压缩dp 因为这个题的状态只要2^12,所以可以用dfs或bfs将所有的可达状态走一遍,然后就可以得到答案了。 我是用二进制压缩以后再进行的dfs;其实也可以直接开一个12位长度数组表示状态,然后dfs或bfs,这样 状态判重可以用hash或二进制压缩。 代码如下: #include #include #include using namesp

荒野孤鹰 857

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

uva 10651 Pebble Solitaire

题意:n组测试数据,每个测试数据有12个字符构成。'o'表示当前位置有珠子,‘-’表示是空位,如果有两个珠子连在一起,且两个珠子的左右有空位,那么,就可以把一个珠子越过另一个珠子,占据空了的位置(左边或右边的空位都可以。很像跳棋) 状态压缩DP,用一个int的当前位有1表示当前位有珠子。 #include #include #include using namespace std; co

1291

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

Uva - 10651 - Pebble Solitaire

题意:12个位置,有些有鹅卵石,有些是空的,2个连续的鹅卵石, 如果其左边连着的那个是空的,那么第二个鹅卵石可移动到那个空的位置上,并移除第1个鹅卵石; 如果其右边连着的那个是空的,那么第一个鹅卵石可移动到那个空的位置上,并移除第2个鹅卵石。 问最后最少可以剩下多少个鹅卵石。 题目链接:http://uva.onlinejudge.org/index.php?option=com_onli

无节操 1463

UVA 10651 Pebble Solitaire 鹅卵石摆放 记忆化搜索+DFS+记忆化搜索

题意:有12个坑,里面有些鹅卵石,游戏规则:如果有连续的两个鹅卵石,且旁边有个空坑,那可以把旁边的那个鹅卵石跳过空坑中间那个鹅卵石放到空坑里面,而中间那个鹅卵石就被去掉了。 只有12个坑,状态为2^12,才4000多个,所以用stl或是位运算去储存都可以,然后DFS。 我这里用的是位运算+记忆化搜索,好像没有记忆化也不会超时 = = PS:这就是传说中的状态压缩? 代码: /* *

水果君の日常 1849

[集合DP] UVA 10651 Pebble Solitaire

根据题目描述,每次变换都减少了一个石子,所以只要求出初始状态最多可以变换多少次,用初始状态石子数目减去这个变换次数就得到最后剩余最少的石子的数目; 最多有12位,用一个 int 表示状态,状态的转移可以用位运算实现。 1 /* 2 UVA 10651 - Pebble Solitaire 3 */ 4 # include <cstdio> 5 # in...

weixin_30810239的博客 104

UVa 10651 Pebble Solitaire(状压DP)

题意:110->001,011->100。问最后最多少几个1。 思路:状压DP水题。 #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long

ACMiao的博客 572

uva10651 - Pebble Solitaire(状态压缩)

状态压缩+记忆化搜索 状态压缩对位运算要求的较多。对位运算不熟的话就复习一下吧。 纯正的暴力然后用记忆化搜索剪枝。 碰到合适的情况就转移。【向右或向左】 求最后在棋盘上剩余最少的棋子数目。 代码如下: #include #include #include using namespace std; #define N 4500 int dp[N]; char s[25]; int

稻草人 1019

UVa 10651 Pebble Solitaire (DP&bitset)

10651 - Pebble Solitaire Time limit: 3.000 seconds  http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=1592 化为二进制进行状态转移,详见代码。 完整代码:

AC,∑ndless 1387

uva 10651 - Pebble Solitaire

Problem A Pebble Solitaire Input: standard input Output: standard output Time Limit: 1 second   Pebble solitaire is an interesting game. This is a game where you are given a board with an arrang

GAUSS_CLB 608

UVa 10651 Pebble Solitaire 记忆化搜索+位运算

/** * 位运算+记忆化搜索: * 这题就当做是熟悉熟悉位运算,练练简单的记忆化搜索的。 * 要是熟悉了位运算,这题其实很容易的。 * 依题意: 一排有12个位置,这样用int去压缩也是很足够的。 * 对于一个数的每个位, 0表示空,1表示有。 * 然后遍历的时候三个三个去分析,然后dfs记忆化搜一下就行了。 */ #include #

xuruoxin的专栏 877

acm专题学习之动态规划(一)状压dp+记忆化搜索+uva 10651 - Pebble Solitaire

题目:由‘o'或’-‘组成的12格子棋盘,有两个规则:’-oo'可以变成’o--',’oo-'可以变成’--o'。问通过这两个规则最少可以只剩多少个‘o'。 状态压缩dp:带入二进制。比如说这道题里,每个格子有两种情况,那么12个格子最多有2的12次方种情况。每个格子里面‘o'对应为1,’-‘对应为0,那么组成的情况就可以用12个格子组成的2进制数表示。例如’-oo-oo-oo-oo'为'011...

qq_40306845的博客 210

UVa10651 - Pebble Solitaire

Problem A Pebble Solitaire Input: standard input Output: standard output Time Limit: 1 second   Pebble solitaire is an interesting game. This is a game where you are given a board with an arrang

mowayao的专栏 836
上一篇: UVA 825 Walkiing on the safe side
下一篇: UVA - 10047 The Monocycle
rootial
博客等级 码龄15年 2粉丝 93原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值