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 ...
随机推荐
- MapReduce第一个项目 WordCount
参考自林子雨大数据教学: http://dblab.xmu.edu.cn/blog/hadoop-build-project-using-eclipse/ 创建一个文件夹:放入一个文本文件:填 ...
- PP: Learning representations for time series clustering
Problem: time series clustering TSC - unsupervised learning/ category information is not available. ...
- php Allowed memory size of 134217728 bytes exhausted
报错:PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 72 bytes) in ...
- 【Unity|C#】基础篇(4)——函数参数类型(值参/ref/out/params)
[学习资料] <C#图解教程>(第5章):https://www.cnblogs.com/moonache/p/7687551.html 电子书下载:https://pan.baidu.c ...
- cc.rectContainsPoint使用中发现的问题
cc.rectContainsPoint(rect, point);此中rect常用node.getBoundingBox()方法取得,而这个方法通过node的x,y和width,height算得.也 ...
- 题解【洛谷P1314】[NOIP2011]聪明的质监员
题面 题解 不难发现,\(W\)增大时,\(Y\)值会随之减小. 于是考虑二分\(W\). 如何\(\mathcal{O}(N)check?\) 每一次前缀和记录一下\(1-i\)之间\(w_i \g ...
- 使用acme.sh签发Let's Encrypt的免费数字证书
--------------安装----------------curl https://get.acme.sh | sh#让alias生效source ~/.bashrc ------------- ...
- 用户注册代码(php)
<!DOCTYPE HTML><html><head><meta charset="utf-8"><script type=& ...
- 【Python】程序计时
- sql注入的原理是什么,怎么预防sql注入
为什么会产生sql注入: 主要原因,对用户输入的绝对信任,相信所有用户的输入都是可信的,没有对用户输入的语句进行过滤或者筛选,直接放到sql语句中进行拼接,从而导致了sql注入的产生 例如: < ...