题面在这里!

比较显而易见的暴力,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. 03.WebView演练-iOS开发Demo(示例程序)源代码

    技术博客http://www.cnblogs.com/ChenYilong/   新浪微博http://weibo.com/luohanchenyilong   //转载请注明出处--本文永久链接:h ...

  2. HttpUtility.UrlEncode与Server.UrlEncode()转码区别

    在对URL进行编码时,该用哪一个?这两都使用上有什么区别吗?测试: string file="文件上(传)篇.doc";string Server_UrlEncode=Server ...

  3. spring mvc convention over configuration 之 RequestToViewNameTranslator

    1. RequestToViewNameTranslator简介 在springmvc中很多地方都是约定优于配置的,比如这种写法: @Controller public class IndexActi ...

  4. King's Quest POJ - 1904 匈牙利算法的思想+tarjan缩点+染色

    题目链接:https://cn.vjudge.net/problem/POJ-1904 自己一开始的想法,打算用匈牙利算法实现,找二分图的最大匹配.但是打了打发现,不太好实现.原因如下:匈牙利算法是不 ...

  5. __inet_insert_ifa/__inet_del_ifa

    /* 添加ip地址 主地址添加到最后一个满足范围的主地址后面 从地址添加到整个列表后面 若列表中存在与插入地址在同一子网的地址,则 要求ip地址不同且范围相同,并且插入地址认为是从地址 */ stat ...

  6. python实现链式调用

    在python中实现链式调用只需在函数返回对象自己就行了. class Person: def name(self, name): self.name = name return self def a ...

  7. [ python ] 软件开发规范

    在python开发中,我们建议采用如下规范: soft/ ├── bin # 程序执行文件目录 │   ├── __init__.py │   └── start.py # 程序开始执行脚本文件 ├─ ...

  8. SilverLight 浏览器出现滚动条

    照网上说的很多解决方案要不得,最后想了下,直接在body上面加 style="overflow:hidden"解决问题,真觉得微软管理混乱,很多它自己的东西都不支持了.

  9. WireShark出现The NPF driver isn't running的问题

    昨天开始尝试装上了wireshark网络监视软件,可是今天打开去总是出现“The NPF driver isn't running.You may have trouble capturing or ...

  10. C++的一大误区——深入解释直接初始化与复制初始化的区别

      转自:http://blog.csdn.net/ljianhui/article/details/9245661 不久前,在博客上发表了一篇文章——提高程序运行效率的10个简单方法,对于其中最后一 ...