---恢复内容开始---

A

枚举l,r

 #include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<vector>
#include<cmath>
#include<queue>
#include<set>
using namespace std;
#define N 210
#define LL long long
#define INF 0xfffffff
const double eps = 1e-;
const double pi = acos(-1.0);
const double inf = ~0u>>;
int a[N],b[N],c[N];
int main()
{
int i,j,n,k,g;
cin>>n>>k;
for(i = ; i<= n; i++)
cin>>a[i];
int s = -INF;
for(i = ;i <= n ;i++)
for(j = i ; j <= n ;j++)
{
int ts = ;
int o = ;
for(g = i ; g <= j; g++)
{
b[o++] = a[g];
}
int e = ;
for(g = ; g < i; g++)
c[e++] = a[g];
for(g = j+ ; g <= n ;g++)
c[e++] = a[g];
sort(b,b+o);
sort(c,c+e);
int ko = e-,kk=;
for(g = ;g <= o ; g++)
{
if(ko==-||kk==k) break;
if(c[ko]>b[g])
{
swap(c[ko],b[g]);
ko--;
kk++;
}
else break;
}
for(g = ;g < o ; g++)
ts+=b[g];
s = max(ts,s);
}
cout<<s<<endl;
return ;
}

B

使每个连通块 变成矩形 所需改变的最小次数。

如果某一行的状态或某一列的状态确定了,整体的划分是确定的。如果列数小于等于K状压枚举列的状态,否则肯定有一列的状态是不变的 枚举那一列的状态。

 #include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<vector>
#include<cmath>
#include<queue>
#include<set>
using namespace std;
#define N 105
#define LL long long
#define INF 0xfffffff
const double eps = 1e-;
const double pi = acos(-1.0);
const double inf = ~0u>>;
int a[N][N];
int main()
{
int i,j,n,m,k,g;
cin>>n>>m>>k;
if(m<n)
{
for(i = ; i < n ; i++)
for(j = ;j < m ;j++)
cin>>a[i][j];
}
else
{
for(i = ; i < n ;i++)
for(j = ; j < m ;j++)
cin>>a[j][i];
swap(n,m);
}
int cnt = INF;
if(m<=k)
{
for(i = ; i < (<<m) ;i++)
{
int ans = ;
for(j = ; j < n; j++)
{
int o = ;
for(g = ; g < m ; g++)
{
if((a[j][g]<<g)!=(i&(<<g)))
o++;
}
ans+=min(o,m-o);
}
cnt = min(cnt,ans);
}
}
else
{
for(i = ;i < m ; i++)
{
int ans = ;
for(j = ;j < m ;j++)
{
if(j==i) continue;
int o = ;
for(g = ; g < n ; g++)
{
if(a[g][j]!=a[g][i]) o++;
}
ans+=min(o,n-o);
}
cnt = min(cnt,ans);
}
}
if(cnt<=k)
cout<<cnt<<endl;
else
cout<<"-1\n"; return ;
}

最新文章

  1. iOS-----程序异常处理----- 断言NSAssert()和NSParameterAssert区别和用处
  2. 监测程序运行的时间,stopWatch
  3. Nginx系列2之Nginx+php
  4. Optimizing Performance: Data Binding(zz)
  5. [codevs3862]竞赛班的垃圾处理
  6. Sql Server专题一:索引(下)
  7. Swift - 环形进度条(UIActivityIndicatorView)的用法
  8. Python实现LDAP用户名密码验证
  9. sau交流学习社区--在element-ui中新建FormData对象组合上传图片和文件的文件对象,同时需要携带其他参数
  10. linux中tar及压缩解压命令用法
  11. java 写一个类,实现对象数的计算
  12. centos中进程管理工具
  13. 协方差分析 | ANCOVA (Analysis of Covariance)
  14. VIP之FrameBuffer
  15. android 8.0变更
  16. 洛谷 P4128 [SHOI2006]有色图 解题报告
  17. hdu 4961 Boring Sum(高效)
  18. angularJS绑定数据中对标签转义的处理二 与pre标签的使用
  19. Tomcat *的安装和运行(绿色版和安装版都适用)
  20. [LuoguP3195] [HNOI2008]玩具装箱TOY

热门文章

  1. (23) java web的struts2框架的使用-struts动态调用和通配符
  2. ios对于枚举的使用
  3. redis.Pool 配置
  4. android提权漏洞CVE-2010-EASY修复【转】
  5. POJ3252 Round Numbers —— 数位DP
  6. Could not load file or assembly &#39;MyAssembly.XmlSerializers
  7. 织梦dedecms内页分类频道友情链接实现方法
  8. html5--6-23 CSS3中的文字与字体
  9. oracle:rman恢复----通过增量备份来恢复
  10. 【HDU 4722】 Good Numbers