제출 #154244

#제출 시각아이디문제언어결과실행 시간메모리
154244Ruxandra985동굴 (IOI13_cave)C++14
컴파일 에러
0 ms0 KiB
#include <cstdio> #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:9:5: error: 'vector' was not declared in this scope
     vector <int> v;
     ^~~~~~
cave.cpp:9:5: note: suggested alternative:
In file included from /usr/include/c++/7/vector:64:0,
                 from cave.cpp:3:
/usr/include/c++/7/bits/stl_vector.h:216:11: note:   'std::vector'
     class vector : protected _Vector_base<_Tp, _Alloc>
           ^~~~~~
cave.cpp:9:13: error: expected primary-expression before 'int'
     vector <int> v;
             ^~~
cave.cpp:11:9: error: 'v' was not declared in this scope
         v.push_back(i); /// switch urile pe care nu le am fixat inca
         ^
cave.cpp:14:20: error: 'v' was not declared in this scope
         for (j=0;j<v.size();j++)
                    ^
cave.cpp:23:14: error: 'v' was not declared in this scope
         dr = v.size()-1;
              ^
cave.cpp:46:9: error: 'swap' was not declared in this scope
         swap(v[st] , v[v.size()-1]);
         ^~~~
cave.cpp:46:9: note: suggested alternatives:
In file included from /usr/include/c++/7/vector:65:0,
                 from cave.cpp:3:
/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/bits/stl_pair.h:59:0,
                 from /usr/include/c++/7/bits/stl_algobase.h:64,
                 from /usr/include/c++/7/vector:60,
                 from cave.cpp:3:
/usr/include/c++/7/bits/move.h:187:5: note:   'std::swap'
     swap(_Tp& __a, _Tp& __b)
     ^~~~
In file included from /usr/include/c++/7/exception:142:0,
                 from /usr/include/c++/7/new:40,
                 from /usr/include/c++/7/ext/new_allocator.h:33,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/c++allocator.h:33,
                 from /usr/include/c++/7/bits/allocator.h:46,
                 from /usr/include/c++/7/vector:61,
                 from cave.cpp:3:
/usr/include/c++/7/bits/exception_ptr.h:166:5: note:   'std::__exception_ptr::swap'
     swap(exception_ptr& __lhs, exception_ptr& __rhs)
     ^~~~