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