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. cocos 的CCScheduler模块

    scheduleSelector函数->查找m_pHashForTimers是否有存储回调的Obj类实例,否,创建新条目tHashTimerEntry,指向回调类实例,tHashTimerEnt ...

  2. socket实例2

    第二个实例创建一个java工程,基于tomcat服务器,程序运行时会启动客户端,实现了一个客户端向其他的客户端发送即时信息的功能 MainWindow.java package com.jikexue ...

  3. js让菜单栏一直悬浮在顶部,经典代码

    js让菜单栏一直悬浮在顶部,经典代码 很简单,你只需要把下面代码放到js中:$(function(){                //获取要定位元素距离浏览器顶部的距离        var na ...

  4. PHPSTORM实用快捷键

    alt + F7 find usages 功能,可以很方便的找到函数在哪里调用了 Ctrl + E 可查看最近打开文件或项目 项目名右键选择"Local History | Show His ...

  5. java Date获取 年月日时分秒

    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 3 ...

  6. XShell连接 Linux系统,显示中文乱码

    摘要: Linux系统,中文显示乱码 XShell是一个强大的安全终端模拟软件,它支持SSH1, SSH2及 Microsoft Windows平台的Telnet NetSarang Xshell 4 ...

  7. jdk-tomcat环境变量设置

    1.export命令直接在shell下设置 export JAVA_HOME=/home/yn4a/jdk1.6.0_16export PATH=$JAVA_HOME/bin:$PATHexport ...

  8. springmvc的讲解

    概述 继 Spring 2.0 对 Spring MVC 进行重大升级后,Spring 2.5 又为 Spring MVC 引入了注解驱动功能.现在你无须让 Controller 继承任何接口,无需在 ...

  9. 重学《C#高级编程》(序)

    小生码农一枚,以前只是看别人写博客,从来没有想过要自己写博文,突然之间“脑抽”想自己也写点什么,遂在博客园开通这个博客. 简单介绍下自己吧,本人90后,父母对我没有大的想法,只是希望我平安成长,多学习 ...

  10. 64位Windows 7平台安装32位Timesten,配置ODBC数据源

    问题: 由于系统版本原因,客户机只能安装32位的Timesten,但客户机的平台是64位的win 7,安装完成后按照常规的控制面板->管理工具->数据源(ODBC)打开的ODBC数据源管理 ...