Language: C++

#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define l first
#define r second

using namespace std;

const int maxn = 3e5 + 1;

int p[maxn];

bool eq(char c, char d) {
    if (c == '#' && c != d) return 0;
    if (d == '#' && c != d) return 0;
    return (c == '?' || d == '?' || c == d);
}

int solve(string a, string b, string c) {
    int ans = 14488;
    for (int i = 0; i <= a.size(); i++) {
        string t = a; bool fg = 1;
        for (int j = i; j < a.size(); j++)
            if (!eq(a[j], b[j - i])) {
                fg = 0; break;
            } else {
                if (a[j] == '?') t[j] = b[j - i];
                if (b[j - i] == '?') t[j] = a[j];
            }
        if (!fg) continue;
        for (int j = a.size() - i; j < b.size(); j++)
            t += b[j];
        string f = c + "#" + t;
        for (int j = 1; j < f.size(); j++) {
            p[j] = p[j - 1];
            while (p[j] && !eq(f[p[j]], f[j]))
                p[j] = p[p[j] - 1];
            if (eq(f[p[j]], f[j])) ++p[j];
        }
        for (int j = c.size(); j < f.size(); j++) {
            if (p[j] == c.size()) {
                ans = min(ans, (int)t.size());
                break;
            }
        }
        ans = min(ans, (int)t.size() + c.size() - p[f.size() - 1]);
    }
    return ans;
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    string a, b, c;
    cin >> a >> b >> c;
    int ans = 14488;
    ans = min(ans, solve(a, b, c));
    ans = min(ans, solve(a, c, b));
    ans = min(ans, solve(b, a, c));
    ans = min(ans, solve(b, c, a));
    ans = min(ans, solve(c, a, b));
    ans = min(ans, solve(c, b, a));
    cout << ans;
    return 0;
}


Compiler output:
a.cc: In function 'long long int solve(std::string, std::string, std::string)':
a.cc:46:18: error: no matching function for call to 'min(long long int&, long long unsigned int)'
   46 |         ans = min(ans, (int)t.size() + c.size() - p[f.size() - 1]);
      |               ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc: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:46:18: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long long unsigned int')
   46 |         ans = min(ans, (int)t.size() + c.size() - p[f.size() - 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
In file included from /usr/include/c++/14/algorithm:61:
/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:   candidate expects 1 argument, 2 provided
/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:   template argument deduction/substitution failed:
a.cc:46:18: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   46 |         ans = min(ans, (int)t.size() + c.size() - p[f.size() - 1]);
      |               ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~