#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<map>
#include<iostream>
#include<algorithm>
using namespace std;
vector<int>a[100];
map<string,int>b;
int main(){
//freopen("data.txt","r",stdin);
int T;
scanf("%d",&T);
while(T--){
int n,cnt=0;
scanf("%d",&n);
getchar();
for(int i=0;i<n;i++)
a[i].clear();
b.clear();
while(n--){
char c;
string line,snum,opp;
while(scanf("%c",&c)&&c!='='&&c!='.'&&c!='[')//得到List名
snum.insert(snum.end(),1,c);
if(c=='='){//清空
if(!b.count(snum))b[snum]=cnt++;
else a[b[snum]].clear();
getline(cin,line);
}
else if(c=='.'){
while(scanf("%c",&c)&&c!='(')
opp.insert(opp.end(),1,c);
if(opp[0]=='a'){//插入
int x;
scanf("%d",&x);
a[b[snum]].push_back(x);
}
else {//排序
sort(a[b[snum]].begin(),a[b[snum]].end());
}
getline(cin,line);
}
else {//查找
int x;
scanf("%d",&x);
if(x<a[b[snum]].size())printf("%d\n",a[b[snum]][x]);
else printf("ERROR\n");
getline(cin,line);
}
}
}
return 0;
}
Bupt OJ-306. Python List-计算机一2014
最新推荐文章于 2024-04-12 14:08:22 发布