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 ...
随机推荐
- mysql 修改语法格式
1.修改字段注释格式 alter table {table} modify column {column} {type} comment '{comment}';
- mac shell命令连接mongo
1. 安装rebomongo 2. mongo 192.168.1.100/databasename -u lsg -p 123456 3.db.drawspecs.find({name:'prize ...
- 【Effective C++】继承与面向对象设计
关于OOP 1,继承可以是单一继承或多重继承,每一个继承连接可以是public.protected或private,也可以是virtual或non-virtual. 2,成员函数的各个选项:virtu ...
- RTP/RTCP学习笔记 -- RFC 3550
The MTU of RTP package payload is (IP) - (UDP) - = 1472 #define DEFAULT_MAX_PACKET_SIZE 1200 video ...
- apache配置文件详解及虚拟主机的搭建
1.404跳转: <IfModule dir_module> DirectoryIndex index.php index.html /error.php</IfModule& ...
- linux内核container_of宏定义分析
看见一个哥们分析container_of很好,转来留给自己看 一.#define offsetof(TYPE, MEMBER) ((size_t) & ((TYPE *)0)->MEMB ...
- [zjoi2003]密码机
一台密码机按照以下的方式产生密码:首先往机器中输入一系列数,然后取出其中一部分数,将它们异或以后得到一个新数作为密码.现在请你模拟这样一台密码机的运行情况,用户通过输入控制命令来产生密码.密码机中存放 ...
- centos6.5 mysql 5.6修改root密码,以及创建用户并授权
mkdir -p mysql_home/{data,temp,undologs,logs} chown -R mysql:mysql /dbfiles/mysql_home mysql_install ...
- iOS7默认状态栏文字颜色为黑色,项目需要修改为白色。
1在Info.plist中设置UIViewControllerBasedStatusBarAppearance 为NO2 在需要改变状态栏颜色的 AppDelegate中在 didFinishLaun ...
- ffmpeg入门基础知识
获取ffmpeg源代码 如果你是在Windows环境下,则可以先装SVN的一个客户端TortoiseSVN(非常好用,强烈推荐),他安装完成后会集成在右键菜单中,点Checkout菜单,在弹出的界面中 ...