Educational Codeforces Round 80 (Rated for Div. 2)D(二分答案,状压检验)
这题1<<M为255,可以logN二分答案后,N*M扫一遍表把N行数据转化为一个小于等于255的数字,再255^2检验答案(比扫一遍表复杂度低),复杂度约为N*M*logN
#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
int a[][];
int b[][];
int n,m;
int ans,ans2;
int tempp[],pre[];
int zhuangya(int x,int y){
for(int i=;i<=m;++i){
if(x%==&&y%==)
return ;
x/=;
y/=;
}
return ;
}
int check(int x){
int mx=<<m;
for(int i=;i<=n;++i){
int temp=;
for(int j=;j<=m;++j){
if(a[i][j]>=x)//大于等于x的二进制下这一位记为1
temp+=pre[j];//加上2^(j-1)
tempp[temp]=i;//记下第i行是可以表示temp这个数字的(在temp二进制下都为1的位全为1)
}
}
for(int i=;i<mx;++i){
if(tempp[i]==-)//有一行数字满足把i转化为二进制后为1的位上全为1
continue;
for(int j=;j<mx;++j){
if(tempp[j]==-)//有一行数字满足把j转化为二进制后为1的位上全为1
continue;
int temppp=zhuangya(i,j);//i和j没有在二进制下同一位全为0的,即这两个数字或起来每一位都为1
if(temppp){
ans=tempp[i];
ans2=tempp[j];
return ;
}
}
}
return ;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
pre[]=;
for(int i=;i<=;++i)
pre[i]=*pre[i-];
cin>>n>>m;
for(int i=;i<=n;++i)
for(int j=;j<=m;++j)
cin>>a[i][j];
int l=,r=1e9;
int ansl=,ansr=;
while(l<=r){
memset(tempp,-,sizeof(tempp));//把桶初始化
int mid=(l+r)>>;//二分答案
int temp=check(mid);
if(temp==){
ansl=ans;
ansr=ans2;
l=mid+;
}
else{
r=mid-;
}
}
cout<<ansl<<" "<<ansr;
return ;
}
Educational Codeforces Round 80 (Rated for Div. 2)D(二分答案,状压检验)的更多相关文章
- Educational Codeforces Round 80 (Rated for Div. 2)E(树状数组,模拟,思维)
#define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> using namespace std; ],mx[],a[],pos[],sum ...
- Educational Codeforces Round 80 (Rated for Div. 2)
A. Deadline 题目链接:https://codeforces.com/contest/1288/problem/A 题意: 给你一个 N 和 D,问是否存在一个 X , 使得 $x+\lce ...
- Educational Codeforces Round 80 (Rated for Div. 2)D E
D枚举子集 题:https://codeforces.com/contest/1288/problem/D题意:给定n个序列,每个序列m个数,求第i个和第j个序列组成b序列,b序列=max(a[i][ ...
- Educational Codeforces Round 80 (Rated for Div. 2) E. Messenger Simulator
可以推出 min[i]要么是i要么是1,当a序列中存在这个数是1 max[i]的话就比较麻烦了 首先对于i来说,如果还没有被提到第一位的话,他的max可由他后面的这部分序列中 j>=i 的不同数 ...
- Educational Codeforces Round 80 (Rated for Div. 2)部分题解
A. Deadline 题目链接 题目大意 给你\(n,d\)两个数,问是否存在\(x\)使得\(x+\frac{d}{x+1}\leq n\),其中\(\frac{d}{x+1}\)向上取整. 解题 ...
- Educational Codeforces Round 80 (Rated for Div. 2)(A-E)
C D E 这三道题感觉挺好 决定程序是否能通过优化在要求的时间内完成,程序运行时间为t,你可以选择花X天来优化,优化后程序的运行时间为t/(x+1)取上整,花费的时间为程序运行时间加上优 ...
- Educational Codeforces Round 80 (Rated for Div. 2)C(DP)
#define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> using namespace std; ; ][],temp[][]; int ...
- Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship
Problem Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship Time Limit: 2000 mSec P ...
- Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems(动态规划+矩阵快速幂)
Problem Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems Time Limit: 3000 mSec P ...
随机推荐
- @HystrixCommand 不能被导包
添加pom文件 <dependency> <groupId>com.netflix.hystrix</groupId> <artifactId>hy ...
- C++——模板、数组类
1.函数模板:可以用来创建一个通用功能的函数,以支持多种不同形参,进一步简化重载函数的函数体设计. 声明方法:template<typename 标识符> 函数声明 求绝对值的模板 #in ...
- JFinal Enjoy指令扩展管理常用文本模板
个人博客 地址:http://www.wenhaofan.com/article/20190304102258 平时在项目中使用短信模板 邮件模板以及 站内消息通知等文本模板一般都是通过手动的字符串拼 ...
- 2020牛客寒假算法基础集训营2 J.求函数 (线段树 推公式 单点修改 区间查询)
https://ac.nowcoder.com/acm/contest/3003/J 题解: #include<bits/stdc++.h> typedef long long ll; u ...
- Tomcatd断点调试Debug
ideaDebug设置
- date-fns时间库的基本使用
在react中使用date-fns: import sub_days from 'date-fns/sub_days'; import start_of_week from 'date-fns/sta ...
- Django中content-type组件的使用
content-type组件 ContentType是Django的内置的一个应用,可以追踪项目的所有APP和model的对应关系,并记录在ContentTpe表中,当我们的项目做数据迁移后,会有很多 ...
- g++运行c++程序提示main()找不到
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crt1.o: In function `_start': (.text+0x20) ...
- 对malloc和free和数据结构和算法的一些感触
当年2013.9.大一学c程序设计,因为当时还没有学数据结构,只学了程序设计,大学上的课真的是承上启下的不好,刚学到这里,就断了旋一样,对这个malloc和free一直很迷惑,这些狗玩意是干嘛,因为用 ...
- js学习(精华帖)
js获取当前域名.Url.相对路径和参数以及指定参数 js获取当前url组成部分 jquery操作select(增加,删除,清空)