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

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 ;
}

Codeforces Round #243 (Div. 1)的更多相关文章

  1. Codeforces Round #243 (Div. 2) B(思维模拟题)

    http://codeforces.com/contest/426/problem/B B. Sereja and Mirroring time limit per test 1 second mem ...

  2. Codeforces Round #243 (Div. 1) A题

    http://codeforces.com/contest/425/problem/A 题目链接: 然后拿出这道题目是很多人不会分析题目,被题目吓坏了,其中包括我自己,想出复杂度,一下就出了啊!真是弱 ...

  3. Codeforces Round #243 (Div. 2) Problem B - Sereja and Mirroring 解读

    http://codeforces.com/contest/426/problem/B 对称标题的意思大概是.应当指出的,当线数为奇数时,答案是线路本身的数 #include<iostream& ...

  4. Codeforces Round #243 (Div. 2) C. Sereja and Swaps

    由于n比较小,直接暴力解决 #include <iostream> #include <vector> #include <algorithm> #include ...

  5. Codeforces Round #243 (Div. 2) B. Sereja and Mirroring

    #include <iostream> #include <vector> #include <algorithm> using namespace std; in ...

  6. Codeforces Round #243 (Div. 2) A. Sereja and Mugs

    #include <iostream> #include <vector> #include <algorithm> #include <numeric> ...

  7. Codeforces Round #243 (Div. 2) C. Sereja and Swaps(优先队列 暴力)

    题目 题意:求任意连续序列的最大值,这个连续序列可以和其他的 值交换k次,求最大值 思路:暴力枚举所有的连续序列.没做对是因为 首先没有认真读题,没看清交换,然后,以为是dp或者贪心 用了一下贪心,各 ...

  8. Codeforces Round #243 (Div. 2) A~C

    题目链接 A. Sereja and Mugs time limit per test:1 secondmemory limit per test:256 megabytesinput:standar ...

  9. Codeforces Round #243 (Div. 1)-A,B,C-D

    此CF真是可笑.. . 由于早晨7初始点,因此,要做好CF时间已经17没有休息一小时,加上中午5小时耐力赛. 心里很清楚.是第一个问题的时候,几乎被解读为寻求最大的领域和.然后找到一个水体,快速A降. ...

  10. Codeforces Round #243 (Div. 2)——Sereja and Swaps

    版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/u012476429/article/details/24665103 题目链接 题意: 给定一个整数 ...

随机推荐

  1. hihoCoder 1584 Bounce 【数学规律】 (ACM-ICPC国际大学生程序设计竞赛北京赛区(2017)网络赛)

    #1584 : Bounce 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 For Argo, it is very interesting watching a cir ...

  2. iOS 常用的几个第三方库

    网络通信 1.ASIHTTPRequest 这是一个经典的老库,功能完全而强大,但已经停止更新很久了(iOS5.0停止更新,但是我最近看github上这个项目有新改动).在不同iOS版本上略微有一些小 ...

  3. goroutine pool,WaitGroup,chan 示例

    服务端高并发编程经常需要写很多goroutine来服务每一个连接,如何正确使用goroutine池是又拍云的工程师们需要考虑的问题,今天这篇文章,分享给同样需要使用go语言的小伙伴们. 文/陶克路 本 ...

  4. CentOS 7.2 安装Gerrit 2.14.6

    1.环境 本文使用VMWare虚拟机进行实验. 2核CPU,4GB内存,20GB硬盘,IP:192.168.159.131 CentOS 7.2最小安装(CentOS-7-x86_64-Minimal ...

  5. POJ3685 Matrix —— 二分

    题目链接:http://poj.org/problem?id=3685 Matrix Time Limit: 6000MS   Memory Limit: 65536K Total Submissio ...

  6. shell脚本怎么调试

    shell是Linux系统上常用的一种脚本语言.一般从事web后台开发的从业者,都会用到shell,因此shell调试也是一项必备的技能.本文教你如何进行shell脚本调试. 工具/原料   Linu ...

  7. codeforces B. Balls Game 解题报告

    题目链接:http://codeforces.com/problemset/problem/430/B 题目意思:给出用不多于k种颜色对n个球的染色情况,以及手中的唯一一个球的颜色.初始时,连续的相同 ...

  8. 666 专题五 AC自动机

    Problem A.Keywords Search d.n个关键字,1段描述,求描述中出现了多少关键字 s. c. /* ac自动机模板 n个关键字,1段描述,求描述中出现了多少关键字 */ #inc ...

  9. [Selenium] 使用自定义的FirefoxProfile

    FirefoxProfile 用于定制待测试的Firefox 浏览器的特定属性,其中包括所存储的密码.书签.历史信息.Cookies等.某些测试用例需要用到特定的用户信息,因此可通过定制当前Firef ...

  10. ASP.NET WebServce项目下添加Http服务,支持Get,Post请求方式;传输格式json/xml

    由于WEBServce老项目中需要增添新的接口,而且添加的接口不希望被其它项目以引用Servces方式使用. 那么得在现有Service项目中添加Http请求方式来实现系统间数据交互.只需要告知请求地 ...