답안 #744144

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
744144 2023-05-18T08:34:21 Z salmon Izvanzemaljci (COI21_izvanzemaljci) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
vector<pair<int,int>> v;
vector<pair<int,int>> o;
int N,K;
int a,b;
int st[400100];

int main(){
    scanf(" %d",&N);
    scanf(" %d",&K);

    int smalla,smallb;
    int biga,bigb;

    for(int i = 0; i < N; i++){
        v.push_back(make_pair(a,b));
        o.push_back(make_pair(b,a));
    }

    sort(v.begin(),v.end());
    sort(o.begin(),o.end());

    int l = max(1,max(v[v.size() - 1].first - v[0].first, o[o.size() - 1].first - o[0].first));

    printf("%d %d %d",v[0].first,o[o].first,l);

}

Compilation message

izvanzemaljci.cpp: In function 'int main()':
izvanzemaljci.cpp:26:35: error: no match for 'operator[]' (operand types are 'std::vector<std::pair<int, int> >' and 'std::vector<std::pair<int, int> >')
   26 |     printf("%d %d %d",v[0].first,o[o].first,l);
      |                                   ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from izvanzemaljci.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1043:7: note: candidate: 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::reference = std::pair<int, int>&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]'
 1043 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1043:28: note:   no known conversion for argument 1 from 'std::vector<std::pair<int, int> >' to 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'}
 1043 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1061:7: note: candidate: 'std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) const [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::const_reference = const std::pair<int, int>&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]'
 1061 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1061:28: note:   no known conversion for argument 1 from 'std::vector<std::pair<int, int> >' to 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'}
 1061 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
izvanzemaljci.cpp:13:9: warning: unused variable 'smalla' [-Wunused-variable]
   13 |     int smalla,smallb;
      |         ^~~~~~
izvanzemaljci.cpp:13:16: warning: unused variable 'smallb' [-Wunused-variable]
   13 |     int smalla,smallb;
      |                ^~~~~~
izvanzemaljci.cpp:14:9: warning: unused variable 'biga' [-Wunused-variable]
   14 |     int biga,bigb;
      |         ^~~~
izvanzemaljci.cpp:14:14: warning: unused variable 'bigb' [-Wunused-variable]
   14 |     int biga,bigb;
      |              ^~~~
izvanzemaljci.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     scanf(" %d",&N);
      |     ~~~~~^~~~~~~~~~
izvanzemaljci.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     scanf(" %d",&K);
      |     ~~~~~^~~~~~~~~~