제출 #1120884

#제출 시각아이디문제언어결과실행 시간메모리
1120884vjudge1Palindrome-Free Numbers (BOI13_numbers)C++17
41.67 / 100
1087 ms516 KiB
#include "bits/stdc++.h" #define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define ll long long #define pb push_back #define in insert #define F first #define S second #define vll vector<ll> #define all(v) v.begin(),v.end() #define endl '\n' #define pii pair<ll,ll> using namespace std; const ll INF =1e18, mod = 1e9 + 7, N = 1e5 + 5; bool check(const string &s){ for(int i = 0; i < s.size() / 2; i++){ if(s[i] != s[s.size() - i - 1]){ return false; } } return true; } bool free(ll n){ string s = to_string(n); for(int i = 2; i <=s.size(); i++){ for(int j = 0; j + i <= s.size(); j++){ if(check(s.substr(j,i))){ return false; } } } return true; } void solve(){ int a,b; cin >> a >> b; int cnt = 0; for(int i = a; i <= b; i++){ string w = to_string(i); if(w.size() == 1){ continue; } else if(w.size() == 2){ if(w[0] != w[1]){ cnt++; } continue; } if(free(i)){ cnt++; } } cout << cnt << endl; } int main(){ fast; solve(); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

numbers.cpp: In function 'bool check(const string&)':
numbers.cpp:15:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |     for(int i = 0; i < s.size() / 2; i++){
      |                    ~~^~~~~~~~~~~~~~
numbers.cpp: In function 'bool free(long long int)':
numbers.cpp:24:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |     for(int i = 2; i <=s.size(); i++){
      |                    ~~^~~~~~~~~~
numbers.cpp:25:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |         for(int j = 0; j + i <= s.size(); j++){
      |                        ~~~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...