Codeforces Round #327 (Div. 2) C Median Smoothing(找规律)
分析:
三个01组合只有八种情况:
000 s
001 s
010 0
011 s
100 s
101 1
110 s
111 s
可以看出只有010,101是不稳定的。其他都是稳定的,且连续地出现了1或0,标记为s。
考虑连续的不稳定串的,例子:
11010100
s s
110100
s s
1100
只有两种情况,两个边界是不同(11和00)或者相同(11或者00)。
前者中间的不稳定串的长度是2*k,且经过k次将变成11110000,而后者的不稳定串的长度是2*k+1,中间经过k+1将变得和两边一样。
变化次数取所有情况的最大值。
熄灯了~碎觉 QAQ ~
(做这种题的科学方法就是,打打表,写程序枚举枚举样例就有思路了。(人工枚举可能会选择性漏掉某些情况
#include<bits/stdc++.h>
using namespace std; typedef long long ll; const int maxn = 5e5;
int x[maxn]; //#define LOCAL
int main()
{
#ifdef LOCAL
freopen("in.txt","r",stdin);
#endif
int n; scanf("%d",&n);
for(int i = ; i < n; i++){
scanf("%d", x+i);
}
int ans = ;
for(int i = ; i < n-; i++){
if(x[i] != x[i-]){
int j = i;
while(j<n- && x[j] != x[j+] && x[j] != x[j-]) j++;
ans = max(ans, (j-i+)>>);
int p = i, q = j-;
while(p<=q){
x[p++] = x[i-];
x[q--] = x[j];
}
i = j;
}
}
printf("%d\n", ans);
for(int i = ; i < n; i++){
printf("%d%c", x[i], i == n-? '\n': ' ');
}
return ;
}
Codeforces Round #327 (Div. 2) C Median Smoothing(找规律)的更多相关文章
- Codeforces Round #327 (Div. 2) C. Median Smoothing 找规律
C. Median Smoothing Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/591/p ...
- Codeforces Round #327 (Div. 2)C. Median Smoothing 构造
C. Median Smoothing A schoolboy named Vasya loves reading books on programming and mathematics. He ...
- Codeforces Round #347 (Div. 2) C. International Olympiad 找规律
题目链接: http://codeforces.com/contest/664/problem/C 题解: 这题最关键的规律在于一位的有1989-1998(9-8),两位的有1999-2098(99- ...
- Codeforces Round #327 (Div. 2) B. Rebranding C. Median Smoothing
B. Rebranding The name of one small but proud corporation consists of n lowercase English letters. T ...
- Codeforces Round #327 (Div. 2)
题目传送门 水 A - Wizards' Duel 题目都没看清就写了,1e-4精度WA了一次... /************************************************ ...
- Codeforces Round #327 (Div. 1), problem: (A) Median Smoothing
http://codeforces.com/problemset/problem/590/A: 在CF时没做出来,当时直接模拟,然后就超时喽. 题意是给你一个0 1串然后首位和末位固定不变,从第二项开 ...
- codeforces590a//Median Smoothing//Codeforces Round #327 (Div. 1)
题意:一个数组,一次操作为:除首尾不变,其它的=它与前后数字的中位数,这样对数组重复几次后数组会稳定不变.问要操作几次,及最后的稳定数组. 挺难的题,参考了别人的代码和思路.总的来说就是找01010, ...
- Codeforces Round #327 (Div. 2) A. Wizards' Duel 水题
A. Wizards' Duel Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/591/prob ...
- Codeforces Round #327 (Div. 2) E. Three States BFS
E. Three States Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/591/probl ...
随机推荐
- ABC118D(DP,完全背包,贪心)
#include<bits/stdc++.h>using namespace std;int cnt[10]={0,2,5,5,4,5,6,3,7,6};int dp[10007];int ...
- Codeforces Round #517 (Div. 2, based on Technocup 2019 Elimination Round 2)D(思维,DP,字符串)
#include<bits/stdc++.h>using namespace std;char c[2007][2007];char ans[4007];int s[2007][2007] ...
- 51nod 1354【DP】
(我一定是A了一题假DP) 给定序列a[0],a[1],a[2],...,a[n-1] 和一个整数K时, 有多少子序列所有元素乘起来恰好等于K. K<=1e8; 思路: 感觉 k 的 约数是突破 ...
- oracle批量插入带主键自增
https://blog.csdn.net/qq_37630354/article/details/82792288
- BadBoy录制模式:Request 和 Navigation比较
[前言] 今天来为大家介绍下BadBoy录制模式: Request 和 Navigation的比较! 如果您的电脑还未安装BadBoy这款工具的话,可以参考下BadBoy安装步骤和简单介绍:http: ...
- P2675 《瞿葩的数字游戏》T3-三角圣地
传送门 考虑最上面每个位置的数对答案的贡献 然后就很容易发现: 如果有n层,位置 i 的数对答案的贡献就是C( n-1,i ) 然后就有很显然的贪心做法: 越大的数放越中间,这样它的贡献就会尽可能的大 ...
- Docker从入门到实战(一)
Docker从入门到实战(一) 一:容器技术与Docker概念 1 什么是容器 容器技术并不是一个全新的概念,它又称为容器虚拟化.虚拟化技术目前主要有硬件虚拟化.半虚拟化.操作系统虚拟化等.1.1关于 ...
- jquery uploadify在IE上传报406HttpError
前端使用uploadify的flash上传控件,后端使用spring MVC,使用IE上传时报406,用Chrome没有问题. 检查发现IE上传时的请求头中,Accept: text/* 而Chrom ...
- GTY's gay friends 线段树判断区间是否有相同数字
http://acm.hdu.edu.cn/showproblem.php?pid=5172 判断一个区间是否为全排列是: 1.区间总和 = (1 + R - L + 1) * (R - L + 1) ...
- Storm概念学习系列之storm核心组件
不多说,直接上干货! Storm核心组件 了解 Storm 的核心组件对于理解 Storm 原理非常重要,下面介绍 Storm 的整体,然后介绍 Storm 的核心. Storm 集群由一个主节点和多 ...