제출 #821461

#제출 시각아이디문제언어결과실행 시간메모리
821461caganyanmaz크레이피쉬 글쓰는 기계 (IOI12_scrivener)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;


constexpr static int MXSIZE = 3e7;
struct STree
{
        int left[MXSIZE], right[MXSIZE];
        int nxt = 1;
        STree()
        {
                left[0] = -1;
                right[0] = -1;
        }
        int set(int l, int r, int index, int i, int val)
        {
                if (r - l == 1)
                {
                        left[nxt] = val;
                        return nxt++;
                }
                int lindex = index != -1 ? left[index] : -1;
                int rindex = index != -1 ? right[index] : -1;
                int m = l+r>>1;
                if (i < m)
                        lindex = set(l, m, lindex, i, val);
                else
                        rindex = set(m, r, rindex, i, val);
                left[nxt] = lindex;
                right[nxt] = rindex;
                return nxt++;
        }
        int get(int l, int r, int index, int i)
        {
                assert(index != -1);
                if (r - l == 1)
                        return left[index];
                int m = l+r>>1;
                if (i < m)
                        return get(l, m, left[index], i);
                return get(m, r, right[index], i);
        }
};
constexpr static int MXN = 1e6;
constexpr static int MXS = MXN + 5;

int current = 0;
int root[MXS];
int size[MXS];
STree st;





void Init() {}

void TypeLetter(char L)
{
        root[current+1] = st.set(0, MXS, root[current], size[current], L);
        size[current+1] = size[current] + 1;
        current++;
}

void UndoCommands(int U)
{
        root[current+1] = root[current-U];
        size[current+1] = size[current-U];
        current++;
}

char GetLetter(int P)
{
        return st.get(0, MXS, root[current], P);

}

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

scrivener.cpp: In member function 'int STree::set(int, int, int, int, int)':
scrivener.cpp:24:26: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   24 |                 int m = l+r>>1;
      |                         ~^~
scrivener.cpp: In member function 'int STree::get(int, int, int, int)':
scrivener.cpp:38:26: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   38 |                 int m = l+r>>1;
      |                         ~^~
scrivener.cpp: In function 'void TypeLetter(char)':
scrivener.cpp:60:57: error: reference to 'size' is ambiguous
   60 |         root[current+1] = st.set(0, MXS, root[current], size[current], L);
      |                                                         ^~~~
In file included from /usr/include/c++/10/string:54,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 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 scrivener.cpp:1:
/usr/include/c++/10/bits/range_access.h:254:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  254 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/10/bits/range_access.h:245:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  245 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
scrivener.cpp:49:5: note:                 'int size [1000005]'
   49 | int size[MXS];
      |     ^~~~
scrivener.cpp:61:9: error: reference to 'size' is ambiguous
   61 |         size[current+1] = size[current] + 1;
      |         ^~~~
In file included from /usr/include/c++/10/string:54,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 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 scrivener.cpp:1:
/usr/include/c++/10/bits/range_access.h:254:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  254 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/10/bits/range_access.h:245:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  245 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
scrivener.cpp:49:5: note:                 'int size [1000005]'
   49 | int size[MXS];
      |     ^~~~
scrivener.cpp:61:27: error: reference to 'size' is ambiguous
   61 |         size[current+1] = size[current] + 1;
      |                           ^~~~
In file included from /usr/include/c++/10/string:54,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 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 scrivener.cpp:1:
/usr/include/c++/10/bits/range_access.h:254:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  254 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/10/bits/range_access.h:245:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  245 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
scrivener.cpp:49:5: note:                 'int size [1000005]'
   49 | int size[MXS];
      |     ^~~~
scrivener.cpp: In function 'void UndoCommands(int)':
scrivener.cpp:68:9: error: reference to 'size' is ambiguous
   68 |         size[current+1] = size[current-U];
      |         ^~~~
In file included from /usr/include/c++/10/string:54,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 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 scrivener.cpp:1:
/usr/include/c++/10/bits/range_access.h:254:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  254 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/10/bits/range_access.h:245:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  245 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
scrivener.cpp:49:5: note:                 'int size [1000005]'
   49 | int size[MXS];
      |     ^~~~
scrivener.cpp:68:27: error: reference to 'size' is ambiguous
   68 |         size[current+1] = size[current-U];
      |                           ^~~~
In file included from /usr/include/c++/10/string:54,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 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 scrivener.cpp:1:
/usr/include/c++/10/bits/range_access.h:254:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  254 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/10/bits/range_access.h:245:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  245 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
scrivener.cpp:49:5: note:                 'int size [1000005]'
   49 | int size[MXS];
      |     ^~~~