zoukankan      html  css  js  c++  java
  • BJFU 1551 ——delightful world——————【暴搜】

    delightful world

    时间限制(C/C++):20000MS/30000MS          运行内存限制:65536KByte
    总提交:33            测试通过:10

    描述

     

    Siny was once a very happy boy. But one day, something awful happened. He felt so sorrowful and he decided to leave the place where he resided at now. So he packs up his clothes and takes a plane to a completely new world called "CareFree world", people there has no worried at all and live in a delightful life. But when he arrives there, he found he has to do something challengeable so that he can be allowed to enter the delightful world.

     

    His task is to guess the code. A code cosists of n numbers, and every number is a 0 or 1, he has made m attempts to guess the code. After each guess, a system will tell him how many position stand the right numebers. But he is unlucky that he never guesses more than 5 correct numbers. So he doubts the system for having mistakes in telling him the right numbers in right position. 

     

    Can you tell him how many possible combinations of code exist that proves the system is working with no problems?

     

    输入

     

    There are multiple cases.

     

    For each case, the first input line contains two integers n and m, which represent the number of numbers in the code and the number of attempts made by Siny.

     

    Then follow m lines, each containing space-separated si and ci which correspondingly indicate Siny's attempt (a line containing n numbers which are 0 or 1) and the system's response (an integer from 0 to 5 inclusively), 6 <= n <= 35, 1 <= m <= 10.

     

    输出

     

    Print the single number which indicates how many possible combinations of code exist that proves the system is working with no problems.

    样例输入

    6 3
    000000 2
    010100 4
    111100 2
    6 3
    000000 2
    010100 4
    111100 0

    样例输出

    1
    0

    提示

     

    In the first example, there exists one possible combination that is 010111, which satisfies all the 3 results the system tells Siny, and it proves that the system is working fine without any problems.

     

    题目来源

    BJFUACM

     

    题目大意:给你n,m表示下面的矩阵是m*n的,用0、1的行去跟矩阵的每行对比,看对应位置相同的是否为每行后面的数字,如果所有的行都能满足,那么就是一种方案,问你总的方案数。

    解题思路:枚举第一行正确的位置,然后跟下面的行去比较。

    #include<stdio.h>
    #include<algorithm>
    #include<string.h>
    #include<math.h>
    #include<string>
    #include<iostream>
    #include<queue>
    #include<vector>
    #include<set>
    using namespace std;
    typedef long long LL;
    #define mid (L+R)/2
    #define lson rt*2,L,mid
    #define rson rt*2+1,mid+1,R
    const int INF = 0x3f3f3f3f;
    const int maxn = 1e2 + 300;
    int a[maxn], v[maxn], Map[maxn][maxn];
    int n, m;
    int dfs(int cur,int dep){
        if(dep > a[1]){
            for(int i = 2; i <= m; i++){
                int tmp = 0;
                for(int j = 1; j <= n; j++){
                    if(v[j]){
                        if(Map[i][j] == Map[1][j]){
                            tmp++;
                        }
                    }else{
                        if(Map[i][j] != Map[1][j]){
                            tmp++;
                        }
                    }
                }
                if(tmp != a[i]){
                    return 0;
                }
            }
            return 1;
        }
        int ret = 0;
        for(int i = cur; i <= n; i++){
            v[i] = 1;
            ret += dfs(i+1,dep+1);
            v[i] = 0;
        }
        return ret;
    }
    int main(){
        char s[333];
        while(scanf("%d%d",&n,&m)!=EOF){
            for(int i = 1; i <= m; i++){
                scanf("%s",s);
                for(int j = 1; j <= n; j++){
                    Map[i][j] = s[j-1] - '0';
                }
                scanf("%d",&a[i]);
            }
            int res = dfs(1,1);
            printf("%d
    ",res);
        }
        return 0;
    }
    

      

  • 相关阅读:
    pygrib的操作用法
    pythonista安装stash
    关于crontab运行python脚本不生效,但是手动执行却正常的问题
    windows下使用tensorboard注意事项
    请教tornadomeet大神Kinect+OpenNI学习笔记之8(Robert Walter手部提取代码的分析)(OpenNI2、NiTE2改编)
    CCV 调试 (一)
    数字图像处理第二次作业
    yangyangcv的OpenNI驱动玩隔空触摸源代码分析
    openFrameworks 学习笔记(一)
    关于error LNK2001: unresolved external symbol "__declspec(dllimport) public
  • 原文地址:https://www.cnblogs.com/chengsheng/p/5435625.html
Copyright © 2011-2022 走看看