Submission #1120201

#TimeUsernameProblemLanguageResultExecution timeMemory
1120201vjudge1Palindrome-Free Numbers (BOI13_numbers)C++17
31.67 / 100
1086 ms512 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #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]){ if(pal(c)) return true; } } } return false; } signed 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 << b - a + 1 - ans << endl; }

Compilation message (stderr)

numbers.cpp: In function 'bool f(long long int)':
numbers.cpp:23:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |     for(int i = 0;i < s.size() - 1;i++)
      |                   ~~^~~~~~~~~~~~~~
numbers.cpp:27:29: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |         for(int j = i + 1;j < s.size();j++)
      |                           ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...