题目链接:http://codeforces.com/group/aUVPeyEnI2/contest/229669

时间限制:1s

空间限制:64MB

题目大意:给定一个长度为2n,由n个大写字母和n小写字母组成的字符串,将对应的字母两两连接,且不相交,按顺序输出没个大写字母对应的小写字母的位置,如果不存在则输出"Impossible"

样例:



解法:

手动建立结构体,维护一个栈

代码:

#include<bits/stdc++.h>
using namespace std;
struct node{
char v;
int id;
}st[11000];
int main()
{
int n;
char s[11000];
int ans[11000]={0};
int sum1=0,sum2=0;
int top=0;
int tot=0;
cin>>n;
for(int i=1;i<=n*2;i++)
{
cin>>s[i];
if(isupper(s[i]))
{
sum1++;
if(s[i]+32==st[top].v)
{
ans[sum1]=st[top].id;
top--;
}
else
{
top++;
st[top].id=sum1;
st[top].v=s[i];
}
}
else
{
sum2++;
if(s[i]-32==st[top].v)
{
ans[st[top].id]=sum2;
top--;
}
else
{
top++;
st[top].v=s[i];
st[top].id=sum2;
}
}
}
if(top!=0)cout<<"Impossible"<<endl;
else
for(int i=1;i<=n;i++)
cout<<ans[i]<<" ";
return 0;
}

2014-2015 ACM-ICPC, NEERC, Eastern Subregional Contest Problem H. Pair: normal and paranormal的更多相关文章

  1. 2014-2015 ACM-ICPC, NEERC, Eastern Subregional Contest Problem G. The Debut Album

    题目来源:http://codeforces.com/group/aUVPeyEnI2/contest/229669 时间限制:1s 空间限制:64MB 题目大意:给定n,a,b的值 求一个长度为n的 ...

  2. 2013-2014 ACM-ICPC, NEERC, Southern Subregional Contest Problem H. Password Service dp

    Problem H. Password Service 题目连接: http://www.codeforces.com/gym/100253 Description Startups are here ...

  3. 2010-2011 ACM-ICPC, NEERC, Moscow Subregional Contest Problem H. Hometask 水题

    Problem H. Hometask 题目连接: http://codeforces.com/gym/100714 Description Kolya is still trying to pass ...

  4. 2018-2019 ICPC, NEERC, Southern Subregional Contest

    目录 2018-2019 ICPC, NEERC, Southern Subregional Contest (Codeforces 1070) A.Find a Number(BFS) C.Clou ...

  5. Codeforces 2018-2019 ICPC, NEERC, Southern Subregional Contest

    2018-2019 ICPC, NEERC, Southern Subregional Contest 闲谈: 被操哥和男神带飞的一场ACM,第一把做了这么多题,荣幸成为7题队,虽然比赛的时候频频出锅 ...

  6. 2013-2014 ACM-ICPC, NEERC, Eastern Subregional Contest PART (8/10)

    $$2013-2014\ ACM-ICPC,\ NEERC,\ Eastern\ Subregional\ Contest$$ \(A.Podracing\) 首先枚举各个折现上的点,找出最小宽度,然 ...

  7. 2018-2019 ICPC, NEERC, Southern Subregional Contest (Online Mirror) Solution

    从这里开始 题目列表 瞎扯 Problem A Find a Number Problem B Berkomnadzor Problem C Cloud Computing Problem D Gar ...

  8. ACM ICPC 2016–2017, NEERC, Northern Subregional Contest Problem J. Java2016

    题目来源:http://codeforces.com/group/aUVPeyEnI2/contest/229510 时间限制:2s 空间限制:256MB 题目大意: 给定一个数字c 用 " ...

  9. Codeforces1070 2018-2019 ICPC, NEERC, Southern Subregional Contest (Online Mirror, ACM-ICPC Rules, Teams Preferred)总结

    第一次打ACM比赛,和yyf两个人一起搞事情 感觉被两个学长队暴打的好惨啊 然后我一直做傻子题,yyf一直在切神仙题 然后放一波题解(部分) A. Find a Number LINK 题目大意 给你 ...

随机推荐

  1. Keil MDK最新版 5.25介绍及下载地址

    看到Keil MDK又出新版咯,分享给大家 Keil MDK-ARM 5.25 uVision5开发工具下载地址:http://www.myir-tech.com/soft.asp?id=1140 K ...

  2. kubernetes常用基础命令

    创建资源对象 创建名为nginx-deploy的控制器资源对象 [root@master ~]# kubectl run nginx-deploy --image=nginx:1.12 --repli ...

  3. anaconda创建python虚拟环境

    参考: 1.https://blog.csdn.net/lyy14011305/article/details/59500819 我的安装过程: 1. 之前已经安装了anaconda,我的版本是ana ...

  4. 1. 文件a.txt内容:每一行内容分别为商品名字,价钱,个数。

    li = []with open('lo', encoding='utf-8', mode='r') as f1: for i in f1: l2=i.strip().split() dic = {' ...

  5. 一个servlet如何处理多个请求

    页面1:表单的action=login?method=login 页面2:表单的action=login?method=insert ..... 然后通过method的值采用不同方法进行处理. 如下 ...

  6. 20155226 mini DC 课堂测试补交

    由于电脑突然出了点问题,我没有完成mini DC这个测试,现将测试内容及结果补交 题目如下 提交测试截图和码云练习项目链接,实现Linux下dc的功能,计算后缀表达式的值 代码如下 MyDC.clas ...

  7. 从码云把之前的代码git push 回IDEA 对IDEA里的文件进行简单操作

    前情提要:我的IDEA里的项目之前已经和码云连接成功可以上传.但我直接在电脑文件夹里对文件进行重命名.剪切.粘贴等操作之后IDEA对操作后的文件不识别,无奈之下我将码云上之前的代码推回重新新建了项目. ...

  8. 1130: [POI2008]POD Subdivision of Kingdom

    1130: [POI2008]POD Subdivision of Kingdom https://lydsy.com/JudgeOnline/problem.php?id=1130 分析: 有效状态 ...

  9. 后端API入门到放弃指北

    后端API入门学习指北 了解一下一下概念. RESTful API标准] 所有的API都遵循[RESTful API标准]. 建议大家都简单了解一下HTTP协议和RESTful API相关资料. 阮一 ...

  10. Django视图层详细介绍

    1 视图函数 一个视图函数,简称视图,是一个简单的Python 函数,它接受Web请求并且返回Web响应.响应可以是一张网页的HTML内容,一个重定向,一个404错误,一个XML文档,或者一张图片. ...