Language: C++

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>;
#define mod 1000000007
#define INF 10000
using namespace std;
vestor <int>point[100000];
struct brige
{
  int str,end;
};
vector <brige> a[1000000];
int end;
int n;
int lead[1000000];
int level[1000000];
int queue[1000000];
int size;
vector <int> qus[1000000][2];
stack <int>zhan[2];
int dfs(int now,int Lev)
{
   if(level[now]>Lev)
   {
       end=now;
       return 0;
   }
      return 1;
   level[now]=Lev;
   queue[size++]=Lve;
   for(int i=0;i<point[now].size();i++)
    if(level[point[now][i]]!=Lev)
     if(dfs(point[now][i],Lev))
       return 1;
   size--;
   level[now]=0;
   return 0;
}
void restrat(int n)
{
  size=0;
  for(int i=0;i<=n;i++)
  {
    level[i]=0;
    a[i].clear();
    qus[i][0].clear();
    qus[i][1].claer();
    point[i].clear();
  }
}
int main()
{
    while(cin>>n)
    {
    int k;
    for(int i=0;i<n;i++)
    {
      int u,v;
      cin>>u>>v;
      point[u].push_back(v);
      point[v].push_back(u);
    }
    level[1]=n+1;
    level[2]=n+1;
    for(int i=1;i<=n;i++)
    if(level[i] && dfs(i,n-i+1))
    {
      zhan[0].clear();
      zhan[1].clear();
      zhan[0].push(i);
      zhan[1].push(i);
      for(int j=0;j<size;j++)
       {
         int mi=queue[j];
          while(zhan[0].size()>1 && zhan[0].top<queue[j])
           {  
              mi=min(zhan[1].top(),mi); 
              zhan[0].pop();
              zhan[1].pop();
           }
           mi=min(zhan[1].top(),mi);
           zhan[1],pop();
           zhan[1].push(mi);
           brige u;
           u.str=queue[j];
           u.end=zhan[0].top();
           a[mi].push(u);
           zhan[0].push(queue[j]);
           zhan[1].push(queue[j]);
       }
      zhan[0].clear();
      zhan[1].clear();
      zhan[0].push(end);
      zhan[1].push(end);
      for(int j=size-1;j>=0;j--)
       {
         int mi=queue[j];
          while(zhan[0].size()>1 && zhan[0].top<queue[j])
           {  
              mi=min(zhan[1].top(),mi); 
              zhan[0].pop();
              zhan[1].pop();
           }
           mi=min(zhan[1].top(),mi);
           zhan[1],pop();
           zhan[1].push(mi);
           brige u;
           u.str=queue[j];
           u.end=zhan[0].top();
           a[mi].push(u);
           zhan[0].push(queue[j]);
           zhan[1].push(queue[j]);
       }
      size=0;
    }
    cin>>k;
    for(int i=0;i<k;i++)
    {
       int l,r;
       cin>>l>>r;
       qus[l][0].push_back(r);
       qus[l][1].push_back(i);
    } 
    int ans[100000];
    for(int i=n;i>1;i--)
    {
       add(i,n,1);
       lead[i]=n+1;
       for(int j=0;j<a[i].size();i++)
       if(a[i].end<lead[a[i].str])
       {
          add(a[i].str,lead[a[i].str]-1,-1); 
          lead[a[i].str]=0;
          if(a[i].end>a[i].str)
          {
          add(a[i].str,a[i].end,-1);  
          lead[a[i].str]=a[i].end;
          }
       }
       for(int j=0;j<que[i][0].size();j++)
       ans[que[i][1][j]]=find(que[i][0][j]);
    }  
    for(int i=0;i<k;i++)
     cout<<ans[i]<<" ";
    cout<<endl;
    }
    return 0;
}

Compiler output:
a.cc:11:17: warning: extra tokens at end of #include directive
   11 | #include <stack>;
      |                 ^
a.cc:15:1: error: 'vestor' does not name a type
   15 | vestor <int>point[100000];
      | ^~~~~~
a.cc: In function 'int dfs(int, int)':
a.cc:33:8: error: reference to 'end' is ambiguous
   33 |        end=now;
      |        ^~~
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:2:
/usr/include/c++/14/bits/range_access.h:116:37: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)'
  116 |   template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept;
      |                                     ^~~
/usr/include/c++/14/bits/range_access.h:115:31: note:                 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)'
  115 |   template<typename _Tp> _Tp* end(valarray<_Tp>&) noexcept;
      |                               ^~~
/usr/include/c++/14/bits/range_access.h:106:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])'
  106 |     end(_Tp (&__arr)[_Nm]) noexcept
      |     ^~~
/usr/include/c++/14/bits/range_access.h:85:5: note:                 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)'
   85 |     end(const _Container& __cont) -> decltype(__cont.end())
      |     ^~~
/usr/include/c++/14/bits/range_access.h:74:5: note:                 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)'
   74 |     end(_Container& __cont) -> decltype(__cont.end())
      |     ^~~
In file included from /usr/include/c++/14/bits/range_access.h:36:
/usr/include/c++/14/initializer_list:99:5: note:                 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)'
   99 |     end(initializer_list<_Tp> __ils) noexcept
      |     ^~~
a.cc:21:5: note:                 'int end'
   21 | int end;
      |     ^~~
a.cc:38:4: error: reference to 'queue' is ambiguous
   38 |    queue[size++]=Lve;
      |    ^~~~~
In file included from /usr/include/c++/14/queue:66,
                 from a.cc:6:
/usr/include/c++/14/bits/stl_queue.h:96:11: note: candidates are: 'template<class _Tp, class _Sequence> class std::queue'
   96 |     class queue
      |           ^~~~~
a.cc:25:5: note:                 'int queue [1000000]'
   25 | int queue[1000000];
      |     ^~~~~
a.cc:38:10: error: reference to 'size' is ambiguous
   38 |    queue[size++]=Lve;
      |          ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:26:5: note:                 'int size'
   26 | int size;
      |     ^~~~
a.cc:38:18: error: 'Lve' was not declared in this scope; did you mean 'Lev'?
   38 |    queue[size++]=Lve;
      |                  ^~~
      |                  Lev
a.cc:39:18: error: 'point' was not declared in this scope
   39 |    for(int i=0;i<point[now].size();i++)
      |                  ^~~~~
a.cc:43:4: error: reference to 'size' is ambiguous
   43 |    size--;
      |    ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:26:5: note:                 'int size'
   26 | int size;
      |     ^~~~
a.cc: In function 'void restrat(int)':
a.cc:49:3: error: reference to 'size' is ambiguous
   49 |   size=0;
      |   ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:26:5: note:                 'int size'
   26 | int size;
      |     ^~~~
a.cc:55:15: error: 'class std::vector<int>' has no member named 'claer'; did you mean 'clear'?
   55 |     qus[i][1].claer();
      |               ^~~~~
      |               clear
a.cc:56:5: error: 'point' was not declared in this scope
   56 |     point[i].clear();
      |     ^~~~~
a.cc: In function 'int main()':
a.cc:68:7: error: 'point' was not declared in this scope
   68 |       point[u].push_back(v);
      |       ^~~~~
a.cc:76:15: error: 'class std::stack<int>' has no member named 'clear'
   76 |       zhan[0].clear();
      |               ^~~~~
a.cc:77:15: error: 'class std::stack<int>' has no member named 'clear'
   77 |       zhan[1].clear();
      |               ^~~~~
a.cc:80:21: error: reference to 'size' is ambiguous
   80 |       for(int j=0;j<size;j++)
      |                     ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:26:5: note:                 'int size'
   26 | int size;
      |     ^~~~
a.cc:82:17: error: reference to 'queue' is ambiguous
   82 |          int mi=queue[j];
      |                 ^~~~~
/usr/include/c++/14/bits/stl_queue.h:96:11: note: candidates are: 'template<class _Tp, class _Sequence> class std::queue'
   96 |     class queue
      |           ^~~~~
a.cc:25:5: note:                 'int queue [1000000]'
   25 | int queue[1000000];
      |     ^~~~~
a.cc:83:49: error: reference to 'queue' is ambiguous
   83 |           while(zhan[0].size()>1 && zhan[0].top<queue[j])
      |                                                 ^~~~~
/usr/include/c++/14/bits/stl_queue.h:96:11: note: candidates are: 'template<class _Tp, class _Sequence> class std::queue'
   96 |     class queue
      |           ^~~~~
a.cc:25:5: note:                 'int queue [1000000]'
   25 | int queue[1000000];
      |     ^~~~~
a.cc:90:20: error: 'pop' was not declared in this scope; did you mean 'pow'?
   90 |            zhan[1],pop();
      |                    ^~~
      |                    pow
a.cc:93:18: error: reference to 'queue' is ambiguous
   93 |            u.str=queue[j];
      |                  ^~~~~
/usr/include/c++/14/bits/stl_queue.h:96:11: note: candidates are: 'template<class _Tp, class _Sequence> class std::queue'
   96 |     class queue
      |           ^~~~~
a.cc:25:5: note:                 'int queue [1000000]'
   25 | int queue[1000000];
      |     ^~~~~
a.cc:95:18: error: 'class std::vector<brige>' has no member named 'push'
   95 |            a[mi].push(u);
      |                  ^~~~
a.cc:96:25: error: reference to 'queue' is ambiguous
   96 |            zhan[0].push(queue[j]);
      |                         ^~~~~
/usr/include/c++/14/bits/stl_queue.h:96:11: note: candidates are: 'template<class _Tp, class _Sequence> class std::queue'
   96 |     class queue
      |           ^~~~~
a.cc:25:5: note:                 'int queue [1000000]'
   25 | int queue[1000000];
      |     ^~~~~
a.cc:97:25: error: reference to 'queue' is ambiguous
   97 |            zhan[1].push(queue[j]);
      |                         ^~~~~
/usr/include/c++/14/bits/stl_queue.h:96:11: note: candidates are: 'template<class _Tp, class _Sequence> class std::queue'
   96 |     class queue
      |           ^~~~~
a.cc:25:5: note:                 'int queue [1000000]'
   25 | int queue[1000000];
      |     ^~~~~
a.cc:99:15: error: 'class std::stack<int>' has no member named 'clear'
   99 |       zhan[0].clear();
      |               ^~~~~
a.cc:100:15: error: 'class std::stack<int>' has no member named 'clear'
  100 |       zhan[1].clear();
      |               ^~~~~
a.cc:101:20: error: reference to 'end' is ambiguous
  101 |       zhan[0].push(end);
      |                    ^~~
/usr/include/c++/14/bits/range_access.h:116:37: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)'
  116 |   template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept;
      |                                     ^~~
/usr/include/c++/14/bits/range_access.h:115:31: note:                 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)'
  115 |   template<typename _Tp> _Tp* end(valarray<_Tp>&) noexcept;
      |                               ^~~
/usr/include/c++/14/bits/range_access.h:106:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])'
  106 |     end(_Tp (&__arr)[_Nm]) noexcept
      |     ^~~
/usr/include/c++/14/bits/range_access.h:85:5: note:                 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)'
   85 |     end(const _Container& __cont) -> decltype(__cont.end())
      |     ^~~
/usr/include/c++/14/bits/range_access.h:74:5: note:                 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)'
   74 |     end(_Contain