# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
563433 | 2022-05-17T07:56:55 Z | tht2005 | Palindrome-Free Numbers (BOI13_numbers) | C++17 | 1 ms | 340 KB |
#include <bits/stdc++.h> using namespace std; typedef long long LL; char a[20]; LL f[20][10][10][2]; LL calc(LL x) { sprintf(a, "%lld", x); int n = strlen(a); for(int i = 0; i <= n; ++i) { memset(f[i], 0, sizeof(f[i])); } f[0][0][0][0] = 1; for(int i = 1; i < n; ++i) { f[i][0][0][1] = 1; } for(int i = 0; i < n; ++i) { for(int j = 0; j < 10; ++j) { for(int k = 0; k < 10; ++k) { for(int t = 0; t < 2; ++t) { LL ft = f[i][j][k][t]; if(ft == 0) continue; for(int c = (i == 0); (t ? (c < 10) : (c <= a[i] - '0')); ++c) { if(i && c == k) continue; if(i > 1 && c == j) continue; f[i + 1][k][c][t || (c < a[i] - '0')] += ft; } } } } } LL res = 0; for(int i = 0; i < 10; ++i) { for(int j = 0; j < 10; ++j) { res += f[n][i][j][1]; } } return res; } int main() { LL l, r; scanf("%lld %lld", &l, &r); printf("%lld", calc(r + 1) - calc(l)); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 212 KB | Output isn't correct |
2 | Incorrect | 0 ms | 212 KB | Output isn't correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Incorrect | 0 ms | 212 KB | Output isn't correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Incorrect | 0 ms | 212 KB | Output isn't correct |
7 | Incorrect | 0 ms | 212 KB | Output isn't correct |
8 | Incorrect | 0 ms | 212 KB | Output isn't correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 1 ms | 212 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Incorrect | 0 ms | 212 KB | Output isn't correct |
15 | Incorrect | 0 ms | 212 KB | Output isn't correct |
16 | Correct | 0 ms | 212 KB | Output is correct |
17 | Correct | 0 ms | 212 KB | Output is correct |
18 | Incorrect | 0 ms | 212 KB | Output isn't correct |
19 | Correct | 0 ms | 212 KB | Output is correct |
20 | Incorrect | 0 ms | 212 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Incorrect | 0 ms | 212 KB | Output isn't correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Incorrect | 1 ms | 212 KB | Output isn't correct |
8 | Incorrect | 1 ms | 212 KB | Output isn't correct |
9 | Incorrect | 0 ms | 212 KB | Output isn't correct |
10 | Incorrect | 1 ms | 212 KB | Output isn't correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Incorrect | 0 ms | 212 KB | Output isn't correct |
13 | Incorrect | 0 ms | 212 KB | Output isn't correct |
14 | Incorrect | 0 ms | 212 KB | Output isn't correct |
15 | Incorrect | 0 ms | 212 KB | Output isn't correct |
16 | Correct | 1 ms | 212 KB | Output is correct |
17 | Correct | 1 ms | 212 KB | Output is correct |
18 | Correct | 1 ms | 212 KB | Output is correct |
19 | Correct | 1 ms | 212 KB | Output is correct |
20 | Correct | 1 ms | 212 KB | Output is correct |
21 | Correct | 1 ms | 212 KB | Output is correct |
22 | Correct | 0 ms | 212 KB | Output is correct |
23 | Correct | 1 ms | 212 KB | Output is correct |
24 | Correct | 1 ms | 212 KB | Output is correct |
25 | Correct | 0 ms | 212 KB | Output is correct |
26 | Correct | 1 ms | 212 KB | Output is correct |
27 | Correct | 1 ms | 212 KB | Output is correct |
28 | Correct | 0 ms | 212 KB | Output is correct |
29 | Correct | 1 ms | 212 KB | Output is correct |
30 | Correct | 1 ms | 212 KB | Output is correct |
31 | Correct | 0 ms | 212 KB | Output is correct |
32 | Correct | 1 ms | 212 KB | Output is correct |
33 | Correct | 1 ms | 212 KB | Output is correct |
34 | Correct | 1 ms | 212 KB | Output is correct |
35 | Correct | 1 ms | 212 KB | Output is correct |
36 | Correct | 0 ms | 212 KB | Output is correct |
37 | Correct | 1 ms | 212 KB | Output is correct |
38 | Correct | 0 ms | 212 KB | Output is correct |
39 | Correct | 1 ms | 212 KB | Output is correct |
40 | Correct | 1 ms | 212 KB | Output is correct |
41 | Correct | 0 ms | 212 KB | Output is correct |
42 | Correct | 1 ms | 212 KB | Output is correct |
43 | Correct | 1 ms | 212 KB | Output is correct |
44 | Correct | 1 ms | 212 KB | Output is correct |
45 | Correct | 0 ms | 212 KB | Output is correct |