Submission #1120531

#TimeUsernameProblemLanguageResultExecution timeMemory
1120531vjudge1Palindrome-Free Numbers (BOI13_numbers)C++17
27.50 / 100
1084 ms508 KiB
#include <bits/stdc++.h> using namespace std; bool check_palindrome(string s) { for(int i=0;i<s.size()/2;i++) if(s[i]!=s[s.size()-i-1]) return false; return true; } bool check(string s) { for(int i=0;i<s.size();i++) { for(int j=i+1;j<s.size();j++) { string cur=""; for(int k=i;k<=j;k++) cur+=s[k]; if(check_palindrome(cur)) return false; } } return true; } void solve() { long long a,b; int res=0; scanf("%ld%ld",&a,&b); for(int i=a;i<=b;i++) { string s=to_string(i); if(check(s)) res++; } printf("%ld",res); } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t=1; //cin>>t; while(t--) { solve(); } }

Compilation message (stderr)

numbers.cpp: In function 'bool check_palindrome(std::string)':
numbers.cpp:7:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    7 |     for(int i=0;i<s.size()/2;i++)
      |                 ~^~~~~~~~~~~
numbers.cpp: In function 'bool check(std::string)':
numbers.cpp:16:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |     for(int i=0;i<s.size();i++)
      |                 ~^~~~~~~~~
numbers.cpp:18:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |         for(int j=i+1;j<s.size();j++)
      |                       ~^~~~~~~~~
numbers.cpp: In function 'void solve()':
numbers.cpp:39:14: warning: format '%ld' expects argument of type 'long int*', but argument 2 has type 'long long int*' [-Wformat=]
   39 |     scanf("%ld%ld",&a,&b);
      |            ~~^     ~~
      |              |     |
      |              |     long long int*
      |              long int*
      |            %lld
numbers.cpp:39:17: warning: format '%ld' expects argument of type 'long int*', but argument 3 has type 'long long int*' [-Wformat=]
   39 |     scanf("%ld%ld",&a,&b);
      |               ~~^     ~~
      |                 |     |
      |                 |     long long int*
      |                 long int*
      |               %lld
numbers.cpp:49:15: warning: format '%ld' expects argument of type 'long int', but argument 2 has type 'int' [-Wformat=]
   49 |     printf("%ld",res);
      |             ~~^  ~~~
      |               |  |
      |               |  int
      |               long int
      |             %d
numbers.cpp:39:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   39 |     scanf("%ld%ld",&a,&b);
      |     ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...