Language: C++

#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <iomanip>
#include <stack>
  
using namespace std;

#define pi 3.141592653589793

int StrToInt(string str)
{
	int i, j, num = 0, ans = 0, l = str.length();
	for(i = l - 1; i >= 0; i--){
		if(isdigit(str[i])){
			num = str[i] - '0';
			for(j = 0; j < l - 1 - i; j++){
				num = num * 10;
			}
			ans += num;
		} else {
			ans = -1;
			break;
		}
	}
	return ans;
}

string IntToStr(int n)
{
	string s = "";
	int i = 0;
	while(n / (int)pow(10, i) != 0){
		i++;
	}
	for(int j = i - 1; j >= 0; j--){
		s += (n / (int)pow(10, j)) + '0';
	}
	return s;
}

string solve(string a[], int n)
{
	int xrange[2] = {-100000001, 100000001};
	// xのとりうる範囲
	int is_x_in[2] = {0, 0};
	// 0がtrue→偶数番目にxあり、1がtrue→奇数番目にxあり
	if(a[1] == "x"){
		if(a[2] == "x") return "none";
		else xrange[1] = min(StrToInt(a[2]), xrange[1]);
		is_x_in[1] = 1;
	}
	for(int i = 2; i < n; i++){
		if(a[i] == "x"){
			if(a[i - 1] == "x" || a[i + 1] == "x") return "none";
			else {
				is_x_in[i % 2] = 1;
				if(i % 2 == 0) xrange[0] = max(max(StrToInt(a[i - 1]), StrToInt(a[i + 1])), xrange[0]);
				else xrange[1] = min(min(StrToInt(a[i - 1]), StrToInt(a[i + 1])), xrange[1]);
			}
		} else if(a[i - 1] == "x" || a[i + 1] == "x") continue;
		else {
			if(i % 2 == 0 && max(StrToInt(a[i - 1], StrToInt(a[i + 1]))) >= a[i]) return "none";
			else if(i % 2 == 1 && min(StrToInt(a[i - 1], StrToInt(a[i + 1]))) <= a[i]) return "none";
		}
	}
	if(a[n] == "x"){
		if(a[n - 1] != "x"){
			if(n % 2 == 0){
				xrange[0] = max(StrToInt(a[n - 1]), xrange[0]);
				is_x_in[0] = 1;
			}
			else{
				xrange[1] = min(StrToInt(a[n - 1]), xrange[1]);
				is_x_in[1] = 1;
			}
		}
	}
	if(is_x_in[0] ^ is_x_in[1]) return "ambiguous";
	else if(!is_x_in[0] && !is_x_in[1]) return "ambiguous";
	else {
		if(xrange[1] - xrange[0] > 2) return "ambiguous";
		else if(xrange[1] - xrange[0] == 2) return IntToStr(xrange[1] - 1);
		else return "none";
	}
}

int main()
{
	int n;
	while(1){
		cin >> n;
		if(n == 0) break;
		string input[1001];
		for(int i = 1; i < n + 1; i++){
			cin >> input[i];
		}
		cout << solve(input, n) << endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'std::string solve(std::string*, int)':
a.cc:74:54: error: too many arguments to function 'int StrToInt(std::string)'
   74 |                         if(i % 2 == 0 && max(StrToInt(a[i - 1], StrToInt(a[i + 1]))) >= a[i]) return "none";
      |                                              ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:22:5: note: declared here
   22 | int StrToInt(string str)
      |     ^~~~~~~~
a.cc:74:45: error: no matching function for call to 'max(int)'
   74 |                         if(i % 2 == 0 && max(StrToInt(a[i - 1], StrToInt(a[i + 1]))) >= a[i]) return "none";
      |                                          ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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: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:   candidate expects 2 arguments, 1 provided
/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, 1 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:8:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   template argument deduction/substitution failed:
a.cc:74:45: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   74 |                         if(i % 2 == 0 && max(StrToInt(a[i - 1], StrToInt(a[i + 1]))) >= a[i]) return "none";
      |                                          ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   candidate expects 2 arguments, 1 provided
a.cc:75:59: error: too many arguments to function 'int StrToInt(std::string)'
   75 |                         else if(i % 2 == 1 && min(StrToInt(a[i - 1], StrToInt(a[i + 1]))) <= a[i]) return "none";
      |                                                   ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:22:5: note: declared here
   22 | int StrToInt(string str)
      |     ^~~~~~~~
a.cc:75:50: error: no matching function for call to 'min(int)'
   75 |                         else if(i % 2 == 1 && min(StrToInt(a[i - 1], StrToInt(a[i + 1]))) <= a[i]) return "none";
      |                                               ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:   candidate expects 2 arguments, 1 provided
/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, 1 provided
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   template argument deduction/substitution failed:
a.cc:75:50: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   75 |                         else if(i % 2 == 1 && min(StrToInt(a[i - 1], StrToInt(a[i + 1]))) <= a[i]) return "none";
      |                                               ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   candidate expects 2 arguments, 1 provided