제출 #1295153

#제출 시각아이디문제언어결과실행 시간메모리
1295153glupanThe Collection Game (BOI21_swaps)C++20
컴파일 에러
0 ms0 KiB
// // --- Sample implementation for the task swaps --- // // To compile this program with the sample grader, place: // swaps.h swaps_sample.cpp sample_grader.cpp // in a single folder and run: // g++ swaps_sample.cpp sample_grader.cpp // in this folder. // #include "swaps.h" #include <bits/stdc++.h> using namespace std; void solve(int N, int V) { int TMP=1; vector<int>idx; for(int i=1; i<=N; i++) idx.push_back(i); for(int v=1; v<=V; v++) { vector<int>vec; if(v%2) TMP=1; else TMP=2; for(int i=TMP; i<N; i+=2) { schedule(idx[i],idx[i+1]); vec.push_back({idx[i], idx[i+1]}); } vector<int> tmp = visit(); for(int i=0; i<vec.size(); i++) { if(tmp[i]) swap(idx[vec[i].first], idx[vec[i].second]); } } vector<int>Ans; for(int i=1; i<=N; i++) Ans.push_back(i); answer(Ans); }

컴파일 시 표준 에러 (stderr) 메시지

swaps.cpp: In function 'void solve(int, int)':
swaps.cpp:25:26: error: no matching function for call to 'std::vector<int>::push_back(<brace-enclosed initializer list>)'
   25 |             vec.push_back({idx[i], idx[i+1]});
      |             ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/vector:66,
                 from swaps.h:5,
                 from swaps.cpp:10:
/usr/include/c++/13/bits/stl_vector.h:1281:7: note: candidate: 'constexpr void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; value_type = int]'
 1281 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/13/bits/stl_vector.h:1281:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::vector<int>::value_type&' {aka 'const int&'}
 1281 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/13/bits/stl_vector.h:1298:7: note: candidate: 'constexpr void std::vector<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = int; _Alloc = std::allocator<int>; value_type = int]'
 1298 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/13/bits/stl_vector.h:1298:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<int>::value_type&&' {aka 'int&&'}
 1298 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
swaps.cpp:29:40: error: request for member 'first' in 'vec.std::vector<int>::operator[](((std::vector<int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   29 |             if(tmp[i]) swap(idx[vec[i].first], idx[vec[i].second]);
      |                                        ^~~~~
swaps.cpp:29:59: error: request for member 'second' in 'vec.std::vector<int>::operator[](((std::vector<int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   29 |             if(tmp[i]) swap(idx[vec[i].first], idx[vec[i].second]);
      |                                                           ^~~~~~