제출 #1198718

#제출 시각아이디문제언어결과실행 시간메모리
1198718nvc2k8Palindrome-Free Numbers (BOI13_numbers)C++20
100 / 100
0 ms328 KiB
#include <bits/stdc++.h> #define TASK "numbers" #define INT_LIM (int) 2147483647 #define LL_LIM (long long) 9223372036854775807 #define endl '\n' #define mp make_pair #define pb push_back #define fi first #define se second #define BIT(i,x) (((i)>>(x))&1) #define FOR(i,a,b) for(int i = (a); i<=(b); i++) #define FORD(i,a,b) for(int i = (a); i>=(b); i--) #define ll long long #define pii pair<int,int> using namespace std; ///------------------------------------------/// string a,b; void inp() { cin >> a >> b; while(a.size()<19) a = '0'+a; while(b.size()<19) b = '0'+b; } ll dp[19][2][2][11][11]; void add(ll &x, const ll &y) { x+=y; } ll calc(int i, int okl, int okr, int la1, int la2) { if (i==19) return 1; ll &ret = dp[i][okl][okr][la1][la2]; if (ret!=-1) return ret; ret = 0; int dl = ((okl)?0:a[i]-'0'); int dh = ((okr)?9:b[i]-'0'); FOR(d, dl, dh) if (d!=la1 && d!=la2) { int nd = d; if (la1==10 && la2==10 && d==0) nd = 10; add(ret, calc(i+1, okl|(d>a[i]-'0'), okr|(d<b[i]-'0'), nd, la1)); } return ret; } void solve() { memset(dp, -1, sizeof dp); cout << calc(0, 0, 0, 10, 10); } signed main() { ///--------------------------/// ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); if (fopen(TASK".INP","r")!=NULL) { freopen(TASK".INP","r",stdin); freopen(TASK".OUT","w",stdout); } ///--------------------------/// int NTEST = 1; //cin >> NTEST; while (NTEST--) { inp(); solve(); } return 0; } ///------------------------------------------///

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

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