BAPC 2014:Button Bashing(暴力+bfs)】的更多相关文章

Open the Lock Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 3847    Accepted Submission(s): 1661 Problem Description Now an emergent task for you is to open a password lock. The password is co…
题意: 给出n,m,代表微波炉有n个按钮,要求达到总时间为m 然后给出n个数,代表n个按钮能增加的时间,问最少几步,能够使得按出的总时间大于等于要求的时间,并且相差最小 输出最小的步数与相差的最小值 要求,当总时间小于0时,时间为0,大于3600时,时间为3600 题意: 给出n,m,代表微波炉有n个按钮,要求达到总时间为m 然后给出n个数,代表n个按钮能增加的时间,问最少几步,能够使得按出的总时间大于等于要求的时间,并且相差最小 输出最小的步数与相差的最小值 要求,当总时间小于0时,时间为0,…
题意: 给出n,m,代表微波炉有n个button,要求达到总时间为m 然后给出n个数.代表n个button能添加的时间,问最少几步,可以使得按出的总时间大于等于要求的时间,而且相差最小 输出最小的步数与相差的最小值 要求,当总时间小于0时.时间为0,大于3600时,时间为3600 思路: 直接暴力BFS.用VIS记录步数 #include <iostream> #include <stdio.h> #include <string.h> #include <sta…
题目链接: http://www.lydsy.com/JudgeOnline/problem.php?id=1295 题解: 对每个点暴力跑一遍bfs,看能够到达的最远位置,这里如果有障碍物则距离为1,如果没有障碍物,则距离为0,用bfs跑距离<=t的所有点并更新答案. 代码: #include<iostream> #include<cstring> #include<cstdio> #include<utility> #include<queu…
Press the Button Time Limit: 1 Second      Memory Limit: 131072 KB BaoBao and DreamGrid are playing a game using a strange button. This button is attached to an LED light (the light is initially off), a counter and a timer and functions as follows: W…
题意:给定4个数,a,b,c,d,分别代表空杯子容积为a,b,一个盛满水的杯子容积为c,让你不断倒水,找一个dd,是不是存在某个时刻, 某个杯子里的水dd,和d相同,或者无限接近.让求最少的倒水量和dd(可能和d相同). 析:首先由于没有刻度,如果用数学方法计算,不好算,样例还好算一点,我们观察那个a,b,c都不大于200,挺小的,适合暴力求解. 就是把所有情况都倒一次,倒水就两种倒法,要么把一个杯子倒满,要么就是这个杯子空了,由于水量是固定的,那么确定两个杯子的水量, 那么第三个也就确定了,所…
Description Harry Potter has some precious. For example, his invisible robe, his wand and his owl. When Hogwarts school is in holiday, Harry Potter has to go back to uncle Vernon's home. But he can't bring his precious with him. As you know, uncle Ve…
八数码问题是一个经典的人工智能问题.具体问题不累述了. 思路:由于存在多组测试数据,可以考虑“打表法“.所谓打表法,即枚举所有的初始情况,记录其到达终点的路径.而在这个题目中,顺序打表会调用很多次BFS,所以我们采用逆序打表,只要调用一次BFS. 代码如下: /*************map存路径,set判重,string存状态*****************/ /*********************暴力广搜 + STL **************************/ #inc…
Description Input is the matrix A of N by N non-negative integers. A distance between two elements Aij and Apq is defined as |i − p| + |j − q|. Your program must replace each zero element in the matrix with the nearest non-zero one. If there are two…
题目链接: http://codeforces.com/gym/100526 http://acm.hunnu.edu.cn/online/?action=problem&type=show&id=11665&courseid=0 题目大意: 一个微波炉,有N个按钮,每个按钮可以让时间加或减一个数,问达到M至少需要按几次按钮.(N<=16,0<=M<=3600) 如果无法达到M输出比M大的最小的值需要按的次数和这个值与M的差值.注意微波炉的时间满足0<=当前…