제출 #1274843

#제출 시각아이디문제언어결과실행 시간메모리
1274843icebearPalindrome-Free Numbers (BOI13_numbers)C++20
71.25 / 100
1 ms636 KiB
// ~~ icebear ~~ #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> ii; typedef pair<int, ii> iii; template<class T> bool minimize(T &a, const T &b) { if (a > b) return a = b, true; return false; } template<class T> bool maximize(T &a, const T &b) { if (a < b) return a = b, true; return false; } #define FOR(i,a,b) for(int i=(a); i<=(b); ++i) #define FORR(i,a,b) for(int i=(a); i>=(b); --i) #define REP(i, n) for(int i=0; i<(n); ++i) #define RED(i, n) for(int i=(n)-1; i>=0; --i) #define MASK(i) (1LL << (i)) #define BIT(S, i) (((S) >> (i)) & 1) #define mp make_pair #define pb push_back #define fi first #define se second #define all(x) x.begin(), x.end() #define task "icebear" const int MOD = 1e9 + 7; const int inf = 1e9 + 27092008; const ll INF = 1e18 + 27092008; const int N = 20 + 5; ll L, R, f[N][11][11][2]; vector<int> digit; ll dp(int pos, int last2, int last1, bool smaller) { if (pos == -1) return 1; ll &ret = f[pos][last2][last1][smaller]; if (ret != -1) return ret; ret = 0; int limit = (smaller ? 9 : digit[pos]); FOR(i, 0, limit) if (last1 != i && last2 != i) ret += dp(pos - 1, last1, i, smaller | (i < limit)); return ret; } ll calc(ll x) { if (x == 0) return 1; memset(f, -1, sizeof f); digit.clear(); while(x > 0) digit.pb(x % 10), x /= 10; return dp((int)digit.size() - 1, 10, 10, 0); } void init(void) { cin >> L >> R; } void process(void) { cout << calc(R) - calc(L - 1); } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if (fopen(task".inp", "r")) { freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout); } int tc = 1; // cin >> tc; while(tc--) { init(); process(); } return 0; }

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

numbers.cpp: In function 'int main()':
numbers.cpp:73:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   73 |         freopen(task".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
numbers.cpp:74:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   74 |         freopen(task".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...