题目链接:点击打开链接

#include<stdio.h>
#include<iostream>
#include<string.h>
#include<set>
#include<vector>
#include<map>
#include<math.h>
#include<queue>
#include<string>
#include<stdlib.h>
#include<algorithm>
using namespace std;
#define N 110
#define ll int ll n, a, b;
ll h[N];
vector<int>G,ans;
void dfs(int u, bool hehe){//hehe=true表示u-1没死
if(u==n && hehe==false){
if(G.size()<ans.size())
ans = G;
return ;
}
int siz = 0;
if(hehe) {
while(h[u-1]>0)siz++,h[u-1]-=b, h[u]-=a, h[u+1]-=b, G.push_back(u);
}
if(h[u]>0) {
while(h[u]>0) {
dfs(u+1,true);
h[u-1]-=b;
h[u]-=a;
h[u+1]-=b;
siz++;
G.push_back(u);
}
}
dfs(u+1,false);
h[u]+=a*siz;
h[u+1]+=b*siz;
h[u-1]+=b*siz;
while(siz--)G.erase(G.end()-1);
}
int main(){
ll i, j;
while(~scanf("%d %d %d",&n,&a,&b)){
G.clear(); ans.clear();
for(i=1;i<=n;i++)scanf("%d",&h[i]), h[i]++;
while(h[1]>0){
h[2] -= a;
h[1] -= b;
h[3] -= b;
ans.push_back(2);
}
while(h[n]>0){
h[n-2] -= b;
h[n-1] -= a;
h[n] -= b;
ans.push_back(n-1);
}
G = ans;
for(i=1;i<=100;i++)ans.push_back(i);
dfs(2,false);
printf("%d\n",ans.size());
for(i = 0; i < ans.size(); i++)printf("%d%c",ans[i],i==ans.size()-1?'\n':' ');
}
return 0;
} /**/

Codeforces 6D Lizards and Basements 2 dfs+暴力的更多相关文章

  1. Codeforces Beta Round #6 (Div. 2 Only) D. Lizards and Basements 2 dfs

    D. Lizards and Basements 2 题目连接: http://codeforces.com/contest/6/problem/D Description This is simpl ...

  2. Codeforces Beta Round #6 (Div. 2 Only) D. Lizards and Basements 2 dp

    题目链接: http://codeforces.com/problemset/problem/6/D D. Lizards and Basements 2 time limit per test2 s ...

  3. codeforces 6D

    D. Lizards and Basements 2 time limit per test 2 seconds memory limit per test 64 megabytes input st ...

  4. ACM: FZU 2107 Hua Rong Dao - DFS - 暴力

    FZU 2107 Hua Rong Dao Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I6 ...

  5. ACM: Gym 100935G Board Game - DFS暴力搜索

    Board Game Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u  Gym 100 ...

  6. hdu 5612 Baby Ming and Matrix games(dfs暴力)

    Problem Description These few days, Baby Ming is addicted to playing a matrix game. Given a n∗m matr ...

  7. hdu 1010 Tempter of the Bone(dfs暴力)

    Problem Description The doggie found a bone in an ancient maze, which fascinated him a lot. However, ...

  8. NOIP 2002提高组 选数 dfs/暴力

    1008 选数 2002年NOIP全国联赛普及组 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 黄金 Gold 题目描述 Description 已知 n 个整数 x1,x2,…, ...

  9. Codeforces Round #313 (Div. 1) B. Equivalent Strings DFS暴力

    B. Equivalent Strings Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/559 ...

随机推荐

  1. 使用C#创建及调用WCF完整实例 (Windows服务宿主)

    关于WCF的概念.原理.优缺点等,在这里就不多说了,网上很多,可以自行搜索,比我解释的要专业的多. 这里直接说使用Windows 服务(Windows Service)作为宿主如何实现,其它方式不在此 ...

  2. jQuery用面向对象的思想来编写验证表单的插件

    本人的重点是怎么构建一个简单有效可扩展的jQuery表单验证插件,这篇文章没有教你怎么用 validate plugin.我们的重点在学习一些jQuery,Javascript面向对象编程的知识. 下 ...

  3. kafka基本原理概述——patition与replication分配

    kafka一直在大数据中承受着数据的压力也扮演着对数据维护转换的角色,下面重点介绍kafka大致组成及其partition副本的分配原则: 文章参考:http://www.linkedkeeper.c ...

  4. Linux上磁盘挂载

    Linux磁盘挂载   一.  磁盘分区 在终端输入fdisk –l 命令查看整个系统的分区情况. 能够看到另一个32G的/dev/vdb磁盘没有挂载使用 watermark/2/text/aHR0c ...

  5. HDU 1495 很可乐 (DFS)

    题目链接:很可乐 解析:一个瓶子,容量为s.两个杯子,容量分别为n和m,问最少多少次倾倒才干将一瓶可乐均分为两份. 直接模拟每次的倾倒.然后递归求解. 能够加个预判的条件,要是s是奇数的时候,不管怎样 ...

  6. 【Canvas】动态正17边光阑 向高斯致敬

    [背景知识] 公元前三世纪,欧几里得在<几何原本>中记载了正方形,正五边形,正六边形的做法,后来人们也掌握了正十五边形作图,但之后两千多年,人们没有在更高阶边形上取得突破. 1796年,1 ...

  7. VM虚拟机启动报错Reason Failed to lock the file怎么办

    VMware启动报错Reason: Failed to lock the file的解决方法 症状:  启动VMware虚拟机的时候出现了Cannot open the disk '*.vmdk' o ...

  8. IIS 之 线程池最大线程数

    .net4.0,32位机器最大线程数,每核1023个 .net4.0,64位机器最大线程数,每核32768个 .net3.0,最大线程数,每核250个 .net2.0,最大线程数,每核25个 默认的最 ...

  9. Java从零开始学二十四(集合工具类Collections)

    一.Collections简介 在集合的应用开发中,集合的若干接口和若干个子类是最最常使用的,但是在JDK中提供了一种集合操作的工具类 —— Collections,可以直接通过此类方便的操作集合 二 ...

  10. 算法笔记_206:第五届蓝桥杯软件类决赛真题(Java语言A组)

    目录 1 海盗分金币 2 六角幻方 3 格子放鸡蛋 4 排列序数 5 幂一矩阵 6 供水设施    前言:以下代码仅供参考,若有错误欢迎指正哦~ 1 海盗分金币 有5个海盗,相约进行一次帆船比赛. 比 ...