Description

给出N(2<=N<=50000)个长度为4的字符串,问有且仅有D(1<=D<=4)处不相同的字符串有几对。

Input

第1行: N,D 以下N行每行一个字符串

Output

一个数:有多少对有且仅有处不相同的字符串。
记录每个字符串出现次数以及带1..4个通配符的字符串出现次数,容斥得到答案
#include<cstdio>
int n,m;
char s[];
int _t2[][][];
int _t3[][];
int t4,ans=;
#define t3(a,b) _t3[a][b]
#define t2(a,b,c) _t2[a][b][c]
const int P=;
struct Map{
int xs[P],ys[P];
int&operator()(int a,int b,int c,int d){
int x=(((a<<|b)<<|c)<<)|d;
int w=x%P;
while(xs[w]){
if(xs[w]==x)return ys[w];
w+=;
if(w>=P)w-=P;
}
xs[w]=x;
return ys[w];
}
}t0,t1;
int main(){
scanf("%d%d",&n,&m);
for(t4=;t4<n;t4++){
scanf("%s",s);
int a=s[],b=s[],c=s[],d=s[];
if(!a||!b||!c||!d)printf("%d",a/=);
if(m==){
ans+=
-t0(a,b,c,d)++*
+t1(a,b,c,)++
+t1(a,b,d,)++
+t1(a,c,d,)++
+t1(b,c,d,)++;
}else if(m==){
int aa1,aa2,aa3;
ans+=
+(aa1=t0(a,b,c,d)++)*
-(aa2=t1(a,b,c,)++
+t1(a,b,d,)++
+t1(a,c,d,)++
+t1(b,c,d,)++)*
+(aa3=t2(a,b,)++
+t2(a,c,)++
+t2(a,d,)++
+t2(b,c,)++
+t2(b,d,)++
+t2(c,d,)++);
}else if(m==){
ans+=
-t0(a,b,c,d)++*
+(t1(a,b,c,)++
+t1(a,b,d,)++
+t1(a,c,d,)++
+t1(b,c,d,)++)*
-(t2(a,b,)++
+t2(a,c,)++
+t2(a,d,)++
+t2(b,c,)++
+t2(b,d,)++
+t2(c,d,)++)*
+t3(a,)++
+t3(b,)++
+t3(c,)++
+t3(d,)++;
}else{
ans+=
t0(a,b,c,d)++
-(t1(a,b,c,)++
+t1(a,b,d,)++
+t1(a,c,d,)++
+t1(b,c,d,)++)
+(t2(a,b,)++
+t2(a,c,)++
+t2(a,d,)++
+t2(b,c,)++
+t2(b,d,)++
+t2(c,d,)++)
-(t3(a,)++
+t3(b,)++
+t3(c,)++
+t3(d,)++)
+t4;
}
}
printf("%d\n",ans);
return ;
}

bzoj2012: [Ceoi2010]Pin的更多相关文章

  1. [Ceoi2010]Pin

    #2012. [Ceoi2010]Pin Online Judge:Bzoj-2012 Label:容斥,STL 题目描述 给出N(2<=N<=50000)个长度为4的字符串,问有且仅有D ...

  2. bzoj AC倒序

    Search GO 说明:输入题号直接进入相应题目,如需搜索含数字的题目,请在关键词前加单引号 Problem ID Title Source AC Submit Y 1000 A+B Problem ...

  3. (原创)QuartusII设置虚拟引脚(Virtual Pin)

    方法一: 在Quartus II中Assignments->Assignment Editor, 在Category栏选择logic options, 到列表中To列下添加要设置的引脚接口,如果 ...

  4. 3.3.2 pulseIn(pin,state,timeout)

    pulseIn函数用于读取引脚脉冲的时间长度,脉冲可以是HIGH或LOW.如果是HIGH,函数将先等引脚变为高电平,然后开始计时,一直到变为低电平为止.返回脉冲持续的时间长短, 单位为ms.如果超时还 ...

  5. Win10 IoT C#开发 3 - GPIO Pin 控制发光二极管

    Windows 10 IoT Core 是微软针对物联网市场的一个重要产品,与以往的Windows版本不同,是为物联网设备专门设计的,硬件也不仅仅限于x86架构,同时可以在ARM架构上运行. 上一篇文 ...

  6. Intel pin 2.14/CentOS 6 X86-64/安装

    环境:Intel Pin 2.14 CentOS 6 X86-64 --linux.tar.gz 进入 ./source/tools/ManualExamples make all TARGET=in ...

  7. DES MAC PIN HEX

    /* void DesEncrypt( UCHAR * auchInput,UCHAR * auchKey,UCHAR * auchOutput=NULL); Function: DesEncrypt ...

  8. quartus II PIN脚相关之一

    FPGA设计中有时候会改变输入输出名称,但是会带来一个问题,在PIN 叫配置页面上会有余留的久名称的Pin脚.如实例中,把 FPGA_CLK_50MHZ 名称修改为 FPGA_CLK,经过编译综合之后 ...

  9. 无线安全专题_破解篇02--kali破解pin码

    最近项目有点紧,所以本应该上周发的文章,拖到了本周三,在此说声抱歉.无线安全专题,我打算系统地写六个部分,分别为破解篇,攻击篇,欺骗篇,路由篇,移动篇和蓝牙篇,当然在发布的过程中,可能还会掺杂着发布f ...

随机推荐

  1. Java 简介

    前言 本文大致介绍 Java 语言 什么是 Java 语言? Java 不仅仅是一门语言,Java 是一个完整的平台,有一个庞大的库,其中包含很多可重用的代码和一个提供诸如安全性,跨操作系统的可移植性 ...

  2. js&jquery验证邮箱和手机号是否正确范例

    实现源码: <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> ...

  3. ntpdate:no server suitable for synchronization found

    Question: 在使用ntpdate同步时间时,出现了no server suitable for synchronization found的报错. 通过ntpdate -d s2m.time. ...

  4. timus 1033 Labyrinth(BFS)

    Labyrinth Time limit: 1.0 secondMemory limit: 64 MB Administration of the labyrinth has decided to s ...

  5. UVALive-4329 Ping pong (树状数组)

    题目大意:有n个数排成一列,问从中能找出几个三元组(ai,aj,ak)满足i<j<k并且这三个数严格单调. 题目分析:枚举中间的数字aj,如果aj前面有c(j)个数a(j)小,后面有d(j ...

  6. Dijkstra + 优先队列优化 模板

    #include <cstdio> #include <cstring> #include <queue> #include <vector> #inc ...

  7. (转) An overview of gradient descent optimization algorithms

    An overview of gradient descent optimization algorithms Table of contents: Gradient descent variants ...

  8. git checkout 和 git checkout --merge <branch_name>使用

    一.git checkout //查看当前分支$ git branch master *t2 testing //checkout会覆盖当前工作区文件和覆盖暂存区内容,所以发现分支有未提交的警告,执行 ...

  9. HttpServletRequest/HttpServletResponse乱码问题解决

    1.request.setCharacterEncoding只对POST请求起作用.GET请求用new String(paramterData.getBytes("iso8859-1&quo ...

  10. 看完com本质论第一章

    class IUnKnown { virtual void QueryInterface(REFIID riid,IUnknown** ppv)=0; virtual void addref()=0; ...