QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#650617#8278. Secret Poemsshiqiaqiaya#Compile Error//C++202.9kb2024-10-18 15:51:102024-10-18 15:51:11

Judging History

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

  • [2024-10-18 15:51:11]
  • 评测
  • [2024-10-18 15:51:10]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long

void QAQ() {
    int n;
    cin >> n;

    vector<string> a(n);
    for (auto & x : a) {
        cin >> x;
    }

    vector<array<int, 2>> D = {{0, 1}, {1, -1}, {1, 0}, {-1, 1}};

    string t;

    t += a[0][0];
    t += a[0][1];

    for (int i = 0, j = 1; ; ) {
        int fl = 0;
        for ( ; ; ) {
            i += D[1][0], j += D[1][1];
            t += a[i][j];
            if (t.size() >= n * n) {
                fl = 1;
                break;
            }
            if (i == n - 1) {
                i += D[0][0], j += D[0][1];
                t += a[i][j];
                if (t.size() >= n * n) {
                    fl = 1;
                    break;
                }
                if (i < 0 || j < 0 || i >= n || j >= n) fl = 1;
                break;
            } else if (j == 0) {
                i += D[2][0], j += D[2][1];
                t += a[i][j];
                if (t.size() >= n * n) {
                    fl = 1;
                    break;
                }
                if (i < 0 || j < 0 || i >= n || j >= n) fl = 1;
                break;
            }
        }
        if (fl) break;
        for ( ; ; ) {
            i += D[3][0], j += D[3][1];
            t += a[i][j];
            if (t.size() >= n * n) {
                fl = 1;
                break;
            }
            if (j == n - 1) {
                i += D[2][0], j += D[2][1];
                t += a[i][j];
                if (t.size() >= n * n) {
                    fl = 1;
                    break;
                }
                if (i < 0 || j < 0 || i >= n || j >= n) fl = 1;
                break;
            } else if (i == 0) {
                i += D[0][0], j += D[0][1];
                t += a[i][j];
                if (t.size() >= n * n) {
                    fl = 1;
                    break;
                }
                if (i < 0 || j < 0 || i >= n || j >= n) fl = 1;
                break;
            }
        }
        if (fl) break;
    }

    D = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};

    vector ans(n, vector<char>(n, ' '));
    for (int i = 0, j = 0, idx = 0, op = 0; idx < t.size(); idx++) {
        ans[i][j] = t[idx];
        if (idx + 1 == t.size()) break;
        auto [dx, dy] = D[op];
        int ti = dx + i, tj = dy + j;
        while (ti < 0 || tj < 0 || ti >= n || tj >= n || ans[ti][tj] != ' ') {
            (op += 1) %= 4;
            tie(dx, dy) = D[op];
            ti = dx + i, tj = dy + j;
        }
        i += dx, j += dy;
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cout << ans[i][j];
        }
        cout << "\n";
    }
}

signed main() {
    cin.tie(0) -> sync_with_stdio(0);
    int t = 1;
    // cin >> t;

    while (t--) {
        QAQ();
    }
}

详细

answer.code: In function ‘void QAQ()’:
answer.code:91:31: error: no match for ‘operator=’ (operand types are ‘std::tuple<long long int&, long long int&>’ and ‘__gnu_cxx::__alloc_traits<std::allocator<std::array<long long int, 2> >, std::array<long long int, 2> >::value_type’ {aka ‘std::array<long long int, 2>’})
   91 |             tie(dx, dy) = D[op];
      |                               ^
In file included from /usr/include/c++/13/bits/uses_allocator_args.h:38,
                 from /usr/include/c++/13/bits/memory_resource.h:41,
                 from /usr/include/c++/13/string:58,
                 from /usr/include/c++/13/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:52,
                 from answer.code:1:
/usr/include/c++/13/tuple:1628:9: note: candidate: ‘template<class _U1, class _U2> constexpr std::__enable_if_t<__assignable<const _U1&, const _U2&>(), std::tuple<_T1, _T2>&> std::tuple<_T1, _T2>::operator=(const std::tuple<_U1, _U2>&) [with _U2 = _U1; _T1 = long long int&; _T2 = long long int&]’
 1628 |         operator=(const tuple<_U1, _U2>& __in)
      |         ^~~~~~~~
/usr/include/c++/13/tuple:1628:9: note:   template argument deduction/substitution failed:
answer.code:91:31: note:   ‘__gnu_cxx::__alloc_traits<std::allocator<std::array<long long int, 2> >, std::array<long long int, 2> >::value_type’ {aka ‘std::array<long long int, 2>’} is not derived from ‘const std::tuple<_T1, _T2>’
   91 |             tie(dx, dy) = D[op];
      |                               ^
/usr/include/c++/13/tuple:1638:9: note: candidate: ‘template<class _U1, class _U2> constexpr std::__enable_if_t<__assignable<_U1, _U2>(), std::tuple<_T1, _T2>&> std::tuple<_T1, _T2>::operator=(std::tuple<_U1, _U2>&&) [with _U2 = _U1; _T1 = long long int&; _T2 = long long int&]’
 1638 |         operator=(tuple<_U1, _U2>&& __in)
      |         ^~~~~~~~
/usr/include/c++/13/tuple:1638:9: note:   template argument deduction/substitution failed:
answer.code:91:31: note:   ‘__gnu_cxx::__alloc_traits<std::allocator<std::array<long long int, 2> >, std::array<long long int, 2> >::value_type’ {aka ‘std::array<long long int, 2>’} is not derived from ‘std::tuple<_T1, _T2>’
   91 |             tie(dx, dy) = D[op];
      |                               ^
/usr/include/c++/13/tuple:1686:9: note: candidate: ‘template<class _U1, class _U2> constexpr std::__enable_if_t<__assignable<const _U1&, const _U2&>(), std::tuple<_T1, _T2>&> std::tuple<_T1, _T2>::operator=(const std::pair<_U1, _U2>&) [with _U2 = _U1; _T1 = long long int&; _T2 = long long int&]’
 1686 |         operator=(const pair<_U1, _U2>& __in)
      |         ^~~~~~~~
/usr/include/c++/13/tuple:1686:9: note:   template argument deduction/substitution failed:
answer.code:91:31: note:   ‘__gnu_cxx::__alloc_traits<std::allocator<std::array<long long int, 2> >, std::array<long long int, 2> >::value_type’ {aka ‘std::array<long long int, 2>’} is not derived from ‘const std::pair<_T1, _T2>’
   91 |             tie(dx, dy) = D[op];
      |                               ^
/usr/include/c++/13/tuple:1697:9: note: candidate: ‘template<class _U1, class _U2> constexpr std::__enable_if_t<__assignable<_U1, _U2>(), std::tuple<_T1, _T2>&> std::tuple<_T1, _T2>::operator=(std::pair<_U1, _U2>&&) [with _U2 = _U1; _T1 = long long int&; _T2 = long long int&]’
 1697 |         operator=(pair<_U1, _U2>&& __in)
      |         ^~~~~~~~
/usr/include/c++/13/tuple:1697:9: note:   template argument deduction/substitution failed:
answer.code:91:31: note:   ‘__gnu_cxx::__alloc_traits<std::allocator<std::array<long long int, 2> >, std::array<long long int, 2> >::value_type’ {aka ‘std::array<long long int, 2>’} is not derived from ‘std::pair<_T1, _T2>’
   91 |             tie(dx, dy) = D[op];
      |                               ^
/usr/include/c++/13/tuple:1605:7: note: candidate: ‘constexpr std::tuple<_T1, _T2>& std::tuple<_T1, _T2>::operator=(std::__conditional_t<__assignable<const _T1&, const _T2&>(), const std::tuple<_T1, _T2>&, const std::__nonesuch&>) [with _T1 = long long int&; _T2 = long long int&; std::__conditional_t<__assignable<const _T1&, const _T2&>(), const std::tuple<_T1, _T2>&, const std::__nonesuch&> = const std::tuple<long long int&, long long int&>&]’
 1605 |       operator=(__conditional_t<__assignable<const _T1&, const _T2&>(),
      |       ^~~~~~~~
/usr/include/c++/13/tuple:1607:52: note:   no known conversion for argument 1 from ‘__gnu_cxx::__alloc_traits<std::allocator<std::array<long long int, 2> >, std::array<long long int, 2> >::value_type’ {aka ‘std::array<long long int, 2>’} to ‘std::__conditional_t<true, const std::tuple<long long int&, long long int&>&, const std::__nonesuch&>’ {aka ‘const std::tuple<long long int&, long long int&>&’}
 1605 |       operator=(__conditional_t<__assignable<const _T1&, const _T2&>(),
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1606 |                                 const tuple&,
      |         ...