TopCoder SRM 694
来源:互联网 发布:瑜伽初学者 知乎 编辑:程序博客网 时间:2024/05/01 17:05
250
让把
然而比赛的时候我用的另一种写法。
#include <bits/stdc++.h>using namespace std;#define ll long longstruct node{ short a,b,c; node(int a=0,int b=0,int c=0):a(a),b(b),c(c){ } bool operator<(const node &other)const{ if(a!=other.a){ return a<other.a; } if(b!=other.b){ return b<other.b; } return c<other.c; }};//开太大内存TC会出奇怪的问题。。 node que[2][256*256*256];class TrySail{public: int get(vector<int> strength){ int cur = 0; int pre = 1; int psz = 1; int csz = 0; que[pre][psz++] = node(0,0,0); int len = strength.size(); for(int i=0;i<len;i++){ int ss = strength[i]; for(int j=0;j<psz;j++){ que[cur][csz ++ ] = que[pre][j]; que[cur][csz ++ ] = que[pre][j]; que[cur][csz ++ ] = que[pre][j]; que[cur][csz-1].a ^= ss; que[cur][csz-2].b ^= ss; que[cur][csz-3].c ^= ss; } sort(que[cur],que[cur]+csz); int newsz = 1; for(int k=1;k<csz;k++){ if(que[cur][k-1] < que[cur][k]){ que[cur][newsz++] = que[cur][k]; } } csz = newsz; swap(cur,pre); swap(csz,psz); csz = 0; } int ans = 0; for(int i=0;i<psz;i++){ ans = max(ans,que[pre][i].a + que[pre][i].b + que[pre][i].c); } return ans; }};
500
一共有
这题有助于开阔思路。。一直想着枚举
然后就是,当拿到这些最大子集以后,不要硬推它们的子集,因为运算量大,应该倒过来循环,一个一个元素去掉。
#include <bits/stdc++.h>using namespace std;#define ll long longclass DistinguishableSetDiv1{public: bool vis[1<<20]; int count(vector<string> answer){ int n = answer.size(); int m = answer[0].size(); memset(vis,0,sizeof(vis)); for(int i = 1;i<n;i++){ for(int j=0;j<i;j++){ int mask = 0; for(int k=0;k<m;k++){ if(answer[i][k] == answer[j][k]){ mask |= (1<<k); } } vis[mask] = 1; } } int M = (1<<m) - 1; int ans = 0; for(int i = M;i>=0;i--){ if(!vis[i]){ ans++; }else{ for(int k=0;k<m;k++){ if(i&(1<<k)){ vis[i^(1<<k)] = 1; } } } } return ans; }};
0 0
- TopCoder SRM 694
- TopCoder SRM 281
- 第一次参加Topcoder SRM
- topcoder SRM 503报告
- topcoder SRM 506
- topcoder SRM 513 DIV2
- Topcoder SRM 495 - 513
- TopCoder SRM 543 DIV2
- topcoder-srm-233-div2
- Topcoder SRM 566 countJourneys
- TopCoder SRM 473 题解
- Topcoder SRM 573 WolfPackDivTwo
- Topcoder SRM Div2 Level2
- topcoder-srm-594
- Topcoder SRM 596
- TopCoder SRM 607 题解
- TopCoder SRM 144 div2
- TOPCODER SRM 612 DIV2
- delphiXE Implicit string cast from 'AnsiString' to 'string'
- 浅谈Java设计模式(十)桥接模式(Bridge)
- C语言断言(assert)小结
- Windows下配置R-FCN
- tomcat如何路由映射网址
- TopCoder SRM 694
- Xilinx FPGA上电时序分析与设计
- SCU2016-04 C题模拟
- android lcd 背光控制流程
- javaWeb基本的pom.xml配置
- nodejs模块nodemailer基本使用-邮件发送(支持附件)
- 转:AngularJS性能优化总结篇
- 关于Xilinx FPGA JTAG下载时菊花链路中的芯片数量
- 应用Druid监控SQL语句的执行情况(测试数据表明,Druid性能比DBCP、C3P0、Proxool、JBoss都好)