제출 #410786

#제출 시각아이디문제언어결과실행 시간메모리
410786VictorPalindrome-Free Numbers (BOI13_numbers)C++17
72.50 / 100
2 ms332 KiB
#include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for (int i = a; i < (b); ++i) #define per(i, a, b) for (int i = b - 1; i >= (a); --i) #define trav(a, x) for (auto &a : x) #define all(x) x.begin(), x.end() #define sz(x) x.size() #define pb push_back #define umap unordered_map #define uset unordered_set typedef pair<int, int> ii; typedef pair<int, ii> iii; typedef vector<int> vi; typedef vector<ii> vii; typedef vector<vi> vvi; typedef long long ll; const int INF = 1'000'000'007; string lo, hi; ll memo[20][11][11][2][2]; ll dp(int num, int prev, int befprev, bool l_bound, bool u_bound) { if (num == sz(hi)) return 1; ll &ans = memo[num][prev][befprev][l_bound][u_bound]; if(ans!=-1)return ans; ans = sz(lo) <= num; if (sz(lo) <= num) l_bound = 0; int start = l_bound ? lo[num] - '0' : 0, stop = u_bound ? hi[num] - '0' + 1 : 10; rep(i, start, stop) { if (i == prev || i == befprev) continue; ans += dp(num + 1, i, prev, l_bound & (i == lo[num] - '0'), u_bound & (i == hi[num] - '0')); } return ans; } int main() { cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit); ll l,h; memset(memo, -1, sizeof(memo)); cin >> l >> h; lo=to_string(l); hi=to_string(h); cout<<dp(0,10,10,1,1)<<endl; return 0; }

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

numbers.cpp: In function 'll dp(int, int, int, bool, bool)':
numbers.cpp:29:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |     if (num == sz(hi)) return 1;
      |             ^
numbers.cpp:34:18: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   34 |     ans = sz(lo) <= num;
      |                  ^
numbers.cpp:35:16: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   35 |     if (sz(lo) <= num) l_bound = 0;
      |                ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...