CodeForces - 1017D The Wu
比较显而易见的暴力,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的更多相关文章
- Codeforces 1017D The Wu(状态压缩+预处理)
题意: 给你n m q,表示在这一组数据中所有的01串长度均为n,然后给你一个含有m个元素的multiset,之后有q次询问.每次询问会给你一个01串t和一个给定常数k,让你输出串t和multiset ...
- 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 ...
- 【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 ...
- Codeforces 1099 - A/B/C/D/E/F - (Done)
链接:https://codeforces.com/contest/1099 A - Snowball - [模拟水题] 题意:有一个雪球从山顶滚落,山坡上有两块石头,每秒钟会一次发生三件事:1.雪球 ...
- 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 ...
- Codeforces Round #532 (Div. 2) 题解
Codeforces Round #532 (Div. 2) 题目总链接:https://codeforces.com/contest/1100 A. Roman and Browser 题意: 给出 ...
- python爬虫学习(5) —— 扒一下codeforces题面
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...
- 【Codeforces 738D】Sea Battle(贪心)
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...
- 【Codeforces 738C】Road to Cinema
http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...
随机推荐
- 【BZOJ】4766: 文艺计算姬
[题目]给定两边节点数为n和m的完全二分图,求生成树数取模给定的p.n,m,p<=10^18. [算法]生成树计数(矩阵树定理) [题解]参考自 [bzoj4766]文艺计算姬 by WerKe ...
- 2008 Round 1A C Numbers (矩阵快速幂)
题目描述: 请输出(3+√5)^n整数部分最后3位.如果结果不超过2位,请补足前导0. 分析: 我们最容易想到的方法肯定是直接计算这个表达式的值,但是这样的精度是不够的.朴素的算法没有办法得到答案.但 ...
- 实验吧CTF题库之二叉树遍历
题目链接:http://www.shiyanbar.com/ctf/1868 直接推算出来这棵树是: 后序遍历是:ACBFGED 参考资料: 1. http://www.shiyanbar.com/c ...
- python-num18 - django进阶一
一.深入django的路由系统 下面为django的请求生命周期 下面来看下整个生命周期中的路由系统: 在Django的urls中我们可以根据一个URL对应一个函数名来定义路由规则如下: " ...
- bugku数字验证绕过正则
题目:http://120.24.86.145:9009/21.php 第6行使用正则匹配如果匹配到$password开头12个字符中有空格则输出flag并执行exit; 12行是正则匹配$passw ...
- django框架<二>
django框架: Models 1.基本创建 Django提供了一个抽象层("Model")的构建和管理Web应用程序的数据. Django使用一种新的方式,即:关系对象映射 ...
- Git远程操作详解【转】
转自:http://www.ruanyifeng.com/blog/2014/06/git_remote.html 作者: 阮一峰 日期: 2014年6月12日 Git是目前最流行的版本管理系统,学会 ...
- python基础===基于cv2的播放器
import cv2 import threading import win32gui,win32con class Producer(threading.Thread): ""& ...
- html的loadrunner脚本2
Action(){ char buf[1911]; //¶¨Òå×Ö·ûÊý×飬Ö÷ÒªÓÃÓÚдÈëXML±¨Îĵ½»º³åÇø char str_Body[4086]; //³Ð½Ó±¨Î ...
- [写出来才有价值系列:node.js]node.js 01-介绍及安装
对于Node.js在百度百科上是这样解释的: Node.js是一个Javascript运行环境(runtime).实际上它是对Google V8引擎进行了封装.V8引 擎执行Javascript的速度 ...