1 // stl+模拟 CCF2016 4 路径解析
2 // 一开始题意理解错了。。。。
3
4 #include <iostream>
5 #include <string>
6 #include <vector>
7 using namespace std;
8 void fre() {freopen("in.txt","r",stdin);}
9 vector<string> l;
10 int main(){
11 int n;
12 string str;
13 cin>>n>>str;
14 getchar();
15 for(int i=1;i<=n;i++){
16 string s;
17 getline(cin,s);
18 if(s[0]!='/') s=str+'/'+s;
19 if(s.size()==0) s=str;
20 int pos;
21 while((pos=s.find("//"))!=-1){
22 int count=2;
23 while(s[pos+count]=='/') count++;
24 s.erase(pos,count-1);
25 }
26 while((pos=s.find("/../"))!=-1){
27 if(pos==0){
28 s.erase(pos+1,3);
29 }
30 else{
31 int p=s.rfind('/',pos-1);
32 s.erase(p,pos-p+3);
33 }
34 }
35
36 while((pos=s.find("/./"))!=-1){
37 s.erase(pos,2);
38 }
39
40 if(s.size()>1&&s[s.size()-1]=='/')
41 s.erase(s.size()-1);
42 l.push_back(s);
43 }
44 for(int i=0;i<n;i++){
45 cout<<l[i]<<endl;
46 }
47 return 0;
48 }