제출 #1367009

#제출 시각아이디문제언어결과실행 시간메모리
1367009eyadooz저울 (IOI15_scales)C++20
컴파일 에러
0 ms0 KiB
#include "scales.h"
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int) (x).size()
#define endl '\n'


void init(int T) {
    /* ... */
}

void orderCoins() {
    int W[] = {1, 2, 3, 4, 5, 6};
    vector<int> a, b;
    a.pb(getLightest(1, 2, 3));  
    a.pb(getMedian(1, 2, 3));  
    a.pb(getHeaviest(1, 2, 3));
    b.pb(getLightest(4, 5, 6));  
    b.pb(getMedian(4, 5, 6));  
    b.pb(getHeaviest(4, 5, 6));
    vector<int> s;
    while(min(sz(a), sz(b))>=1&&sz(a)+sz(b)>=3) {
        if(sz(a)<sz(b)) swap(a, b);
        auto it=getLightest(a[0], a[1], b[0]);
        s.pb(it);
        a.erase(it);
        b.erase(it);
    }
    if(sz(a)&&sz(b)) {
        auto it=getMedian(a[0], b[0], s.back());
        s.pb(it);
        if(sz(a)) s.pb(a.back());
        else s.pb(b.back());
        return s;
    }
    else {
        reverse(all(a));
        reverse(all(b));
        while(sz(a)) s.pb(a.back()), a.pop_back();
        while(sz(b)) s.pb(b.back()), b.pop_back();
    }
    answer(s);
}
    

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

scales.cpp: In function 'void orderCoins()':
scales.cpp:33:16: error: no matching function for call to 'std::vector<int>::erase(int&)'
   33 |         a.erase(it);
      |         ~~~~~~~^~~~
In file included from /usr/include/c++/13/vector:66,
                 from /usr/include/c++/13/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:53,
                 from scales.cpp:2:
/usr/include/c++/13/bits/stl_vector.h:1534:7: note: candidate: 'constexpr std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::erase(const_iterator) [with _Tp = int; _Alloc = std::allocator<int>; iterator = std::vector<int>::iterator; const_iterator = std::vector<int>::const_iterator]'
 1534 |       erase(const_iterator __position)
      |       ^~~~~
/usr/include/c++/13/bits/stl_vector.h:1534:28: note:   no known conversion for argument 1 from 'int' to 'std::vector<int>::const_iterator'
 1534 |       erase(const_iterator __position)
      |             ~~~~~~~~~~~~~~~^~~~~~~~~~
/usr/include/c++/13/bits/stl_vector.h:1562:7: note: candidate: 'constexpr std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::erase(const_iterator, const_iterator) [with _Tp = int; _Alloc = std::allocator<int>; iterator = std::vector<int>::iterator; const_iterator = std::vector<int>::const_iterator]'
 1562 |       erase(const_iterator __first, const_iterator __last)
      |       ^~~~~
/usr/include/c++/13/bits/stl_vector.h:1562:7: note:   candidate expects 2 arguments, 1 provided
scales.cpp:34:16: error: no matching function for call to 'std::vector<int>::erase(int&)'
   34 |         b.erase(it);
      |         ~~~~~~~^~~~
/usr/include/c++/13/bits/stl_vector.h:1534:7: note: candidate: 'constexpr std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::erase(const_iterator) [with _Tp = int; _Alloc = std::allocator<int>; iterator = std::vector<int>::iterator; const_iterator = std::vector<int>::const_iterator]'
 1534 |       erase(const_iterator __position)
      |       ^~~~~
/usr/include/c++/13/bits/stl_vector.h:1534:28: note:   no known conversion for argument 1 from 'int' to 'std::vector<int>::const_iterator'
 1534 |       erase(const_iterator __position)
      |             ~~~~~~~~~~~~~~~^~~~~~~~~~
/usr/include/c++/13/bits/stl_vector.h:1562:7: note: candidate: 'constexpr std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::erase(const_iterator, const_iterator) [with _Tp = int; _Alloc = std::allocator<int>; iterator = std::vector<int>::iterator; const_iterator = std::vector<int>::const_iterator]'
 1562 |       erase(const_iterator __first, const_iterator __last)
      |       ^~~~~
/usr/include/c++/13/bits/stl_vector.h:1562:7: note:   candidate expects 2 arguments, 1 provided
scales.cpp:41:16: error: return-statement with a value, in function returning 'void' [-fpermissive]
   41 |         return s;
      |                ^
scales.cpp:49:12: error: cannot convert 'std::vector<int>' to 'int*'
   49 |     answer(s);
      |            ^
      |            |
      |            std::vector<int>
In file included from scales.cpp:1:
scales.h:10:17: note:   initializing argument 1 of 'void answer(int*)'
   10 | void answer(int W[]);
      |             ~~~~^~~