제출 #666883

#제출 시각아이디문제언어결과실행 시간메모리
666883teesla크레이피쉬 글쓰는 기계 (IOI12_scrivener)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; char last; string prev,s; void Init() { s=""; return; } void TypeLetter(char L) { last = L; prev=s; s=s+last; return; } void UndoCommands(int U) { s=prev; return; } char GetLetter(int P) { return s[P]; }

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

scrivener.cpp: In function 'void TypeLetter(char)':
scrivener.cpp:15:3: error: reference to 'prev' is ambiguous
   15 |   prev=s;
      |   ^~~~
In file included from /usr/include/c++/10/bits/stl_algobase.h:66,
                 from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 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/stl_iterator_base_funcs.h:224:5: note: candidates are: 'template<class _BidirectionalIterator> _BidirectionalIterator std::prev(_BidirectionalIterator, typename std::iterator_traits<_Iter>::difference_type)'
  224 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
scrivener.cpp:5:8: note:                 'std::string prev'
    5 | string prev,s;
      |        ^~~~
scrivener.cpp: In function 'void UndoCommands(int)':
scrivener.cpp:22:5: error: reference to 'prev' is ambiguous
   22 |   s=prev;
      |     ^~~~
In file included from /usr/include/c++/10/bits/stl_algobase.h:66,
                 from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 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/stl_iterator_base_funcs.h:224:5: note: candidates are: 'template<class _BidirectionalIterator> _BidirectionalIterator std::prev(_BidirectionalIterator, typename std::iterator_traits<_Iter>::difference_type)'
  224 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
scrivener.cpp:5:8: note:                 'std::string prev'
    5 | string prev,s;
      |        ^~~~