제출 #586718

#제출 시각아이디문제언어결과실행 시간메모리
586718MDario로봇 (IOI13_robots)C++11
컴파일 에러
0 ms0 KiB
#include "robots.h"
#include<bits/stdc++.h>
int f(int xf[], int yf){
    if(xf[yf]==yf)return yf;
    else return xf[yf]=f(xf, xf[yf]);
}
int putaway(int A, int B, int T, int X[], int Y[], int W[], int s[]) {
    vector<int> x, y;
    for(int i=0; i<A; i++)x.push_back(X[i]);
    x.push_back(0);
    for(int i=0; i<B; i++)y.push_back(Y[i]);
    y.push_back(0);
    sort(x, x+A);
    sort(y, y+B);
    pair<int, int> a[T];
    int l, r, m, b[T], b1[A+2], b2[B+2], nexa[A+2], nexb[B+2], c[20];
    for(int i=0; i<T; i++){
        l=0;
        r=A+1;
        while(l+1<r){
            m=(l+r)/2;
            if(w[i]>x[m])l=m;
            else r=m;
        }
        a[i].F=r;
        l=0;
        r=B+1;
        while(l+1<r){
            m=(l+r)/2;
            if(s[i]>y[m])l=m;
            else r=m;
        }
        a[i].S=r;
    }
    sort(a, a+T);
    l=-1;
    r=T+1;
    while(l+1<r){
        m=(l+r)/2;
        c[1]=0;
        for(int i=0; i<T; i++)b[i]=0;
        for(int i=0; i<=A; i++){
            b1[i]=0;
            nexa[i]=i;
        }
        b1[A+1]=m;
        nexa[A+1]=A+1;
        for(int i=0; i<=B; i++){
            b2[i]=0;
            nexb[i]=i;
        }
        b2[B+1]=m;
        nexb[B+1]=B+1;
        for(int i=T-1; i>=0; i--){
            c[0]=f(nexb, a[i].S);
            if(c[0]!=B+1){
                b[i]=1;
                b2[c[0]]++;
                if(b2[c[0]]==m)nexb[c[0]]=c[0]+1;
            }
        }
        for(int i=0; i<T; i++){
            if(!b[i]){
                c[0]=f(nexa, a[i].F);
                if(c[0]!=A+1){
                    b1[c[0]]++;
                    if(b1[c[0]]==m)nexa[c[0]]=c[0]+1;
                }
                else c[1]=1;
            }
        }
        if(!c[1])r=m;
        else l=m;
    }
    if(r==T+1)return -1;
    return r;
}

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

robots.cpp: In function 'int putaway(int, int, int, int*, int*, int*, int*)':
robots.cpp:8:5: error: 'vector' was not declared in this scope; did you mean 'std::vector'?
    8 |     vector<int> x, y;
      |     ^~~~~~
      |     std::vector
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from robots.cpp:2:
/usr/include/c++/10/bits/stl_vector.h:389:11: note: 'std::vector' declared here
  389 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
robots.cpp:8:12: error: expected primary-expression before 'int'
    8 |     vector<int> x, y;
      |            ^~~
robots.cpp:9:27: error: 'x' was not declared in this scope
    9 |     for(int i=0; i<A; i++)x.push_back(X[i]);
      |                           ^
robots.cpp:10:5: error: 'x' was not declared in this scope
   10 |     x.push_back(0);
      |     ^
robots.cpp:11:27: error: 'y' was not declared in this scope
   11 |     for(int i=0; i<B; i++)y.push_back(Y[i]);
      |                           ^
robots.cpp:12:5: error: 'y' was not declared in this scope
   12 |     y.push_back(0);
      |     ^
robots.cpp:13:5: error: 'sort' was not declared in this scope; did you mean 'std::sort'?
   13 |     sort(x, x+A);
      |     ^~~~
      |     std::sort
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from robots.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:4880:5: note: 'std::sort' declared here
 4880 |     sort(_RandomAccessIterator __first, _RandomAccessIterator __last,
      |     ^~~~
robots.cpp:15:5: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
   15 |     pair<int, int> a[T];
      |     ^~~~
      |     std::pair
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from robots.cpp:2:
/usr/include/c++/10/bits/stl_pair.h:211:12: note: 'std::pair' declared here
  211 |     struct pair
      |            ^~~~
robots.cpp:15:10: error: expected primary-expression before 'int'
   15 |     pair<int, int> a[T];
      |          ^~~
robots.cpp:22:16: error: 'w' was not declared in this scope
   22 |             if(w[i]>x[m])l=m;
      |                ^
robots.cpp:25:9: error: 'a' was not declared in this scope
   25 |         a[i].F=r;
      |         ^
robots.cpp:35:10: error: 'a' was not declared in this scope
   35 |     sort(a, a+T);
      |          ^