Submission #1120522

#TimeUsernameProblemLanguageResultExecution timeMemory
1120522vjudge1Palindrome-Free Numbers (BOI13_numbers)C++17
49.17 / 100
1099 ms508 KiB
#include <bits/stdc++.h> using namespace std; #define ld double const int INF = 1e18; const int mod = 12345; const int sz = 1e5 + 5; bool pal(string z) { string s = z; reverse(s.begin() , s.end()); return z == s; } bool f(int x) { string s; s = to_string(x); for(int i = 0;i < s.size() - 1;i++) { string c = ""; c += s[i]; for(int j = i + 1;j < s.size();j++) { c += s[j]; if(c[0] == c[c.size() - 1] && c[1] == c[c.size() - 2]){ if(pal(c)) return false; } } } return true; } int main() { ios_base::sync_with_stdio(0);cin.tie(0); int a , b; cin >> a >> b; int ans = 0; for(int i = a;i <= b;i++) { if(f(i)) { ans++; //cout << i << endl; } } cout << ans << endl; }

Compilation message (stderr)

numbers.cpp:7:17: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
    7 | const int INF = 1e18;
      |                 ^~~~
numbers.cpp: In function 'bool f(int)':
numbers.cpp:22:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |     for(int i = 0;i < s.size() - 1;i++)
      |                   ~~^~~~~~~~~~~~~~
numbers.cpp:26:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |         for(int j = i + 1;j < s.size();j++)
      |                           ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...