Submission #790539

# Submission time Handle Problem Language Result Execution time Memory
790539 2023-07-22T20:13:07 Z tch1cherin Palindrome-Free Numbers (BOI13_numbers) C++17
8.75 / 100
1 ms 340 KB
#include <bits/stdc++.h>
using namespace std;

const int MAX_N = 26;
int64_t DP[MAX_N][11][11];

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  int64_t l, r;
  cin >> l >> r;
  r++;
  string _L = to_string(l), _R = to_string(r);
  reverse(_L.begin(), _L.end());
  reverse(_R.begin(), _R.end());
  while (_L.size() < MAX_N - 1) {
    _L += '0' + 10;
  }
  while (_R.size() < MAX_N - 1) {
    _R += '0' + 10;
  }
  reverse(_L.begin(), _L.end());
  reverse(_R.begin(), _R.end());
  auto Count = [](string R) {
    memset(DP, 0, sizeof DP);
    for (int i = 2; i < MAX_N - 1; i++) {
      for (int A = 0; A <= 10; A++) {
        for (int B = 0; B <= 10; B++) {
          for (int C = 0; C < 10; C++) {
            if (A == C || B == C) {
              continue;
            }
            if (R[i] != '0' + 10 && C < R[i] - '0' && A == R[i - 2] - '0' && B == R[i - 1] - '0') {
              DP[i + 1][B][A == 10 && B == 10 && C == 0 ? 10 : C]++;
            }
            DP[i + 1][B][C] += DP[i][A][B]; 
          }
        }
      }
    }
    int64_t ans = 0;
    for (int A = 0; A <= 10; A++) {
      for (int B = 0; B <= 10; B++) {
        ans += DP[MAX_N - 1][A][B];
      }
    }
    return ans;
  };
  cout << Count(_R) - Count(_L) << "\n";
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Incorrect 1 ms 340 KB Output isn't correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Incorrect 0 ms 340 KB Output isn't correct
5 Correct 1 ms 340 KB Output is correct
6 Incorrect 1 ms 340 KB Output isn't correct
7 Incorrect 1 ms 340 KB Output isn't correct
8 Incorrect 0 ms 212 KB Output isn't correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Incorrect 1 ms 340 KB Output isn't correct
14 Incorrect 1 ms 340 KB Output isn't correct
15 Incorrect 1 ms 212 KB Output isn't correct
16 Incorrect 0 ms 340 KB Output isn't correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Incorrect 1 ms 340 KB Output isn't correct
20 Incorrect 1 ms 336 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Incorrect 1 ms 340 KB Output isn't correct
3 Incorrect 1 ms 256 KB Output isn't correct
4 Incorrect 1 ms 340 KB Output isn't correct
5 Incorrect 1 ms 212 KB Output isn't correct
6 Incorrect 1 ms 340 KB Output isn't correct
7 Incorrect 0 ms 340 KB Output isn't correct
8 Incorrect 0 ms 340 KB Output isn't correct
9 Incorrect 0 ms 340 KB Output isn't correct
10 Incorrect 0 ms 212 KB Output isn't correct
11 Incorrect 1 ms 340 KB Output isn't correct
12 Incorrect 1 ms 340 KB Output isn't correct
13 Incorrect 1 ms 212 KB Output isn't correct
14 Incorrect 0 ms 212 KB Output isn't correct
15 Incorrect 1 ms 212 KB Output isn't correct
16 Incorrect 1 ms 340 KB Output isn't correct
17 Incorrect 1 ms 340 KB Output isn't correct
18 Incorrect 1 ms 340 KB Output isn't correct
19 Incorrect 1 ms 340 KB Output isn't correct
20 Incorrect 1 ms 340 KB Output isn't correct
21 Incorrect 1 ms 340 KB Output isn't correct
22 Incorrect 1 ms 212 KB Output isn't correct
23 Incorrect 1 ms 340 KB Output isn't correct
24 Incorrect 1 ms 340 KB Output isn't correct
25 Incorrect 1 ms 340 KB Output isn't correct
26 Incorrect 1 ms 212 KB Output isn't correct
27 Incorrect 1 ms 340 KB Output isn't correct
28 Incorrect 1 ms 340 KB Output isn't correct
29 Incorrect 1 ms 212 KB Output isn't correct
30 Incorrect 1 ms 212 KB Output isn't correct
31 Incorrect 1 ms 340 KB Output isn't correct
32 Incorrect 1 ms 340 KB Output isn't correct
33 Incorrect 1 ms 340 KB Output isn't correct
34 Incorrect 1 ms 340 KB Output isn't correct
35 Incorrect 1 ms 212 KB Output isn't correct
36 Incorrect 1 ms 212 KB Output isn't correct
37 Incorrect 1 ms 340 KB Output isn't correct
38 Incorrect 1 ms 340 KB Output isn't correct
39 Incorrect 1 ms 212 KB Output isn't correct
40 Incorrect 1 ms 340 KB Output isn't correct
41 Incorrect 1 ms 340 KB Output isn't correct
42 Incorrect 1 ms 340 KB Output isn't correct
43 Incorrect 1 ms 212 KB Output isn't correct
44 Incorrect 1 ms 340 KB Output isn't correct
45 Incorrect 1 ms 212 KB Output isn't correct