Submission #500742

#TimeUsernameProblemLanguageResultExecution timeMemory
500742MurotYPalindrome-Free Numbers (BOI13_numbers)C++14
23.75 / 100
1094 ms312 KiB
#include <bits/stdc++.h>
#define ios ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ff first
#define ll long long
#define ss second
using namespace std;
const int N=1e6+1;

bool ok(ll n){
	string s;
	while (n){
		s=char(48+(n % 10))+s;
		n/=10;
	}
	
	if (s.size() == 1) return 0;
	for (int i=1;i<s.size()-1;i++){
		if (s[i-1] == s[i+1]) return 1;
	}
	for (int i=0;i<s.size()-1;i++){
		if (s[i] == s[i+1]) return 1;
	}
	return 0;
}
int main()
{
	ios;
	ll a, b, ans=0;
	
	cin >> a >> b;
	
	for (int i=a;i<=b;i++){
		if (!ok(i)) ans++;
	}
	cout << ans;
}

Compilation message (stderr)

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