#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的更多相关文章

  1. Codeforces Round #298 (Div. 2) D. Handshakes 构造

    D. Handshakes Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/534/problem ...

  2. Codeforces Round #298 (Div. 2) D. Handshakes [贪心]

    传送门 D. Handshakes time limit per test 1 second memory limit per test 256 megabytes input standard in ...

  3. 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 ...

  4. CodeForces Round #298 Div.2

    A. Exam 果然,并没有3分钟秒掉水题的能力,=_=|| n <= 4的时候特判.n >= 5的时候将奇数和偶数分开输出即可保证相邻的两数不处在相邻的位置. #include < ...

  5. 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 ...

  6. 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 ...

  7. 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 ...

  8. 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 ...

  9. 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 ...

随机推荐

  1. C# oracle 日期型字段,使用参数传值时,遇到ORA-01810: format code appears twice错误

    C#操作oracle数据库时,发现使用to_date('2014-01-03 18:00:00','yyyy-mm-dd hh:MM:ss')时,会出现ORA-01810: format code a ...

  2. PAT 1013 数素数 (20)(代码)

    1013 数素数 (20)(20 分) 令P~i~表示第i个素数.现任给两个正整数M <= N <= 10^4^,请输出P~M~到P~N~的所有素数. 输入格式: 输入在一行中给出M和N, ...

  3. iOS.WWDC

    1. ASCIIwwdc: Searchable full-text transcripts of WWDC sessions http://asciiwwdc.com

  4. 比较两个List列表,取得List中不同项返回

    /// <summary> /// 比对模型及属性数组 /// </summary> /// <typeparam name="TM">< ...

  5. 最详细的Axure动态面板使用教程

    1.打开[Axure]软件,在index文件上新建一个375*667大小的背景矩形并绘制页面. 具体如图所示. 2.在banner的位置上新建一个[动态面板],双击动态面板在其中新建state1.st ...

  6. Eclipse 安装使用 M2Eclipse 插件

    help --> Install New Software --> Add 安装完后需要重启eclipse 通常 Eclipse 会自带 Maven.但可能按自己安装的 Maven 存在版 ...

  7. MySQL中varchar与char区别

    MySQL中varchar与char区别(转) MySQL中varchar最大长度是多少? 一. varchar存储规则: 4.0版本以下,varchar(20),指的是20字节,如果存放UTF8汉字 ...

  8. Can I win LT464

    In the "100 game," two players take turns adding, to a running total, any integer from 1.. ...

  9. JavaScript学习笔记:基础知识点总结

    基础概念 JavaScript(以下简称Js)中数据类型:Number 字符串 布尔值 数组 对象(Js的对象是一组由键值对组成的无序集合) Js中基础概念:变量(概念和Java中变量概念类似 指示某 ...

  10. 使用crf++

    在example文件夹下存在4个使用crf的实例 1.在命令行执行 进入路径:./example/seg 执行:sh exec.sh 2. 在python中执行 进入路径:./python 执行:(1 ...