UVA 10651 Pebble Solitaire

SAP采购订单行项目增强实战:用BADI ME_GUI_PO_CUST添加自定义字段(避坑指南) 本文详细解析了如何通过BADI ME_GUI_PO_CUST在SAP采购订单行项目中添加自定义字段,包括技术架构理解、字段扩展步骤、自定义函数组创建及BADI实现。文章特别强调了避开官方文档未提及的陷阱,如字段映射限制和屏幕显示问题,并提供了高级优化技巧和性能建议。 阅读详情

【题意】12个位置,有些有鹅卵石,有些是空的,2个连续的鹅卵石,如果其左边连着的那个是空的,那么第二个鹅卵石可移动到那个空的位置上,并移除第1个鹅卵石;如果其右边连着的那个是空的,那么第一个鹅卵石可移动到那个空的位置上,并移除第2个鹅卵石。问最后最少可以剩下多少个鹅卵石?

【分析】由于3个连续出现的鹅卵石才有可能发生交换,所以枚举所有能够出现的状态,交换直接相邻3位取异或即可!记得回溯!

【AC代码】

#include <stdio.h>
#include <string.h>
#include <iostream>
using namespace std;
const int inf = 0x3f3f3f3f;
int ans,n;
char s[13];
int dfs(int sta)
{
    int temp,last=0;
    for(int i=1; i<=10; i++)
    {
        if((sta&(1<<(i-1))&&sta&(1<<i)&&!(sta&(1<<(i+1))))||(!(sta&(1<<(i-1)))&&sta&(1<<i)&&sta&(1<<(i+1))))
        {
            sta^=(1<<(i-1));
            sta^=(1<<i);
            sta^=(1<<(i+1));
            temp = dfs(sta);
            ans = min(ans,temp);
            sta^=(1<<(i-1));
            sta^=(1<<i);
            sta^=(1<<(i+1));
        }
    }
    if(last==0)
    {
        int cnt=0;
        for(int i=0; i<12; i++)
        {
            if(sta&(1<<i))cnt++;
        }
        ans = min(ans,cnt);
    }
    return ans;
}
int main()
{
    while(~scanf("%d",&n))
    {
        for(int i=0; i<n; i++)
        {
            int sta=0;
            scanf("%s",s);
            for(int j=0; j<12; j++)
            {
                if(s[j]=='o')
                {
                    sta = sta^(1<<j);
                }
            }
            ans = inf;
            dfs(sta);
            printf("%d\n",ans);
        }
    }
    return 0;
}


提交 ieee 手稿出现:Do not include the Reviewer PDF with my submission 怎么办 IEEE投稿Reviewer PDF选项说明 投稿时出现的"Do not include the Reviewer PDF with my submission"选项控制是否附带评审专用PDF文件。Reviewer PDF是系统自动生成包含所有投稿材料的完整PDF,用于同行评审。建议保持默认不勾选状态,除非确认编辑部不需要该文件,否则可能影响审稿流程。勾选表示不附带此PDF,不勾选则会正常生成并提交该评审文件。 阅读详情

相关推荐

PCIe链路均衡实战:从Preset调节到系数优化的完整指南(附Synopsy IP案例)

本文深入解析PCIe链路均衡技术,从Preset调节到系数优化的全流程实战指南,特别针对PCIe 3.0/4.0中的Recovery.Equalization状态进行详细说明。通过Synopsy IP案例,展示如何应对高速信号完整性挑战,优化前向反馈均衡(FFE)机制,提升系统性能。

peace的博客 1053

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

实测对比:DJI O3、Walksnail Avatar、HDZero三大高清图传,谁才是低延迟王者?

本文对DJI O3、Walksnail Avatar V2和HDZero三大高清图传系统进行了实测对比,重点分析其在FPV飞行中的低延迟表现。通过专业测试环境和量化数据,揭示HDZero在原生低延迟架构上的优势,DJI O3在画质与延迟间的平衡,以及Walksnail的动态码率调整特点,为不同场景下的选购提供决策依据。

weixin_30756499的博客 442

10651 - Pebble Solitaire

描述:对于这道题,实在想不出如何用动规,所以就直接bfs #include #include char s[5010][15]; int main() { // freopen("a.txt","r",stdin); int n,flag; while(scanf("%d",&n)!=EOF) for(int i=0; i<n; i++)

moyan_min的专栏 744

深入解析安卓性能分析工具systrace/atrace的使用技巧与实战场景

本文深入解析了安卓性能分析工具systrace/atrace的核心使用技巧与实战场景。文章澄清了环境搭建的常见误区,详细拆解了命令参数,并通过列表卡顿、启动优化等具体案例,手把手指导开发者利用这些工具精准定位性能瓶颈,提升应用流畅度。

yyy34的博客 239

麒麟系统grub被锁怎么办?双密码遗忘救援指南(实测V10 SP3版本)

本文详细介绍了麒麟系统V10 SP3版本在GRUB和root密码双遗忘情况下的救援指南。通过ISO镜像进入救援模式,结合单用户模式操作,实现密码重置与系统权限恢复,特别适用于等保合规环境。

384

uva 10651 Pebble Solitaire (BFS)

uva 10651 Pebble SolitairePebble solitaire is an interesting game. This is a game where you are given a board with an arrangement of small cavities, initially all but one occupied by a pebble each. The

总有那么一群人喜欢盯着我的博客看,估计这是他们见过最长的博客名,我必须得告诉他们博客名最长可以写多长 655

Quantum Espresso Hands-On实战训练(四)——PDOS计算与轨道分析

本文详细介绍了Quantum Espresso中PDOS计算与轨道分析的实战方法,重点解析了PDOS在材料电子结构研究中的核心价值,包括原子级分辨率、轨道级解析和自旋极化分析。通过具体案例和操作步骤,帮助读者掌握从输入文件准备到结果解读的全流程,并提供了高级分析技巧和疑难问题解决方案。

weixin_29211309的博客 503

UVA10651 Pebble Solitaire【DFS+记忆化搜索+位运算】

Pebble solitaire is an interesting game. This is a game where you are given a board with an arrangement of small cavities, initially all but one occupied by a pebble each. The aim of the game is to re...

海岛Blog 569

智能园艺:AI Agent控制的室内种植系统

随着城市化进程的加速和人们对健康生活的追求,室内种植逐渐成为一种流行的生活方式。然而,传统的室内种植方式往往需要人工进行大量的监测和管理,效率低下且难以保证植物的生长质量。智能园艺:AI Agent控制的室内种植系统旨在利用先进的人工智能技术和传感器设备,实现室内种植的自动化和智能化管理,提高种植效率和植物生长质量。本系统的范围涵盖了从植物生长环境的监测到种植过程的自动化控制,包括温度、湿度、光照、土壤水分等环境参数的实时监测,以及灌溉、施肥、通风等种植操作的自动执行。

AI天才研究院 782

【主题建模】一种基于深度学习的主题建模方法:BERTopic(实战篇)

BERTopic 是基于深度学习的一种主题建模方法。2018 年底,Devlin et al. 提出了 Bidirectional Encoder Representations from Transformers (BERT)。BERT 是一种用于 NLP 的预训练策略,它成功地利用了句子的深层语义信息。

Data · Model · Agent · Repeat 2万+

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

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

水果君の日常 1849

点云配准SIFT+SI+RANSAC+ICP

Spin Image(SI)是一种用于点云数据描述的特征描述子,广泛应用于三维点云配准、识别和重建等领域。它能够捕捉点云中的局部几何信息,具有旋转不变性和部分平移不变性等优点,是一种非常强大的特征描述子。Spin Image是一种强大的点云特征描述子,具有旋转不变性、局部几何信息捕捉等优点,适用于点云配准、目标识别和三维重建等多个领域。通过合理选择局部区域、建立参考框架和计算描述子,可以充分利用Spin Image描述点云的特征,从而实现各种三维场景分析和处理任务。

点云兔子的博客 557

uva10651 - Pebble Solitaire(记忆化搜索)

题目:uva10651 - Pebble Solitaire(记忆化搜索) 题目大意:12个坑,每个坑里面可以哟

578

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

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

uva 10651 - Pebble Solitaire(记忆化搜索)

题目链接:10651 - Pebble Solitaire 题目大意:给出一个12格的棋盘,‘o'代表摆放棋子,’-‘代表没有棋子, 当满足’-oo'时, 最右边的棋子可以跳到最左边的位子,而中间的棋子则被消除,‘o--', 问对于一个给定了的棋盘,通过上述消除棋子的方法最后最少绳几个棋子在棋盘上。 解题思路:递归搜索 + 记忆化, 并且记忆化的值为所有测试数据公用的,也就是

不慌不忙、不急不躁 1349

IEM模型,地表粗糙度模拟

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

UVa10651 Pebble Solitaire

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

天亮说晚安 1588

uva 10651 Pebble Solitaire

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

1291

uva10651 - 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

不戚的专栏 660

UVa 10651 Pebble Solitaire(DP 记忆化搜索)

Pebble Solitaire   Pebble solitaire is an interesting game. This is a game where you are given a board with an arrangement of small cavities, initially all but one occupied by a pebble each. The

Good morning,good afternoon and good night 1138

UVA 10651 Pebble Solitaire

UVA_10651 由于总状态很少,所以直接广搜即可。 #include<stdio.h>#include<string.h>#define MAXD 10010char b[20];int d[MAXD], q[MAXD], hash[MAXD], N;void init(){ int i, j; scanf("%s", b); N = ...

weixin_30339969的博客 81

UVa 10651 - Pebble Solitaire

题目:有一个类似跳棋的游戏,一共有12个位置'o'代表棋子'-'代表空位,             'oo-'可以转化成'--o','-oo'可以转化成'o--',给你初始状态,问最后,至少剩下几个棋子。 分析:dp,记忆化搜索,位运算。利用搜索在相邻状态间dp即可。             每个状态的最优解为他能转化所有状态中的最优解。             因为,一共有2^12 =

小白菜又菜 1019

UVA - 10651 Pebble Solitaire

题意:大意是“-oo”可以变成“o--”,"oo-”可以变成“--o”,问最后最少还剩多少,看到只有两种状态的就用位运算比较简单 1代表“o”,0代表“-”,模拟一下就出来了 #include #include #include #include using namespace std; const int MAXN = 5000; int dp[MAXN]; int dps(in

那些年 802

【UVA】10651-Pebble Solitaire(直接递归或者记忆化)

动态规划

花月阁 843

[集合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

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

无节操 1463

uva10651Pebble Solitaire

就是模拟搜索,也可以记忆化提高速度 期末结束后的第一发水题 寒假,加油吧 #include #include #include using namespace std; const int MAX=12; int map[12]={1,2,4,8,16,32,64,128,256,512,1024,2048},minus; void dfs(int state,int left){

cgjiayou 417
上一篇: UVA 10051 Tower of Cubes
下一篇: HDU 5667 Sequence
just_sort
博客等级 码龄11年 2356粉丝 1667原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值