poj 3185 The Water Bowls】的更多相关文章

任意门:http://poj.org/problem?id=3185 The Water Bowls Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7676   Accepted: 3036 Description The cows have a line of 20 water bowls from which they drink. The bowls can be either right-side-up (pro…
The Water Bowls 题意:给定20个01串(最终的状态),每个点变化时会影响左右点,问最终是20个0所需最少操作数? 水题..直接修改增广矩阵即可:看来最优解不是用高斯消元(若是有Gauss消元0ms A的请留言~~),很多是0ms过的,我用了32ms; #include<iostream> #include<cstdio> #include<cstring> #include<string.h> #include<algorithm>…
Description The cows have a line of water bowls water bowls to be right-side-up and thus use their wide snouts to flip bowls. Their snouts, though, are so wide that they flip not only one bowl but also the bowls on either side of that bowl (a total o…
题目链接:http://poj.org/problem?id=3185 题意:20盏灯排成一排.操作第i盏灯的时候,i-1和i+1盏灯的状态均会改变.给定初始状态,问最少操作多少盏灯使得所有灯的状态最后均为0. 思路:高斯消元,记录变元个数,枚举变元. int a[N][N],ans[N]; vector<int> b; int Gauss() { b.clear(); int i,j=1,k,t; for(i=1;i<=20;i++) { for(k=j;k<=20;k++) i…
题目链接 题意:翻译过来就是20个0或1的开关,每次可以改变相邻三个的状态,问最小改变多少次使得所有开关都置为0,题目保证此题有解. 题解:因为一定有解,所以我们可以正序逆序遍历两次求出较小值即可.当然这题也可以用万能的高斯消元来做.给出两种代码. 暴力代码: #include <iostream> #include <cstdio> #include <cmath> #include <cstring> #include <algorithm>…
题目链接 题意:有20个数字,0或1.如果改变一个数的状态,它左右两边的两个数的状态也会变反.问从目标状态到全0,至少需要多少次操作. 分析: 和上一题差不多,但是比上一题还简单,不多说了,但是在做题的时候犯了一个非常二的错误..看图吧. 先输入了a[0]又,初始了a[][]数组 #include <iostream> #include <cstdio> #include <cstring> #include <cstdlib> #include <c…
题目链接 给一行0 1 的数, 翻转一个就会使他以及它左右两边的都变, 求最少多少次可以变成全0. 模板题. #include <iostream> #include <vector> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #include <map> #include <set> #include…
The Water Bowls Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7402 Accepted: 2927 Description The cows have a line of 20 water bowls from which they drink. The bowls can be either right-side-up (properly oriented to serve refreshing cool…
http://poj.org/problem?id=1222 http://poj.org/problem?id=1830 http://poj.org/problem?id=1681 http://poj.org/problem?id=1753 http://poj.org/problem?id=3185 这几个题目都类似,都可以使用高斯消元来求解一个模2的01方程组来解决. 有时候需要枚举自由变元,有的是判断存不存在解 POJ 1222 EXTENDED LIGHTS OUT 普通的问题.…
The Water Bowls Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 4088   Accepted: 1609 Description The cows have a line of 20 water bowls from which they drink. The bowls can be either right-side-up (properly oriented to serve refreshing…