Submission #321183

#TimeUsernameProblemLanguageResultExecution timeMemory
321183phathnvTriangles (CEOI18_tri)C++11
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define mp make_pair #define X first #define Y second #define taskname "Triangle" using namespace std; typedef long long ll; typedef pair <int, int> point; const int N = 40001; int _n, ind[N]; int main(){ _n = get_n(); int tmp = 2; for(int i = 3; i <= n; i++) if (is_clockwise(1, tmp, i)) tmp = i; bool flag = 0; for(int i = 2; i <= n; i++){ if (tmp == i) continue; if (is_clockwise(1, tmp, i)){ flag = 1; break; } } if (flag == 0){ /// 1 in convex hull for(int i = 1; i <= _n; i++) ind[i] = i; sort(ind + 2, ind + 1 + _n, [](const int &a, const int &b){ return (!is_clockwise(1, a, b)); }); vector <int> st; st.push_back(1); for(int i = 2; i <= n; i++){ while (st.size() >= 2){ if (is_clockwise(st[st.size() - 2], st[st.size() - 1], ind[i])) st.pop_back(); else break; } st.push_back(ind[i]); } cout << st.size(); } else { for(int i = 1; i <= _n; i++) ind[i] = i; sort(ind + 3, ind + 1 + _n, [](const int &a, const int &b){ bool tA = is_clockwise(1, 2, a); bool tB = is_clockwise(1, 2, b); if (tA != tB) return tB; return (!is_clockwise(1, a, b)); }); vector <int> st; st.push_back(2); for(int i = 3; i <= n; i++){ while (st.size() >= 2){ if (is_clockwise(st[st.size() - 2], st[st.size() - 1], ind[i])) st.pop_back(); else break; } st.push_back(ind[i]); } int l = 0, r = st.size() - 1; while (r - l + 1 > 3){ if (is_clockwise(st[r], st[l], st[l + 1])){ l++; continue; } if (is_clockwise(st[r - 1], st[r], st[l])){ r--; continue; } break; } cout << r - l + 1; } return 0; } /* 6 2 2 4 3 1 1 1 4 5 1 3 2 */

Compilation message (stderr)

tri.cpp: In function 'int main()':
tri.cpp:17:10: error: 'get_n' was not declared in this scope
   17 |     _n = get_n();
      |          ^~~~~
tri.cpp:19:25: error: 'n' was not declared in this scope
   19 |     for(int i = 3; i <= n; i++)
      |                         ^
tri.cpp:20:13: error: 'is_clockwise' was not declared in this scope
   20 |         if (is_clockwise(1, tmp, i))
      |             ^~~~~~~~~~~~
tri.cpp:23:25: error: 'n' was not declared in this scope
   23 |     for(int i = 2; i <= n; i++){
      |                         ^
tri.cpp:26:13: error: 'is_clockwise' was not declared in this scope
   26 |         if (is_clockwise(1, tmp, i)){
      |             ^~~~~~~~~~~~
tri.cpp: In lambda function:
tri.cpp:35:26: error: 'is_clockwise' was not declared in this scope
   35 |                 return (!is_clockwise(1, a, b));
      |                          ^~~~~~~~~~~~
tri.cpp: In function 'int main()':
tri.cpp:39:29: error: 'n' was not declared in this scope
   39 |         for(int i = 2; i <= n; i++){
      |                             ^
tri.cpp:41:21: error: 'is_clockwise' was not declared in this scope
   41 |                 if (is_clockwise(st[st.size() - 2], st[st.size() - 1], ind[i]))
      |                     ^~~~~~~~~~~~
tri.cpp: In lambda function:
tri.cpp:53:27: error: 'is_clockwise' was not declared in this scope
   53 |                 bool tA = is_clockwise(1, 2, a);
      |                           ^~~~~~~~~~~~
tri.cpp: In function 'int main()':
tri.cpp:61:29: error: 'n' was not declared in this scope
   61 |         for(int i = 3; i <= n; i++){
      |                             ^
tri.cpp:63:21: error: 'is_clockwise' was not declared in this scope
   63 |                 if (is_clockwise(st[st.size() - 2], st[st.size() - 1], ind[i]))
      |                     ^~~~~~~~~~~~
tri.cpp:72:17: error: 'is_clockwise' was not declared in this scope
   72 |             if (is_clockwise(st[r], st[l], st[l + 1])){
      |                 ^~~~~~~~~~~~
tri.cpp:76:17: error: 'is_clockwise' was not declared in this scope
   76 |             if (is_clockwise(st[r - 1], st[r], st[l])){
      |                 ^~~~~~~~~~~~
In file included from /usr/include/c++/9/bits/stl_algobase.h:71,
                 from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from tri.cpp:1:
/usr/include/c++/9/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_comp_iter<_Compare>::operator()(_Iterator1, _Iterator2) [with _Iterator1 = int*; _Iterator2 = int*; _Compare = main()::<lambda(const int&, const int&)>]':
/usr/include/c++/9/bits/stl_algo.h:1846:14:   required from 'void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = int*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<main()::<lambda(const int&, const int&)> >]'
/usr/include/c++/9/bits/stl_algo.h:1884:25:   required from 'void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = int*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<main()::<lambda(const int&, const int&)> >]'
/usr/include/c++/9/bits/stl_algo.h:1970:31:   required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = int*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<main()::<lambda(const int&, const int&)> >]'
/usr/include/c++/9/bits/stl_algo.h:4899:18:   required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = int*; _Compare = main()::<lambda(const int&, const int&)>]'
tri.cpp:36:15:   required from here
/usr/include/c++/9/bits/predefined_ops.h:143:18: error: void value not ignored as it ought to be
  143 |         { return bool(_M_comp(*__it1, *__it2)); }
      |                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/9/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Val_comp_iter<_Compare>::operator()(_Value&, _Iterator) [with _Value = int; _Iterator = int*; _Compare = main()::<lambda(const int&, const int&)>]':
/usr/include/c++/9/bits/stl_algo.h:1827:20:   required from 'void std::__unguarded_linear_insert(_RandomAccessIterator, _Compare) [with _RandomAccessIterator = int*; _Compare = __gnu_cxx::__ops::_Val_comp_iter<main()::<lambda(const int&, const int&)> >]'
/usr/include/c++/9/bits/stl_algo.h:1854:36:   required from 'void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = int*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<main()::<lambda(const int&, const int&)> >]'
/usr/include/c++/9/bits/stl_algo.h:1884:25:   required from 'void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = int*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<main()::<lambda(const int&, const int&)> >]'
/usr/include/c++/9/bits/stl_algo.h:1970:31:   required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = int*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<main()::<lambda(const int&, const int&)> >]'
/usr/include/c++/9/bits/stl_algo.h:4899:18:   required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = int*; _Compare = main()::<lambda(const int&, const int&)>]'
tri.cpp:36:15:   required from here
/usr/include/c++/9/bits/predefined_ops.h:215:11: error: void value not ignored as it ought to be
  215 |  { return bool(_M_comp(__val, *__it)); }
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/9/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_comp_val<_Compare>::operator()(_Iterator, _Value&) [with _Iterator = int*; _Value = int; _Compare = main()::<lambda(const int&, const int&)>]':
/usr/include/c++/9/bits/stl_heap.h:133:48:   required from 'void std::__push_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare&) [with _RandomAccessIterator = int*; _Distance = long int; _Tp = int; _Compare = __gnu_cxx::__ops::_Iter_comp_val<main()::<lambda(const int&, const int&)> >]'
/usr/include/c++/9/bits/stl_heap.h:237:23:   required from 'void std::__adjust_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare) [with _RandomAccessIterator = int*; _Distance = long int; _Tp = int; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<main()::<lambda(const int&, const int&)> >]'
/usr/include/c++/9/bits/stl_heap.h:342:22:   required from 'void std::__make_heap(_RandomAccessIterator, _RandomAccessIterator, _Compare&) [with _RandomAccessIterator = int*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<main()::<lambda(const int&, const int&)> >]'
/usr/include/c++/9/bits/stl_algo.h:1671:23:   required from 'void std::__heap_select(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = int*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<main()::<lambda(const int&, const int&)> >]'
/usr/include/c++/9/bits/stl_algo.h:1932:25:   required from 'void std::__partial_sort(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = int*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<main()::<lambda(const int&, const int&)> >]'
/usr/include/c++/9/bits/stl_algo.h:1947:27:   required from 'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = int*; _Size = long int; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<main()::<lambda(const int&, const int&)> >]'
/usr/include/c++/9/bits/stl_algo.h:1967:25:   required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = int*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<main()::<lambda(const int&, const int&)> >]'
/usr/include/c++/9/bits/stl_algo.h:4899:18:   required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = int*; _Compare = main()::<lambda(const int&, const int&)>]'
tri.cpp:36:15:   required from here
/usr/include/c++/9/bits/predefined_ops.h:177:11: error: void value not ignored as it ought to be
  177 |  { return bool(_M_comp(*__it, __val)); }
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~