Submission #564473

#TimeUsernameProblemLanguageResultExecution timeMemory
564473MrDebooQuestion (Grader is different from the original contest) (CEOI14_question_grader)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; int encode (int n, int x, int y) { if(x>n)x=0; if(y>n)y=0; string s; string f=to_string(x); while(f.size()<3)f="0"+f; s+=f; f=to_string(y); while(f.size()<3)f="0"+f; s+=f; return stoi(s); }
#include <bits/stdc++.h> using namespace std; int decode (int n, int q, int h) { string s=to_string(h); int a=0; for(int i=0;i<3;i++){ a+=(h.back()-'0')*ceil(pow(10,i)); h.pop_back(); } int b=stoi(h); if(q==b)return 1; return 0; }

Compilation message (stderr)

decoder.cpp: In function 'int decode(int, int, int)':
decoder.cpp:7:9: error: request for member 'back' in 'h', which is of non-class type 'int'
    7 |   a+=(h.back()-'0')*ceil(pow(10,i));
      |         ^~~~
decoder.cpp:8:5: error: request for member 'pop_back' in 'h', which is of non-class type 'int'
    8 |   h.pop_back();
      |     ^~~~~~~~
decoder.cpp:10:14: error: no matching function for call to 'stoi(int&)'
   10 |  int b=stoi(h);
      |              ^
In file included from /usr/include/c++/10/string:55,
                 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 decoder.cpp:1:
/usr/include/c++/10/bits/basic_string.h:6546:3: note: candidate: 'int std::__cxx11::stoi(const string&, std::size_t*, int)'
 6546 |   stoi(const string& __str, size_t* __idx = 0, int __base = 10)
      |   ^~~~
/usr/include/c++/10/bits/basic_string.h:6546:22: note:   no known conversion for argument 1 from 'int' to 'const string&' {aka 'const std::__cxx11::basic_string<char>&'}
 6546 |   stoi(const string& __str, size_t* __idx = 0, int __base = 10)
      |        ~~~~~~~~~~~~~~^~~~~
/usr/include/c++/10/bits/basic_string.h:6677:3: note: candidate: 'int std::__cxx11::stoi(const wstring&, std::size_t*, int)'
 6677 |   stoi(const wstring& __str, size_t* __idx = 0, int __base = 10)
      |   ^~~~
/usr/include/c++/10/bits/basic_string.h:6677:23: note:   no known conversion for argument 1 from 'int' to 'const wstring&' {aka 'const std::__cxx11::basic_string<wchar_t>&'}
 6677 |   stoi(const wstring& __str, size_t* __idx = 0, int __base = 10)
      |        ~~~~~~~~~~~~~~~^~~~~