ICPCの過去問
●問題→http://www.deqnotes.net/acmicpc/2684/ja
●模範解答→http://www.deqnotes.net/acmicpc/2684/2684-deq_1.cpp
PKUに模範解答を提出すると、コンパイルエラーになります。なぜだか教えてください。
●エラーの内容↓
Main.cpp
F:\temp\11340104.347790\Main.cpp(17) : error C2679: binary '>>' : no operator found which takes a right-hand operand of type 'int' (or there is no acceptable conversion) istream(1000): could be 'std::basic_istream<_Elem,_Traits> &std::operator >><std::char_traits<char>>(std::basic_istream<_Elem,_Traits> &,signed char *)' with [
_Elem=char,
_Traits=std::char_traits<char>
]
istream(1007): or 'std::basic_istream<_Elem,_Traits> &std::operator >><std::char_traits<char>>(std::basic_istream<_Elem,_Traits> &,signed char &)'
with [
_Elem=char,
_Traits=std::char_traits<char>
] istream(1014): or 'std::basic_istream<_Elem,_Traits> &std::operator >><std::char_traits<char>>(std::basic_istream<_Elem,_Traits> &,unsigned char *)'
with [ _Elem=char,
_Traits=std::char_traits<char>
] istream(1021): or 'std::basic_istream<_Elem,_Traits> &std::operator >><std::char_traits<char>>(std::basic_istream<_Elem,_Traits> &,unsigned char &)'
with [_Elem=char,
_Traits=std::char_traits<char>
] istream(155): or 'std::basic_istream<_Elem,_Traits> &std::basic_istream<_Elem,_Traits>::operator >>(std::basic_istream<_Elem,_Traits> &(*)(std::basic_istream<_Elem,_Traits> &))'
with [_Elem=char,
_Traits=std::char_traits<char>
] istream(161): or 'std::basic_istream<_Elem,_Traits> &std::basic_istream<_Elem,_Traits>::operator >>(std::basic_ios<_Elem,_Traits> &(*)(std::basic_ios<_Elem,_Traits> &))'
with
[
_Elem=char,
_Traits=std::char_traits<char>
] istream(168): or 'std::basic_istream<_Elem,_Traits> &std::basic_istream<_Elem,_Traits>::operator >>(std::ios_base &(*)(std::ios_base &))'
with [
_Elem=char,
_Traits=std::char_traits<char>
] istream(175): or 'std::basic_istream<_Elem,_Traits> &std::basic_istream<_Elem,_Traits>::operator >>(std::_Bool &)'
with
[ _Elem=char,
_Traits=std::char_traits<char>
] istream(194): or 'std::basic_istream<_Elem,_Traits> &std::basic_istream<_Elem,_Traits>::operator >>(short &)'
with
[ _Elem=char,
_Traits=std::char_traits<char>
] istream(228): or 'std::basic_istream<_Elem,_Traits> &std::basic_istream<_Elem,_Traits>::operator >>(unsigned short &)'
with[
_Elem=char,
_Traits=std::char_traits<char>
] istream(247): or 'std::basic_istream<_Elem,_Traits> &std::basic_istream<_Elem,_Traits>::operator >>(int &)'
with [
_Elem=char,
_Traits=std::char_traits<char>
] istream(273): or 'std::basic_istream<_Elem,_Traits> &std::basic_istream<_Elem,_Traits>::operator >>(unsigned int &)'
with [ _Elem=char,
_Traits=std::char_traits<char>
] istream(291): or 'std::basic_istream<_Elem,_Traits> &std::basic_istream<_Elem,_Traits>::operator >>(long &)'
with [ _Elem=char, _Traits=std::char_traits<char>
] istream(309): or 'std::basic_istream<_Elem,_Traits> &std::basic_istream<_Elem,_Traits>::operator >>(__w64 unsigned long &)'
with [_Elem=char,
_Traits=std::char_traits<char>
]
istream(329): or 'std::basic_istream<_Elem,_Traits> &std::basic_istream<_Elem,_Traits>::operator >>(__int64 &)'
with
[ _Elem=char,
_Trait
・・・って感じでエラー文が続きます。全部入りきらなかったのでここまでとりあえず載せます。
お礼
ありがとうございました! vectorのsizeを書き出さないかなと思っていたのですが、readの時にassignするところなどは考えが及んでおりませんでした。ありがとうございます。 reinterpret_castについても今まで知識がなかったので、いろいろと調べてみます。