QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#693363#5420. InscryptionUItace#Compile Error//C++202.0kb2024-10-31 16:01:172024-10-31 16:01:22

Judging History

你现在查看的是最新测评结果

  • [2024-10-31 16:01:22]
  • 评测
  • [2024-10-31 16:01:17]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;
#define int __int128
#define endl '\n'
typedef pair<int, int> pii;
const int inf = 1e9;
const int N = 2e5 + 5;

int read() {
    int x = 0, t = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9') {
        if (ch == '-')
            t = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9') {
        x = (x << 1) + (x << 3) + (ch ^ 48);
        ch = getchar();
    }
    return x * t;
}

void write(int x) {
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    if (x > 9) write(x / 10);
    putchar(x % 10 + '0');
}

void solve() {
    int n;
    n = read();
    vector<int> v(n + 1, 0);
    for (int i = 1; i <= n; ++i) v[i] = read();
    auto Max = [&](pii a, pii b) -> pii {
        if (a.first * b.second > b.first * a.second)return a;
        else return b;
    };
    int sum = 1, cnt = 1, zero = 0;
    for (int i = 1; i <= n; ++i) {
        if (v[i] == 1) ++sum, ++cnt;
        else if (!v[i]) ++zero;
        else {
            if (cnt == 1) {
                if (zero) --zero, ++sum;//1.
                else {
                    cout << -1 << endl;
                    return;
                }
            } else --cnt;
        }
    }
    pii res = {1, inf};
    for (int i = 0; i <= zero; ++i) {
        if (cnt + 2 * i - zero > 0) {
            pii tmp = {sum + i, cnt - zero + 2 * i};
            int tmpG = gcd(tmp.first, tmp.second);
            tmp.first /= tmpG, tmp.second /= tmpG;
            res = Max(res, tmp);
        }
    }
    int g = gcd(res.first, res.second);
    res.first /= g, res.second /= g;
    write(res.first), putchar(' '), write(res.second), putchar('\n');
//    cout << res.first << ' ' << res.second << endl;
}

signed main() {
//    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int _ = 1;
//    cin >> _;
    _ = read();
    while (_--) {
        solve();
    }

    return 0;
}

詳細信息

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:61:27:   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:61:27:   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;
      |           ^~~~~~~~~~~~~~~~~~~~~~~~