Submission #1120731

#TimeUsernameProblemLanguageResultExecution timeMemory
1120731vjudge1Palindrome-Free Numbers (BOI13_numbers)C++17
33.75 / 100
1094 ms592 KiB
/**
██╗░░██╗████████╗██╗░░░░░███╗░░░███╗
██║░░██║╚══██╔══╝██║░░░░░████╗░████║
███████║░░░██║░░░██║░░░░░██╔████╔██║
██╔══██║░░░██║░░░██║░░░░░██║╚██╔╝██║
██║░░██║░░░██║░░░███████╗██║░╚═╝░██║
╚═╝░░╚═╝░░░╚═╝░░░╚══════╝╚═╝░░░░░╚═╝
**/

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

#define int l
#define f first
#define ara <<" "<<
#define s second
#define endl '\n'
#define l long long
#define pb push_back
#define pairs pair<l,l>
#define all(v) v.begin(),v.end()
#define yesno(v) ((v) ? "YES" : "NO")
#define dbg(x) cout<<#x<<" = "<<x<<endl;
#define filereader() ifstream cin(input);
#define fileprinter() ofstream cout(output);
#define fast ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);


using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less_equal<int> , rb_tree_tag, tree_order_statistics_node_update> indexed_set;

ifstream in;
ofstream out;

l gcd(l a, l b){
    return (b == 0) ? a : gcd(b, a%b);
}

const l N = 3e5 + 5;
const l INF = 1e18;
const l mod = 1e9 + 7;

const string  input =  "input.txt";
const string output = "output.txt";

l delta = 0;
bool on = false;

l ch(l n){
    string s = to_string(n);

    for(int i = 0 ; i < s.size(); i++){
        for(int j = i + 1 ; j < s.size();j++){
            string p = s.substr(i, j - i + 1);
            string k = p;reverse(all(k));
            if(k == p){
                delta = s.size() - j - 1;
                on = true;
                return 0;
            }
        }
    }

    return 1;

}

signed main(){
    fast;
    l a,b;


    cin>>a>>b;

    l ans = 0;

    for(int i = a ; i <= b;i++){
        on = false;

        ans += ch(i);

        if(on){
            i += pow(10,delta) - 1;
        }

    }
    cout<<ans<<endl;

}

Compilation message (stderr)

numbers.cpp: In function 'long long int ch(long long int)':
numbers.cpp:55:23: 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]
   55 |     for(int i = 0 ; i < s.size(); i++){
      |                     ~~^~~~~~~~~~
numbers.cpp:56:31: 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]
   56 |         for(int j = i + 1 ; j < s.size();j++){
      |                             ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...