【UVALive】2965 Jurassic Remains(中途相遇法)
题目
传送门:QWQ
分析
太喵了~~~~~
还有中途相遇法这种东西的。
嗯 以后可以优化一些暴力
详情左转蓝书P58
(但可能我OI生涯中都遇不到正解是这个的题把。。。。。。
代码
#include <bits/stdc++.h>
using namespace std;
const int maxn=;
map<int,int> table;
int bitcount(int x){return x==?:bitcount(x>>)+(x&);}
int main(){
int n,A[maxn];
char s[];
while(scanf("%d",&n)== && n){
for(int i=;i<n;i++){
scanf("%s",s); A[i]=;
for(int j=;s[j]!='\0';j++) A[i]|=(<<(s[j]-'A'));
}
table.clear();
int n1=n>>, n2=n-n1;
for(int i=;i<(<<n1);i++){
int x=;
for(int j=;j<n1;j++) if(i&(<<j)) x^=A[j];
if(!table.count(x) || bitcount(table[x])<bitcount(i)) table[x]=i;
} int ans=;
for(int i=;i<(<<n2);i++){
int x=;
for(int j=;j<n2;j++) if(i&(<<j)) x^=A[j+n1];
if(table.count(x) && bitcount(ans)<bitcount(i)+bitcount(table[x])) ans=(i<<n1)^table[x];
}
printf("%d\n",bitcount(ans));
for(int i=;i<n;i++) if(ans&(<<i)) printf("%d ",i+);
puts("");
}
return ;
}
【UVALive】2965 Jurassic Remains(中途相遇法)的更多相关文章
- UVALive - 2965 Jurassic Remains (LA)
Jurassic Remains Time Limit: 18000MS Memory Limit: Unknown 64bit IO Format: %lld & %llu [Sub ...
- uvalive 2965 Jurassic Remains
https://vjudge.net/problem/UVALive-2965 题意: 给出若干个由大写字母组成的字符串,要求选出尽量多的字符串,使得每个大写字母出现的次数是偶数. 思路: 如果说我们 ...
- UVa LA 2965 - Jurassic Remains 中间相遇,状态简化 难度: 2
题目 https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_pr ...
- UVaLive 2965 Jurassic Remains (状态压缩)
题意:给定 n 个大写字母组成的字符串,选择尽量多的串,使得大写字母都能出现偶数次. 析:由于n比较小,我们可以枚举前n/2的所有组合,然后再从后面查找. 代码如下: #pragma comment( ...
- LA 2965 Jurassic Remains (中途相遇法)
Jurassic Remains Paleontologists in Siberia have recently found a number of fragments of Jurassic pe ...
- LA 2965 中途相遇法
题目链接:https://vjudge.net/problem/UVALive-2965 题意: 有很多字符串(24),选出一些字符串,要求这些字符串的字母都是偶数次: 分析: 暴力2^24也很大了, ...
- uva 6757 Cup of Cowards(中途相遇法,貌似)
uva 6757 Cup of CowardsCup of Cowards (CoC) is a role playing game that has 5 different characters (M ...
- HDU 5936 Difference 【中途相遇法】(2016年中国大学生程序设计竞赛(杭州))
Difference Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total ...
- 【中途相遇法】【STL】BAPC2014 K Key to Knowledge (Codeforces GYM 100526)
题目链接: http://codeforces.com/gym/100526 http://acm.hunnu.edu.cn/online/?action=problem&type=show& ...
随机推荐
- Windows 搭建 Linux kernal0.11 环境
下载:http://www.oldlinux.org/Linux.old/bochs/ 安装bochs 运行 界面:
- 动画的使用—Drawable Animation
Drawable Animation可以称为帧动画,因为它是通过每次播放一帧Drawable资源实现的. Drawable Animation算不上真正意义上的动画,因为它的内部实现是通过定时发送消息 ...
- [osgearth]osgearth原数据获取途径
Help us add useful sources of Free data to this list. Raster data ReadyMap.org - Free 15m imagery, e ...
- [原][osgearth]FAQ
参考:http://docs.osgearth.org/en/latest/faq.html Common Usage How do I place a 3D model on the map? Th ...
- @pathVariable的作用
//url中的id 可通过@pathVariable绑定到函数的参数中
- [vuex]——使用vuex解决模块间传值问题
二月的第四个周末,在家.受寒流的影响,深圳天气持续冰冻了好几天,天冷人就变得懒动,迷迷糊糊睡到了快十点,终于在饥饿的催促下起床. 和妹子吃完粥后,百无聊赖.透过窗户,发现太阳依旧没有露头的打算,我们也 ...
- Word 开发资料集合
Word 对象模型概述 https://msdn.microsoft.com/zh-cn/library/kw65a0we.aspx DSOframer微软官方API的查阅方法 http://sh ...
- js 数据函数
//shift:删除原数组第一项,并返回删除元素的值:如果数组为空则返回undefined var a = [1,2,3,4,5]; var b = a.shift(); //a:[2,3,4,5] ...
- 『转』Bitdefender Internet Security 2013 – 免费1年
活动中可以选择获取Bitdefender Internet Security 2013+Bitdefender Mobile Security (手机版)各一年激活码申请地址:https://part ...
- 宏使用 Tricks
人为地定义一些"无意义"的宏(宏名本身有意义),以起到提升代码程序的可读性. 1. IN/OUT 指定参数用于输入还是输出: #define IN #define OUT void ...