D. Merge Equals(from Educational Codeforces Round 42 (Rated for Div. 2))
模拟题,运用强大的stl。
#include <iostream>
#include <map>
#include <algorithm>
#include <set> #define N 150005
using namespace std;
typedef long long Int;
const int maxn = 1e9 + ;
map<long long, set<int> > mapp;
long long a[N]; int main()
{
int n;
cin >> n;
int all = n;
for (int i = ; i <= n; i++)
{
cin >> a[i];
mapp[a[i]].insert(i);
}
for (map<long long, set<int> >::iterator i = mapp.begin(); i != mapp.end(); i++)
{
while (i->second.size() > )
{
set<int>::iterator op1 = i->second.begin(), op2;
op2 = op1; op2++;
all--;
int t1 = *op1, t2 = *op2;
a[t1] = -;
a[t2] *= ;
mapp[a[t2]].insert(t2);
i->second.erase(op1);
i->second.erase(op2);
}
}
cout << all << endl;
for (int i = ; i <= n; i++)
{
if (a[i] != -)
cout << a[i] << " ";
} //system("pause");
return ;
}
D. Merge Equals(from Educational Codeforces Round 42 (Rated for Div. 2))的更多相关文章
- D Merge Equals Educational Codeforces Round 42 (Rated for Div. 2) (STL )
D. Merge Equals time limit per test2 seconds memory limit per test256 megabytes inputstandard input ...
- Educational Codeforces Round 42 (Rated for Div. 2) D. Merge Equals
http://codeforces.com/contest/962/problem/D D. Merge Equals time limit per test 2 seconds memory lim ...
- Educational Codeforces Round 42 (Rated for Div. 2)
A. Equator(模拟) 找权值的中位数,直接模拟.. 代码写的好丑qwq.. #include<cstdio> #include<cstring> #include< ...
- Multidimensional Queries(二进制枚举+线段树+Educational Codeforces Round 56 (Rated for Div. 2))
题目链接: https://codeforces.com/contest/1093/problem/G 题目: 题意: 在k维空间中有n个点,每次给你两种操作,一种是将某一个点的坐标改为另一个坐标,一 ...
- (模拟)关于进制的瞎搞---You Are Given a Decimal String...(Educational Codeforces Round 70 (Rated for Div. 2))
题目链接:https://codeforc.es/contest/1202/problem/B 题意: 给你一串数,问你插入最少多少数可以使x-y型机器(每次+x或+y的机器,机器每次只取最低位--% ...
- Educational Codeforces Round 42 (Rated for Div. 2) E. Byteland, Berland and Disputed Cities(贪心)
E. Byteland, Berland and Disputed Cities time limit per test2 seconds memory limit per test256 megab ...
- Educational Codeforces Round 78 (Rated for Div. 2)E(构造,DFS)
DFS,把和当前结点相连的点全都括在当前结点左右区间里,它们的左端点依次++,然后对这些结点进行DFS,优先对左端点更大的进行DFS,这样它右端点会先括起来,和它同层的结点(后DFS的那些)的区间会把 ...
- D. Pair Of Lines( Educational Codeforces Round 41 (Rated for Div. 2))
#include <vector> #include <iostream> #include <algorithm> using namespace std; ty ...
- C. Chessboard( Educational Codeforces Round 41 (Rated for Div. 2))
//暴力 #include <iostream> #include <algorithm> #include <string> using namespace st ...
随机推荐
- jQuery——能够编辑的表格
版权声明:欢迎转载,请注明出处 https://blog.csdn.net/suneqing/article/details/26856635 今天学习了利用jQuery实现能够编辑的表格这个 ...
- ABAP OLE常用方法和属性
转自 http://www.cnblogs.com/eric0701/p/5213694.htmlSAP EXCEL OLE常用方法和属性 附加网上找到的比较好的源代码示例一份 1.ole中如何保存和 ...
- 微信小程序开发:学习笔记[8]——页面跳转及传参
微信小程序开发:学习笔记[8]——页面跳转及传参 页面跳转 一个小程序拥有多个页面,我们可以通过wx.navigateTo推入一个新的页面.在首页使用2次wx.navigateTo后,页面层级会有三层 ...
- Ace(一)环境搭建
1.下载ACE源码代码 http://www.cs.wustl.edu/~schmidt/ACE.html 2.编译源代码 2.1 进入源码包解压后的ACE_wrappers\ace目录, ...
- .PHP生成静态html文件的方法
1. [代码][PHP]代码 1,下面使用模版的一个方法! <?php $fp = fopen ("templets.html","a"); ...
- html5--5-16 综合实例绘制饼图
html5--5-16 综合实例绘制饼图 实例 <!doctype html> <html> <head> <meta charset="utf-8 ...
- html5--5-5 绘制填充矩形
html5--5-5 绘制填充矩形 学习要点 掌握绘制矩形的方法:strkeRect()/fillRect() 掌握绘制路径的 beginPath()和closePath() 矩形的绘制方法 rect ...
- python学习笔记:第二天(运算符)
Python3 运算符 注:以下部分示例源自于http://www.runoob.com/ 1.算术运算符 假设变量a为10,变量b为20: 运算符 描述 实例 + 加 - 两个对象相加 a + b ...
- jQuery comet
下面程序是例用从数据端推送信息,原理是每隔10秒读取一下data.txt文件,看有木有新的数据输入,如果有,则alert文件内容. hmtl代码是 <!DOCTYPE html> < ...
- 谈谈java中成员变量与成员方法继承的问题
谈谈java中成员变量与成员方法继承的问题 关于成员变量和成员方法的的继承问题,我也可以做一个小测试,来看看结果. 首先我们先创建一个父类: