Sagheer, the Hausmeister CodeForces - 812B 题意:有一栋楼房,里面有很多盏灯没关,为了节约用电小L决定把这些灯都关了. 这楼有 n 层,最左边和最右边有楼梯.每一层有 m 个房间排成一排.这栋楼可以被表示成一个 n 行 m + 2 列的矩阵,其中每行第一个和最后一个格点表示楼梯, 剩余 m 个格点表示房间. 现在小L在最底层的最左边楼梯,他想要关掉所有的灯.他每次可以走到相邻的房间,如果在楼梯口可以上下楼梯.他打算关掉所有开着的灯,在他没有将一层的所有灯…
题目链接:http://codeforces.com/contest/812/problem/B 题意 : 给出一个 n (1 ≤ n ≤ 15)层的教学楼, 每一层楼包含 m (1 ≤ m ≤ 100)个房间, 另外每一层的两边还有楼梯口, 接下来有n 行每行有 m+2(包含楼梯口) 用0和1来表示这栋楼的信息, 0代表这个房间的灯没亮, 1代表亮, 现在保安在整栋楼的左下角的楼梯口, 他的目的是关掉这栋楼所有的灯, 而且保安在上楼时他所在的当前楼层灯需全灭才能继续上楼, 而且每经过一个房间和…
题意:给你n行长度为m的01串(n<15,m<100) .每次只能走一步,要将所有的1变为零,问最少的步数,注意从左下角开始,每次要将一层清完才能走到上一层,每次只有在第一列或者最后一列才能往上走一层,否则只能左右移动. 题解:由于清完当前层才能继续上一层,所以必然存在一个递推关系.先递推预处理,然后输出ans即可.用far来存最远的那个1,如果这层没有1,假设有一个,令其距离为1 具体看代码注释吧. 坑:没考虑没有1以及只有1层的情况 #define _CRT_SECURE_NO_WARNI…
812B - Sagheer, the Hausmeister 思路: 搜索: 代码: #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; #define maxn 20 #define maxm 105 #define INF 0x7fffffff ],num[maxn],ans=INF,k,sum[maxn],…
B. Sagheer, the Hausmeister time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Some people leave the lights at their workplaces on when they leave that is a waste of resources. As a hausmeiste…
B. Sagheer, the Hausmeister time limit per test  1 second memory limit per test  256 megabytes   Some people leave the lights at their workplaces on when they leave that is a waste of resources. As a hausmeister of DHBW, Sagheer waits till all studen…
题目链接:http://codeforces.com/problemset/problem/812/B B. Sagheer, the Hausmeister time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Some people leave the lights at their workplaces on when they…
http://codeforces.com/problemset/problem/812/B B. Sagheer, the Hausmeister time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Some people leave the lights at their workplaces on when they leav…
http://codeforces.com/contest/812/problem/B [题意] 有一个n*m的棋盘,每个小格子有0或1两种状态,现在要把所有的1都变成0,问最少的步数是多少?初始位置在左下角,只有把下面一层的1都变成0后才可以到上一层,只有在每层的最右边和最左边可以向上走(up),否则只能左右移动(left or right).只要经过1,就可以把1变成0,只要把最后一个1,就可以立即停止操作. [Accepted] #include <iostream> #include…
[题目链接]:http://codeforces.com/contest/812/problem/B [题意] 一个老大爷在一楼; 然后他有n楼的灯要关(最多n楼); 每楼有m个房间; 给出每个房间的灯的信息(亮或不亮) 然后他移动到相邻的房间,或者是移动到上一层都花费一分钟; 每一层的灯没有全部关掉之前,他不会往上层走; (每层的最左和最右是两个楼道,那两个地方才能往上走); 问你最小时间: [题解] dfs; 每层楼有两种情况; 从左楼道上楼,从右楼道上楼; 然后记录最小的,有灯是开着的楼层…