QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#625736#8708. PortalDimashCompile Error//C++231.4kb2024-10-09 20:46:062024-10-09 20:46:06

Judging History

This is the latest submission verdict.

  • [2024-10-09 20:46:06]
  • Judged
  • [2024-10-09 20:46:06]
  • Submitted

answer

#include <bits/stdc++.h>
    
using namespace std;
    
// typedef long long ll;
const int  N = 3e5 + 12, MOD = (int)1e9 + 7;

using ll = __int128_t;
int n, x[N], y[N];
ll G = 0;
vector<array<ll, 2>> a;

array<ll, 2> Gcd(array<ll, 2> c,array<ll, 2> d) {
    if(!c[0]) {
        G = gcd(G, c[1]);
        return d;
    }
    if(!d[0]) {
        G = gcd(G, d[1]);
        return c;
    }
    if(c[0] < d[0]) {
        swap(c, d);
    }
    ll col = c[0] / d[0];
    c[0] -= col * 1ll * d[0];
    c[1] -= col * 1ll * d[1];
    return Gcd(c, d);
}
void test() {
    cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> x[i] >> y[i];
    }
    for(int i = 2; i <= n; i++) {
        if(x[i] == x[i - 1]) {
            G = gcd(G, y[i] - y[i - 1]);
            continue;
        }
        if(x[i] > x[i - 1]) {
            a.push_back({x[i] - x[i - 1], y[i] - y[i - 1]});
        } else {
            a.push_back({x[i - 1] - x[i], y[i - 1] - y[i]});
        }
    }
    while((int)a.size() >= 2) {
        auto i = a.back();
        a.pop_back();
        auto k = Gcd(i, a[0]);
        a[0] = k;
    }
    assert(G);
    if(a.empty() || !a[0][0] ) {
        cout << -1 << '\n';
        return;
    }
    long long res = G * a[0][0];
    cout << res << '\n';
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); 

    int t = 1; 
    // cin >> t;

    while(t--) 
        test();

    return 0;
}

Details

In file included from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:58,
                 from answer.code:1:
/usr/include/c++/13/numeric: In instantiation of ‘constexpr std::common_type_t<_Tp1, _Tp2> std::gcd(_Mn, _Nn) [with _Mn = __int128; _Nn = __int128; common_type_t<_Tp1, _Tp2> = __int128]’:
answer.code:15:16:   required from here
/usr/include/c++/13/numeric:166:21: error: static assertion failed: std::gcd arguments must be integers
  166 |       static_assert(is_integral_v<_Mn> && is_integral_v<_Nn>,
      |                     ^~~~~~~~~~~~~~~~~~
/usr/include/c++/13/numeric:166:21: note: ‘std::is_integral_v<__int128>’ evaluates to false
In file included from /usr/include/c++/13/bits/stl_pair.h:60,
                 from /usr/include/c++/13/bits/stl_algobase.h:64,
                 from /usr/include/c++/13/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51:
/usr/include/c++/13/type_traits: In instantiation of ‘struct std::make_unsigned<__int128>’:
/usr/include/c++/13/type_traits:1983:11:   required by substitution of ‘template<class _Tp> using std::make_unsigned_t = typename std::make_unsigned::type [with _Tp = __int128]’
/usr/include/c++/13/numeric:173:24:   required from ‘constexpr std::common_type_t<_Tp1, _Tp2> std::gcd(_Mn, _Nn) [with _Mn = __int128; _Nn = __int128; common_type_t<_Tp1, _Tp2> = __int128]’
answer.code:15:16:   required from here
/usr/include/c++/13/type_traits:1836:62: error: invalid use of incomplete type ‘class std::__make_unsigned_selector<__int128, false, false>’
 1836 |     { typedef typename __make_unsigned_selector<_Tp>::__type type; };
      |                                                              ^~~~
/usr/include/c++/13/type_traits:1744:11: note: declaration of ‘class std::__make_unsigned_selector<__int128, false, false>’
 1744 |     class __make_unsigned_selector;
      |           ^~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/numeric: In instantiation of ‘constexpr std::common_type_t<_Tp1, _Tp2> std::gcd(_Mn, _Nn) [with _Mn = __int128; _Nn = int; common_type_t<_Tp1, _Tp2> = __int128]’:
answer.code:37:20:   required from here
/usr/include/c++/13/numeric:166:21: error: static assertion failed: std::gcd arguments must be integers
  166 |       static_assert(is_integral_v<_Mn> && is_integral_v<_Nn>,
      |                     ^~~~~~~~~~~~~~~~~~
/usr/include/c++/13/numeric:166:21: note: ‘std::is_integral_v<__int128>’ evaluates to false