제출 #1289240

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

namespace {

int variable_example = 1;

}  // namespace

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++){
            std::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:12:12: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
   12 |     vector<pair<int, int>> ans;
      |            ^~~~
      |            std::pair
In file included from /usr/include/c++/13/bits/stl_algobase.h:64,
                 from /usr/include/c++/13/vector:62,
                 from chameleon.h:5,
                 from chameleon.cpp:1:
/usr/include/c++/13/bits/stl_pair.h:187:12: note: 'std::pair' declared here
  187 |     struct pair
      |            ^~~~
chameleon.cpp:12:5: error: 'vector' was not declared in this scope
   12 |     vector<pair<int, int>> ans;
      |     ^~~~~~
chameleon.cpp:12:5: note: suggested alternatives:
In file included from /usr/include/c++/13/vector:66:
/usr/include/c++/13/bits/stl_vector.h:428:11: note:   'std::vector'
  428 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
/usr/include/c++/13/vector:86:13: note:   'std::pmr::vector'
   86 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
chameleon.cpp:12:17: error: expected primary-expression before 'int'
   12 |     vector<pair<int, int>> ans;
      |                 ^~~
chameleon.cpp:30:17: error: 'ans' was not declared in this scope
   30 |                 ans.push_back(i, j);
      |                 ^~~
chameleon.cpp:36:16: error: 'ans' was not declared in this scope
   36 |         Answer(ans[i].first, ans[i].second);
      |                ^~~