Lattice Animals UVA - 1602 set判重+打表+模拟

例题7-14 网格动物 UVa1602 1.题目描述:点击打开链接 2.解题思路:本题利用回溯法解决。本题实际上是要搜索n连通块不同形态的个数(平移,翻转,旋转后相同的算作一种形态),因此能够有效的判断n连通块是否重复是关键。 那么如何判断是否重复呢?我们一步步的分析。由于可能要涉及对一个对象的旋转,平移,翻转操作,因此我们有必要定义好相应的结构体去支持这些操作的完成。首先不难发现,每个单元格应当作为一个结构体出现,用(x, 阅读详情

对紫书的代码加了注释,参考了 https://blog.youkuaiyun.com/ecnu_lzj/article/details/52830231的文章  主要是模块化各个功能、打表的思想 SET判重的思想 和标准化联通块的思想

 

 

// UVa1602 Lattice Animals
// Rujia Liu
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<set>
using namespace std;

struct Cell {  //点结构
  int x, y;
  Cell(int x=0, int y=0):x(x),y(y) {};
  bool operator < (const Cell& rhs) const {
    return x < rhs.x || (x == rhs.x && y < rhs.y);
  }
};

typedef set<Cell> Polyomino; //连通快的点集合

#define FOR_CELL(c, p) for(Polyomino::const_iterator c = (p).begin(); c != (p).end(); ++c)

inline Polyomino normalize(const Polyomino &p) {//将图形标准化,即从(0,0)开始
  int minX = p.begin()->x, minY = p.begin()->y;
  FOR_CELL(c, p) {
    minX = min(minX, c->x);
    minY = min(minY, c->y);
  }
  Polyomino p2;    
  FOR_CELL(c, p)
    p2.insert(Cell(c->x - minX, c->y - minY));
  return p2;
}

inline Polyomino rotate(const Polyomino &p) {//顺时针旋转90°  即 x y互换位置
  Polyomino p2;
  FOR_CELL(c, p)
    p2.insert(Cell(c->y, -c->x));
  return normalize(p2);  //返回标准化的
}

inline Polyomino flip(const Polyomino &p) {//关于x对称  即 X不变 Y为相反数
  Polyomino p2;
  FOR_CELL(c, p)
    p2.insert(Cell(c->x, -c->y));
  return normalize(p2);//返回标准化的
}

const int dx[] = {-1,1,0,0};
const int dy[] = {0,0,-1,1};
const int maxn = 10;  

set<Polyomino> poly[maxn+1];//联通快集合
int ans[maxn+1][maxn+1][maxn+1];//打表的答案

// add a cell to p0 and check whether it's new. If so, add to the polyonimo set
void check_polyomino(const Polyomino& p0, const Cell& c) {
  Polyomino p = p0;
  p.insert(c);
  p = normalize(p);

  int n = p.size();
  for(int i = 0; i < 4; i++) {   //旋转后看有没有重复的
    if(poly[n].count(p) != 0) return;
    p = rotate(p);
  }      
  p = flip(p);
  for(int i = 0; i < 4; i++) {   //折叠后再旋转看有没有重复的
    if(poly[n].count(p) != 0) return;
    p = rotate(p);
  }
  poly[n].insert(p);
}

void generate() {
  Polyomino s;
  s.insert(Cell(0, 0));//一个连通快就只有一个点 poly[n]表示n连通的集合
  poly[1].insert(s);

  // generate
  for(int n = 2; n <= maxn; n++) {//n连通由n-1连通推出
    for(set<Polyomino>::iterator p = poly[n-1].begin(); p != poly[n-1].end(); ++p)
      FOR_CELL(c, *p)
        for(int dir = 0; dir < 4; dir++) {
          Cell newc(c->x + dx[dir], c->y + dy[dir]);//不用管越不越界 这是找出所有情况后打表
          if(p->count(newc) == 0) check_polyomino(*p, newc);
        }
  }

  // precompute answers
  for(int n = 1; n <= maxn; n++)
    for(int w = 1; w <= maxn; w++)
      for(int h = 1; h <= maxn; h++) {
        int cnt = 0;
        for(set<Polyomino>::iterator p = poly[n].begin(); p != poly[n].end(); ++p) {//打表看各个连通快的个数
          int maxX = 0, maxY = 0;
          FOR_CELL(c, *p) {
            maxX = max(maxX, c->x);
            maxY = max(maxY, c->y);  
          }
          if(min(maxX, maxY) < min(h, w) && max(maxX, maxY) < max(h, w))    
            ++cnt;
        } 
        ans[n][w][h] = cnt;
      }
}

int main() {
  generate();

  int n, w, h;
  while(scanf("%d%d%d", &n, &w, &h) == 3) {
    printf("%d\n", ans[n][w][h]);
  }
  return 0;
}

 

ADS仿真设计平行定向耦合器学习笔记 ADS仿真设计平行定向耦合器 阅读详情

相关推荐

【Qt实战项目】记事本完整项目

效果图如下所示: 全部代码如下: #include “notepad.h” #include int main(int argc, char *argv[]) { QApplication a(argc, argv); MainWindow w; w.showMaximized(); return a.exec(); }

YIZHILIUSHA2020的博客 575

uva1602(poj3523)-The morning after Halloween

uva1601 or poj3523 AC代码 坑点 双向bfs 刘汝佳老师 无详细题解,自读注释

D_primarybold的博客 325

LangChain Agent Skills 实战指南:12个案例玩转智能体技能封装与编排

大语言模型应用开发中,智能体(Agent)的能力扩展正从零散的函数调用走向标准化封装。Agent Skills 将某项具体能力组织为带说明、代码与依赖的技能目录,让模型能自动发现和调度,其核心价值在于解决工具数量膨胀后的维护混乱与调用失控问题。与 Tool 的单一执行、MCP 的协议连接不同,Skill 更强调能力的语义描述与组合复用,配合 LangGraph 的状态编排和 LangSmith 的可观测性,可构建生产级智能体系统。在实际场景中,Agent Skills 可覆盖 RAG 知识库问答、多轮记忆保

weixin_34335458的博客 407

Set集合如何判断对象是否重复

Set集合如何判断对象是否重复

小白的博客 2674

ThinkPad T14 Gen 2与T14P系列对比

表格您的需求推荐机型日常办公、出差、文档处理、视频会议✅(够用、轻便、便宜)视频剪辑、3D建模、编程编译、AI训练、高色准设计✅(性能强、屏幕好、扩展佳)想要未来 5 年不换机✅T14p预算低于 5000 元✅T14 Gen 2(或考虑 T14 Gen 3/4)T14p 2025 款 ≠ 小改款,而是架构级升级它从“高性能笔记本”进化为“AI 移动工作站”,核心差异在于NPU + Ultra 平台 + 全面屏显 + 超长续航。如果您从事AI 开发、视频创作、工程仿真、多任务编程。

tecoes的博客 2737

LVGL v9的lv_scale控件实战:5分钟打造动态仪表盘(附完整代码)

本文详细介绍了LVGL v9中lv_scale控件的实战应用,通过5个关键步骤快速打造动态仪表盘。文章涵盖核心特性解析、代码实现、样式定制及性能优化,适用于工业HMI、智能家居等场景,并附完整代码示例。

gin88的博客 261

uva1602

uva1602 题意 链接如下:https://vjudge.net/problem/UVA-1602 中文解释: 输入n,w,h(1<=n<=10,1<=w,h<=n).求能放在w*h网格里的不同的n连块的个数(平移,旋转,翻转算一种) 例如:第一排为n=5,w=2,h=4 第2牌为n=8,w=3,h=3 题解 很直接的思路:打表+STL(set) 重难点是 如何判断重复 因为可以平移,旋转,翻转,所以我们需要给每一个连通块一个标准化(让其的相对起始点都在(0,0))。 利用se

麦片老板的博客 364

nnU-Net v2实战:从零开始配置环境与训练自定义医学影像数据集

本文详细介绍了nnU-Net v2在医学影像分割中的实战应用,从环境配置到自定义数据集训练的全流程。重点讲解了Python 3.9+环境搭建、PyTorch安装技巧、医学影像数据预处理规范,以及五折交叉验证训练方法,帮助开发者快速掌握这一先进的医学影像分析工具。

weixin_28718487的博客 352

Java集合方面的面试题:Set集合是如何判断重复

我们知道Set集合有“自动去重”的特性,如果我们在其中存放的不是String、Integer之类的基本数据类型,而是自定义的类,那么Set集合凭什么来判断“重复”?我们来看一下SetDupDemo.java的代码。 1 //省略import集合包的代码 2 //请注意实现了Comparable接口 3 class Student implements Comparable{ 4 private int id; 5 public Student(int id){ this.id = id; } 6

hsm_computer的博客 2472

基于Simulink进行步进电机的重复控制仿真建模

目的:通过引入一个周期延迟环节来补偿系统的周期性误差,从而提高系统对周期性参考信号或扰动的跟踪性能。方法内部模型原理:在控制器中嵌入一个与周期性信号相关的模型(例如周期延迟环节),以实现对周期性误差的零稳态误差控制。滤波器设计:为了避免高频噪声放大,通常会在重复控制器中加入低通滤波器。优势对周期性信号具有良好的跟踪性能。不需要精确的数学模型即可实现高性能控制。挑战:需要合理设计重复控制器的参数以避免系统不稳定。

MHD0815的博客 380

2026美赛数学建模竞赛 MCM C题:与星共舞的数据 问题一 粉丝投票估计模型 详细解题思路和代码

2026美赛数学建模竞赛 MCM C题:与星共舞的数据 问题一 粉丝投票估计模型 详细解题思路和代码.。开发一个(或多个)数学模型,用于估算每位选手在他们参赛的各周的粉丝投票数(这是未知且严格保密的)。您的模型是否能正确估算出导致每周淘汰结果一致的粉丝投票数?提供一致性度量。您估算出的粉丝投票总数有多少确定性?这种确定性对于每位选手/每周是否总是相同?为您的估算提供确定性度量。

YOLO 852

自定义Set的判重方法

默认的 equals 比较的是地址值 在重写 equals 方法的同时,必须重写hashCode方法。 示例:我们想 只根据 id 判定是不是同一个学生,即 set 中不能出现 id 相同的学生。 import java.util.HashSet; import java.util.Set; public class Main { public static void main(String[] args) { Set<Stu> set = new HashSet<>();

QinLaoDeMaChu的博客 504

【NIPS 2022】时序精选论文07|Non-stationary Transformers: 引入非平稳性信息的平稳化序列预测模型(代码解读附源码)

整体代码框架基本上与传统 Transformer 类似,基本上只有在内嵌的注意力机制模块有区别,因此这里只对关键部分进行讲解,代码整体框架可参考 Transformer。非平稳时序很难预测,尤其对模型泛化性影响很大,试想下推理阶段的数据分布变了,模型很难适应这种变化。,比如很早以前的差分就是一种平稳化操作。序列平稳化能增强数据的可预测性,但这时也会带来一个问题,叫。,通过MLP层进行定义,使得参数可学习,以便于更好的融合到注意力网络中。代码中整体注意力的计算方式与原生Transformer类似,

ViolenceTemper的博客 1490

UVA1602 Lattice Animals 回溯+set判重

按照题意,只要我们能找出所有n连块,然后再判断能不能放进w*h的方格中就行了。找出所有n连块可以用回溯法,从k连块搜索,通过在其周围放一个方块,从而得到k+1连块,从而这样不断搜索下去直到n连块,搜索过程的判重就交给set了。因为题目中有多组输入,假如连续输入1000组相同的数据,我们都要一遍一遍的dfs吗?显然太复杂。所以我们可以事先把所有可能的输入数据对应的答案打表,这样输出就快的多了。在打表

每天都要进步哦~ 1281

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

Uva 1602 Lattice Animals (网格动物)

The Solution Of Uva 1602 Lattice Animals (网格动物)题目地址UVa 原地址 VJudge题目大意给定一个 w * h 的 矩阵,在矩阵中找不同连通块的个数(旋转,翻转,平移算作一种)题目做法判重编码判重无疑是这道题的重点。那么从判重的方法来看,有两种方法: STL 的 set 手写 hash 从时间来看,set 所消耗的时间肯定更多,但是更加的方便。那么用

mukevinran的博客 2240

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

Set集合如何判断重复元素

1.TreeSet子类是利用Comparable接口来实现重复元素的判断,但是Set集合的整体特征就是不允许保存重复元素。 2.HashSet判断元素重复是利用Object类中的方法实现的: -|对象编码:public int hashCode(); -|对象...

chengmi6360的博客 5433

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

Set中添加数据和删除数据的判重方式

  Set集合中可以使用add(Object o)方法向其中添加数据,但是与List集合不同的是,Set中不允许添加重复的数据,那么Set中判重的方式是什么呢?一句话概括就是:当且仅当Set集合中没有包含满足(o==null ? e==null : o.equals(e))条件的元素e时才能将元素o添加到集合中。   由三目运算可知,当要添加的数据为空时,只要原来set集合中没有空值就可以向其中...

jisuanji_qiyongjie的博客 2813

UVa 1602 Lattice Animals

Lattice animal is a set of connected sites on a lattice. Lattice animals on a square lattice are especially popular subject of study and are also known as polyominoes. Polyomino is usually represent

c21c21的专栏 1440

Set判重操作实现

需求:Set判重操作实现 问题:Set未进行排重 分析:对于基本数据相应的封装类的泛型;由于相应的封装类已经重写Object的hashcode与equals方法,故能够进行唯一性的区分 解决: 1.原集合 举例: [code="java"] public class Man { private int id ; private String name ...

走在命运的左岸 1120

UVA - 1602(Polyomino的存储和判重)

#include #include #include #include using namespace std; struct Cell{ int x,y; Cell(int x=0,int y=0):x(x),y(y){} bool operator < (const Cell& rhs) const{ return x < rhs.x || x==rhs.x && y< rhs.y;

playwfun的专栏 1688

UVA1602

题目描述:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=51164/* solution: 本题利用回溯法解决。本题实际上是要搜索n连通块不同形态的个数(平移,翻转,旋转后相同的算作一种形态),因此能够有效的判断n连通块是否重复是关键。 那么如何判断是否重复呢?我们一步步的分析。由于可能要涉及对一个对象的旋转,平

林伏案的博客 1053

(隐式图)八数码问题(三种判重方法:排列计数、哈希技术、STL_set判重)

#include #include #include #include using namespace std; typedef int State[9]; const int maxstate = 1000000; State st[maxstate], goal; //这个st数组就像一个队列 有front队首和rear队尾 int dist[maxstate]; const int

穿着裤衩跳 1452

uva1602:回溯+判重

题解:这一题思路很清晰,就是回溯+判重。但是难点在于判重。旋转、平移、翻转该怎么统一呢?参考了大佬的代码,终于豁然开朗。 首先判重想到set,这里要用的双set,代码里有说明。 旋转操作,每次旋转90度,就是(x,y)-->(y,-x) 平移操作,找出整个图形的x和y坐标的最小值,然后每个图形相应的平移。 翻转,就是(x,y)-->(y,x),但是翻转完之后,还有经过旋转判重。...

FlyingJack 285

关于八数码问题中的状态判重的三种解决方法(编码、hash、<set>)

八数码问题搜索有很多高效方法:如A*算法、双向广搜等 但在搜索过程中都会遇到同一个问题,那就是判重操作(如果重复就剪枝),如何高效的判重是8数码问题中效率的关键 下面关于几种判重方法进行比较:编码、hash、set 看到问题初学者最先想到的应该就是用一个vis数组标志一下即可。但是该申请多大的数组呢?一个9维数组(9^9=387420489太大了吧)?如果内存允许这是最高效的办法:O(1)

Crazy_Bear 4651

UVA - 1602 Lattice Animals

题目链接 这道题……真的小细节太多了,做的十分头痛。贴一篇博文吧,他讲的非常细致。 AC代码: #include &lt;iostream&gt; #include &lt;cstring&gt; #include &lt;cstdio&gt; #include &lt;set&gt; using namespace std; #define ssit set&lt; set&lt;Cel...

这是一个博客 235

利用stl的map判重poj3087

DescriptionAcommon pastime for poker players at a poker table is to shuffle stacksof chips. Shuffling chips is performed by starting with two stacks ofpoker chips, S1 and S2, each stack containi

Eli's XXX 1947
上一篇: Power Calculus UVA - 1374 IDA*
下一篇: Square Destroyer UVA - 1603 IDA*
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值