2016 ICPC World Finals -Ceiling Function
2016-05-19 22:01
369 查看
直接建树伪哈希,哈希大法好,哈希出奇迹
然而本非好久没刷题了,WA了好多发,orz
然而本非好久没刷题了,WA了好多发,orz
#include<cstdio> #include<cstring> #include<algorithm> #include<map> using namespace std; #define ul unsigned long long const ul mod=1000000009; const ul modx=100000007; const int maxn=2008; struct fuck{ int u,left,right; }edge[maxn]; int tol; void init() { tol=0; } ul mody; void fuckbitch(int x) { edge[tol].u=x; edge[tol].left=-1; edge[tol].right=-1; tol++; } bool dfs(int u,int x) { if(u==-1) { fuckbitch(x); return true; } if(edge[u].u>x) { if(dfs(edge[u].left,x)) edge[u].left=tol-1; } else { if(dfs(edge[u].right,x)) edge[u].right=tol-1; } return false; } map<ul,int> mp; void fuckdfs(int u,ul md) { mody=mody*modx+md; if(edge[u].left!=-1) fuckdfs(edge[u].left,(md<<1)); if(edge[u].right!=-1) fuckdfs(edge[u].right,(md<<1|1)); } int main() { int t,i,j,x; int n,m; scanf("%d%d",&n,&m); int sum=n; mp.clear(); for(i=1;i<=n;i++) { mody=0; init(); for(j=1;j<=m;j++) { scanf("%d",&x); if(j==1) fuckbitch(x); else dfs(0,x); } fuckdfs(0,1); ul ans=mody; if(mp[ans]==0) mp[ans]++; else sum--; } printf("%d\n",sum); return 0; }
相关文章推荐
- php中final关键字
- SQL、HQL中left join、right join、inner join的区别
- JAVA设计模式(21):行为型-迭代器模式(Iterator)
- 04 替换空格
- 水题只会让自己更水,告别水题
- Apache访问控制
- poj 2653 线段与线段相交
- Extjs MVC架构 (官方文档翻译)【带源码】
- 创建tornado应用输出hello world
- Eclipse添加注释模板
- TensorFlow Machine Learning with Financial Data on Google Cloud Platform
- Python map reduce
- MySQL入门--创建数据库、显示警告信息、显示数据库、显示数据库创建信息、指定字符编码集
- LeetCode-237.Delete Node in a Linked List
- 如何去掉导航器下面的黑线
- Linux面试题(1)
- 闽江学院软件学院2015级学生职业人物访谈
- 九度OJ 1348-数组中的逆序对【逆序对模板】
- 前端性能优化小知识点(javascript)
- JavaScript Array和string的转换