2014-2015 Acm-icpc, NEERC, Eastern subregional Contest problem H. Pair:normal and Paranormal

Source: Internet
Author: User

Title Link: http://codeforces.com/group/aUVPeyEnI2/contest/229669
time limit: 1s
Space limit: 64MB
Topic: Given a length of 2n, a string consisting of n uppercase and N lowercase letters, the corresponding letter 22 is concatenated, and does not intersect, in order to output the position of the lowercase letter corresponding to no capital letter, if not present the output "impossible"
Examples:
/home/destr/desktop/Depth _ Select area _20181006175058.png
/home/destr/desktop/Depth _ Select area _20181006175126.png
Solution:
Build the structure manually, maintain a stack
Code:

#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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.