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 ...
随机推荐
- css 权重值(层叠性)详解
目录 css权重值(重叠性)实例 权重值的计算 !important 提升权重值实例 什么情况下可以使用!important ? 总结: css权重值(重叠性)实例 css中有很多选择器,那在多个选择 ...
- 设置Input标签Date默认值为当前时间
需求:想设置Imput标签Date默认值为当前时间,通过JavaScript实现. <html> ...... <body> <input type="date ...
- php静态方法和属性
静态方法和属性由static关键字定义 静态方法和属性不用实例化也可以直接访问,如 self::test(),self::tt 类实例化后可以访问静态方法,但是不可以访问静态属性 声明类属性或方法为静 ...
- PAT甲级——1095 Cars on Campus (排序、映射、字符串操作、题意理解)
本文同步发布在CSDN:https://blog.csdn.net/weixin_44385565/article/details/93135047 1095 Cars on Campus (30 分 ...
- webpack坑系列--安装webpack-cli
综下所述: 还是装3.11.0版本吧 cnpm i webpack@3.11.0 -D 最近在学习webpack过程中,根据官方文档推荐局部安装webpack,执行webpack -h命令出现以下提示 ...
- vue中一些常见错误
一:在抽取路由模块时路径没有更改过来 二:跨域的问题
- 华东交通大学2017年ACM“双基”程序设计竞赛 1002
Problem Description 一天YZW参加了学校组织交际舞活动,活动的开始活动方分别给男生和女生从1-n进行编号,按照从小到大顺时针的方式进行男女搭档分配,相同编号的男女组合成一对,例如一 ...
- aspnetcore配置log4net并添加全局异常处理
第一步:在NuGet中引用log4net 第二步:创建log4net.config <?xml version="1.0" encoding="utf-8" ...
- Ubuntu系统下同时打开多个终端窗口的软件
sudo apt-get install Terminator
- (转)深入浅出linux系统umask值及其对应的文件权限讲解
浅出linux系统umask值及其对应的文件权限讲解 原文:http://blog.51cto.com/oldboy/1060032 缘起:1.此文的撰写特别为感谢51cto的博客工作人员和领导,老男 ...