uva 639 - Don't Get Rooked

解锁医疗AI密码:医疗人工智能专业大学四年学习路径 医疗AI人才培养路径解析 本文系统梳理了医疗人工智能专业四年培养方案,分为基础、进阶、应用和拓展四个阶段: 大一聚焦基础学科,涵盖高等数学、医学概论、Python编程等核心课程,辅以医学数据认知实习。大二深入机器学习和医学数据处理领域,学习监督/无监督学习算法及医学影像分析技术。大三进入深度学习阶段,掌握CNN/RNN等神经网络模型,并实践医疗AI应用开发。大四关注前沿技术如大模型在医疗中的应用,完成毕业设计与企业实习。 课程体系强调医工交叉,每学期均配置实践环节,从基础编程到参与真实医疗AI项目,逐步培养 阅读详情

原题

这题比起八皇后问题更复杂。有两种状态转移方式:直接进入下一行搜索;在这一行选一个,仍在这一行搜索。

#include<stdio.h>
#include<string.h>
#include<stdlib.h>

struct Pos
{
	int x,y;
};

Pos C[16];
int n,max,mat[6][6],vis[6][6];

int is_capture(int x,int y,int s)
{
	int i,j,ok;
	for(i=0;i<s;i++)
	{
		if(C[i].x==x)
		{
			ok=1;
			int y1,y2;
			y1=C[i].y<y? C[i].y:y;
			y2=C[i].y+y-y1;
			//printf("%d %d\n",y1,y2);
			for(j=y1+1;j<y2;j++)  if(mat[C[i].x][j])
			{
				ok=0;
				break;
			}
			if(ok) return 1;
		}
		if(C[i].y==y)
		{
			int x1,x2;
			x1=C[i].x<x? C[i].x:x;
			x2=C[i].x+x-x1;
			ok=1;
			//printf("%d %d\n",x1,x2);
			for(j=x1+1;j<x2;j++) if(mat[j][y])
			{
				ok=0;
				break;
			}
			if(ok) return 1;
		}
	}
	return 0;
}

void search(int cur,int s)
{
	if(cur==n) 
	{
		if(max<s) max=s;
	}
	else
	{
		for(int i=0;i<n;i++) if(!mat[cur][i] && 
	  !vis[cur][i] && !is_capture(cur,i,s))
   	 {
		C[s].x=cur;
		C[s].y=i;
		vis[cur][i]=1;
		search(cur,s+1);
		//search(cur+1,s+1);
		vis[cur][i]=0;
	 }
	    search(cur+1,s);
	} 
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("639.txt","r",stdin);
#endif
	char s[6];
	while(scanf("%d",&n)==1 && n)
	{
		int i,j;
		memset(mat,0,sizeof(mat));
		memset(vis,0,sizeof(vis));
		for(i=0;i<n;i++)
		{
			scanf("%s",s);
			for(j=0;j<n;j++) 
			  if(s[j]=='X') mat[i][j]=1;
			  else mat[i][j]=0;
		}
		//for(i=0;i<n;i++,printf("\n"))
		  //for(j=0;j<n;j++) printf("%d",mat[i][j]);
  		max=0;
  		search(0,0);
  		printf("%d\n",max);
	}
    return 0;
}


LVGL 拨盘菜单(Dial Menu) h。 阅读详情

相关推荐

FDTD脚本教程——结构的创建

文章目录结构的搭建创建长方体创建柱体多边形柱体(椭)圆柱体圆环柱自定义形状创建surface波导球棱锥 在lumerical中,可以使用脚本进行操作,可在右侧脚本编辑器运行,或者直接在下方shell输入。 结构的搭建 创建长方体 um = 1e-6; nm = 1e-7; addrect; set("name","myRect"); set("material","SiO2 (Glass) - Palik"); set("render type","wireframe"); # 默认是细节渲染,也就是det

战斗果冻的训练中心 2万+

UVA 639 Don't Get Rooked

UVA-639题意:给出一个地图,x为障碍物。可以放置一些喷火器(?),可以攻击和它同行同列的东西,攻击会被x障碍物阻隔。求在这个地图上可以放多少个喷火器。 解题思路:因为地图很小,暴力枚举每个点能不能放,放下去之后对它所在的行列的可攻击范围内的计数的pd[i][j]++。只有pd[i][j]==0 的点才可以放。/*****************************************

QzNarsh的博客 337

PTrade数据交互全流程详解:从本地文件上传到定时导出交易数据

本文详细解析了PTrade量化交易平台的数据交互全流程,涵盖从本地文件自动上传交易指令到定时导出成交数据的完整链路。通过文件媒介实现本地策略与云端实盘的安全、稳定对接,并提供了构建自动化、稳健数据流水线的实战配置方案与代码示例,助力量化工作流平滑过渡至实盘。

gg901的博客 900

UVA 639 Don't Get Rooked

UVA_639 这个题目可以先将横向相连的“.”看作一个块,并记录下块开始和结束的坐标,每个块中只能放一个rook。 之后便顺序枚举每种方案并判断rook是否可以放在假设的位置,如果可以就继续深搜。当搜完搜有的块之后,就可以比较放置的rook总数与ans了,如果比ans大,则更新ans的值。 #include&lt;stdio.h&gt;#include&lt;string.h&gt;i...

weixin_33834628的博客 88

ubuntu虚拟机搭建OP-TEE

在网上找了一些搭建OP-TEE的过程,模仿着进行搭建,结果有好多报错,为了方便自己以后重新搭建,所以将整个过程记录下来。

weixin_44213847的博客 1018

别再到处找模板了!手把手教你用Vue3+Element Plus搭建一个‘能跑起来’的管理后台原型

本文详细介绍了如何利用Vue3和Element Plus在72小时内快速搭建一个功能完整的管理后台原型。从环境准备到项目获取、依赖安装、原型定制、数据模拟以及构建优化,手把手教你打造一个可直接演示的后台系统,特别适合创业者快速验证产品逻辑。

weixin_26854555的博客 190

UVA 639 (13.08.25)

Don't Get Rooked In chess, the rook is a piece that can move any number of squaresvertically or horizontally. In this problem we will consider smallchess boards (at most 44) that can also...

445822357 176

Cloudflare 5秒盾逆向实战:从503到cf_clearance的全流程拆解(附避坑指南)

本文深入拆解了Cloudflare 5秒盾的完整逆向流程,从首次503响应到最终获取cf_clearance令牌,详细解析了五层挑战机制。文章重点分享了实战中的核心避坑指南,包括时间戳校验、动态图片尺寸获取、会话保持方案选择以及复杂环境检测的应对策略,为开发者提供了一套绕过5秒盾的实用方法论。

weixin_29327977的博客 2356

UVa 639 放车问题

题意:给定一个 n x n 的棋盘,在上面放置车。其中.号表示可放置,X表示墙。在同一行或同一列的两个车,如果它们之间没有X墙挡着,则是不合法的放置。给定一棋盘,最多可以放置车的数量。 思路:枚举所有的格子,看是否可以在此放置。每次放一个车后,修改棋盘的横行、竖列直到X的位置为1,即不可放置。因为要修改棋盘,所以需拷贝一个过来,修改拷贝的。还有一些注意的,如注释,总感觉写得不是很简洁。 还有就

buxizhizhou530的专栏 872

这5组白月光少女三视图提示词直接用

今天分享5组治愈系白月光少女女主提示词,适合用于AI漫剧角色设计、角色库搭建和人物设定参考,所有提示词均是完整可复刻。

欢迎来到鸾姝淡月博客,专为程序员和编程爱好者打造的技术博客。我们分享编程语言趋势、开发工具、编程哲学、职业发展等,助你掌握新技术,优化技能,激发编程热情。 217

锂电池寿命预测 | Pytorch实现基于Transformer 的锂电池寿命预测(NASA数据集)

锂电池寿命预测 | Pytorch实现基于Transformer 的锂电池寿命预测(NASA数据集)

算法如诗的博客 5606

uva639 暴力、回溯

题意: 在象棋中,“车”是可以在棋盘上沿着纵向或横向走任意格子的棋子。 在这个问题中,我们假设有一个4*4的小棋盘, 在这个棋盘上面包含着“墙”,而“车”是不能越过墙的。而我们的目标就是尽可能地放置更多地“车”到这个棋盘上去,使所有 的这些”车“互相不能吃到其它棋子。 在上面几副图中给出了几个样例, 棋盘上,格子全部是黑色的代表是“墙”, 黑色圆形的代表是“车”。 其中第二,三...

angchen2660的博客 165

MuJoCo 入门教程(一)

在 MuJoCo 仿真中输入自定义数字有三种方法。首先,可在 XML 中定义全局数字字段。它们有一个名称和一个实数值数组。其次,可以通过特定元素的自定义数组来扩展某些模型元素的定义。具体方法是在 XML 元素大小中设置 nuser_XXX 属性。第三,数组 mjData.userdata 不用于任何 MuJoCo 计算。用户可以在这里存储自定义计算的结果;请记住,所有随时间变化的内容都应存储在 mjData 中,而不是 mjModel 中。自定义文本字段可以保存在模型中。

机器人控制与仿真应用 1万+

UVa 639 Don't Get Rooked

/* coder: ACboy date: 2010-3-19 result: 1A description: UVa 639 Dont Get Rooked*/#include using namespace std;char chess[4][4];char tempChess[4][4];int everyPos[70000][16];i

个人独立博客http://www.acb0y.cn/ 1032

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

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

uva 639 Don't Get Rooked (暴力回溯 )

uva 639 Don't Get Rooked In chess, the rook is a piece that can move any number of squares vertically or horizontally. In this problem we will consider small chess boards (at most 44) tha

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

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 - 639 - Don't Get Rooked (暴力回溯)

UVA - 639 Don't Get Rooked Time Limit: 3000MS   Memory Limit: Unknown   64bit IO Format: %lld & %llu Submit Status Description In chess, the rook is a piece that

Never say never 1139

Devexpress16.2.6破解工具

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

uva 639 Don't Get Rooked

题目地址:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=108&page=show_problem&problem=580 题目描述:  Don't Get Rooked  In chess, the rook is a

心之所向,无惧无悔! 862

UVa 639 - Don't Get Rooked

类似“八皇后问题”,但加了“墙”的概念,如果有墙相隔,则同一行墙两边可同时存在两个元素。 枚举子集+判断可行性,在枚举子集时,可以进行适当剪枝,如此可以减少很多不必要的枚举,比如:当n == 4时,其最大的的“车”的位置为8个,则我们可以加一个计数器,最多将子集的枚举量设为8,超过8则不再往子集中加入元素。 代码如下: #include #include #include #inc

GooMaple 1191

uva 639 Don't Get Rooked ( 回溯 )

这道题确实是标准的回溯,果然还是早上比较清醒一些,昨天晚上想了好长一会儿都没有想起来,早上一会的功夫就A 了,估计也有昨天晚上的帮助。。。总感觉不想写太多私人的东西在这上面,因为这个是每个人都可以无条件访问的。。。 思路: 由于数据比较小,可以把每个元素都遍历一遍,回溯选择,最多4*4,还是很小的,我交的才1ms,1A。。 贴代码: #include #include #include

勿忘初心 1016

UVA 639- Don't Get Rooked

In chess, the rook is a piece that can move any number of squares vertically or horizontally. In this problem we will consider small chess boards (at most 44) that can also contain walls through whi

小shan在努力~ 531

UVA639 Don't Get Rooked

UVA639 Don't Get Rooked 类似八皇后问题,不过中间多了障碍物。。 深搜回溯,标记放过的点,。然后利用标记的点进行判断能不能放入。 #include #include int n; char map[10][10]; int vis[10][10]; int max; void dfs(int num) { if (max < num

Remilia's 1150

POJ1315 UVA639 UVALive5325 Don't Get Rooked【DFS】

Don’t Get Rooked Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 2631 Accepted: 1682 Description In chess, the rook is a piece that can move any number of squares vertically or horizontal...

海岛Blog 595
上一篇: uva 110 - Meta-Loopless Sorts
下一篇: uva 539 - The Settlers of Catan
lzw_java
博客等级 码龄15年 49粉丝 73原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址