http://codeforces.com/contest/353/problem/B

题意:要把2*n个两位数分成两部分,使得第一部分上的数和第二部分上的两位数组成四位数。求怎么分能使构成的不同的四位数个数最多

如果2*n个数都是不同的,怎么分都一样的组成n*n个。如果有相同的,将它们按数量排序,均分到两个集合中就可以。

 #include <cstdio>
#include <cstring>
#include <map>
#include <algorithm>
using namespace std; int n;
int num[];
int a[],b[];
struct node
{
int x;
int id;
int flag;
int num;
bool operator <(const node &a)const
{
return (num<a.num)||(num==a.num&&x<a.x);
}
}p[]; bool cmp(node a,node b)
{
return a.id<b.id;
}
int main()
{
while(scanf("%d",&n)!=EOF)
{
int cnt=;
memset(num,,sizeof(num));
for(int i=; i<=*n; i++)
{
int m;
scanf("%d",&m);
p[cnt].id=i;
p[cnt++].x=m;
num[m]++;
}
for(int i=; i<cnt; i++)
{
p[i].num=num[p[i].x];
}
sort(p,p+cnt);
int t1=,t2=;
for(int i=; i<cnt; i+=)
{
p[i].flag=;
if(!a[p[i].x])
{
a[p[i].x]++;
t1++;
}
p[i+].flag=;
if(!b[p[i+].x])
{
b[p[i+].x]++;
t2++;
}
}
printf("%d\n",t1*t2);
sort(p,p+cnt,cmp);
for(int i=; i<cnt; i++)
{
if(i==)
{
if(p[i].flag==)
printf("");
else
printf("");
}
else
{
if(p[i].flag==)
printf("");
else printf("");
}
}printf("\n");
}
return ;
}

  

cf B. Two Heaps的更多相关文章

  1. CF 253B Two Heaps

    #include<stdio.h> #include<algorithm> #include<map> using namespace std; struct No ...

  2. CF数据结构练习

    1. CF 438D The Child and Sequence 大意: n元素序列, m个操作: 1,询问区间和. 2,区间对m取模. 3,单点修改 维护最大值, 取模时暴力对所有>m的数取 ...

  3. ORA-00494: enqueue [CF] held for too long (more than 900 seconds) by 'inst 1, osid 5166'

    凌晨收到同事电话,反馈应用程序访问Oracle数据库时报错,当时现场现象确认: 1. 应用程序访问不了数据库,使用SQL Developer测试发现访问不了数据库.报ORA-12570 TNS:pac ...

  4. cf之路,1,Codeforces Round #345 (Div. 2)

     cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....   ...

  5. cf Round 613

    A.Peter and Snow Blower(计算几何) 给定一个点和一个多边形,求出这个多边形绕这个点旋转一圈后形成的面积.保证这个点不在多边形内. 画个图能明白 这个图形是一个圆环,那么就是这个 ...

  6. ARC下OC对象和CF对象之间的桥接(bridge)

    在开发iOS应用程序时我们有时会用到Core Foundation对象简称CF,例如Core Graphics.Core Text,并且我们可能需要将CF对象和OC对象进行互相转化,我们知道,ARC环 ...

  7. [Recommendation System] 推荐系统之协同过滤(CF)算法详解和实现

    1 集体智慧和协同过滤 1.1 什么是集体智慧(社会计算)? 集体智慧 (Collective Intelligence) 并不是 Web2.0 时代特有的,只是在 Web2.0 时代,大家在 Web ...

  8. CF memsql Start[c]UP 2.0 A

    CF memsql Start[c]UP 2.0 A A. Golden System time limit per test 1 second memory limit per test 256 m ...

  9. CF memsql Start[c]UP 2.0 B

    CF memsql Start[c]UP 2.0 B B. Distributed Join time limit per test 1 second memory limit per test 25 ...

随机推荐

  1. Android视图框架

    Android视图框架 Android的UI系统是android应用系统框架最核心,最基础的内容! 1. Android视图系统.层次关系 Android应用设计和Web应用设计类似,也分前端和后端设 ...

  2. HDOJ(HDU) 1587 Flowers(水、、)

    Problem Description As you know, Gardon trid hard for his love-letter, and now he's spending too muc ...

  3. 2015.9.11模拟赛 codevs 4160【会玩的】

    题目描述 Description hzwer真的很会玩啊…他有一个n*m的方格,每次可以给方格添加一整行或一整列,但是不能删除.现在他想要让总格子数超过k个,但是又想让总格子数尽可能小.请找出这时的n ...

  4. cf498C Array and Operations

    C. Array and Operations time limit per test 1 second memory limit per test 256 megabytes input stand ...

  5. MyEclipse中用Maven创建Web项目(亲测有效)

    new --> other   1.Wizards: mvaen 2.Maven Project 3.Next   Use Default Workspace Location   1.weba ...

  6. (转)Linux下apache限速和限制同一IP连接数的实现

    单位有一台DELL的服务器,4核双CPU,4G内存,1TB的存储空间,闲来无事,申请了域名http://www.zxzy123.cn,做了个网站,本以为用这样的配置做个下载站是绰绰有余了,没想到上线没 ...

  7. Jmeter接口测试案例实践(一)

    1.1. 接口介绍 本次测试的接口采用内网中的通讯录查询接口进行测试,接口参数如下: 1.2. 使用Jmeter进行接口测试 1.2.1. 打开Jmeter 下载好Jmeter后,双击bin目录下的j ...

  8. [Angular 2] Async Http

    Async Pipe: The Asynce pipe receive a Promise or Observable as  input and subscribes to the input, e ...

  9. [Angular 2] Simple intro Http

    To use http, we need to import the HTTP_PROVIDER, so that we can inject http to other component: imp ...

  10. Linux系统 fdisk命令 创建新分区

    --fdisk命令fdisk -l /dev/sda           # 查看分区 fdisk    /dev/sda           # 创建分区  n                    ...