2019. Pair: normal and paranormal

Time limit: 1.0 second
Memory limit: 64 MB
If you find yourself in Nevada at an abandoned nuclear range during Halloween time, you’ll become a witness of an unusual show. Here Ghostbusters hold annual tests for new versions of their proton packs. There are n Ghostbusters and n portable traps with ghosts, all are located on a semicircle. Each trap contains exactly one ghost. The ghosts may be of different types, but each Ghostbuster can neutralize with his weapon only one type of the evil spirits.
On the count of three all ghost traps open at once and all Ghostbusters start to fire. Of course, each Ghostbuster shoots at the ghost, which his proton gun is able to neutralize. The most important thing here is not to cross proton beams of the guns.

You know positions of all Ghostbusters and all the traps in this year’s tests. For each Ghostbuster determine which ghost he should shoot at, so that all the ghosts are neutralized and no two gun beams cross. You can assume that all proton beams are in the same horizontal plane and they don’t shoot ghosts through in case of a hit.

Input

In the first line there is an integer n that is the number of Ghostbusters (1 ≤ n ≤ 5 000). In the second line the sequence of 2n Latin letters is written, describing the allocation of the Ghostbusters and the traps on the semicircle. Uppercase letters correspond to the Ghostbusters and lowercase letters correspond to the traps. For example, “a” stands for a trap with the ghost of type “a”, while “A” stands for the Ghostbuster with the gun neutralizing ghosts of type “a”. The sequence has exactly nlowercase letters and exactly n uppercase letters.

Output

If the problem has a solution, output n space-separated integers g1, g2, …, gn, where gi is the number of the ghost i-th Ghostbuster should shoot at. Both Ghostbusters and ghosts are numbered with integers from 1 to n in the order of their positions along the semicircle. All gi must be pairwise different. If the problem has several solutions, output any of them. If the problem has no solution, output “Impossible”.

Samples

input output
2
AbBa
2 1
2
AbaB
Impossible
1
Ab
Impossible
Problem Author: Denis Dublennykh (prepared by Oleg Merkurev)
Problem Source: NEERC 2014, Eastern subregional contest
 
 
 
 

ural 2019 Pair: normal and paranormal的更多相关文章

  1. URAL 2019 Pair: normal and paranormal (STL栈)

    题意:在一个半圆内,有2*n个点,其中有大写字母和小写字母.其中你需要连接大写字母到小写字母,其中需要保证这些连接的线段之间没有相交. 如果能够实现,将大写字母对应的小写字母的序号按序输出. 析:我把 ...

  2. URAL 2019 Pair: normal and paranormal (贪心) -GDUT联合第七场

    比赛题目链接 题意:有n个人每人拿着一把枪想要杀死n个怪兽,大写字母代表人,小写字母代表怪兽.A只能杀死a,B只能杀死b,如题目中的图所示,枪的弹道不能交叉.人和怪兽的编号分别是1到n,问是否存在能全 ...

  3. Gym 100507H Pair: normal and paranormal (贪心)

    Pair: normal and paranormal 题目链接: http://acm.hust.edu.cn/vjudge/contest/126546#problem/H Description ...

  4. H - Pair: normal and paranormal URAL - 2019

    If you find yourself in Nevada at an abandoned nuclear range during Halloween time, you’ll become a  ...

  5. 2014-2015 ACM-ICPC, NEERC, Eastern Subregional Contest Problem H. Pair: normal and paranormal

    题目链接:http://codeforces.com/group/aUVPeyEnI2/contest/229669 时间限制:1s 空间限制:64MB 题目大意:给定一个长度为2n,由n个大写字母和 ...

  6. 【贪心】Gym - 100507H - Pair: normal and paranormal

    每次取相邻的两个可以射击的从序列中删除,重复n次. 可以看作括号序列的匹配. #include<cstdio> #include<vector> using namespace ...

  7. Gym 100507H - Pair: normal and paranormal

    题目链接:http://codeforces.com/gym/100507/attachments -------------------------------------------------- ...

  8. NEERC 2014, Eastern subregional contest

    最近做的一场比赛,把自己负责过的题目记一下好了. Problem B URAL 2013 Neither shaken nor stirred 题意:一个有向图,每个结点一个非负值,可以转移到其他结点 ...

  9. 【English EMail】2019 Q2 Public Holiday Announcement

    Hi all, According to 2019 public holiday announcement released by Chinese government, this is to ann ...

随机推荐

  1. 洛谷 P4768 [NOI2018]归程

    洛谷 361行代码的由来 数据分治大发好啊- NOI的签到题,可怜我在家打了一下午才搞了80分. 正解应该是kruskal重构树或排序+可持久化并查集. 我就分点来讲暴力80分做法吧(毕竟正解我也没太 ...

  2. Python电影投票系统

    电影投票:程序先给出几个目前正在上映的电影列表. 由用户给每个电影投票.最终将该用户投票信息公布出来 lst = ['北京遇上西雅图', '解救吴先生', '美国往事', '西西里的美丽传说']结果: ...

  3. centos添加定时任务

    安装crontab: yum install crontabs 查看crontab服务状态:service crond status 手动启动crontab服务:service crond start ...

  4. MySQL 第四天

    回顾 列属性: 主键, 自增长, 唯一键     关系: 一对一,一对多和多对多 范式: 三层范式 1NF: 字段设计必须符合原子性 2NF: 不存在部分依赖(没有复合主键) 3NF: 不存在传递依赖 ...

  5. JavaScript四则运算计算器

    直接上代码: 首先是HTML代码 <form> 第一个数字:<br> <input type="text" id="num1"&g ...

  6. 001-unity3d简介以及界面说明

    一.简介 学习路线1.C#.网络[http,socket]io2.GUI.NGUI.2DToolKit3.3D控制.物理引擎.角色控制4.粒子系统.音频等5.android.IOS开发基础6.sock ...

  7. 《Python数据分析》笔记——数据可视化

    数据可视化 matplotlib绘图入门 为了使用matplotlib来绘制基本图像,需要调用matplotlib.pyplot子库中的plot()函数 import matplotlib.pyplo ...

  8. 《Python机器学习》笔记(三)

    使用scikit-learning 实现机器学习分类算法 分类算法的选择 没有免费的午餐理论:没有任何一种分类器可以在所有可能的应用场景下都有良好的表现. 实践证明,只有比较了多种学习算法的性能,才能 ...

  9. 2015/7/29 (高开,V形反转,各种指标背离——可惜没买进,填补空缺图形的心理分析)

    1.李大--謝先生℡:早盘决策:如今日再次出现大幅低开  或者盘中大幅下跌可逢低 3成仓位左右分散资金做短线抄底,切记是超短 绝不追高,设置5个点止损.市场有很多名家在谈论3373点即前低点,本人告诉 ...

  10. PAT 天梯赛 L1-040. 最佳情侣身高差 【水】

    题目链接 https://www.patest.cn/contests/gplt/L1-040 AC代码 #include <iostream> #include <cstdio&g ...