题目链接: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. 最火的.NET开源项目(转)

    综合类 微软企业库 微软官方出品,是为了协助开发商解决企业级应用开发过程中所面临的一系列共性的问题, 如安全(Security).日志(Logging).数据访问(Data Access).配置管理( ...

  2. c语言编程之循环队列

    利用链表实现的循环队列,完成了队列的入队和出队,对于队空和队满用了一个flag进行标记.入队flag++,出队flag-- #include"stdio.h" typedef in ...

  3. windows 2008 怎么对外开放端口

    服务器已经运行了程序,但是android客户端连接不上, 网上提示说用: start /min telnet 192.168.3.42 2121 查看,但是我的提示tenlet找不到命令,估计是端口的 ...

  4. NeatUpload 同时选择并上传多个文件

    neatUpload是asp.net 中可以同时上传多个文件的控件,主页:http://neatupload.codeplex.com/. 效果如下图(显示有点不正常...): 使用步骤: 1. 在a ...

  5. 3036: 绿豆蛙的归宿 - BZOJ

    Description 随着新版百度空间的下线,Blog宠物绿豆蛙完成了它的使命,去寻找它新的归宿. 给出一个有向无环的连通图,起点为1终点为N,每条边都有一个长度.绿豆蛙从起点出发,走向终点.到达每 ...

  6. mysql merge

    merge 是一组 myisam 表的组合, 锁住一个 merge 表它会吧底下所有的表全给锁住. 创建只读表 )) engine = merge union (t1,t2); 创建可插入的表, (以 ...

  7. hihocoder #1301 : 筑地市场 数位dp+二分

    题目链接: http://hihocoder.com/problemset/problem/1301?sid=804672 题解: 二分答案,每次判断用数位dp做. #include<iostr ...

  8. 有n个整数,使其前面各数顺序向后移m个位置,最后m个数变成最前面m个数。

    #include<stdio.h> #include<stdlib.h> int main() { setvbuf(stdout,NULL,_IONBF,); //使用Ecli ...

  9. Mac OS X 安装并测试 OpenCV

    1. 安装 打开官网的Linux安装OpenCV的网页,打开这个网页的目的不是按照它所提供的步骤安装OpenCV(因为你会遇到一个坑,下文会提到),而是为了安装一些依赖的包或库. 其中的pkg-con ...

  10. java poi导出EXCEL xls文件代码

    String _currentPage = request.getParameter("currentPage"); Integer currentPage = 0; if(_cu ...