제출 #154245

#제출 시각아이디문제언어결과실행 시간메모리
154245Ruxandra985Cave (IOI13_cave)C++14
컴파일 에러
0 ms0 KiB
#include <cstdio>
#include <iostream>
#define DIMN 5010
#include <vector>
#include "cave.h"

void exploreCave(int n){
    int i,x,pos,st,dr,mid,j;
    int s[DIMN],d[DIMN];
    vector <int> v;
    for (i=0;i<n;i++)
        v.push_back(i); /// switch urile pe care nu le am fixat inca
    for (i=1;i<=n;i++){

        for (j=0;j<v.size();j++)
            s[v[j]] = 0;

        x = tryCombination (s);
        if (x == -1 || x >= i)
            pos = 0;
        else pos = 1;

        st = 0;
        dr = v.size()-1;
        while (st<dr){
            mid = (st + dr)/2;
            /// pui st..mid 0 si mid+1 dr 1
            for (j=st;j<=mid;j++)
                s[v[j]] = 0;
            for (j=mid+1;j<=dr;j++)
                s[v[j]] = 1;
            x = tryCombination(s);
            if (x >= i || x == -1){
                if (pos == 0)
                    dr = mid;
                else st = mid + 1;
            }
            else {
                if (pos == 1)
                    dr = mid;
                else st = mid + 1;
            }
        }
        //printf ("%d\n",v[st]);
        d[v[st]] = i-1;
        s[v[st]] = pos;
        swap(v[st] , v[v.size()-1]);
        v.pop_back();

    }
    answer (s,d);
}

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

cave.cpp: In function 'void exploreCave(int)':
cave.cpp:10:5: error: 'vector' was not declared in this scope
     vector <int> v;
     ^~~~~~
cave.cpp:10:5: note: suggested alternative:
In file included from /usr/include/c++/7/vector:64:0,
                 from cave.cpp:4:
/usr/include/c++/7/bits/stl_vector.h:216:11: note:   'std::vector'
     class vector : protected _Vector_base<_Tp, _Alloc>
           ^~~~~~
cave.cpp:10:13: error: expected primary-expression before 'int'
     vector <int> v;
             ^~~
cave.cpp:12:9: error: 'v' was not declared in this scope
         v.push_back(i); /// switch urile pe care nu le am fixat inca
         ^
cave.cpp:15:20: error: 'v' was not declared in this scope
         for (j=0;j<v.size();j++)
                    ^
cave.cpp:24:14: error: 'v' was not declared in this scope
         dr = v.size()-1;
              ^
cave.cpp:47:9: error: 'swap' was not declared in this scope
         swap(v[st] , v[v.size()-1]);
         ^~~~
cave.cpp:47:9: note: suggested alternatives:
In file included from /usr/include/c++/7/vector:65:0,
                 from cave.cpp:4:
/usr/include/c++/7/bits/stl_bvector.h:128:3: note:   'std::swap'
   swap(bool& __x, _Bit_reference __y) noexcept
   ^~~~
In file included from /usr/include/c++/7/exception:142:0,
                 from /usr/include/c++/7/ios:39,
                 from /usr/include/c++/7/ostream:38,
                 from /usr/include/c++/7/iostream:39,
                 from cave.cpp:2:
/usr/include/c++/7/bits/exception_ptr.h:166:5: note:   'std::__exception_ptr::swap'
     swap(exception_ptr& __lhs, exception_ptr& __rhs)
     ^~~~
In file included from /usr/include/c++/7/bits/nested_exception.h:40:0,
                 from /usr/include/c++/7/exception:143,
                 from /usr/include/c++/7/ios:39,
                 from /usr/include/c++/7/ostream:38,
                 from /usr/include/c++/7/iostream:39,
                 from cave.cpp:2:
/usr/include/c++/7/bits/move.h:187:5: note:   'std::swap'
     swap(_Tp& __a, _Tp& __b)
     ^~~~