题目链接:

http://codeforces.com/contest/673/problem/C

题解:

枚举所有的区间,维护一下每种颜色出现的次数,记录一下出现最多且最小的就可以了。

暴力n*n.

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std; const int maxn=;
const int INF=0x3f3f3f3f; int arr[maxn],ans[maxn],cnt[maxn]; int main() {
int n;
while(scanf("%d",&n)==&&n) {
memset(ans,,sizeof(ans));
for(int i=; i<=n; i++) {
scanf("%d",&arr[i]);
}
for(int st=;st<=n;st++){
memset(cnt,,sizeof(cnt));
int ma=-,tmp=INF;
for(int ed=st;ed<=n;ed++){
cnt[arr[ed]]++;
if(cnt[arr[ed]]>ma){
ma=cnt[arr[ed]]; tmp=arr[ed];
}else if(cnt[arr[ed]]==ma){
tmp=min(tmp,arr[ed]);
}
ans[tmp]++;
}
}
for(int i=;i<n;i++){
printf("%d ",ans[i]);
}
printf("%d\n",ans[n]);
}
return ;
}

Codeforces Round #351 (VK Cup 2016 Round 3, Div. 2 Edition) C - Bear and Colors的更多相关文章

  1. Codeforces Round #351 (VK Cup 2016 Round 3, Div. 2 Edition) C. Bear and Colors 暴力

    C. Bear and Colors 题目连接: http://www.codeforces.com/contest/673/problem/C Description Bear Limak has ...

  2. Codeforces Round #351 (VK Cup 2016 Round 3, Div. 2 Edition) B. Problems for Round 水题

    B. Problems for Round 题目连接: http://www.codeforces.com/contest/673/problem/B Description There are n ...

  3. Codeforces Round #351 (VK Cup 2016 Round 3, Div. 2 Edition) B

    B. Problems for Round time limit per test 2 seconds memory limit per test 256 megabytes input standa ...

  4. Codeforces Round #351 (VK Cup 2016 Round 3, Div. 2 Edition)只有A题和B题

    连接在这里,->点击<- A. Bear and Game time limit per test 2 seconds memory limit per test 256 megabyte ...

  5. Codeforces Round #351 (VK Cup 2016 Round 3, Div. 2 Edition) D Bear and Two Paths

    题目链接: http://codeforces.com/contest/673/problem/D 题意: 给四个不同点a,b,c,d,求是否能构造出两条哈密顿通路,一条a到b,一条c到d. 题解: ...

  6. Codeforces Round #351 (VK Cup 2016 Round 3, Div. 2 Edition) D. Bear and Two Paths 构造

    D. Bear and Two Paths 题目连接: http://www.codeforces.com/contest/673/problem/D Description Bearland has ...

  7. Codeforces Round #351 (VK Cup 2016 Round 3, Div. 2 Edition) A. Bear and Game 水题

    A. Bear and Game 题目连接: http://www.codeforces.com/contest/673/problem/A Description Bear Limak likes ...

  8. Codeforces Round #351 (VK Cup 2016 Round 3, Div. 2 Edition)

    A.暴力枚举,注意游戏最长为90分钟 B.暴力,c[l]++,c[r]--,记录中间有多长的段是大小为n的,注意特判m=0的情况 C.暴力枚举,我居然一开始没想出来!我一直以为每次都要统计最大的,就要 ...

  9. Codeforces Round #351 (VK Cup 2016 Round 3, Div. 2 Edition) D

    D. Bear and Two Paths time limit per test 2 seconds memory limit per test 256 megabytes input standa ...

随机推荐

  1. php无法加载Memcache缓存模块问题及Memcache的安装

    今天早上去迁移网站发现打开网站报错 然后我去phpinfo.php看了一下,果然我的测试页里面有加载到Memcache这个模块,如下图: 这时候,既然发现了问题的所在我们就要去排查问题,当前这个问题呢 ...

  2. 测试一个C段网络的联通性

    #!/bin/bashPATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/binexport PATHnetwork ...

  3. aspx页面与服务器控件间运行原理

    一.进入服务器控件以及aspx页面前,必须的准备: a)在WebForm 中只要带有runat="server" 那么那就是一个控件. b)如果form有runat="s ...

  4. app.config *.exe.config 和*.vshost.exe.config基础学习

    一.问题描述 在使用config文件来保存一些参数,便于下次启动程序时自动加载上次设置的参数的功能时, 碰到个问题,vs2010下调试运行程序始终无法实现config记录上次参数值,而直接运行exe程 ...

  5. WordPress 主题开发 - (八) Head模板 待翻译

    THE WORDPRESS THEME HEADER TEMPLATE Now we get into the nitty-gritty: building up your header.php an ...

  6. 十天学会单片机Day4串行口通信

    并行与串行基本通信方式 1.并行通信方式 通常是将数据字节的各位用多条数据线同时进行传送. 并行通信控制简单.传输速度快:由于传输线较多,长距离传送时成本高且接收方的各位同时接收存在困难. 2.串行通 ...

  7. rspec的一些常见用法

    这里讲了如何安装rspec,安装使用rspec. 下面介绍一下rspec中常见的使用方法. 下面是一个最简单的测试用例,判断true是不是等于true,should_be是旧的用法,新用法推荐使用ex ...

  8. Node.js学习笔记 02 Implementing flow control

    What is flow control? 和其它语言一样,Node.js 在代码编写时,如何组织代码,如何写出clean code都是不可避免的难点. 同时,由于Node.js的天然特性(异步,事件 ...

  9. 窗体皮肤实现 - 实现简单Toolbar(六)

    自定义皮肤很方便,基础开发的工作也是很大的.不过还好一般产品真正需要开发的并不是很多.现在比较漂亮的界面产品都会有个大大的工具条. Toolbar工具条实现皮肤的方法还是可以使用Form的处理方案.每 ...

  10. React Native分析(index.ios.js)

    定义创建组件MyComponent(index.ios.js): 'use strict' var React = require('react-native'); var { AppRegistry ...