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 ...
随机推荐
- 有关 java 不定参数
不定参数实际为数组参数的一种写法而已,本质上与数组参数完全相同 //1.数组参数函数 public static int sum(int[] values) { } //2.不定参数函数 不定参数只能 ...
- (linux)struct inode 和 struct file
转自:http://www.cnblogs.com/QJohnson/archive/2011/06/24/2089414.html 1.struct inode──字符设备驱动相关的重要结构介绍 内 ...
- [NOIP2011提高组day1]-3-mayan游戏
3.Mayan 游戏 (mayan.cpp/c/pas) [问题描述] Mayan puzzle 是最近流行起来的一个游戏.游戏界面是一个 7行 5 列的棋盘,上面堆放着一些方块,方块不能悬空堆放,即 ...
- LightOJ1336 Sigma Function —— 质因子分解、约数和为偶数
题目链接:https://vjudge.net/problem/LightOJ-1336 1336 - Sigma Function PDF (English) Statistics Forum ...
- linux应用之用户管理相关命令
1. useradd useradd 命令可以创建一个新的用户帐号,其最基本用法为: useradd 用户名 如输入以下命令: useradd newuser 系统将创建一个新用户 newuser,该 ...
- 自建 AppRTC
自建 AppRTC 字数3158 阅读1718 评论2 喜欢2 AppRTC 是 webrtc 的一个 demo.自建 AppRTC 可以苦其心志劳其筋骨饿其体肤,更重要的是能学会 webrtc 服务 ...
- web安全字体
webfont解剖 Unicode字体可以包含数以千计字形 有四个字体格式: WOFF2, WOFF, EOT, TTF 一些字体格式需要使用GZIP压缩 一个web字体是字形的集合,且每个字形是一个 ...
- 静态路由配置及RIP配置实验
[实验环境] Packet Trace 5.3 模拟软件. [实验步骤] 1.首先要进行IP地址规划.(例如下图格式) 网络名 网络地址 子网掩码 网关 主机IP vlan1 10.10.1.0 25 ...
- jquery跨域3
这两天用 Jquery 跨域取数据的时候,经常碰到 invalid label 这个错误,十分的郁闷,老是取不到服务器端发送回来的 json 值, 一般跨域用到的两个方法为:$.ajax 和$.get ...
- juery的跨域请求2
时间过得好快,又被拉回js战场时, 跨域问题这个伤疤又开疼了. 好在,有jquery帮忙,跨域问题似乎没那么难缠了.这次也借此机会对跨域问题来给刨根问底,结合实际的开发项目,查阅了相关资料,算是解决了 ...