题面在这里!

比较显而易见的暴力,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. Calf Flac

    1.3.3 Calf Flac Time Limit: 1 Sec  Memory Limit: 64 MBSubmit: 223  Solved: 42[Submit][Status][Forum] ...

  2. SDUT 3918

    Description 这一天希酱又补了一卦,没想到每个人都发到了一张印有整数的牌,现在希酱想要继续占卜的话需要知道每个人手里拿的牌的整数具体是多少,但是她们却打起了哑谜.  穗乃果:我拿到的是 2 ...

  3. HDU 1059 Dividing (dp)

    题目链接 Problem Description Marsha and Bill own a collection of marbles. They want to split the collect ...

  4. 45、如何使用python删除一个文件?

    若想利用python删除windows里的文件,这里需要使用os模块!那接下来就看看利用os模块是如何删除文件的! 具体实现方法如下! os.remove(path) 删除文件 path. 如果pat ...

  5. THINKPHP简单商品查询项目

    代码:http://files.cnblogs.com/files/wordblog/test.zip

  6. 批量生成AWR报告(转载总结)

    [前提] 对Oracle进行性能分析其中一个“帮手”就是Oracle的AWR报告 PS:Oracle的企业版才有AWR报告,标准版是没有的{可以导出来,但是没有数据显示} [需求] 当需要针对某个月的 ...

  7. centos7安装Python3的过程中会和Python2.7版本冲突导致yum版本比对应,致使yum不能使用的问题。

    centos7安装Python3的过程中会和Python2.7版本冲突导致yum版本比对应,致使yum不能使用的问题. 原因:yum调用Python,启动程/usr/bin/yum就是一个python ...

  8. 进程一些命令pstree,ps,pstack,top

    1. pstree pstree以树结构显示进程$ pstree -p work | grep adsshd(22669)---bash(22670)---ad_preprocess(4551)-+- ...

  9. plsql实例精讲部分笔记

    转换sql: create or replace view v_sale(year,month1,month2,month3,month4,month5,month6,month7,month8,mo ...

  10. 用 python 来操作 docx, xlsx 格式文件(二)(使用 docx 库操作 docx 格式文件

    docx 库 文章结构: 一.docx 基本用,创建 docx 文件并添加数据 二.深入理解文本格式(format),并设置所格式属性(attribute) 三.深入理解样式(styles),以及如何 ...