Language: C++

#include<map>
#include<vector>
#include<sstream>
using namespace std;
#define DIR 1
#define FILE 2
#define ARB 3
#define REP(i,b,e) for(int i=b;i<e;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(),(c).end()
class Tree{
public:
  int type;
  string myname;
  map<string, Tree* > M;
  Tree(){type=0;M.clear();myname="";}
};

void get_path(string a,vector<string>&b){
  rep(i,a.size())if (a[i]=='/')a[i]=' ';
  stringstream sin(a);
  while(sin>>a)b.push_back(a);
}

void get_query(string a,vector<pair<string,int> > & b){
  REP(i,1,a.size()){
    string t;
    while(i<a.size() && a[i] != '/')t+=a[i++];
    b.push_back(make_pair(t,DIR) );
  }
  if ( b.size() == 0)return;
  if ( a[a.size()-1]=='/')b[b.size()-1].second=DIR;
  else b[b.size()-1].second=ARB;
}

void make_tree(Tree *a,vector<string>&b,int &p){
  if (b.size()==p){return;}
  Tree *next=a->M[b[p]];
  if ( next == 0){
    next = new Tree;
    next->myname=b[p];
    a->M[b[p]]=next;
    if ( p+1 ==b.size())next->type=FILE;
    else next->type=DIR;
    make_tree(next,b,++p);
  }else {
    if (p+1 == b.size())next->type=(next->type|FILE);
    else next->type=(next->type|DIR);
    make_tree(next,b,++p);
  }
}

Tree* Find_Page(Tree *a,vector<pair<string,int> >&b,int &p){
  if ( b.size() == p)return a;
  Tree *ret=a;
  while(p < b.size()){
    if (b[p].first == "."){p++;continue;}
    else if ( b[p].first ==".."){p++;return a->myname==""?NULL:a;}
    //exceptional case "index.html"
    if ( p+1 == b.size() && b[p].first == "index.html" ){
      Tree *index = a->M[b[p].first];
      if ( index != 0 && b[p].second == ARB){
	p++;
	return index->type== FILE?a:index;
      }
    }
    Tree *next = a->M[b[p].first];
    if ( next == 0 || (next->type&b[p].second)==0 )return NULL;
    ret = Find_Page(next,b,++p);
    if ( ret == NULL)return NULL;
  }
  return ret;
}

void solve(string *q,Tree *root){
  Tree *data[2];
  rep(i,2){
    vector<pair<string,int> > a;
    int p=0;
    data[i]=NULL;
    get_query(q[i],a);
    data[i]=Find_Page(root,a,p);
    //cout << data[i]<< " " << i << endl;
    if ( a.size()==0 || data[i] == NULL){puts("not found");return;}
  }
  if (data[0] == data[1] )puts("yes");
  else puts("no");
  //cout << "case0 " <<data[0]->myname << " case1 " << data[1]->myname << endl;
  //cout << "case0 " <<data[0] << " case1 " << data[1] << endl;
}

void check(Tree *a){
  map<string,Tree*>::iterator itr = a->M.begin();
  assert(a->type != ARB);
  while(itr != a->M.end())check((*itr++).second);
}

main(){
  int n,q;
  while(cin>>n>>q &&n){
    Tree root;
    string t;
    vector<string> a;
    int p=0;
    rep(i,n)cin>>t,get_path(t,a),make_tree(&root,a,p=0),a.clear();
    check(&root);
    rep(i,q){
      string in[2];
      cin>>in[0]>>in[1];
      solve(in,&root);
    }
  }
  return false;
}

Compiler output:
a.cc: In function 'void check(Tree*)':
a.cc:94:3: error: 'assert' was not declared in this scope
   94 |   assert(a->type != ARB);
      |   ^~~~~~
a.cc:4:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>'
    3 | #include<sstream>
  +++ |+#include <cassert>
    4 | using namespace std;
a.cc: At global scope:
a.cc:98:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   98 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:100:9: error: 'cin' was not declared in this scope
  100 |   while(cin>>n>>q &&n){
      |         ^~~
a.cc:4:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    3 | #include<sstream>
  +++ |+#include <iostream>
    4 | using namespace std;