题意: 给你n m q,表示在这一组数据中所有的01串长度均为n,然后给你一个含有m个元素的multiset,之后有q次询问.每次询问会给你一个01串t和一个给定常数k,让你输出串t和multiset里面多少个元素的“Wu”值不超过k.对于“Wu”值的定义:如果两个01串s和t在位置i上满足s[i]==t[i],那么加上w[i],处理完s和t的所有n位之后的结果即为这两个01串的“Wu”值. n<12,k<100,m<5e5 思路: n很小,k也很小,所以串的状态最多2^12次,预处理出…
[题目描述] In the game of Sudoku, you are given a large 9 × 9 grid divided into smaller 3 × 3 subgrids. For example, . 2 7 3 8 . . 1 . . 1 . . . 6 7 3 5 . . . . . . . 2 9 3 . 5 6 9 2 . 8 . . . . . . . . . . . 6 . 1 7 4 5 . 3 6 4 . . . . . . . 9 5 1 8 . .…
题目链接:Codeforces 417D Cunning Gena 题目大意:n个小伙伴.m道题目,每一个监视器b花费,给出n个小伙伴的佣金,所须要的监视器数,以及能够完毕的题目序号. 注意,这里仅仅要你拥有的监视器数量大于小伙伴须要的监视器数量就可以. 求最少花费多少金额能够解决全部问题. 解题思路:dp[i],i为一个二进制数.表示完毕这些题目的最小代价,可是这里要注意,由于有个监视器的数量.普通情况下要开一个二维的状态.可是2^20次方有一百万,再多一维的数组会超内存,所以我的做法是将每一…
#include<bits/stdc++.h> #define bit(t) (1 << t) using namespace std; <<; ;//k是集合s的大小 int sg[maxn];//sg[n] n表示每堆数量 ]; void get_sg(){ <<; ; sta < maxm; sta ++){ // printf("**%d**\n",sta); memset(vis, , sizeof(vis)); ; i…
题面在这里! 比较显而易见的暴力,O(2^(2n) + 2^n * 100) 就可以直接做了 #include<bits/stdc++.h> #define ll long long using namespace std; const int N=4105; #define pb push_back inline int getint(){ int x=0; char ch=getchar(); for(;!isdigit(ch);ch=getchar()); for(;isdigit(ch…
这题数据大容易TLE 优化:预处理, 可以先枚举出5^3的状态然后判断合不合法,但是由于题目说了有很多墙壁,实际上没有那么多要转移的状态那么可以把底图抽出来,然后3个ghost在上面跑到时候就不必判断了,减少了两次无用的枚举. 减少代码的方法:1.结点没有3个时增加冗余点,2.把位置坐标二元组编号成一个数,这点在预处理时可以顺便完成(坐标范围0~15),3.把三个ghost的位置状态压缩成一个数字,方便push,但是注意重时不能直接用Hash掉的值来判断vis,因为Hash以后数字范围很大. 这…
题目描述:  A Simple Task time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Given a simple graph, output the number of simple cycles in it. A simple cycle is a cycle with no repeated vertices or…
B. Preparing Olympiad You have n problems. You have estimated the difficulty of the i-th one as integer ci. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at le…
题目链接: A. Sonya and Queries time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Today Sonya learned about long integers and invited all her friends to share the fun. Sonya has an initially empty…
题目 给出一个n*m的01矩阵, 让你最多改变k个里面的值(0变1,1变0), 使得0.1的连通分量是矩阵.输出最少步数 1 ≤ n, m ≤ 100; 1 ≤ k ≤ 10 题解: 如果01连通分量是矩形, 那么矩形一定是这样的: 0101010 1010101 0101010 1010101 (上面的01代表子矩阵块). 也就是每一行要么是相同,要么是相反的. 如果n>k, 肯定有一行是不能改变的,那么枚举这一行,然后其余的要么变相同,要么变相反,看最少的步数. 如果n<k ,那么可以枚举…