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个大写字母和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的更多相关文章
- 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的 ...
- 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 ...
- 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 ...
- 2018-2019 ICPC, NEERC, Southern Subregional Contest
目录 2018-2019 ICPC, NEERC, Southern Subregional Contest (Codeforces 1070) A.Find a Number(BFS) C.Clou ...
- Codeforces 2018-2019 ICPC, NEERC, Southern Subregional Contest
2018-2019 ICPC, NEERC, Southern Subregional Contest 闲谈: 被操哥和男神带飞的一场ACM,第一把做了这么多题,荣幸成为7题队,虽然比赛的时候频频出锅 ...
- 2013-2014 ACM-ICPC, NEERC, Eastern Subregional Contest PART (8/10)
$$2013-2014\ ACM-ICPC,\ NEERC,\ Eastern\ Subregional\ Contest$$ \(A.Podracing\) 首先枚举各个折现上的点,找出最小宽度,然 ...
- 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 ...
- ACM ICPC 2016–2017, NEERC, Northern Subregional Contest Problem J. Java2016
题目来源:http://codeforces.com/group/aUVPeyEnI2/contest/229510 时间限制:2s 空间限制:256MB 题目大意: 给定一个数字c 用 " ...
- Codeforces1070 2018-2019 ICPC, NEERC, Southern Subregional Contest (Online Mirror, ACM-ICPC Rules, Teams Preferred)总结
第一次打ACM比赛,和yyf两个人一起搞事情 感觉被两个学长队暴打的好惨啊 然后我一直做傻子题,yyf一直在切神仙题 然后放一波题解(部分) A. Find a Number LINK 题目大意 给你 ...
随机推荐
- com.alibaba.druid检测排查数据库连接数不释放定位代码
1.可能标题说的很不明白,其实就是这样一个情况,一个工程项目错误日志出现GetConnectionTimeoutException: wait millis 90000, active 22000的异 ...
- html网站meta标签大全
案例 一.天猫 <meta charset="utf-8"> <title>天猫TMALL</title> <meta name=&quo ...
- echarts 地图 免费离线js,json包分享
最近,项目中需要用到地图,由于项目的特殊性,只能使用内网获取数据. 然而,echarts官网上的离线地图包(http://echarts.baidu.com/download-map.html)早在一 ...
- Unity判断鼠标是否在UI(UGUI)上
"EventSystem.current.IsPointerOverGameObject()" UI和3D场景同时都需要响应触摸事件,如果同时响应可能就会出现触摸UI的时候影响到了 ...
- 2.5 USB摄像头驱动程序框架
学习目标:根据vivi驱动架构和linux-2.6.31/linux-2.6.31.14/drivers/media/video/uvc/Uvc_driver.c驱动源码,分析usb摄像头驱动程序框架 ...
- Asp.net Core Startup Class中是如何获取配置信息的
默认的网站构建方式 VS2015新建asp.net core项目,项目建立完成后,有两个文件,Program.cs和Startup.cs. public class Program { public ...
- JVM内存模型(转载)
原文地址:http://blog.csdn.net/u012152619/article/details/46968883 JVM定义了若干个程序执行期间使用的数据区域.这个区域里的一些数据在JVM启 ...
- 20155234 2006-2007-2 《Java程序设计》第4周学习总结
20155234 2006-2007-2 <Java程序设计>第4周学习总结 教材学习内容总结 为了避免重复的行为定义使用继承. 要学会如何正确判断使用继承的时机以及继承之后如何活用多态. ...
- 面试:sql语句-1-基础查询
1.基础查询
- JDK1.7的HashMap的put(key, value)源码剖析
目录 HashMap的put操作源码解析 1.官方文档 2.put(key, value) 3.完结 HashMap的put操作源码解析 1.官方文档 1.1.继承结构 java.lang.Objec ...