Language: C++

#include <iostream>
#include <string>
#define INF 2000000000
#define N 1002
using namespace std;
void Bynary_Search(int,int);
int Judge(int);
string str[N];
int n,data[N];

int main(){
  while(1){
    cin>>n;
    if(!n) break;
    data[0]=INF;
    if(n%2) data[n+1]=INF;
    else data[n+1]=-INF;
    for(int i=1;i<=n;i++){
      cin>>str[i];
      if(str[i]=="x") continue;
      data[i]=stoi(str[i]);
    }
    Bynary_Search(-1000000003,1000000003);
  }
  return 0;
}

void Bynary_Search(int l,int r){
  int m;
  while(l+1<r){
    m=(int)((long long)(l+r)/2);
    if(Judge(m)==-2) break;
    else if(Judge(m)<0) l=m;
    else if(Judge(m)>0) r=m;
    else{
      if(!Judge(m-1)||!Judge(m+1)){
	cout<<"ambiguous"<<endl;
      }else cout<<m<<endl;
      return ;
    }
  }
  cout<<"none"<<endl;
}

int Judge(int d){
  int judge[N];
  for(int i=1;i<=n;i++){
    if(str[i]=="x") judge[i]=d;
    else judge[i]=data[i];
  }
  for(int i=1;i<=n;i++)
    if(str[i]!="x"&&str[i+1]!="x")
      if(((i%2)&&judge[i]>=judge[i+1])||(!(i%2)&&judge[i]<=judge[i+1])) return -2;
  for(int i=1;i<=n;i++){
    if(str[i]!="x") continue;
    if((i%2)&&(judge[i-1]<=judge[i]||judge[i]>=judge[i+1])) return 1;
    if(!(i%2)&&(judge[i-1]>=judge[i]||judge[i]<=judge[i+1])) return -1;
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:5: error: reference to 'data' is ambiguous
   15 |     data[0]=INF;
      |     ^~~~
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:1:
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:9:7: note:                 'int data [1002]'
    9 | int n,data[N];
      |       ^~~~
a.cc:16:13: error: reference to 'data' is ambiguous
   16 |     if(n%2) data[n+1]=INF;
      |             ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:9:7: note:                 'int data [1002]'
    9 | int n,data[N];
      |       ^~~~
a.cc:17:10: error: reference to 'data' is ambiguous
   17 |     else data[n+1]=-INF;
      |          ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:9:7: note:                 'int data [1002]'
    9 | int n,data[N];
      |       ^~~~
a.cc:21:7: error: reference to 'data' is ambiguous
   21 |       data[i]=stoi(str[i]);
      |       ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:9:7: note:                 'int data [1002]'
    9 | int n,data[N];
      |       ^~~~
a.cc: In function 'int Judge(int)':
a.cc:49:19: error: reference to 'data' is ambiguous
   49 |     else judge[i]=data[i];
      |                   ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:9:7: note:                 'int data [1002]'
    9 | int n,data[N];
      |       ^~~~