특별 블로그 링크
Peking University C ++ POJ 수업 후 연습 블로그 전체 솔루션 기록
원제
암호
#include <iostream>
#include <list>
#include <algorithm>
using namespace std;
typedef list<int> L;
void printlist(const list<int>::iterator stri,const list<int>::iterator endi)
{
list<int>::iterator tmp;
for(tmp = stri;tmp!=endi;tmp++)
cout<<*tmp<<' ';
cout<<endl;
return;
}
int main()
{
L lst[10010];
L::iterator i;
string func;
int opernumbers,number,target,name;
cin>>opernumbers;
while(opernumbers--)
{
cin>>func;
if(func == "new")
cin>>name;
else if(func == "add")
{
cin>>name>>number;
lst[name].push_back(number);
}
else if(func == "merge")
{
cin>>name>>target;
lst[name].merge(lst[target]);
}
else if(func == "unique")
{
cin>>name;
lst[name].sort();
lst[name].unique();
}
else
{
cin>>name;
lst[name].sort();
printlist(lst[name].begin(),lst[name].end());
}
}
return 0;
}