| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 977129 | VMaksimoski008 | Palindrome-Free Numbers (BOI13_numbers) | C++17 | 3 ms | 1880 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
string s;
ll dp[19][11][11][2][2][19];
ll f(int p, int L1, int L2, bool U, bool S, int L) {
if(p == s.size()) return 1;
if(dp[p][L1][L2][U][S][L] != -1) return dp[p][L1][L2][U][S][L];
ll ans = 0;
for(int i=0; i<=9; i++) {
if(L >= 1 && i == L1) continue;
if(L >= 2 && i == L2) continue;
if(!U && (i > (s[p] - '0'))) continue;
bool ns = S | (i > 0);
ans += f(p+1, i, L1, U | (i < (s[p] - '0')), ns, L + ns);
}
return dp[p][L1][L2][U][S][L] = ans;
}
ll cnt(ll x) {
s = to_string(x);
memset(dp, -1, sizeof(dp));
return f(0, 10, 10, 0, 0, 0);
}
int main() {
ll l, r;
cin >> l >> r;
cout << cnt(r) - cnt(l-1) << '\n';
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
