题目链接:http://codeforces.com/contest/673/problem/C

题意:给一串数,不同大小的区间内出现次数最多的那个数在计数的时候会+1,问所有区间都这样计一次数,所有的数字的计数结果。如果有数字出现次数相同多,取最小的那个。

数据<=5000,那就暴力枚举每一个区间,每次维护当前出现最多次数和当前需要计数的那个数,每次更新一个值,那最大值就是这个值或者是之前存好的。每次判断就可以了,注意相同的时候取最小的那个数。

 /*
━━━━━┒ギリギリ♂ eye!
┓┏┓┏┓┃キリキリ♂ mind!
┛┗┛┗┛┃\○/
┓┏┓┏┓┃ /
┛┗┛┗┛┃ノ)
┓┏┓┏┓┃
┛┗┛┗┛┃
┓┏┓┏┓┃
┛┗┛┗┛┃
┓┏┓┏┓┃
┛┗┛┗┛┃
┓┏┓┏┓┃
┃┃┃┃┃┃
┻┻┻┻┻┻
*/
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <climits>
#include <complex>
#include <fstream>
#include <cassert>
#include <cstdio>
#include <bitset>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <ctime>
#include <set>
#include <map>
#include <cmath>
using namespace std;
#define fr first
#define sc second
#define cl clear
#define BUG puts("here!!!")
#define W(a) while(a--)
#define pb(a) push_back(a)
#define Rlf(a) scanf("%llf", &a);
#define Rint(a) scanf("%d", &a)
#define Rll(a) scanf("%I64d", &a)
#define Rs(a) scanf("%s", a)
#define Cin(a) cin >> a
#define FRead() freopen("in", "r", stdin)
#define FWrite() freopen("out", "w", stdout)
#define Rep(i, len) for(int i = 0; i < (len); i++)
#define For(i, a, len) for(int i = (a); i < (len); i++)
#define Cls(a) memset((a), 0, sizeof(a))
#define Clr(a, x) memset((a), (x), sizeof(a))
#define Full(a) memset((a), 0x7f7f, sizeof(a))
#define lrt rt << 1
#define rrt rt << 1 | 1
#define pi 3.14159265359
#define RT return
#define lowbit(x) x & (-x)
#define onenum(x) __builtin_popcount(x)
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef map<string, int> msi;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef vector<vl> vvl;
typedef vector<bool> vb; const int maxn = ;
int n;
int t[maxn];
int vis[maxn];
int cnt[maxn]; int main() {
// FRead();
while(~Rint(n)) {
Cls(vis); Cls(cnt);
For(i, , n+) Rint(t[i]);
For(i, , n+) {
int curmax = , pos; Cls(vis);
curmax = ++vis[t[i]];
pos = t[i];
cnt[pos]++;
For(j, i+, n+) {
vis[t[j]]++;
if(curmax < vis[t[j]]) {
curmax = vis[t[j]];
pos = t[j];
}
else if(curmax == vis[t[j]]) pos = min(pos, t[j]);
cnt[pos]++;
}
}
For(i, , n+) printf("%d ", cnt[i]);
printf("\n");
}
RT ;
}

[Codeforces673C]Bear and Colors(枚举,暴力)的更多相关文章

  1. codeforces 351 div2 C. Bear and Colors 暴力

    C. Bear and Colors time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  2. 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 ...

  3. codeforces 673C C. Bear and Colors(暴力)

    题目链接: C. Bear and Colors time limit per test 2 seconds   memory limit per test 256 megabytes input s ...

  4. C. Bear and Colors

    C. Bear and Colors time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  5. Tomb Raider HihoCoder - 1829 (二进制枚举+暴力)(The 2018 ACM-ICPC Asia Beijing First Round Online Contest)

    Lara Croft, the fiercely independent daughter of a missing adventurer, must push herself beyond her ...

  6. HDU 3484 Matrix Game 枚举暴力

    上次周赛碰到这个题目,居然都没思路,真是不应该啊,起码也应该想到枚举法. 因为题目只允许每一row进行reverse操作,而每两列可以进行交换操作,所以首先把row的变化固定下来,即枚举第一列与第1- ...

  7. Codeforces 791A Bear and Big Brother(暴力枚举,模拟)

    A. Bear and Big Brother time limit per test:1 second memory limit per test:256 megabytes input:stand ...

  8. C. Bear and Colors 区间枚举的技巧

    http://codeforces.com/problemset/problem/673/C 先说一个枚举区间的技巧,枚举前缀,不要枚举后缀. 就是下面这个代码是不好的 ; i <= n; ++ ...

  9. POJ - 3279(枚举+暴力)

    Fliptile Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 14297   Accepted: 5257 Descrip ...

随机推荐

  1. self,parent,this区别

    我容易混淆public,private,protected,还容易混淆this,self这些东西.前面已经写了一篇关于public,private,protected博文了,下面来说一下this,se ...

  2. .net视图中日期格式化

    昨天在做一个功能,要在界面上按照规定的格式显示一个时间,如果直接在expression那里格式化的话(如下:) @Html.DisplayFor(c => Convert.ToDateTime( ...

  3. mutable和volatile关键字

    1.mutable 在C++中,mutable是为了突破const的限制而设置的.被mutable修饰的变量,将永远处于可变的状态,即使在一个const函数中,甚至结构体变量或者类对象为const,其 ...

  4. TypeError: Object #<IncomingMessage> has no method 'flash'

    JavaScript相关代码: router.post('/reg', function(req, res) { //检验用户两次输入的口令是否一致 if (req.body['password-re ...

  5. Discuz!NT3.6与网站整合(操作用户信息)解决方案

    因为网站要加个论坛,所以就用到了Discuz!NT3.6. 可惜目前官方论坛已经关闭,只有3.6版本的有源码,3.9的没有源码,不好操作,下载地址: http://download.comsenz.c ...

  6. 1452: [JSOI2009]Count - BZOJ

    Description Input Output Sample Input Sample Output 1 2HINT 一开始还想什么离线做,其实不用,空间足够,我们直接开100个二维树状数组,然后就 ...

  7. 输入n个整数,找出其中最小的K个数。例如输入4,5,1,6,2,7,3,8这8个数字,则最小的4个数字是1,2,3,4,。

    // ConsoleApplication2.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include "stdafx.h ...

  8. action间传多个参数时注意问题

    通常我们action之间传参可以有多种形式,举例说明:示例1: <result name="test" type="redirect-action"> ...

  9. Win 7怎样拒绝所有可移动存储设备的所有权限

    在Windows 7中,我们可拒绝对任何可移动存储类的权限.下面让我来教大家怎样在组策略中启用“所有可移动存储类:拒绝所有权限”策略,具体操作步骤如下所述: 步骤/方法 在开始搜索框中键入“gpedi ...

  10. Socket 阻塞模式和非阻塞模式

    阻塞I/O模型: 简介:进程会一直阻塞,直到数据拷贝 完成 应用程序调用一个IO函数,导致应用程序阻塞,等待数据准备好. 如果数据没有准备好,一直等待….数据准备好了,从内核拷贝到用户空间,IO函数返 ...