제출 #1002608

#제출 시각아이디문제언어결과실행 시간메모리
1002608hasan2006로봇 (IOI13_robots)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "robots.h" using namespace std; #define TL ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); #define rall(s) s.rbegin(),s.rend() #define all(s) s.begin(),s.end() #define pb push_back #define se second #define fi first #define ll long long #define ld long double #define YES cout<<"YES\n" #define Yes cout<<"Yes\n" #define yes cout<<"yes\n" #define NO cout<<"NO\n" #define No cout<<"No\n" #define no cout<<"no\n" int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) { ll i , j , l ,r , s = 0 , f , x , y , k , n, m , ans = 0; sort(X , X + A); sort(Y , Y + B); vector<pair<int,int>>v; for(i = 0; i < T; i++){ v.pb({W[i] , S[i]}); if(A > 0 && X[A - 1] > W[i]) continue; if(B > 0 && Y[B - 1] > S[i]) continue; return -1; } sort(all(v)); l = T / (A + B); r = T; while(l != r){ m = (l + r) / 2; ll R = 0; multiset<pair<int,int>>st; for(i = 0; i < A; i++){ while(R < v.size() && v[R].fi < X[i]) st.insert({v[R].se , v[R].fi}),R++; y = m; while((y--) && st.size()){ st.erase(st.find(st.rbegin()->fi , st.rbegin()->se)); } } for(i = R; i < v.size(); i++) st.insert({v[i].se, v[i].fi}); for(i = 0; i < B; i++){ y = m; while((y--) && st.size() && st.begin()->fi < Y[i]) st.erase(st.begin()); } if(st.size()) l = m + 1; else r = m; } return l; } /* int main(){ TL; #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif int a[] = {6 , 2 , 9}; int b[] = {4 , 7}; int c[] = {4 , 8 , 2 , 7 , 1 , 5 , 3 ,8 , 7 , 10}; int d[] = {6 , 5 , 3 , 9 , 8, 1 , 3 , 7 , 6 , 5}; cout<<putaway(3 , 2 , 10 , a , b , c , d )<<"\n"; }*/ // Author : حسن

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

robots.cpp: In function 'int putaway(int, int, int, int*, int*, int*, int*)':
robots.cpp:43:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |             while(R < v.size() && v[R].fi < X[i])
      |                   ~~^~~~~~~~~~
robots.cpp:47:67: error: no matching function for call to 'std::multiset<std::pair<int, int> >::find(const int&, const int&)'
   47 |                 st.erase(st.find(st.rbegin()->fi , st.rbegin()->se));
      |                                                                   ^
In file included from /usr/include/c++/10/set:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:87,
                 from robots.cpp:1:
/usr/include/c++/10/bits/stl_multiset.h:775:7: note: candidate: 'std::multiset<_Key, _Compare, _Alloc>::iterator std::multiset<_Key, _Compare, _Alloc>::find(const key_type&) [with _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >; std::multiset<_Key, _Compare, _Alloc>::iterator = std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator; std::multiset<_Key, _Compare, _Alloc>::key_type = std::pair<int, int>]'
  775 |       find(const key_type& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_multiset.h:775:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/10/bits/stl_multiset.h:779:7: note: candidate: 'std::multiset<_Key, _Compare, _Alloc>::const_iterator std::multiset<_Key, _Compare, _Alloc>::find(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::multiset<_Key, _Compare, _Alloc>::const_iterator = std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator; std::multiset<_Key, _Compare, _Alloc>::key_type = std::pair<int, int>]'
  779 |       find(const key_type& __x) const
      |       ^~~~
/usr/include/c++/10/bits/stl_multiset.h:779:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/10/bits/stl_multiset.h:785:2: note: candidate: 'template<class _Kt> decltype (std::multiset<_Key, _Compare, _Alloc>::iterator{((std::multiset<_Key, _Compare, _Alloc>*)this)->std::multiset<_Key, _Compare, _Alloc>::_M_t._M_find_tr(__x)}) std::multiset<_Key, _Compare, _Alloc>::find(const _Kt&) [with _Kt = _Kt; _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >]'
  785 |  find(const _Kt& __x)
      |  ^~~~
/usr/include/c++/10/bits/stl_multiset.h:785:2: note:   template argument deduction/substitution failed:
robots.cpp:47:67: note:   candidate expects 1 argument, 2 provided
   47 |                 st.erase(st.find(st.rbegin()->fi , st.rbegin()->se));
      |                                                                   ^
In file included from /usr/include/c++/10/set:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:87,
                 from robots.cpp:1:
/usr/include/c++/10/bits/stl_multiset.h:791:2: note: candidate: 'template<class _Kt> decltype (std::multiset<_Key, _Compare, _Alloc>::const_iterator{((const std::multiset<_Key, _Compare, _Alloc>*)this)->std::multiset<_Key, _Compare, _Alloc>::_M_t._M_find_tr(__x)}) std::multiset<_Key, _Compare, _Alloc>::find(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> >]'
  791 |  find(const _Kt& __x) const
      |  ^~~~
/usr/include/c++/10/bits/stl_multiset.h:791:2: note:   template argument deduction/substitution failed:
robots.cpp:47:67: note:   candidate expects 1 argument, 2 provided
   47 |                 st.erase(st.find(st.rbegin()->fi , st.rbegin()->se));
      |                                                                   ^
robots.cpp:50:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |         for(i = R; i < v.size(); i++)
      |                    ~~^~~~~~~~~~
robots.cpp:23:12: warning: unused variable 'j' [-Wunused-variable]
   23 |     ll i , j , l ,r , s = 0 , f , x , y , k , n, m , ans = 0;
      |            ^
robots.cpp:23:23: warning: unused variable 's' [-Wunused-variable]
   23 |     ll i , j , l ,r , s = 0 , f , x , y , k , n, m , ans = 0;
      |                       ^
robots.cpp:23:31: warning: unused variable 'f' [-Wunused-variable]
   23 |     ll i , j , l ,r , s = 0 , f , x , y , k , n, m , ans = 0;
      |                               ^
robots.cpp:23:35: warning: unused variable 'x' [-Wunused-variable]
   23 |     ll i , j , l ,r , s = 0 , f , x , y , k , n, m , ans = 0;
      |                                   ^
robots.cpp:23:43: warning: unused variable 'k' [-Wunused-variable]
   23 |     ll i , j , l ,r , s = 0 , f , x , y , k , n, m , ans = 0;
      |                                           ^
robots.cpp:23:47: warning: unused variable 'n' [-Wunused-variable]
   23 |     ll i , j , l ,r , s = 0 , f , x , y , k , n, m , ans = 0;
      |                                               ^
robots.cpp:23:54: warning: unused variable 'ans' [-Wunused-variable]
   23 |     ll i , j , l ,r , s = 0 , f , x , y , k , n, m , ans = 0;
      |                                                      ^~~