제출 #550856

#제출 시각아이디문제언어결과실행 시간메모리
550856David_M로봇 (IOI13_robots)C++14
컴파일 에러
0 ms0 KiB
#include "robots.h"
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define pb push_back
 
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) {
    int ans=-1;
    vector<array<int, 3>> p(T);
    for (int i=0; i<T; i++)p[i]={W[i]+1, S[i]+1, i};
    sort(all(p));
    sort(X, X+A);
    sort(Y, Y+B);
 
    int l=1, r=T+1;
    while(l<=r){
        int m=l+r>>1;
        int M=0, k=0, o=0;
        vector<bool> f(T,0);
        vector<int> v;
        priority_queue<array<int, 2>> s;
        for (auto x : X){
            M=m;
            while(k<T && x>=p[k][0])
                s.push({p[k][1],p[k][2]}), k++;
            while(!s.empty() && M--)
                f[s.top()[1]]=1, s.pop();
        }
        for (int i=0; i<T; i++)
            if(!f[i])v.pb(S[i]+1);
        sort(all(v));
        k=M=0;
        for (auto y : v){
            if(k==B){o=1;break;}
            while(k<B && y>Y[k])k++,M=0;
            if(k==B){o=1;break;}
            M++;
            if(M==m)k++,M=0;
        }
        if(o)l=m+1; else ans=m, r=m-1;
    }
    return ans;
}

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

robots.cpp: In function 'int putaway(int, int, int, int*, int*, int*, int*)':
robots.cpp:17:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   17 |         int m=l+r>>1;
      |               ~^~
robots.cpp:22:23: error: 'begin' was not declared in this scope; did you mean 'std::begin'?
   22 |         for (auto x : X){
      |                       ^
      |                       std::begin
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from robots.cpp:2:
/usr/include/c++/10/valarray:1224:5: note: 'std::begin' declared here
 1224 |     begin(const valarray<_Tp>& __va)
      |     ^~~~~
robots.cpp:22:23: error: 'end' was not declared in this scope; did you mean 'std::end'?
   22 |         for (auto x : X){
      |                       ^
      |                       std::end
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from robots.cpp:2:
/usr/include/c++/10/valarray:1244:5: note: 'std::end' declared here
 1244 |     end(const valarray<_Tp>& __va)
      |     ^~~