Codeforces 590A Median Smoothing(暴力)
来源:互联网 发布:ubuntu etc目录在哪 编辑:程序博客网 时间:2024/06/06 01:43
题目链接:Codeforces 590A Median Smoothing
解题思路
只有连续的0101串会边,次数和两端终止状态有关。
代码
#include <cstdio>#include <cstring>#include <algorithm>using namespace std;const int maxn = 500005;int N, A[maxn], T[maxn];void draw (int l, int r) { int a = A[l], b = A[r]; while (l <= r) { A[l++] = a; A[r--] = b; }}int main () { scanf("%d", &N); memset(T, 0, sizeof(T)); for (int i = 1; i <= N; i++) scanf("%d", &A[i]); T[1] = T[N] = 1; for (int i = 2; i < N; i++) if (A[i] == A[i-1] || A[i] == A[i+1]) T[i] = 1; int ans = 0, len = 0, pos = 0; for (int i = 1; i <= N; i++) { if (T[i]) { draw(pos, i); ans = max(ans, (len + 1) / 2); len = 0; pos = i; } else len++; } printf("%d\n", ans); for (int i = 1; i <= N; i++) printf("%d%c", A[i], i == N ? '\n' : ' '); return 0;}
0 0
- Codeforces 590A Median Smoothing(暴力)
- Codeforces 590A Median Smoothing
- Codeforces 590 A:Median Smoothing
- CodeForces-590A Median Smoothing
- CodeForces 590A Median Smoothing
- CodeForces 590A Median Smoothing
- Codeforces 590A Median Smoothing
- 590 A. Median Smoothing
- Codeforces Round #327 (Div. 2) C. Median Smoothing 暴力
- Code Forces 590 A. Median Smoothing(机智)
- Codeforces #591 C Median Smoothing(思维)
- codeforces 591 C. Median Smoothing
- Codeforces Round #327 (Div. 2) C. Median Smoothing(规律)
- codeforces#327-C.Median Smoothing-规律题
- codeforces#327->C.Median Smoothing(规律题 )
- 【22.70%】【codeforces 591C】 Median Smoothing
- Codeforces 591C Median Smoothing【思维】
- Codeforces Round #327 (Div. 1) A题: Median Smoothing [规律题]
- cuDNN V3上手体验
- C语言设计模式
- 网络字节序与主机字节序
- js中的电话号码和手机验证已经身份号码解析年龄出生日期和性别
- 史上最短小的俄罗斯方块
- Codeforces 590A Median Smoothing(暴力)
- 关于正则化话的理解
- git应用技巧
- LeetCode15:3Sum
- 域名访问和IP访问问题
- postgresql常用的查询语句
- 主机名突然变成bogon的解决方法
- CTP开发——登录/查询
- linux (centos 6.4)安装自定义分区方案