Codeforces Round #298 (Div. 2)--D. Handshakes
#include <stdio.h>
#include <algorithm>
#include <set> using namespace std; #define forn(i, n) for (int i = 0; i < int(n); i++) typedef pair<int, int> pii;
const int N = ; int n;
set<pii> a[];
int ans[N]; int main() {
scanf("%d", &n);
forn(i, n) {
int x;
scanf("%d", &x);
a[x % ].insert(make_pair(x, i));
} int cur = ;
forn(i, n) {
set <pii> :: iterator it = a[cur % ].lower_bound(make_pair(cur, -));
pii c;
if (it != a[cur % ].end() && (*it).first == cur) {
c = *(it);
ans[i] = c.second + ;
} else {
if (it == a[cur % ].begin()) {
puts("Impossible");
return ;
} else {
it--;
c = *(it);
ans[i] = c.second + ;
}
} a[cur % ].erase(c);
cur = c.first + ;
} puts("Possible");
forn(i, n)
printf("%d ", ans[i]); return ;
}
Codeforces Round #298 (Div. 2)--D. Handshakes的更多相关文章
- Codeforces Round #298 (Div. 2) D. Handshakes 构造
D. Handshakes Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/534/problem ...
- Codeforces Round #298 (Div. 2) D. Handshakes [贪心]
传送门 D. Handshakes time limit per test 1 second memory limit per test 256 megabytes input standard in ...
- Codeforces Round #298 (Div. 2) A、B、C题
题目链接:Codeforces Round #298 (Div. 2) A. Exam An exam for n students will take place in a long and nar ...
- CodeForces Round #298 Div.2
A. Exam 果然,并没有3分钟秒掉水题的能力,=_=|| n <= 4的时候特判.n >= 5的时候将奇数和偶数分开输出即可保证相邻的两数不处在相邻的位置. #include < ...
- Codeforces Round #298 (Div. 2) E. Berland Local Positioning System 构造
E. Berland Local Positioning System Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.c ...
- Codeforces Round #298 (Div. 2) C. Polycarpus' Dice 数学
C. Polycarpus' Dice Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/534/p ...
- Codeforces Round #298 (Div. 2) B. Covered Path 物理题/暴力枚举
B. Covered Path Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/534/probl ...
- Codeforces Round #298 (Div. 2) A. Exam 构造
A. Exam Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/534/problem/A Des ...
- Codeforces Round #298 (Div. 2)A B C D
A. Exam time limit per test 1 second memory limit per test 256 megabytes input standard input output ...
随机推荐
- 如何提高php应用的性能?
1. 如果能将类的方法定义成static,就尽量定义成static,它的速度会提升将近4倍.2.$row[’id’] 的速度是$row[id]的7倍.3.echo 比 print快,并且使用echo的 ...
- readv writev示例程序
当 readv() 时候,需要程序自己提供space,接收数据. #include <stdio.h> #include <stdlib.h> #include <str ...
- UI设计教程分享:关于海报的合成过程
一张好的产品创意合成海报,能瞬间提升商品价值感,同时场景和相关元素的融入,让消费者瞬间明白商品属性及内涵.同时为商品营造的使用场景拥有更强的代入感,从而刺激转化.好的创意合成海报能为消费者带来视觉冲击 ...
- [Selenium Grid] 搭建Hub和Node环境
Note : 先在Hub和Node的机器上安装好JDK, IE浏览器,Chrome浏览器,Firefox浏览器 准备好红色框标示的东西: Hub.bat :启动Hub AllNodes.bat : ...
- Python之路(第十九篇)hashlib模块
一.hashlib模块 HASH Hash,一般翻译做“散列”,也有直接音译为”哈希”的,就是把任意长度的输入(又叫做预映射,pre-image),通过散列算法,变换成固定长度的输出,该输出就是散列值 ...
- 论坛:获取当前原始请求中的远程IP地址
topic.setIpAddr(ServletActionContext.getRequest().getRemoteAddr());//当前原始请求中的远程IP地址
- mybatis 插入数据并返回主键值
<insert id="insert" parameterType="com.pojo.TSubject" useGeneratedKeys=" ...
- SQL 中的Begin...End语句
Begin...End通常用来表示一个语句块,其内部的代码可以包含一组T-SQL语句,可以理解为高级语言中的{},这样在使用while循环时才知道判断什么时候结束.
- Python 单列
1.__new__内置方法 在对类进行实例化时自动执行 功能1:为对象分配空间 功能2:返回空间的引用 2.单列实现方法 class MusicPlayer: # 记录对象内存引用,初始值为None ...
- hbase shell 命令
HBase使用教程 时间 2014-06-01 20:02:18 IT社区推荐资讯 原文 http://itindex.net/detail/49825-hbase 主题 HBase 1 基 ...