제출 #23617

#제출 시각아이디문제언어결과실행 시간메모리
23617Hiasat앵무새 (IOI11_parrots)C++14
컴파일 에러
0 ms0 KiB
#include "encoder.h" #include "encoderlib.h" #include <bits/stdc++.h> using namespace std; string to_string(int num){ int tmp = num; string r = ""; if(num == 0) r = '0'; while(tmp){ r +=(char)((tmp%10) + '0'); tmp /= 10; } reverse(r.begin(),r.end()); return r; } int toNum(string r){ int num = 0; for (int i = 0; i < r.size(); ++i){ num *= 10; num += (r[i]-'0'); } return num; } void encode(int N, int M[]) { for(int i=0; i<N; i++){ string cur = to_string(M[i]); string f = to_string(i); if(f.size() == 1) f = '0' + f; cur = cur + f; send(toNum(cur)); } }
#include "decoder.h" #include "decoderlib.h" #include <bits/stdc++.h> using namespace std; string to_string1(int num){ int tmp = num; string r = ""; if(num == 0) r = '0'; while(tmp){ r +=(char)((tmp%10) + '0'); tmp /= 10; } reverse(r.begin(),r.end()); return r; } int ans[110]; void decode(int N, int L, int X[]) { int i, b; for(i=0; i<L; i++) { string cur = to_string1(X[i]); int test = 0; for (int j = (int)cur.size() - 2 ; j <= (int)cur.size()-1; ++j){ if(j < 0) continue; test *= 10; test += (cur[j]-'0'); } int num = 0; for (int j = 0; j < (int)cur.size() - 2 ; ++j){ num *= 10; num += (cur[j]-'0'); } ans[test] = num; } for (int i = 0; i < N; ++i){ output(ans[i]); } }

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

encoder.cpp: In function 'int toNum(std::__cxx11::string)':
encoder.cpp:24:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < r.size(); ++i){
                  ~~^~~~~~~~~~
encoder.cpp: In function 'void encode(int, int*)':
encoder.cpp:33:31: error: call of overloaded 'to_string(int&)' is ambiguous
    string cur = to_string(M[i]);
                               ^
encoder.cpp:10:8: note: candidate: std::__cxx11::string to_string(int)
 string to_string(int num){
        ^~~~~~~~~
In file included from /usr/include/c++/7/string:52:0,
                 from /usr/include/c++/7/bits/locale_classes.h:40,
                 from /usr/include/c++/7/bits/ios_base.h:41,
                 from /usr/include/c++/7/ios:42,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from encoder.cpp:4:
/usr/include/c++/7/bits/basic_string.h:6454:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(long double)
   to_string(long double __val)
   ^~~~~~~~~
/usr/include/c++/7/bits/basic_string.h:6445:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(double)
   to_string(double __val)
   ^~~~~~~~~
/usr/include/c++/7/bits/basic_string.h:6436:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(float)
   to_string(float __val)
   ^~~~~~~~~
/usr/include/c++/7/bits/basic_string.h:6430:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(long long unsigned int)
   to_string(unsigned long long __val)
   ^~~~~~~~~
/usr/include/c++/7/bits/basic_string.h:6424:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(long long int)
   to_string(long long __val)
   ^~~~~~~~~
/usr/include/c++/7/bits/basic_string.h:6418:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(long unsigned int)
   to_string(unsigned long __val)
   ^~~~~~~~~
/usr/include/c++/7/bits/basic_string.h:6413:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(long int)
   to_string(long __val)
   ^~~~~~~~~
/usr/include/c++/7/bits/basic_string.h:6407:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(unsigned int)
   to_string(unsigned __val)
   ^~~~~~~~~
/usr/include/c++/7/bits/basic_string.h:6402:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(int)
   to_string(int __val)
   ^~~~~~~~~
encoder.cpp:34:25: error: call of overloaded 'to_string(int&)' is ambiguous
   string f = to_string(i);
                         ^
encoder.cpp:10:8: note: candidate: std::__cxx11::string to_string(int)
 string to_string(int num){
        ^~~~~~~~~
In file included from /usr/include/c++/7/string:52:0,
                 from /usr/include/c++/7/bits/locale_classes.h:40,
                 from /usr/include/c++/7/bits/ios_base.h:41,
                 from /usr/include/c++/7/ios:42,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from encoder.cpp:4:
/usr/include/c++/7/bits/basic_string.h:6454:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(long double)
   to_string(long double __val)
   ^~~~~~~~~
/usr/include/c++/7/bits/basic_string.h:6445:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(double)
   to_string(double __val)
   ^~~~~~~~~
/usr/include/c++/7/bits/basic_string.h:6436:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(float)
   to_string(float __val)
   ^~~~~~~~~
/usr/include/c++/7/bits/basic_string.h:6430:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(long long unsigned int)
   to_string(unsigned long long __val)
   ^~~~~~~~~
/usr/include/c++/7/bits/basic_string.h:6424:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(long long int)
   to_string(long long __val)
   ^~~~~~~~~
/usr/include/c++/7/bits/basic_string.h:6418:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(long unsigned int)
   to_string(unsigned long __val)
   ^~~~~~~~~
/usr/include/c++/7/bits/basic_string.h:6413:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(long int)
   to_string(long __val)
   ^~~~~~~~~
/usr/include/c++/7/bits/basic_string.h:6407:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(unsigned int)
   to_string(unsigned __val)
   ^~~~~~~~~
/usr/include/c++/7/bits/basic_string.h:6402:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(int)
   to_string(int __val)
   ^~~~~~~~~

decoder.cpp: In function 'void decode(int, int, int*)':
decoder.cpp:27:10: warning: unused variable 'b' [-Wunused-variable]
   int i, b;
          ^