# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1082829 | 2024-09-01T16:51:43 Z | lamlamlam | Palindrome-Free Numbers (BOI13_numbers) | C++17 | 1 ms | 456 KB |
#include <bits/stdc++.h> using namespace std; #define int long long #define endl '\n' int a,b,dp[20][2][11][11][2],n; string s; int f(int pos,int tight,int prev1,int prev2,int started) { if(pos==n) return started; if(dp[pos][tight][prev1][prev2][started]!=-1) return dp[pos][tight][prev1][prev2][started]; int res = 0, ub = 9; if(tight) ub = s[pos] - '0'; for(int i=0; i<=ub; i++){ if(i==prev1 or i==prev2) continue; int is_tight = (tight && i==ub); int has_started = (started or i!=0); res += f(pos+1,is_tight,i,prev1,has_started); } return dp[pos][tight][prev1][prev2][started] = res; } int sol(int x) { for(int i=0; i<20; i++) for(int j=0; j<11; j++) for(int k=0; k<11; k++) dp[i][0][j][k][0] = dp[i][0][j][k][1] = dp[i][1][j][k][0] = dp[i][1][j][k][1] = -1; s = to_string(x); n = s.size(); return f(0,1,10,10,0); } signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); #define task "troll" if(fopen(task".inp","r")){ freopen(task".inp","r",stdin); freopen(task".out","w",stdout); } cin >> a >> b; cout << sol(b) - sol(a-1); cerr << "\nTime: " << clock(); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | Output isn't correct |
2 | Incorrect | 0 ms | 348 KB | Output isn't correct |
3 | Correct | 1 ms | 344 KB | Output is correct |
4 | Incorrect | 0 ms | 348 KB | Output isn't correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Incorrect | 1 ms | 348 KB | Output isn't correct |
7 | Incorrect | 0 ms | 348 KB | Output isn't correct |
8 | Incorrect | 1 ms | 348 KB | Output isn't correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 344 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 0 ms | 348 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Incorrect | 0 ms | 348 KB | Output isn't correct |
15 | Incorrect | 0 ms | 348 KB | Output isn't correct |
16 | Correct | 0 ms | 348 KB | Output is correct |
17 | Correct | 0 ms | 348 KB | Output is correct |
18 | Incorrect | 1 ms | 348 KB | Output isn't correct |
19 | Correct | 1 ms | 456 KB | Output is correct |
20 | Incorrect | 1 ms | 344 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 344 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Incorrect | 0 ms | 348 KB | Output isn't correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Incorrect | 0 ms | 348 KB | Output isn't correct |
8 | Incorrect | 1 ms | 348 KB | Output isn't correct |
9 | Incorrect | 0 ms | 348 KB | Output isn't correct |
10 | Incorrect | 1 ms | 348 KB | Output isn't correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Incorrect | 0 ms | 348 KB | Output isn't correct |
13 | Incorrect | 0 ms | 348 KB | Output isn't correct |
14 | Incorrect | 0 ms | 348 KB | Output isn't correct |
15 | Incorrect | 0 ms | 348 KB | Output isn't correct |
16 | Correct | 1 ms | 348 KB | Output is correct |
17 | Correct | 0 ms | 348 KB | Output is correct |
18 | Correct | 1 ms | 344 KB | Output is correct |
19 | Correct | 0 ms | 348 KB | Output is correct |
20 | Correct | 1 ms | 348 KB | Output is correct |
21 | Correct | 1 ms | 348 KB | Output is correct |
22 | Correct | 1 ms | 348 KB | Output is correct |
23 | Correct | 0 ms | 348 KB | Output is correct |
24 | Correct | 1 ms | 348 KB | Output is correct |
25 | Correct | 0 ms | 348 KB | Output is correct |
26 | Correct | 0 ms | 348 KB | Output is correct |
27 | Correct | 0 ms | 348 KB | Output is correct |
28 | Correct | 1 ms | 348 KB | Output is correct |
29 | Correct | 1 ms | 348 KB | Output is correct |
30 | Correct | 1 ms | 348 KB | Output is correct |
31 | Correct | 1 ms | 348 KB | Output is correct |
32 | Correct | 0 ms | 348 KB | Output is correct |
33 | Correct | 0 ms | 348 KB | Output is correct |
34 | Correct | 0 ms | 456 KB | Output is correct |
35 | Correct | 1 ms | 348 KB | Output is correct |
36 | Correct | 1 ms | 348 KB | Output is correct |
37 | Correct | 1 ms | 348 KB | Output is correct |
38 | Correct | 1 ms | 348 KB | Output is correct |
39 | Correct | 1 ms | 348 KB | Output is correct |
40 | Correct | 1 ms | 348 KB | Output is correct |
41 | Correct | 1 ms | 348 KB | Output is correct |
42 | Correct | 1 ms | 348 KB | Output is correct |
43 | Correct | 1 ms | 348 KB | Output is correct |
44 | Correct | 1 ms | 348 KB | Output is correct |
45 | Correct | 0 ms | 348 KB | Output is correct |