poj 1903 zoj 2469 la2965(live archive) 中途相遇法
来源:互联网 发布:长沙智工软件 编辑:程序博客网 时间:2024/05/18 14:23
题意:给定n个大写字母组成字符串,选尽量多的串,使得每个大写字母都能出现偶数次
这题目自己想纠结了好久,想到位运算模拟26个字母异或求偶数,但是怎么在o(n^2)求配对想了好久一直实现不了。看了书上的代码。纠结了一下午没想到。后来和队友一起模拟了下才懂这段代码的真谛!真是神代码。。。10S时限的代码 100多ms就可以A了 叼爆了啊!!膜拜啊!!
输入的位运算
for(int i=0; i<n; i++) { scanf("%s",&s); a[i]=0; for(int j=0; s[j]!='\0'; j++) a[i] ^= (1<<(s[j]-'A')); } table.clear();
扫描每种情况!这个1<<n1真心叼爆了!
int n1=n/2,n2=n-n1; for(int i=0; i<(1<<n1); i++) { int x=0; for(int j=0; j<n1; j++) if(i & (1<<j))x^=a[j]; if(!table.count(x) || bitcount(table[x])<bitcount(i))table[x]=i; }
- poj 1903 zoj 2469 la2965(live archive) 中途相遇法
- poj 1903 中途相遇法
- POJ 1903 Jurassic Remains -- 中途相遇法
- poj 1903 Jurassic Remains 中途相遇法
- POJ 1903 - Jurassic Remains 中途相遇法(枚举)
- uva10125 (中途相遇法)
- 中途相遇法
- poj3977 Subset 中途相遇法...
- UvaLive 2965 中途相遇法
- HDU5936 Difference 【中途相遇法】
- POJ #1186 方程的解数 | 中途相遇法 + Hash | 解题报告
- Jurassic Remains,NEERC 2003,中途相遇法
- uva 1326 Jurassic Remains(中途相遇法)
- Uva 1326 - Jurassic Remains 中途相遇法
- LA 2965 - Jurassic Remains 中途相遇法
- LA 2965 Jurassic Remains / 中途相遇法
- uva1326 - Jurassic Remains 中途相遇法
- UVa 10125 - Sumsets (中途相遇法 hash)
- UVaOJ 10361 - Automatic Poetry
- 较为简单的一种判断Retina屏幕的方法
- Extjs自定义组件
- C#学习之四---ListBox
- 一个牛人给java初学者的建议
- poj 1903 zoj 2469 la2965(live archive) 中途相遇法
- 编写一个方法,输出在一个字符串中,指定字符串出现的次数
- C#事件(event)解析(转)
- smarty保留变量
- hdu 3549 Flow Problem 最大流入门 EK算法
- WEB水晶报表直接打印 ---设置
- GCC-C语言编辑器
- 读论文:CVPR2012,A unified Approach to Salient Object Detection via Low Rank Maxtrix Recovery
- JAVA基础--JAVA中的反射机制详解