제출 #1029327

#제출 시각아이디문제언어결과실행 시간메모리
1029327kiethm07Palindrome-Free Numbers (BOI13_numbers)C++11
73.75 / 100
1 ms460 KiB
#include <bits/stdc++.h> #define pii pair<int,int> #define iii pair<int,pii> #define fi first #define se second #define vi vector<int> #define vii vector<pii> #define pb(i) push_back(i) #define all(x) x.begin(),x.end() #define TEXT "a" using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; const int inf = 1e9 + 7; const ld eps = 1e-8; const double pi = acos(-1); ll dp[20][11][11][2][2]; string s; int n; string conv(ll x){ string res = ""; while(x){ res += (x % 10) + '0'; x /= 10; } reverse(all(res)); return res; } ll f(int pos,int l,int p,bool small,bool start){ if (pos == n) return 1; ll &res = dp[pos][l][p][small][start]; if (res != -1) return res; int num = s[pos] - '0'; res = 0; for (int i = 0; i <= 9; i++){ bool nsmall = small | (i < num); bool nstart = start | (i > 0); if ((small == 0) && (i > num)) break; if (start && (i == p || i == l)) continue; res += f(pos + 1,i,l,nsmall,nstart); } return res; } ll cal(ll x){ if (x < 0) return 0; memset(dp,-1,sizeof(dp)); s = conv(x); n = s.size(); return f(0,10,10,0,0); } int main(){ cin.tie(0) -> sync_with_stdio(0); if (fopen(TEXT".inp","r")){ freopen(TEXT".inp","r",stdin); freopen(TEXT".out","w",stdout); } ll a,b; cin >> a >> b; ll res = cal(b) - cal(a - 1); cout << res << "\n"; return 0; }

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

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