# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
148873 | 20190901 (#200) | HicCup (FXCUP4_hiccup) | C++17 | 컴파일 에러 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "hiccup.h"
#include <vector>
using namespace std;
bool Check(string str, int mid)
{
vector<pair<char, int>> stk;
int hCnt = 0;
int cCnt = 0;
for (int i = 0; i < str.size(); i++)
{
if (str[i] == 'H')
{
stk.push_back({ 'H', -1 });
hCnt++;
}
else if (str[i] == 'C')
{
if (hCnt > cCnt)
stk.push_back({ 'C', 0 });
else
return false;
cCnt++;
}
else
{
if (stk.empty() || stk.back().first == 'H')
continue;
else
stk.push_back({ '!', stk.back().second + 1 });
}
if (stk.back().second == mid)
{
for (int i = 0; i < mid + 2; i++)
{
if (stk.empty())
return false;
if (stk.back() == 'C')
cCnt--;
else if (stk.back() == 'H')
hCnt--;
stk.pop_back();
}
}
}
for (int i = 0; i < stk.size(); i++)
{
if (stk[i].first != '!')
return false;
}
return true;
}
int HicCup(string S)
{
int lo = -1;
int hi = (int)S.size();
while (lo + 1 < hi)
{
int mid = (lo + hi) >> 1;
if (Check(S, mid))
{
lo = mid;
}
else
{
hi = mid;
}
}
return lo;
}
컴파일 시 표준 에러 (stderr) 메시지
hiccup.cpp: In function 'bool Check(std::__cxx11::string, int)': hiccup.cpp:13:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for (int i = 0; i < str.size(); i++) ~~^~~~~~~~~~~~ hiccup.cpp:43:20: error: no match for 'operator==' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::pair<char, int> > >::value_type {aka std::pair<char, int>}' and 'char') if (stk.back() == 'C') ~~~~~~~~~~~^~~~~~ In file included from /usr/include/c++/7/bits/stl_algobase.h:64:0, from /usr/include/c++/7/bits/char_traits.h:39, from /usr/include/c++/7/string:40, from hiccup.h:2, from hiccup.cpp:1: /usr/include/c++/7/bits/stl_pair.h:443:5: note: candidate: template<class _T1, class _T2> constexpr bool std::operator==(const std::pair<_T1, _T2>&, const std::pair<_T1, _T2>&) operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) ^~~~~~~~ /usr/include/c++/7/bits/stl_pair.h:443:5: note: template argument deduction/substitution failed: hiccup.cpp:43:23: note: mismatched types 'const std::pair<_T1, _T2>' and 'char' if (stk.back() == 'C') ^~~ In file included from /usr/include/c++/7/bits/stl_algobase.h:67:0, from /usr/include/c++/7/bits/char_traits.h:39, from /usr/include/c++/7/string:40, from hiccup.h:2, from hiccup.cpp:1: /usr/include/c++/7/bits/stl_iterator.h:299:5: note: candidate: template<class _Iterator> constexpr bool std::operator==(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_Iterator>&) operator==(const reverse_iterator<_Iterator>& __x, ^~~~~~~~ /usr/include/c++/7/bits/stl_iterator.h:299:5: note: template argument deduction/substitution failed: hiccup.cpp:43:23: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<char, int> > >::value_type {aka std::pair<char, int>}' is not derived from 'const std::reverse_iterator<_Iterator>' if (stk.back() == 'C') ^~~ In file included from /usr/include/c++/7/bits/stl_algobase.h:67:0, from /usr/include/c++/7/bits/char_traits.h:39, from /usr/include/c++/7/string:40, from hiccup.h:2, from hiccup.cpp:1: /usr/include/c++/7/bits/stl_iterator.h:337:5: note: candidate: template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_IteratorR>&) operator==(const reverse_iterator<_IteratorL>& __x, ^~~~~~~~ /usr/include/c++/7/bits/stl_iterator.h:337:5: note: template argument deduction/substitution failed: hiccup.cpp:43:23: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<char, int> > >::value_type {aka std::pair<char, int>}' is not derived from 'const std::reverse_iterator<_Iterator>' if (stk.back() == 'C') ^~~ In file included from /usr/include/c++/7/bits/stl_algobase.h:67:0, from /usr/include/c++/7/bits/char_traits.h:39, from /usr/include/c++/7/string:40, from hiccup.h:2, from hiccup.cpp:1: /usr/include/c++/7/bits/stl_iterator.h:1118:5: note: candidate: template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const std::move_iterator<_IteratorL>&, const std::move_iterator<_IteratorR>&) operator==(const move_iterator<_IteratorL>& __x, ^~~~~~~~ /usr/include/c++/7/bits/stl_iterator.h:1118:5: note: template argument deduction/substitution failed: hiccup.cpp:43:23: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<char, int> > >::value_type {aka std::pair<char, int>}' is not derived from 'const std::move_iterator<_IteratorL>' if (stk.back() == 'C') ^~~ In file included from /usr/include/c++/7/bits/stl_algobase.h:67:0, from /usr/include/c++/7/bits/char_traits.h:39, from /usr/include/c++/7/string:40, from hiccup.h:2, from hiccup.cpp:1: /usr/include/c++/7/bits/stl_iterator.h:1124:5: note: candidate: template<class _Iterator> constexpr bool std::operator==(const std::move_iterator<_IteratorL>&, const std::move_iterator<_IteratorL>&) operator==(const move_iterator<_Iterator>& __x, ^~~~~~~~ /usr/include/c++/7/bits/stl_iterator.h:1124:5: note: template argument deduction/substitution failed: hiccup.cpp:43:23: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<char, int> > >::value_type {aka std::pair<char, int>}' is not derived from 'const std::move_iterator<_IteratorL>' if (stk.back() == 'C') ^~~ In file included from /usr/include/c++/7/bits/char_traits.h:40:0, from /usr/include/c++/7/string:40, from hiccup.h:2, from hiccup.cpp:1: /usr/include/c++/7/bits/postypes.h:216:5: note: candidate: template<class _StateT> bool std::operator==(const std::fpos<_StateT>&, const std::fpos<_StateT>&) operator==(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs) ^~~~~~~~ /usr/include/c++/7/bits/postypes.h:216:5: note: template argument deduction/substitution failed: hiccup.cpp:43:23: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<char, int> > >::value_type {aka std::pair<char, int>}' is not derived from 'const std::fpos<_StateT>' if (stk.back() == 'C') ^~~ In file included from /usr/include/c++/7/string:41:0, from hiccup.h:2, from hiccup.cpp:1: /usr/include/c++/7/bits/allocator.h:146:5: note: candidate: template<class _T1, class _T2> bool std::operator==(const std::allocator<_CharT>&, const std::allocator<_T2>&) operator==(const allocator<_T1>&, const allocator<_T2>&) ^~~~~~~~ /usr/include/c++/7/bits/allocator.h:146:5: note: template argument deduction/substitution failed: hiccup.cpp:43:23: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<char, int> > >::value_type {aka std::pair<char, int>}' is not derived from 'const std::allocator<_CharT>' if (stk.back() == 'C') ^~~ In file included from /usr/include/c++/7/string:41:0, from hiccup.h:2, from hiccup.cpp:1: /usr/include/c++/7/bits/allocator.h:152:5: note: candidate: template<class _Tp> bool std::operator==(const std::allocator<_CharT>&, const std::allocator<_CharT>&) operator==(const allocator<_Tp>&, const allocator<_Tp>&) ^~~~~~~~ /usr/include/c++/7/bits/allocator.h:152:5: note: template argument deduction/substitution failed: hiccup.cpp:43:23: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<char, int> > >::value_type {aka std::pair<char, int>}' is not derived from 'const std::allocator<_CharT>' if (stk.back() == 'C') ^~~ In file included from /usr/include/c++/7/bits/basic_string.h:48:0, from /usr/include/c++/7/string:52, from hiccup.h:2, from hiccup.cpp:1: /usr/include/c++/7/string_view:450:5: note: candidate: template<class _CharT, class _Traits> constexpr bool std::operator==(std::basic_string_view<_CharT, _Traits>, std::basic_string_view<_CharT, _Traits>) operator==(basic_string_view<_CharT, _Traits> __x, ^~~~~~~~ /usr/include/c++/7/string_view:450:5: note: template argument deduction/substitution failed: hiccup.cpp:43:23: note: 'std::pair<char, int>' is not derived from 'std::basic_string_view<_CharT, _Traits>' if (stk.back() == 'C') ^~~ In file included from /usr/include/c++/7/bits/basic_string.h:48:0, from /usr/include/c++/7/string:52, from hiccup.h:2, from hiccup.cpp:1: /usr/include/c++/7/string_view:456:5: note: candidate: template<class _CharT, class _Traits> constexpr bool std::operator==(std::basic_string_view<_CharT, _Traits>, std::__detail::__idt<std::basic_string_view<_CharT, _Traits> >) operator==(basic_string_view<_CharT, _Traits> __x, ^~~~~~~~ /usr/include/c++/7/string_view:456:5: note: template argument deduction/substitution failed: hiccup.cpp:43:23: note: 'std::pair<char, int>' is not derived from 'std::basic_string_view<_CharT, _Traits>' if (stk.back() == 'C') ^~~ In file included from /usr/include/c++/7/bits/basic_string.h:48:0, from /usr/include/c++/7/string:52, from hiccup.h:2, from hiccup.cpp:1: /usr/include/c++/7/string_view:462:5: note: candidate: template<class _CharT, class _Traits> constexpr bool std::operator==(std::__detail::__idt<std::basic_string_view<_CharT, _Traits> >, std::basic_string_view<_CharT, _Traits>) operator==(__detail::__idt<basic_string_view<_CharT, _Traits>> __x, ^~~~~~~~ /usr/include/c++/7/string_view:462:5: note: template argument deduction/substitution failed: hiccup.cpp:43:23: note: mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'char' if (stk.back() == 'C') ^~~ In file included from /usr/include/c++/7/string:52:0, from hiccup.h:2, from hiccup.cpp:1: /usr/include/c++/7/bits/basic_string.h:5997:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs, ^~~~~~~~ /usr/include/c++/7/bits/basic_string.h:5997:5: note: template argument deduction/substitution failed: hiccup.cpp:43:23: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<char, int> > >::value_type {aka std::pair<char, int>}' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>' if (stk.back() == 'C') ^~~ In file included from /usr/include/c++/7/string:52:0, from hiccup.h:2, from hiccup.cpp:1: /usr/include/c++/7/bits/basic_string.h:6005:5: note: candidate: template<class _CharT> typename __gnu_cxx::__enable_if<std::__is_char<_Tp>::__value, bool>::__type std::operator==(const std::__cxx11::basic_string<_CharT>&, const std::__cxx11::basic_string<_CharT>&) operator==(const basic_string<_CharT>& __lhs, ^~~~~~~~ /usr/include/c++/7/bits/basic_string.h:6005:5: note: template argument deduction/substitution failed: hiccup.cpp:43:23: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<char, int> > >::value_type {aka std::pair<char, int>}' is not derived from 'const std::__cxx11::basic_string<_CharT>' if (stk.back() == 'C') ^~~ In file included from /usr/include/c++/7/string:52:0, from hiccup.h:2, from hiccup.cpp:1: /usr/include/c++/7/bits/basic_string.h:6019:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const _CharT*, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) operator==(const _CharT* __lhs, ^~~~~~~~ /usr/include/c++/7/bits/basic_string.h:6019:5: note: template argument deduction/substitution failed: hiccup.cpp:43:23: note: mismatched types 'const _CharT*' and 'std::pair<char, int>' if (stk.back() == 'C') ^~~ In file included from /usr/include/c++/7/string:52:0, from hiccup.h:2, from hiccup.cpp:1: /usr/include/c++/7/bits/basic_string.h:6031:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, const _CharT*) operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs, ^~~~~~~~ /usr/include/c++/7/bits/basic_string.h:6031:5: note: template argument deduction/substitution failed: hiccup.cpp:43:23: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<char, int> > >::value_type {aka std::pair<char, int>}' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>' if (stk.back() == 'C') ^~~ In file included from /usr/include/c++/7/vector:64:0, from hiccup.cpp:2: /usr/include/c++/7/bits/stl_vector.h:1596:5: note: candidate: template<class _Tp, class _Alloc> bool std::operator==(const std::vector<_Tp, _Alloc>&, const std::vector<_Tp, _Alloc>&) operator==(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y) ^~~~~~~~ /usr/include/c++/7/bits/stl_vector.h:1596:5: note: template argument deduction/substitution failed: hiccup.cpp:43:23: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<char, int> > >::value_type {aka std::pair<char, int>}' is not derived from 'const std::vector<_Tp, _Alloc>' if (stk.back() == 'C') ^~~ hiccup.cpp:45:25: error: no match for 'operator==' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::pair<char, int> > >::value_type {aka std::pair<char, int>}' and 'char') else if (stk.back() == 'H') ~~~~~~~~~~~^~~~~~ In file included from /usr/include/c++/7/bits/stl_algobase.h:64:0, from /usr/include/c++/7/bits/char_traits.h:39, from /usr/include/c++/7/string:40, from hiccup.h:2, from hiccup.cpp:1: /usr/include/c++/7/bits/stl_pair.h:443:5: note: candidate: template<class _T1, class _T2> constexpr bool std::operator==(const std::pair<_T1, _T2>&, const std::pair<_T1, _T2>&) operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) ^~~~~~~~ /usr/include/c++/7/bits/stl_pair.h:443:5: note: template argument deduction/substitution failed: hiccup.cpp:45:28: note: mismatched types 'const std::pair<_T1, _T2>' and 'char' else if (stk.back() == 'H') ^~~ In file included from /usr/include/c++/7/bits/stl_algobase.h:67:0, from /usr/include/c++/7/bits/char_traits.h:39, from /usr/include/c++/7/string:40, from hiccup.h:2, from hiccup.cpp:1: /usr/include/c++/7/bits/stl_iterator.h:299:5: note: candidate: template<class _Iterator> constexpr bool std::operator==(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_Iterator>&) operator==(const reverse_iterator<_Iterator>& __x, ^~~~~~~~ /usr/include/c++/7/bits/stl_iterator.h:299:5: note: template argument deduction/substitution failed: hiccup.cpp:45:28: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<char, int> > >::value_type {aka std::pair<char, int>}' is not derived from 'const std::reverse_iterator<_Iterator>' else if (stk.back() == 'H') ^~~ In file included from /usr/include/c++/7/bits/stl_algobase.h:67:0, from /usr/include/c++/7/bits/char_traits.h:39, from /usr/include/c++/7/string:40, from hiccup.h:2, from hiccup.cpp:1: /usr/include/c++/7/bits/stl_iterator.h:337:5: note: candidate: template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_IteratorR>&) operator==(const reverse_iterator<_IteratorL>& __x, ^~~~~~~~ /usr/include/c++/7/bits/stl_iterator.h:337:5: note: template argument deduction/substitution failed: hiccup.cpp:45:28: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<char, int> > >::value_type {aka std::pair<char, int>}' is not derived from 'const std::reverse_iterator<_Iterator>' else if (stk.back() == 'H') ^~~ In file included from /usr/include/c++/7/bits/stl_algobase.h:67:0, from /usr/include/c++/7/bits/char_traits.h:39, from /usr/include/c++/7/string:40, from hiccup.h:2, from hiccup.cpp:1: /usr/include/c++/7/bits/stl_iterator.h:1118:5: note: candidate: template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const std::move_iterator<_IteratorL>&, const std::move_iterator<_IteratorR>&) operator==(const move_iterator<_IteratorL>& __x, ^~~~~~~~ /usr/include/c++/7/bits/stl_iterator.h:1118:5: note: template argument deduction/substitution failed: hiccup.cpp:45:28: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<char, int> > >::value_type {aka std::pair<char, int>}' is not derived from 'const std::move_iterator<_IteratorL>' else if (stk.back() == 'H') ^~~ In file included from /usr/include/c++/7/bits/stl_algobase.h:67:0, from /usr/include/c++/7/bits/char_traits.h:39, from /usr/include/c++/7/string:40, from hiccup.h:2, from hiccup.cpp:1: /usr/include/c++/7/bits/stl_iterator.h:1124:5: note: candidate: template<class _Iterator> constexpr bool std::operator==(const std::move_iterator<_IteratorL>&, const std::move_iterator<_IteratorL>&) operator==(const move_iterator<_Iterator>& __x, ^~~~~~~~ /usr/include/c++/7/bits/stl_iterator.h:1124:5: note: template argument deduction/substitution failed: hiccup.cpp:45:28: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<char, int> > >::value_type {aka std::pair<char, int>}' is not derived from 'const std::move_iterator<_IteratorL>' else if (stk.back() == 'H') ^~~ In file included from /usr/include/c++/7/bits/char_traits.h:40:0, from /usr/include/c++/7/string:40, from hiccup.h:2, from hiccup.cpp:1: /usr/include/c++/7/bits/postypes.h:216:5: note: candidate: template<class _StateT> bool std::operator==(const std::fpos<_StateT>&, const std::fpos<_StateT>&) operator==(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs) ^~~~~~~~ /usr/include/c++/7/bits/postypes.h:216:5: