Language: C++

#include <cstdint>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

bool is_valid(vector<string> signals) {
  for (uint32_t i = 0; i < signals.size() - 1; i++) {
    if (signals[i] == "x" && signals[i + 1] == "x") {
      return false;
    }
    if (signals[i] != "x" && signals[i + 1] != "x") {
      int32_t sig1 = stoi(signals[i]);
      int32_t sig2 = stoi(signals[i + 1]);
      if (i % 2 == 0) {
        if (sig1 >= sig2) {
          return false;
        }
      } else {
        if (sig1 <= sig2) {
          return false;
        }
      }
    }
  }
  return true;
}

int32_t main() {
  while (true) {
    uint32_t N;
    cin >> N;

    if (N == 0) break;

    vector<string> signals;
    for (uint32_t i = 0; i < N; i++) {
      string str;
      cin >> str;
      signals.push_back(str);
    }

    int64_t x_max = INT64_MIN;
    int64_t x_min = INT64_MAX;
    bool valid = true;
    if (valid = is_valid(signals)) {
      for (uint32_t i = 0; i < signals.size(); i++) {
        if (signals[i] == "x") {
          if (i % 2 == 0) {
            if (i > 0) {
              x_min = min(x_min, stoll(signals[i - 1]) - 1);
            }
            if (i + 1 < signals.size()) {
              x_min = min(x_min, stoll(signals[i + 1]) - 1);
            }
          } else {
            if (i > 0) {
              x_max = max(x_max, stoll(signals[i - 1]) + 1);
            }
            if (i + 1 < signals.size()) {
              x_max = max(x_max, stoll(signals[i + 1]) + 1);
            }
          }
        }
      }
    }

    if (valid) {
      if (x_max == x_min) {
        cout << x_max << endl;
      } else if (x_max == INT64_MIN || x_min == INT64_MAX) {
        cout << "ambiguous" << endl;
      } else {
        cout << "none" << endl;
      }
    } else {
      cout << "none" << endl;
    }
  }

  return 0;
}

Compiler output:
a.cc: In function 'int32_t main()':
a.cc:52:26: error: no matching function for call to 'min(int64_t&, long long int)'
   52 |               x_min = min(x_min, stoll(signals[i - 1]) - 1);
      |                       ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 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/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:52:26: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int')
   52 |               x_min = min(x_min, stoll(signals[i - 1]) - 1);
      |                       ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
a.cc:55:26: error: no matching function for call to 'min(int64_t&, long long int)'
   55 |               x_min = min(x_min, stoll(signals[i + 1]) - 1);
      |                       ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:55:26: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int')
   55 |               x_min = min(x_min, stoll(signals[i + 1]) - 1);
      |                       ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
a.cc:59:26: error: no matching function for call to 'max(int64_t&, long long int)'
   59 |               x_max = max(x_max, stoll(signals[i - 1]) + 1);
      |                       ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:59:26: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int')
   59 |               x_max = max(x_max, stoll(signals[i - 1]) + 1);
      |                       ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
a.cc:62:26: error: no matching function for call to 'max(int64_t&, long long int)'
   62 |               x_max = max(x_max, stoll(signals[i + 1]) + 1);
      |                       ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:62:26: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int')
   62 |               x_max = max(x_max, stoll(signals[i + 1]) + 1);
      |                       ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided