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

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. Linux系统(Centos)下安装Java环境配置步骤详述

    1.首先要去下载好JDK,Java SE 8的官方网址是http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2 ...

  2. table 中的thead tbody

    通过thead 下的tr 设置样式以及 tbody 下的 tr 设置样式 避免冲突 <table> <thead> <tr> <td> </td& ...

  3. HDU1495 非常可乐 —— BFS + 模拟

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1495 非常可乐 Time Limit: 2000/1000 MS (Java/Others)    M ...

  4. YTU 2577: 小数计算——结构体

    2577: 小数计算--结构体 时间限制: 1 Sec  内存限制: 128 MB 提交: 978  解决: 647 题目描述 小数可以看成是一个点和两个数组成的,因此可以定义成一个小数的结构体,现在 ...

  5. 类、对象(java基础知识六)

    1.Java约定俗成 java约定俗成 1,类名接口名 一个单词首字母大写,多个单词每个单词首字母都大写 2,方法名和变量名 一个单词全部小写,多个单词从第二个单词首字母大写 建议:如果能用英语尽量用 ...

  6. MYSQL初级学习笔记三:数据的操作DML!(视频序号:初级_24,25,36)

    知识点五:数据的操作DML(24,25,36) 插入数据: --测试插入记录INSERT CREATE TABLE IF NOT EXISTS user13( id TINYINT UNSIGNED ...

  7. html5--6-5 CSS选择器2

    html5--6-5 CSS选择器2 实例 学习要点 掌握常用的CSS选择器 了解不太常用的CSS选择器 什么是选择器 当我们定义一条样式时候,这条样式会作用于网页当中的某些元素,所谓选择器就是样式作 ...

  8. Oracle:datafile删除后,重启server报ORA-01110

    模拟实验: 创建一个表空间后,直接把数据文件删除了:然后重启server. 1. create tablespace w56 datafile '/u01/app/oracle/product/10. ...

  9. 哈希表的C实现(一)

    哈希表(Hash table,也叫散列表),是根据关键码值(Key value)而直接进行访问的数据结构.也就是说,它通过把关键码值映射到表中一个位置来访问记录,以加快查找的速度.具体的介绍网上有很详 ...

  10. bzoj 3653 谈笑风生 —— 主席树

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=3653 对于一个 (a,b,c),分成 b 是 a 的祖先和 b 在 a 子树里两部分: 第一 ...