QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#484860#8651. Table TennisQwerty1232Compile Error//C++232.0kb2024-07-20 03:16:332024-07-20 03:16:33

Judging History

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

  • [2024-07-20 03:16:33]
  • 评测
  • [2024-07-20 03:16:33]
  • 提交

answer

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

int count(int n, const std::vector<std::vector<bool>> &data) {
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            for (int k = j + 1; k < n; k++) {
                if (data[i][j] == data[j][k] && data[j][k] == data[k][i]) {
                    cnt++;
                }
            }
        }
    }
    return cnt;
}

std::mt19937 rnd;

void solve() {
    int n, m;
    std::cin >> n >> m;
    std::vector<std::vector<bool>> ans(n, std::vector<bool>(n));
    if (m <= n - 2) {
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                ans[i][j] = (i == 0 && j == m + 1);
                ans[j][i] = !ans[i][j];
            }
        }
        std::cout << "Yes\n";
        for (int i = 1; i < n; i++) {
            for (int j = 0; j < i; j++) {
                std::cout << ans[i][j];
            }
            std::cout << std::endl;
        }
        return;
    }
    // assert(n <= 7);
    int cnt = n * (n - 1) / 2;
    for (int t = 0; t < 0.5e9 / pow(n, 3); t++) {
        int x = t;
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                int b = x & 1;
                x >>= 1;
                b = rnd() % 2;

                ans[i][j] = b;
                ans[j][i] = !b;
            }
        }
        int ct = count(n, ans);
        if (ct == m) {
            std::cout << "Yes\n";
            for (int i = 1; i < n; i++) {
                for (int j = 0; j < i; j++) {
                    std::cout << ans[i][j];
                }
                std::cout << std::endl;
            }
            return;
        }
    }
    std::cout << "No\n";
}

int32_t main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);

    int t;
    std::cin >> t;
    while (t--) {
        solve();
    }

    return 0;
}

Details

In file included from /usr/include/c++/13/string:43,
                 from /usr/include/c++/13/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:52,
                 from answer.code:3:
/usr/include/c++/13/bits/allocator.h: In destructor ‘constexpr std::_Bvector_base<std::allocator<bool> >::_Bvector_impl::~_Bvector_impl()’:
/usr/include/c++/13/bits/allocator.h:184:7: error: inlining failed in call to ‘always_inline’ ‘constexpr std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = long unsigned int]’: target specific option mismatch
  184 |       ~allocator() _GLIBCXX_NOTHROW { }
      |       ^
In file included from /usr/include/c++/13/vector:67,
                 from /usr/include/c++/13/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:53:
/usr/include/c++/13/bits/stl_bvector.h:557:14: note: called from here
  557 |       struct _Bvector_impl
      |              ^~~~~~~~~~~~~