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 题目大意 给你 ...
随机推荐
- Bootstrap03
一.表单(以下示例 * 代表class) 注意:a.使用表单的关键字form b.所有的提示词使用label包裹 c.所写内容按div分类,使得层次分明 1.基本表单+表单组合+内联表单 *=form ...
- 一种比使用协程更方便的方法:Invoke(),同样达到等待执行的效果
1.Invoke(string methodName,float time) 在一定时间调用methodName函数 using UnityEngine; using System.Collectio ...
- python学习笔记:第10天 函数进阶和作用域
目录 1. 函数进阶 2. 命名空间 3. 关键字global和nonlocal 1. 函数进阶 动态接收位置参数 之前写的函数都是固定参数的,假设有个函数需要的参数由几十个,一个个写在形参的位置会非 ...
- Leetcode---栈系列刷题(python3实现)----#496 下一个更大元素I
给定两个没有重复元素的数组 nums1 和 nums2 ,其中nums1 是 nums2 的子集.找到 nums1 中每个元素在 nums2 中的下一个比其大的值. nums1 中数字 x 的下一个更 ...
- upload-labs19记录
upload-labs19记录 本次做题为白盒,因为只是fuzz的话并不能学到什么,所以从漏洞源下手. 前端校验 Pass1 源码 function checkFile() { var file = ...
- LFS搭建第一天
1. 前期准备 vmware 软件安装 LFS iso 下载:http://ftp.osuosl.org/pub/lfs-livecd/lfslivecd-x86-6.3-r2145.iso 2.新建 ...
- OpenStack部署博客推荐
OpenStack部署推荐博客 shhnwangjian https://www.cnblogs.com/shhnwangjian/category/942049.html(推荐) 点评: 1.实现过 ...
- 30. Insert Interval【LintCode by java】
Description Given a non-overlapping interval list which is sorted by start point. Insert a new inter ...
- centos7安装cacti
参考博客地址:https://blog.csdn.net/kenn_lee/article/details/80565385 Cacti是一套基于PHP,MySQL,SNMP及RRDTool开发的网络 ...
- 【BZOJ3527】[ZJOI3527]力
[BZOJ3527][ZJOI3527]力 题面 bzoj 洛谷 题解 易得 \[ E_i=\sum_{j<i}\frac{q_j}{(i-j)^2}-\sum_{j>i}\frac{q_ ...