제출 #144565

#제출 시각아이디문제언어결과실행 시간메모리
144565youssefbou62로봇 (IOI13_robots)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "robots.h" using namespace std; #define mp make_pair #define fi first #define se second #define all(v) v.begin(),v.end() #define allarr(a) a , a + n #define ll long long #define ull unsigned long long #define pb push_back #define fastio ios_base::sync_with_stdio(false) ; cin.tie(NULL); cout.tie(NULL) typedef pair<int, int> pi; typedef pair<ll,ll> pll; typedef pair<int,pi> trp ; typedef vector<pi> vpi; typedef vector<pll> vpll ; // int ab (int x ) { return (x>0?x:-x); } const int TT = 1e6+5; bool done[TT]; int putaway(int A, int B, int T,int X[], int Y[], int W[], int S[]){ int l = 0 , r = T; sort(X,X+A); sort(Y,Y+B); vector<vector<int>> ByWei(T),BySi(T); for(int i = 0 ; i < T ; i++ ){ // ByWei.pb({W[i],S[i],i}); // BySi.pb({S[i],W[i],i}); ByWei[i]={W[i],S[i],i}; BySi[i]={S[i],W[i],i}; } sort(all(ByWei)); sort(all(BySi)); int ans = -1 ; // priority_queue<pi> q; pi p;int mins,i; while ( l <= r ){ int mid = l + (r-l)/2; // for( i = 0 ; i < T ; i++ )done[i]=0; memset(done,0,sizeof done); i = 0 ; priority_queue<pi> q; for(int a=0;a<A;a++){ while(i < T && ByWei[i][0]<X[a]){ if( !done[ByWei[i][2]]) q.push({ByWei[i][1],ByWei[i][2]}); i++; } mins = mid; while(mins&&!q.empty()){ p = q.top(); q.pop(); // assert(!done[p.se]); done[p.se]=1; mins--; } } // while(!q.empty())q.pop(); i =0; p = priority_queue<pi> () ; for(int b=0;b<B;b++){ while(i < T && BySi[i][0]<Y[b]){ if( !done[BySi[i][2]]) q.push({BySi[i][1],BySi[i][2]}); i++; } mins = mid; while(mins&&!q.empty()){ p = q.top(); q.pop(); // assert(!done[p.se]); done[p.se]=1; mins--; } } // while(!q.empty())q.pop(); bool doneAll =1; for( i = 0 ; i < T ; i++ )doneAll = doneAll&&done[i]; if( doneAll ){ ans = mid ; r = mid-1; }else { l = mid+1; } } return ans ; } // int main(){ // int A , B , T ; // cin >> A >> B >> T ; // int X[A] , Y[B] , W[T] , S[T] ; // for(int i = 0 ; i < A ; i++ )cin >> X[i]; // for(int i = 0 ; i < B ; i++ )cin >> Y[i]; // for(int i = 0 ; i < T ; i++ ){ // cin >> W[i] >> S[i] ; // } // cout << putaway(A,B,T,X,Y,W,S); // }

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

robots.cpp: In function 'int putaway(int, int, int, int*, int*, int*, int*)':
robots.cpp:61:27: error: no match for 'operator=' (operand types are 'pi {aka std::pair<int, int>}' and 'std::priority_queue<std::pair<int, int> >')
   p = priority_queue<pi> () ; 
                           ^
In file included from /usr/include/c++/7/bits/stl_algobase.h:64:0,
                 from /usr/include/c++/7/bits/char_traits.h:39,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from robots.cpp:1:
/usr/include/c++/7/bits/stl_pair.h:367:7: note: candidate: std::pair<_T1, _T2>& std::pair<_T1, _T2>::operator=(typename std::conditional<std::__and_<std::is_copy_assignable<_Tp>, std::is_copy_assignable<_T2> >::value, const std::pair<_T1, _T2>&, const std::__nonesuch_no_braces&>::type) [with _T1 = int; _T2 = int; typename std::conditional<std::__and_<std::is_copy_assignable<_Tp>, std::is_copy_assignable<_T2> >::value, const std::pair<_T1, _T2>&, const std::__nonesuch_no_braces&>::type = const std::pair<int, int>&]
       operator=(typename conditional<
       ^~~~~~~~
/usr/include/c++/7/bits/stl_pair.h:367:7: note:   no known conversion for argument 1 from 'std::priority_queue<std::pair<int, int> >' to 'std::conditional<true, const std::pair<int, int>&, const std::__nonesuch_no_braces&>::type {aka const std::pair<int, int>&}'
/usr/include/c++/7/bits/stl_pair.h:384:7: note: candidate: std::pair<_T1, _T2>& std::pair<_T1, _T2>::operator=(typename std::conditional<std::__and_<std::is_move_assignable<_Tp>, std::is_move_assignable<_T2> >::value, std::pair<_T1, _T2>&&, std::__nonesuch_no_braces&&>::type) [with _T1 = int; _T2 = int; typename std::conditional<std::__and_<std::is_move_assignable<_Tp>, std::is_move_assignable<_T2> >::value, std::pair<_T1, _T2>&&, std::__nonesuch_no_braces&&>::type = std::pair<int, int>&&]
       operator=(typename conditional<
       ^~~~~~~~
/usr/include/c++/7/bits/stl_pair.h:384:7: note:   no known conversion for argument 1 from 'std::priority_queue<std::pair<int, int> >' to 'std::conditional<true, std::pair<int, int>&&, std::__nonesuch_no_braces&&>::type {aka std::pair<int, int>&&}'
/usr/include/c++/7/bits/stl_pair.h:400:2: note: candidate: template<class _U1, class _U2> typename std::enable_if<std::__and_<std::is_assignable<_T1&, const _U1&>, std::is_assignable<_T2&, const _U2&> >::value, std::pair<_T1, _T2>&>::type std::pair<_T1, _T2>::operator=(const std::pair<_U1, _U2>&) [with _U1 = _U1; _U2 = _U2; _T1 = int; _T2 = int]
  operator=(const pair<_U1, _U2>& __p)
  ^~~~~~~~
/usr/include/c++/7/bits/stl_pair.h:400:2: note:   template argument deduction/substitution failed:
robots.cpp:61:27: note:   'std::priority_queue<std::pair<int, int> >' is not derived from 'const std::pair<_T1, _T2>'
   p = priority_queue<pi> () ; 
                           ^
In file included from /usr/include/c++/7/bits/stl_algobase.h:64:0,
                 from /usr/include/c++/7/bits/char_traits.h:39,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from robots.cpp:1:
/usr/include/c++/7/bits/stl_pair.h:411:2: note: candidate: template<class _U1, class _U2> typename std::enable_if<std::__and_<std::is_assignable<_T1&, _U1&&>, std::is_assignable<_T2&, _U2&&> >::value, std::pair<_T1, _T2>&>::type std::pair<_T1, _T2>::operator=(std::pair<_U1, _U2>&&) [with _U1 = _U1; _U2 = _U2; _T1 = int; _T2 = int]
  operator=(pair<_U1, _U2>&& __p)
  ^~~~~~~~
/usr/include/c++/7/bits/stl_pair.h:411:2: note:   template argument deduction/substitution failed:
robots.cpp:61:27: note:   'std::priority_queue<std::pair<int, int> >' is not derived from 'std::pair<_T1, _T2>'
   p = priority_queue<pi> () ; 
                           ^