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 ...
随机推荐
- Liunx touch
http://blog.csdn.net/tanga842428/article/category/6355419 linux的touch命令不常用,一般在使用make的时候可能会用到,用来修改文件时 ...
- hdu 1686 & poj 2406 & poj 2752 (KMP入门三弹连发)
首先第一题 戳我穿越;http://acm.hdu.edu.cn/showproblem.php?pid=1686 题目大意好理解,每组输入一个子串和一个母串,问在母串中有多少个子串? 文明人不要暴力 ...
- Thrift.0
0. Thrift的特性 1. 安装Thrift编译器 [Todo] http://thrift.apache.org/docs/install/ http://thrift.apache.org/d ...
- WebDriverException:Message:'geckodriver'executable needs to be in Path
geckodriver是一原生态的第三方浏览器,对于selenium3.x版本都会使用geckodriver来驱动firefox,所以需要下载geckodriver.exe,下载地址:https:// ...
- 高级数据库技术SQL
- Java的OOP三大特征之一——多态
OOP(面对对象)三大特征之一——多态 What:多态性是指允许不同类的对象对同一消息作出响应,多态性包括参数化多态性和包含多态性,多态性语言具有灵活.抽象.行为共享.代码共享的优势,很好的解决了应用 ...
- 采用RedisLive监控Redis服务——安装手册
#1.gcc编译环境确认 .tgz cd Python- ./configure /bin/python2. /usr/bin/python #运行python查看版本 python -V #进行更改 ...
- 超详细的PS抠图方法
步骤: 1.打开图片,根据图片的特点选择抠图工具: 2.在图像上找到第一个定点,要求定点要完全暴露在画布中,并且是清晰可见的顶点: 3.抠取图像时,多边形套索的定点以及边线应该向内1-2个像素,为了避 ...
- mysql Error_code: 1593
mysql slave_IO_running no 查看data目录下的.err文件提示:mysql Error_code: 1593 解决方法: 1.检查 data目录下auto.cnf 文件中 ...
- python之web开发“三剑客”
# django import django # flask import flask # tornado import tornado