题面在这里!

比较显而易见的暴力,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);ch=getchar()) x=x*10+ch-'0';
return x;
} inline int getbit(){
int x=0; char ch=getchar();
for(;ch!='0'&&ch!='1';ch=getchar());
for(;ch=='0'||ch=='1';ch=getchar()) x=(x<<1)|(ch=='1');
return x;
} void W(int x){ if(x>=10) W(x/10); putchar(x%10+'0');} vector<int> g[N][105];
int w[N],n,m,q,ans[500005],cnt[N],all,qz[105]; inline void solve(){
for(int i=0;i<=all;i++){
memset(qz,0,sizeof(qz)); for(int j=0,x;j<=all;j++){
x=w[i^j^all];
if(x<=100) qz[x]+=cnt[j];
} for(int j=0;j<=100;j++){
if(j) qz[j]+=qz[j-1];
for(int k:g[i][j]) ans[k]=qz[j];
}
}
} int main(){
n=getint(),m=getint(),q=getint(),all=(1<<n)-1; for(int i=n-1;i>=0;i--) w[1<<i]=getint();
for(int i=1;i<=all;i++) w[i]=w[i&-i]+w[i^(i&-i)]; for(int i=0;i<m;i++) cnt[getbit()]++;
for(int i=0,X,Y;i<q;i++) X=getbit(),Y=getint(),g[X][Y].pb(i); solve(); for(int i=0;i<q;i++) W(ans[i]),puts(""); return 0;
}

  

CodeForces - 1017D The Wu的更多相关文章

  1. Codeforces 1017D The Wu(状态压缩+预处理)

    题意: 给你n m q,表示在这一组数据中所有的01串长度均为n,然后给你一个含有m个元素的multiset,之后有q次询问.每次询问会给你一个01串t和一个给定常数k,让你输出串t和multiset ...

  2. CodeForces - 1017D Round #502 D. The Wu(状压预处理)

    D. The Wu time limit per test 2 seconds memory limit per test 256 megabytes input standard input out ...

  3. 【Codeforces Round #502 (in memory of Leopoldo Taravilse, Div. 1 + Div. 2) D】The Wu

    [链接] 我是链接,点我呀:) [题意] 给你n个字符串放在multiset中. 这些字符串都是长度为m的01串. 然后给你q个询问 s,k 问你set中存在多少个字符串t 使得∑(t[i]==s[i ...

  4. Codeforces 1099 - A/B/C/D/E/F - (Done)

    链接:https://codeforces.com/contest/1099 A - Snowball - [模拟水题] 题意:有一个雪球从山顶滚落,山坡上有两块石头,每秒钟会一次发生三件事:1.雪球 ...

  5. Educational Codeforces Round 46 (Div 2) (A~G)

    目录 Codeforces 1000 A.Codehorses T-shirts B.Light It Up C.Covered Points Count(差分) D.Yet Another Prob ...

  6. Codeforces Round #532 (Div. 2) 题解

    Codeforces Round #532 (Div. 2) 题目总链接:https://codeforces.com/contest/1100 A. Roman and Browser 题意: 给出 ...

  7. python爬虫学习(5) —— 扒一下codeforces题面

    上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...

  8. 【Codeforces 738D】Sea Battle(贪心)

    http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...

  9. 【Codeforces 738C】Road to Cinema

    http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...

随机推荐

  1. mysql 使用shell时出现 ERROR 2006 (HY000): MySQL server has gone away 解决方法

    ERROR (HY000): MySQL server has gone away No connection. Trying to reconnect... Connection Current d ...

  2. KS(Kolmogorov-Smirnov)(转)

    来源:https://blog.csdn.net/u013421629/article/details/78217498 KS(Kolmogorov-Smirnov):KS用于模型风险区分能力进行评估 ...

  3. django框架<二>

    django框架:   Models 1.基本创建 Django提供了一个抽象层("Model")的构建和管理Web应用程序的数据. Django使用一种新的方式,即:关系对象映射 ...

  4. 有关mysql的innodb_flush_log_at_trx_commit参数【转】

    一.参数解释 0:log buffer将每秒一次地写入log file中,并且log file的flush(刷到磁盘)操作同时进行.该模式下在事务提交的时候,不会主动触发写入磁盘的操作. 1:每次事务 ...

  5. 「caffe编译bug」python/caffe/_caffe.cpp:10:31: fatal error: numpy/arrayobject.h: No such file or directory

    在Makefile.config找到PYTHON_INCLUDE,发现有点不同: PYTHON_INCLUDE := /usr/include/python2.7 \         /usr/lib ...

  6. Mac OS X 编译android内核 error: elf.h: No such file or directory 的解决方法

    1. 从网上下个elf.h放到scripts/mod/文件夹(http://www.rockbox.org/tracker/9006?getfile=16683) 2. 修改两个文件mk_elfcon ...

  7. 删除数组某一项,使用splice的坑

    var arr=[1,2,3,4,5,6,7,8,9,10];//创建数组 var testArr=arr;//让testArr等于创建的数组 arr.splice(0,1);删除arr数组的第一项 ...

  8. Spring Cloud Feign 输出日志

    还需要在application 文件中配置: #feign调用日志输出logging.level.cn.XXX=DEBUG Logger.Level下面有几种级别. BASIC : 只输出 请求URL ...

  9. 记一次spring boot中MongoDB Prematurely reached end of stream的异常解决

    在spring boot项目中使用了mongodb,当一段时间没有操作mongodb,下次操作mongodb时就会出现异常.异常如下: org.springframework.data.mongodb ...

  10. php返回json数据函数实例_php技巧_脚本之家

    本文实例讲述了php返回json数据函数的用法,分享给大家供大家参考.具体方法如下: json_encode()函数用法: echo json_encode(array('a'=>'bbbb', ...