QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#783661#9810. Obliviate, Then ReincarnatekonbiCompile Error//C++202.2kb2024-11-26 11:14:302024-11-26 11:14:37

Judging History

This is the latest submission verdict.

  • [2024-11-26 23:19:26]
  • hack成功,自动添加数据
  • (/hack/1260)
  • [2024-11-26 11:14:37]
  • Judged
  • [2024-11-26 11:14:30]
  • Submitted

answer

#include <bits/stdc++.h>
#define fi first 
#define se second
using namespace std;
#define pb push_back
#define ls (u << 1)
#define rs (u << 1 | 1)

typedef long long LL;
typedef pair<__uint128_t, __uint128_t> PII;

// #define debug(args...) {}
#define debug(args...) { \
     string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
     stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); cout << '\n';}
void err(istream_iterator<string> it){}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << ' ';
    err(++it, args...);
}

void print(__int128 x) {
    if (x / 10) print(x / 10);
    cout << (int)(x % 10);
}

void solve() {
    int n; cin >> n;
    vector<LL> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i]; 
        int _; cin >> _;
    }
    sort(a.begin(), a.end());
    a.erase(unique(a.begin(), a.end()), a.end());
    auto query = [&](LL a, LL b = 1)->PII {
        cout << "? " << a << ' ' << b << endl;
        LL c, d; cin >> c >> d;
        return {c, d};
    };
    
    PII res = {0, 1};

    auto plus = [&](PII x, PII y)->PII {
        auto [a, b] = x;
        auto [c, d] = y;
        __int128 na = a * d + b * c;
        __int128 nb = b * d;
        __int128 nd = gcd(na, nb);
        na /= nd; nb /= nd;
        return {na, nb};
    };

    auto cal = [&](PII lst, PII now, LL h)->PII {
        PII p = plus(lst, now);
        auto [a, b] = p;
        a = a * h;
        b = b * 2;
        __int128 d = gcd(a, b);
        a /= d; b /= d;
        return {a, b};
    };

    PII lst = query(a[0]);
    for (int i = 1; i < a.size(); i++) {
        PII now = query(a[i]);
        LL h = a[i] - a[i - 1];
        PII ret = cal(lst, now, h);
        res = plus(res, ret);
        lst = now;
    }
    cout << "! ";
    print(res.fi);
    cout << ' ';
    print(res.se);
    cout << endl;

}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int tt = 1; cin >> tt;
    while (tt--) solve();
    return 0;
}
/*
g++ std.cpp -Wall --extra -o std && ./std < in.txt > out.txt
*/

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:50:26:   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:50:26:   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 unsigned; _Nn = __int128 unsigned; common_type_t<_Tp1, _Tp2> = __int128 unsigned]’:
answer.code:60:25:   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 unsigned>’ evaluates to false
/usr/include/c++/13/type_traits: In instantiation of ‘struct std::make_unsigned<__int128 unsigned>’:
/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 unsigned]’
/usr/include/c++/13/numeric:173:24:   required from ‘constexpr std::common_type_t<_Tp1, _Tp2> std::gcd(_Mn, _Nn) [with _Mn = __int128 unsigned; _Nn = __int128 unsigned; common_type_t<_Tp1, _Tp2> = __int128 unsigned]’
answer.code:60:25:   required from here
/usr/include/c++/13/type_traits:1836:62: error: invalid use of incomplete type ‘class std::__make_unsigned_selector<__int128 unsigned, 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 unsigned, false, false>’
 1744 |     class __make_unsigned_selector;
      |           ^~~~~~~~~~~~~~~~~~~~~~~~