제출 #1289244

#제출 시각아이디문제언어결과실행 시간메모리
1289244iq500카멜레온의 사랑 (JOI20_chameleon)C++20
컴파일 에러
0 ms0 KiB
#include "chameleon.h"
#include <vector>
using namespace std;

void Solve(int N) {
    bool cnt[2*N+1]={0};
    vector<pair<int, int>> ans;
  /*std::vector<int> p(3);
  p[0] = 1;
  p[1] = 2;
  p[2] = 3;
  variable_example = Query(p);
  for (int i = 0; i < N; ++i) {
    Answer(i * 2 + 1, i * 2 + 2);
  }*/
    for(int i=1; i<=2*N; i++){
        if(cnt[i]) continue;
        for(int j=i+1; j<=2*N; j++){
            vector<int> q(2);
            q[0]=i; q[1]=j;
            int s=Query(q);
            if(s==1){
                cnt[i]=true;
                cnt[j]=true;
                ans.push_back(i, j);
                break;
            }
        }
    }
    for(int i=0; i<N; i++){
        Answer(ans[i].first, ans[i].second);
    }

}

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

chameleon.cpp: In function 'void Solve(int)':
chameleon.cpp:25:30: error: no matching function for call to 'std::vector<std::pair<int, int> >::push_back(int&, int&)'
   25 |                 ans.push_back(i, j);
      |                 ~~~~~~~~~~~~~^~~~~~
In file included from /usr/include/c++/13/vector:66,
                 from chameleon.h:5,
                 from chameleon.cpp:1:
/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 = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; value_type = std::pair<int, int>]'
 1281 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/13/bits/stl_vector.h:1281:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/13/bits/stl_vector.h:1298:7: note: candidate: 'constexpr void std::vector<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; value_type = std::pair<int, int>]'
 1298 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/13/bits/stl_vector.h:1298:7: note:   candidate expects 1 argument, 2 provided