Submission #1324123

#TimeUsernameProblemLanguageResultExecution timeMemory
1324123sh_qaxxorov_571Secret (JOI14_secret)C++20
Compilation error
0 ms0 KiB
#include "secret.h" #include <vector> using namespace std; // data[level][i] i-chi elementning ma'lum bir rekursiya darajasidagi natijasini saqlaydi int data[12][1005]; int n_val; void build(int level, int L, int R, int A[]) { if (L == R) { data[level][L] = A[L]; return; } int mid = (L + R) / 2; // O'rtadan chapga qarab natijalarni hisoblash data[level][mid] = A[mid]; for (int i = mid - 1; i >= L; i--) { data[level][i] = Secret(A[i], data[level][i + 1]); } // O'rtadan o'ngga qarab natijalarni hisoblash data[level][mid + 1] = A[mid + 1]; for (int i = mid + 2; i <= R; i++) { data[level][i] = Secret(data[level][i - 1], A[i]); } // Rekursiyani davom ettirish if (L <= mid) build(level + 1, L, mid, A); if (mid + 1 <= R) build(level + 1, mid + 1, R, A); } void Init(int N, int A[]) { n_val = N; build(0, 0, N - 1, A); } int solve_query(int level, int L, int R, int qL, int qR) { int mid = (L + R) / 2; if (qL <= mid && qR > mid) { // Maqsadli oraliq mid nuqtasi orqali kesishgan joyni topdik return Secret(data[level][qL], data[level][qR]); } if (qR <= mid) return solve_query(level + 1, L, mid, qL, qR); else return solve_query(level + 1, mid + 1, R, qL, qR); } int Query(int L, int R) { if (L == R) { // Agar oraliq bitta elementdan iborat bo'lsa, Secret chaqirish shart emas // Buni build vaqtida eng yuqori darajada saqlab qo'yganmiz return find_single(0, 0, n_val - 1, L); } return solve_query(0, 0, n_val - 1, L, R); } // Yordamchi funksiya bitta elementni topish uchun int find_single(int level, int L, int R, int pos) { if (L == R) return data[level][L]; int mid = (L + R) / 2; if (pos <= mid) return find_single(level + 1, L, mid, pos); else return find_single(level + 1, mid + 1, R, pos); }

Compilation message (stderr)

secret.cpp: In function 'void build(int, int, int, int*)':
secret.cpp:12:9: error: reference to 'data' is ambiguous
   12 |         data[level][L] = A[L];
      |         ^~~~
In file included from /usr/include/c++/13/vector:69,
                 from secret.cpp:2:
/usr/include/c++/13/bits/range_access.h:346:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  346 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/13/bits/range_access.h:336:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  336 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/13/bits/range_access.h:325:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  325 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/13/bits/range_access.h:314:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  314 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
secret.cpp:7:5: note:                 'int data [12][1005]'
    7 | int data[12][1005];
      |     ^~~~
secret.cpp:19:5: error: reference to 'data' is ambiguous
   19 |     data[level][mid] = A[mid];
      |     ^~~~
/usr/include/c++/13/bits/range_access.h:346:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  346 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/13/bits/range_access.h:336:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  336 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/13/bits/range_access.h:325:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  325 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/13/bits/range_access.h:314:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  314 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
secret.cpp:7:5: note:                 'int data [12][1005]'
    7 | int data[12][1005];
      |     ^~~~
secret.cpp:21:9: error: reference to 'data' is ambiguous
   21 |         data[level][i] = Secret(A[i], data[level][i + 1]);
      |         ^~~~
/usr/include/c++/13/bits/range_access.h:346:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  346 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/13/bits/range_access.h:336:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  336 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/13/bits/range_access.h:325:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  325 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/13/bits/range_access.h:314:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  314 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
secret.cpp:7:5: note:                 'int data [12][1005]'
    7 | int data[12][1005];
      |     ^~~~
secret.cpp:21:39: error: reference to 'data' is ambiguous
   21 |         data[level][i] = Secret(A[i], data[level][i + 1]);
      |                                       ^~~~
/usr/include/c++/13/bits/range_access.h:346:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  346 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/13/bits/range_access.h:336:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  336 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/13/bits/range_access.h:325:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  325 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/13/bits/range_access.h:314:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  314 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
secret.cpp:7:5: note:                 'int data [12][1005]'
    7 | int data[12][1005];
      |     ^~~~
secret.cpp:25:5: error: reference to 'data' is ambiguous
   25 |     data[level][mid + 1] = A[mid + 1];
      |     ^~~~
/usr/include/c++/13/bits/range_access.h:346:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  346 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/13/bits/range_access.h:336:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  336 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/13/bits/range_access.h:325:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  325 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/13/bits/range_access.h:314:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  314 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
secret.cpp:7:5: note:                 'int data [12][1005]'
    7 | int data[12][1005];
      |     ^~~~
secret.cpp:27:9: error: reference to 'data' is ambiguous
   27 |         data[level][i] = Secret(data[level][i - 1], A[i]);
      |         ^~~~
/usr/include/c++/13/bits/range_access.h:346:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  346 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/13/bits/range_access.h:336:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  336 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/13/bits/range_access.h:325:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  325 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/13/bits/range_access.h:314:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  314 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
secret.cpp:7:5: note:                 'int data [12][1005]'
    7 | int data[12][1005];
      |     ^~~~
secret.cpp:27:33: error: reference to 'data' is ambiguous
   27 |         data[level][i] = Secret(data[level][i - 1], A[i]);
      |                                 ^~~~
/usr/include/c++/13/bits/range_access.h:346:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  346 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/13/bits/range_access.h:336:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  336 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/13/bits/range_access.h:325:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  325 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/13/bits/range_access.h:314:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  314 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
secret.cpp:7:5: note:                 'int data [12][1005]'
    7 | int data[12][1005];
      |     ^~~~
secret.cpp: In function 'int solve_query(int, int, int, int, int)':
secret.cpp:45:23: error: reference to 'data' is ambiguous
   45 |         return Secret(data[level][qL], data[level][qR]);
      |                       ^~~~
/usr/include/c++/13/bits/range_access.h:346:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  346 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/13/bits/range_access.h:336:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  336 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/13/bits/range_access.h:325:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  325 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/13/bits/range_access.h:314:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  314 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
secret.cpp:7:5: note:                 'int data [12][1005]'
    7 | int data[12][1005];
      |     ^~~~
secret.cpp:45:40: error: reference to 'data' is ambiguous
   45 |         return Secret(data[level][qL], data[level][qR]);
      |                                        ^~~~
/usr/include/c++/13/bits/range_access.h:346:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  346 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/13/bits/range_access.h:336:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  336 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/13/bits/range_access.h:325:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  325 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/13/bits/range_access.h:314:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  314 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
secret.cpp:7:5: note:                 'int data [12][1005]'
    7 | int data[12][1005];
      |     ^~~~
secret.cpp: In function 'int Query(int, int)':
secret.cpp:56:16: error: 'find_single' was not declared in this scope
   56 |         return find_single(0, 0, n_val - 1, L);
      |                ^~~~~~~~~~~
secret.cpp: In function 'int find_single(int, int, int, int)':
secret.cpp:63:24: error: reference to 'data' is ambiguous
   63 |     if (L == R) return data[level][L];
      |                        ^~~~
/usr/include/c++/13/bits/range_access.h:346:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  346 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/13/bits/range_access.h:336:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  336 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/13/bits/range_access.h:325:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  325 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/13/bits/range_access.h:314:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  314 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
secret.cpp:7:5: note:                 'int data [12][1005]'
    7 | int data[12][1005];
      |     ^~~~