QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#821262#8934. Challenge NPCSuzuranovo#Compile Error//C++231.0kb2024-12-19 14:48:332024-12-19 14:48:34

Judging History

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

  • [2024-12-19 14:48:34]
  • 评测
  • [2024-12-19 14:48:33]
  • 提交

answer

#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

void solve() {
    int k; cin >> k;
    int cur = 1;
    vector<int> co = { 0 };
    vector<array<int, 2>> side; side.reserve(k * k * 4);
    // vector<int> lv = { 0 };
    vector<array<int, 2>> pos = { {0,0} };
    for (int i = 1; i <= k + 2; ++i) {
        // 每次暴力构造两个点
        pos.push_back({ cur,cur + 1 });
        co.push_back(0); co.push_back(1);
        for (int i = 1; i <= cur / 2; ++i) {
            side.push_back({ cur, pos[i][1] });
        }
        for (int i = 1; i <= cur / 2; ++i) {
            side.push_back({ cur + 1,pos[i][0] });
        }
        cur += 2;
    }
    cout << cur - 1 << ' ' << side.size() << " 2 \n";
    for (int i = 1; i < cur; ++i)
        cout << co[i] + 1 << " \n"[i == cur - 1];
    for (auto [x, y] : side)
        cout << x << " " << y << '\n';
}

int main() {
    cin.tie(nullptr)->sync_with_stdio(0);
    solve();
    return 0;
}

Details

answer.code: In function ‘void solve()’:
answer.code:13:41: error: could not convert ‘{{0, 0}}’ from ‘<brace-enclosed initializer list>’ to ‘std::vector<std::array<int, 2> >’
   13 |     vector<array<int, 2>> pos = { {0,0} };
      |                                         ^
      |                                         |
      |                                         <brace-enclosed initializer list>
answer.code:16:22: error: no matching function for call to ‘std::vector<std::array<int, 2> >::push_back(<brace-enclosed initializer list>)’
   16 |         pos.push_back({ cur,cur + 1 });
      |         ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/vector:66,
                 from answer.code:2:
/usr/include/c++/13/bits/stl_vector.h:1278:7: note: candidate: ‘constexpr void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::array<int, 2>; _Alloc = std::allocator<std::array<int, 2> >; value_type = std::array<int, 2>]’
 1278 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/13/bits/stl_vector.h:1278:35: note:   no known conversion for argument 1 from ‘<brace-enclosed initializer list>’ to ‘const std::vector<std::array<int, 2> >::value_type&’ {aka ‘const std::array<int, 2>&’}
 1278 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/13/bits/stl_vector.h:1295:7: note: candidate: ‘constexpr void std::vector<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = std::array<int, 2>; _Alloc = std::allocator<std::array<int, 2> >; value_type = std::array<int, 2>]’
 1295 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/13/bits/stl_vector.h:1295:30: note:   no known conversion for argument 1 from ‘<brace-enclosed initializer list>’ to ‘std::vector<std::array<int, 2> >::value_type&&’ {aka ‘std::array<int, 2>&&’}
 1295 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
answer.code:19:41: error: no match for ‘operator[]’ (operand types are ‘__gnu_cxx::__alloc_traits<std::allocator<std::array<int, 2> >, std::array<int, 2> >::value_type’ {aka ‘std::array<int, 2>’} and ‘int’)
   19 |             side.push_back({ cur, pos[i][1] });
      |                                         ^
answer.code:19:27: error: no matching function for call to ‘std::vector<std::array<int, 2> >::push_back(<brace-enclosed initializer list>)’
   19 |             side.push_back({ cur, pos[i][1] });
      |             ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_vector.h:1278:7: note: candidate: ‘constexpr void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::array<int, 2>; _Alloc = std::allocator<std::array<int, 2> >; value_type = std::array<int, 2>]’
 1278 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/13/bits/stl_vector.h:1278:35: note:   no known conversion for argument 1 from ‘<brace-enclosed initializer list>’ to ‘const std::vector<std::array<int, 2> >::value_type&’ {aka ‘const std::array<int, 2>&’}
 1278 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/13/bits/stl_vector.h:1295:7: note: candidate: ‘constexpr void std::vector<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = std::array<int, 2>; _Alloc = std::allocator<std::array<int, 2> >; value_type = std::array<int, 2>]’
 1295 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/13/bits/stl_vector.h:1295:30: note:   no known conversion for argument 1 from ‘<brace-enclosed initializer list>’ to ‘std::vector<std::array<int, 2> >::value_type&&’ {aka ‘std::array<int, 2>&&’}
 1295 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
answer.code:22:44: error: no match for ‘operator[]’ (operand types are ‘__gnu_cxx::__alloc_traits<std::allocator<std::array<int, 2> >, std::array<int, 2> >::value_type’ {aka ‘std::array<int, 2>’} and ‘int’)
   22 |             side.push_back({ cur + 1,pos[i][0] });
      |                                            ^
answer.code:22:27: error: no matching function for call to ‘std::vector<std::array<int, 2> >::push_back(<brace-enclosed initializer list>)’
   22 |             side.push_back({ cur + 1,pos[i][0] });
      |             ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_vector.h:1278:7: note: candidate: ‘constexpr void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::array<int, 2>; _Alloc = std::allocator<std::array<int, 2> >; value_type = std::array<int, 2>]’
 1278 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/13/bits/stl_vector.h:1278:35: note:   no known conversion for argument 1 from ‘<brace-enclosed initializer list>’ to ‘const std::vector<std::array<int, 2> >::value_type&’ {aka ‘const std::array<int, 2>&’}
 1278 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/13/bits/st...