| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 832070 | allw | Palindrome-Free Numbers (BOI13_numbers) | C++17 | 1092 ms | 340 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <algorithm>
#include <cstdio>
#include <vector>
#include <iostream>
#include <map>
#include <cstring>
#define LOCAL true
/*
Author: Oleksii Renov
*/
using namespace std;
using ll = long long int;
int dp[100];
ll run(int pos, int last1, int last2, bool smaller, bool started, const string& x) {
if (pos == x.size()) {
return 1;
}
int end = smaller ? 9 : (x[pos] - '0');
ll cnt = 0;
for (int i = 0; i <= end; ++i) {
if (!started && i == 0) continue;
if (i != last1 && i != last2) {
cnt += run(pos + 1, i, last1, smaller || (i != end), started || (i != 0), x);
}
}
return cnt;
}
int main() {
ll a, b;
cin >> a >> b;
memset(dp, -1, sizeof(dp));
ll cnt1 = run(0, 10, 10, false, false, to_string(b));
memset(dp, -1, sizeof(dp));
ll cnt2 = run(0, 10, 10, false, false, to_string(a-1));
std::cout << cnt1 - cnt2 << '\n';
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
