Submission #232053

# Submission time Handle Problem Language Result Execution time Memory
232053 2020-05-15T20:32:02 Z Blerargh King of Chairs (FXCUP4_chairs) C++17
Compilation error
0 ms 0 KB
#include "king.h"
long long SendInfo(int W[], int C[]) return 0;
#include <bits/stdc++.h>
#include "vassal.h"
using namespace std;

typedef pair<int, int> ii;
set<ii> chairs;

void Init(long long B, int C[]){
  int n = sizeof(C);
  for (int i=0; i<n; i++){
    chairs.insert(make_pair(C[i],i));
  }
}

int Maid(int w){
  auto it = chairs.lower_bound(w,0);
  if (it == chairs.end()) return -1;
  else {
    int ans = (*it).second;
    chairs.erase(it);
    return ans;
  }
}

Compilation message

king.cpp: In function 'long long int SendInfo(int*, int*)':
king.cpp:2:45: error: expected identifier before numeric constant
 long long SendInfo(int W[], int C[]) return 0;
                                             ^
king.cpp:2:38: error: named return values are no longer supported
 long long SendInfo(int W[], int C[]) return 0;
                                      ^~~~~~
king.cpp:2:46: error: expected '{' at end of input
 long long SendInfo(int W[], int C[]) return 0;
                                              ^
king.cpp:2:46: warning: no return statement in function returning non-void [-Wreturn-type]

vassal.cpp: In function 'void Init(long long int, int*)':
vassal.cpp:9:19: warning: 'sizeof' on array function parameter 'C' will return size of 'int*' [-Wsizeof-array-argument]
   int n = sizeof(C);
                   ^
vassal.cpp:8:30: note: declared here
 void Init(long long B, int C[]){
                              ^
vassal.cpp: In function 'int Maid(int)':
vassal.cpp:16:35: error: no matching function for call to 'std::set<std::pair<int, int> >::lower_bound(int&, int)'
   auto it = chairs.lower_bound(w,0);
                                   ^
In file included from /usr/include/c++/7/set:61:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:87,
                 from vassal.cpp:1:
/usr/include/c++/7/bits/stl_set.h:800:7: note: candidate: std::set<_Key, _Compare, _Alloc>::iterator std::set<_Key, _Compare, _Alloc>::lower_bound(const key_type&) [with _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >; std::set<_Key, _Compare, _Alloc>::iterator = std::_Rb_tree_const_iterator<std::pair<int, int> >; std::set<_Key, _Compare, _Alloc>::key_type = std::pair<int, int>]
       lower_bound(const key_type& __x)
       ^~~~~~~~~~~
/usr/include/c++/7/bits/stl_set.h:800:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/7/bits/stl_set.h:804:7: note: candidate: std::set<_Key, _Compare, _Alloc>::const_iterator std::set<_Key, _Compare, _Alloc>::lower_bound(const key_type&) const [with _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >; std::set<_Key, _Compare, _Alloc>::const_iterator = std::_Rb_tree_const_iterator<std::pair<int, int> >; std::set<_Key, _Compare, _Alloc>::key_type = std::pair<int, int>]
       lower_bound(const key_type& __x) const
       ^~~~~~~~~~~
/usr/include/c++/7/bits/stl_set.h:804:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/7/bits/stl_set.h:810:2: note: candidate: template<class _Kt> decltype ((std::set<_Key, _Compare, _Alloc>::iterator)(((std::set<_Key, _Compare, _Alloc>*)this)->std::set<_Key, _Compare, _Alloc>::_M_t._M_lower_bound_tr(__x))) std::set<_Key, _Compare, _Alloc>::lower_bound(const _Kt&) [with _Kt = _Kt; _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >]
  lower_bound(const _Kt& __x)
  ^~~~~~~~~~~
/usr/include/c++/7/bits/stl_set.h:810:2: note:   template argument deduction/substitution failed:
vassal.cpp:16:35: note:   candidate expects 1 argument, 2 provided
   auto it = chairs.lower_bound(w,0);
                                   ^
In file included from /usr/include/c++/7/set:61:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:87,
                 from vassal.cpp:1:
/usr/include/c++/7/bits/stl_set.h:816:2: note: candidate: template<class _Kt> decltype ((std::set<_Key, _Compare, _Alloc>::const_iterator)(((const std::set<_Key, _Compare, _Alloc>*)this)->std::set<_Key, _Compare, _Alloc>::_M_t._M_lower_bound_tr(__x))) std::set<_Key, _Compare, _Alloc>::lower_bound(const _Kt&) const [with _Kt = _Kt; _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >]
  lower_bound(const _Kt& __x) const
  ^~~~~~~~~~~
/usr/include/c++/7/bits/stl_set.h:816:2: note:   template argument deduction/substitution failed:
vassal.cpp:16:35: note:   candidate expects 1 argument, 2 provided
   auto it = chairs.lower_bound(w,0);
                                   ^
vassal.cpp:23:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^