uva 11988
程序员文章站
2022-06-01 22:50:05
...
题目主要是运用单向链表,主要是讲数据结构课中的链式线性表用数组表示
#include<bits/stdc++.h>
using namespace std;
string s;
int a[100005];
int main(){
while(cin>>s){
int cur=0,end=0,len=s.size();
a[0]=0;
for(int i=0;i<len;i++){
if(s[i]=='['){
cur=0;
}else if(s[i]==']'){
cur=end;
}else{//这个语句相当于是在p节点以后插入一个节点
a[i+1]=a[cur];
a[cur]=i+1;
if(cur==end){
end=i+1;
}
cur=i+1;
}
}
for(int i=a[0];i!=0;i=a[i]){
cout<<s[i-1];
}
cout<<endl;
}
}
推荐阅读
-
团体队列 UVA540 Team Queue
-
丑数(Ugly Numbers, UVa 136)
-
破损的键盘(悲剧文本)(Broken Keyboard(a.k.a. Beiju Text),Uva 11988)
-
集合栈计算机(The SetStack Computer, ACM/ICPC NWERC 2006,Uva12096)
-
唯一的雪花(Unique snowflakes,UVa 11572)滑动窗口+set
-
[UVA - 11584] Partitioning by Palindromes dp预处理
-
UVA227-Puzzle
-
UVA 442 Matrix Chain Multiplication ( stack 应用)
-
UVA 136 - Ugly Numbers(优先队列 + 集合)
-
(UVa 136) Ugly Numbers(丑数的生成+整数分解定理+优先队列)