【BZOJ】2102: [Usaco2010 Dec]The Trough Game(暴力)
http://www.lydsy.com/JudgeOnline/problem.php?id=2102
直接枚举所有情况。。。。。。然后判断是否可行。。
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define for1(i,a,n) for(int i=(a);i<=(n);++i)
#define for2(i,a,n) for(int i=(a);i<(n);++i)
#define for3(i,a,n) for(int i=(a);i>=(n);--i)
#define for4(i,a,n) for(int i=(a);i>(n);--i)
#define CC(i,a) memset(i,a,sizeof(i))
#define read(a) a=getint()
#define print(a) printf("%d", a)
#define dbg(x) cout << #x << " = " << x << endl
#define printarr2(a, b, c) for1(i, 1, b) { for1(j, 1, c) cout << a[i][j]; cout << endl; }
#define printarr1(a, b) for1(i, 1, b) cout << a[i]; cout << endl
inline const int getint() { int r=0, k=1; char c=getchar(); for(; c<'0'||c>'9'; c=getchar()) if(c=='-') k=-1; for(; c>='0'&&c<='9'; c=getchar()) r=r*10+c-'0'; return k*r; }
inline const int max(const int &a, const int &b) { return a>b?a:b; }
inline const int min(const int &a, const int &b) { return a<b?a:b; } const int N=105;
int n, m, cnt, ans, a[N][N], b[N]; bool check(int t) {
for1(i, 1, m) {
int tot=0;
rep(j, n) if(a[i][j] && (t&(1<<j))) ++tot;
if(tot!=b[i]) return 0;
}
return 1;
} int main() {
read(n); read(m);
for1(i, 1, m) {
rep(j, n) {
char ch=getchar();
while(ch<'0'||ch>'9') ch=getchar();
a[i][j]=ch-'0';
}
b[i]=getint();
}
int mx=(1<<n)-1, flag=0;
for1(x, 0, mx) {
if(check(x)) {
if(cnt) { puts("NOT UNIQUE"); return 0; }
flag=1;
ans=x;
++cnt;
}
}
if(!flag) puts("IMPOSSIBLE");
else rep(i, n) printf("%d", (bool)(ans&(1<<i)));
return 0;
}
Description
Input
Output
Sample Input
1000 1
0110 1
1001 1
0011 1
Sample Output
HINT
Source
【BZOJ】2102: [Usaco2010 Dec]The Trough Game(暴力)的更多相关文章
- 2102: [Usaco2010 Dec]The Trough Game
2102: [Usaco2010 Dec]The Trough Game Time Limit: 10 Sec Memory Limit: 64 MBSubmit: 117 Solved: 84[ ...
- BZOJ 2100: [Usaco2010 Dec]Apple Delivery( 最短路 )
跑两遍最短路就好了.. 话说这翻译2333 ---------------------------------------------------------------------- #includ ...
- BZOJ 2101: [Usaco2010 Dec]Treasure Chest 藏宝箱( dp )
dp( l , r ) = sum( l , r ) - min( dp( l + 1 , r ) , dp( l , r - 1 ) ) 被卡空间....我们可以发现 l > r 是无意义的 ...
- BZOJ2102 : [Usaco2010 Dec]The Trough Game
暴力枚举答案然后检验. #include<cstdio> int n,m,i,j,k,a[100],b[100],cnt,ans;char s[20]; int main(){ for(s ...
- BZOJ 2101 [Usaco2010 Dec]Treasure Chest 藏宝箱:区间dp 博弈【两种表示方法】【压维】
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=2101 题意: 共有n枚金币,第i枚金币的价值是w[i]. 把金币排成一条直线,Bessie ...
- BZOJ——2101: [Usaco2010 Dec]Treasure Chest 藏宝箱
http://www.lydsy.com/JudgeOnline/problem.php?id=2101 Time Limit: 10 Sec Memory Limit: 64 MBSubmit: ...
- bzoj 2097: [Usaco2010 Dec]Exercise 奶牛健美操【二分+树形dp】
二分答案,然后dp判断是否合法 具体方法是设f[u]为u点到其子树中的最长链,每次把所有儿子的f值取出来排序,如果某两条能组合出大于mid的链就断掉f较大的一条 a是全局数组!!所以要先dfs完子树才 ...
- bzoj 2101: [Usaco2010 Dec]Treasure Chest 藏宝箱【区间dp】
就是区间dp啦f[i][j]表示以i开头的长为j+1的一段的答案,转移是f[i][j]=s[i+l]-s[i-1]+min(f[i][j-1],f[i+1][j-1]),初始是f[i][1]=a[i] ...
- bzoj 2100: [Usaco2010 Dec]Apple Delivery【spfa】
洛谷数据好强啊,普通spfa开o2都过不了,要加双端队列优化 因为是双向边,所以dis(u,v)=dis(v,u),所以分别以pa1和pa2为起点spfa一遍,表示pb-->pa1-->p ...
随机推荐
- wifi简单笔记
什么是wifi: Wi-Fi是一种可以将个人电脑.手持设备(如PDA.手机)等终端以无线方式互相连接的技术.Wi-Fi是一个无线网路通信技术的品牌,由Wi-Fi联盟(Wi-Fi Alliance)所持 ...
- android之Activity.startManagingCursor方法详解
在使用数据库操作查询数据后,如果是在Activity里面处理,那么很可能就会用到startManagingCursor()方法,在这里讲一下它的作用和使用注意事项. 调用这个方法,就是将获得的Curs ...
- 初识 Swift编程语言(中文版)
前言 今天Apple公布了新的编程语言Swift.也提供了一本将近400页的 The Swift Programming Language(Swift编程语言). 尽管我没有开发人员账号.没法实际上机 ...
- [读后感]spring Mvc 教程框架实例以及系统演示下载
[读后感]spring Mvc 教程框架实例以及系统演示下载 太阳火神的漂亮人生 (http://blog.csdn.net/opengl_es) 本文遵循"署名-非商业用途-保持一致&qu ...
- mysql 严格模式取消 group by 和 date zore
取消单个库的时间严格模式 set global sql_mode=(select replace(@@sql_mode,'NO_ZERO_IN_DATE,NO_ZERO_DATE',''));
- Protocol Informatics (PI项目)【基于网络轨迹的协议逆向工程文献学习】
Protocol Informatics[基于网络轨迹的协议逆向工程文献学习]by tsy 声明: 1)本报告由博客园bitpeach撰写,版权所有,免费转载,请注明出处,并请勿作商业用途.恕作者著作 ...
- Intellij IDEA 10.5 语言设置
适应于:英文操作系统,但是语言和区域设置为中文的环境. Mac: /Applications/IntelliJ IDEA CE.app/Contents/bin/idea.vmoptions 增加 - ...
- SQL SERVER 如何处理带字母的自增列--【叶子】
--需求说明: /* id col ---------- ---------- AB00001 a AB00002 b --当再插入数据的时候让id自动变成AB00003 ...
- C#实现播放声音的方法
文章来自学IT网:http://www.xueit.com/html/2009-09/21_4598_00.html 在这里介绍使用C#实现播放声音的几种方法,都是利用组件等方法来实现的,有兴趣的话可 ...
- Windows 环境下分布式跨域Session共享
为什么还是那句话,在网上找了N篇Session共享,但真正可以直接解决问题的还是没有找到. 一.以下为本人亲测,为防止环境不一致,对本文产生歧义,限定环境如下: 1. IIS7.0 2. Asp.ne ...