Submission #1121036

#TimeUsernameProblemLanguageResultExecution timeMemory
1121036AtabayRajabliPalindrome-Free Numbers (BOI13_numbers)C++17
55.83 / 100
1071 ms552 KiB
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
using namespace std;

int get(string s)
{
    int ok = 0;
    for(int i = 0; i < s.size() - 1; i++)
    {
        if(s[i] == s[i + 1]) return 0;
        if(i + 2 < s.size() && (s[i] == s[i + 2])) return 0;
    }
    return !ok;
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int l, r, ans = 0;
    cin >> l >> r;
    while(l <= r)
    {
        ans += get(to_string(l++));
    }
    cout << ans;
}  

Compilation message (stderr)

numbers.cpp: In function 'int get(std::string)':
numbers.cpp:8:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |     for(int i = 0; i < s.size() - 1; i++)
      |                    ~~^~~~~~~~~~~~~~
numbers.cpp:11:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |         if(i + 2 < s.size() && (s[i] == s[i + 2])) return 0;
      |            ~~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...